From: Philipp Zabel <p.zabel@pengutronix.de> To: Sudeep Holla <sudeep.holla@arm.com>, linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] firmware: arm_scmi: Use {get,put}_unaligned_le32 accessors Date: Wed, 07 Aug 2019 15:36:11 +0200 [thread overview] Message-ID: <1565184971.5048.8.camel@pengutronix.de> (raw) In-Reply-To: <20190807130038.26878-1-sudeep.holla@arm.com> Hi Sudeep, On Wed, 2019-08-07 at 14:00 +0100, Sudeep Holla wrote: > Instead of type-casting the {tx,rx}.buf all over the place while > accessing them to read/write __le32 from/to the firmware, let's use > the nice existing {get,put}_unaligned_le32 accessors to hide all the > type cast ugliness. > > Suggested-by: Philipp Zabel <p.zabel@pengutronix.de> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> > --- > drivers/firmware/arm_scmi/base.c | 2 +- > drivers/firmware/arm_scmi/clock.c | 10 ++++------ > drivers/firmware/arm_scmi/common.h | 2 ++ > drivers/firmware/arm_scmi/perf.c | 8 ++++---- > drivers/firmware/arm_scmi/power.c | 6 +++--- > drivers/firmware/arm_scmi/reset.c | 2 +- > drivers/firmware/arm_scmi/sensors.c | 12 +++++------- > 7 files changed, 20 insertions(+), 22 deletions(-) > > diff --git a/drivers/firmware/arm_scmi/base.c b/drivers/firmware/arm_scmi/base.c > index 204390297f4b..f804e8af6521 100644 > --- a/drivers/firmware/arm_scmi/base.c > +++ b/drivers/firmware/arm_scmi/base.c [...] > @@ -204,14 +204,12 @@ scmi_clock_rate_get(const struct scmi_handle *handle, u32 clk_id, u64 *value) > if (ret) > return ret; > > - *(__le32 *)t->tx.buf = cpu_to_le32(clk_id); > + put_unaligned_le32(clk_id, t->tx.buf); > > ret = scmi_do_xfer(handle, t); > if (!ret) { > - __le32 *pval = t->rx.buf; > - > - *value = le32_to_cpu(*pval); > - *value |= (u64)le32_to_cpu(*(pval + 1)) << 32; > + *value = get_unaligned_le32(t->rx.buf); > + *value |= (u64)get_unaligned_le32(t->rx.buf + 1) << 32; Isn't t->rx.buf a void pointer? If I am not mistaken, you'd either have to keep the pval local variables, or cast to (__le32 *) before doing pointer arithmetic. regards Philipp
WARNING: multiple messages have this Message-ID (diff)
From: Philipp Zabel <p.zabel@pengutronix.de> To: Sudeep Holla <sudeep.holla@arm.com>, linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] firmware: arm_scmi: Use {get,put}_unaligned_le32 accessors Date: Wed, 07 Aug 2019 15:36:11 +0200 [thread overview] Message-ID: <1565184971.5048.8.camel@pengutronix.de> (raw) In-Reply-To: <20190807130038.26878-1-sudeep.holla@arm.com> Hi Sudeep, On Wed, 2019-08-07 at 14:00 +0100, Sudeep Holla wrote: > Instead of type-casting the {tx,rx}.buf all over the place while > accessing them to read/write __le32 from/to the firmware, let's use > the nice existing {get,put}_unaligned_le32 accessors to hide all the > type cast ugliness. > > Suggested-by: Philipp Zabel <p.zabel@pengutronix.de> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> > --- > drivers/firmware/arm_scmi/base.c | 2 +- > drivers/firmware/arm_scmi/clock.c | 10 ++++------ > drivers/firmware/arm_scmi/common.h | 2 ++ > drivers/firmware/arm_scmi/perf.c | 8 ++++---- > drivers/firmware/arm_scmi/power.c | 6 +++--- > drivers/firmware/arm_scmi/reset.c | 2 +- > drivers/firmware/arm_scmi/sensors.c | 12 +++++------- > 7 files changed, 20 insertions(+), 22 deletions(-) > > diff --git a/drivers/firmware/arm_scmi/base.c b/drivers/firmware/arm_scmi/base.c > index 204390297f4b..f804e8af6521 100644 > --- a/drivers/firmware/arm_scmi/base.c > +++ b/drivers/firmware/arm_scmi/base.c [...] > @@ -204,14 +204,12 @@ scmi_clock_rate_get(const struct scmi_handle *handle, u32 clk_id, u64 *value) > if (ret) > return ret; > > - *(__le32 *)t->tx.buf = cpu_to_le32(clk_id); > + put_unaligned_le32(clk_id, t->tx.buf); > > ret = scmi_do_xfer(handle, t); > if (!ret) { > - __le32 *pval = t->rx.buf; > - > - *value = le32_to_cpu(*pval); > - *value |= (u64)le32_to_cpu(*(pval + 1)) << 32; > + *value = get_unaligned_le32(t->rx.buf); > + *value |= (u64)get_unaligned_le32(t->rx.buf + 1) << 32; Isn't t->rx.buf a void pointer? If I am not mistaken, you'd either have to keep the pval local variables, or cast to (__le32 *) before doing pointer arithmetic. regards Philipp _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-08-07 13:36 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-08-07 13:00 [PATCH] firmware: arm_scmi: Use {get,put}_unaligned_le32 accessors Sudeep Holla 2019-08-07 13:00 ` Sudeep Holla 2019-08-07 13:36 ` Philipp Zabel [this message] 2019-08-07 13:36 ` Philipp Zabel 2019-08-07 13:57 ` Sudeep Holla 2019-08-07 13:57 ` Sudeep Holla 2019-08-07 14:07 ` Robin Murphy 2019-08-07 14:07 ` Robin Murphy 2019-08-07 14:37 ` Sudeep Holla 2019-08-07 14:37 ` Sudeep Holla 2019-08-07 15:18 ` David Laight 2019-08-07 15:18 ` David Laight 2019-08-07 17:08 ` Sudeep Holla 2019-08-07 17:08 ` Sudeep Holla 2019-08-07 17:37 ` [PATCH v2] firmware: arm_scmi: Use {get,put}_unaligned_le{32,64} accessors Sudeep Holla 2019-08-07 17:37 ` [PATCH v2] firmware: arm_scmi: Use {get, put}_unaligned_le{32, 64} accessors Sudeep Holla 2019-08-08 9:47 ` [PATCH v2] firmware: arm_scmi: Use {get,put}_unaligned_le{32,64} accessors Philipp Zabel 2019-08-08 9:47 ` Philipp Zabel
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1565184971.5048.8.camel@pengutronix.de \ --to=p.zabel@pengutronix.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=sudeep.holla@arm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.