linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: sboyd@codeaurora.org (Stephen Boyd)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 8/8] regulator: qcom_smd: Handle big endian CPUs
Date: Wed,  2 Sep 2015 15:46:51 -0700	[thread overview]
Message-ID: <1441234011-4259-9-git-send-email-sboyd@codeaurora.org> (raw)
In-Reply-To: <1441234011-4259-1-git-send-email-sboyd@codeaurora.org>

The smd rpm structures are always in little endian, but this
driver is not capable of being used on big endian CPUs. Annotate
the little endian data members and update the code to do the
proper byte swapping.

Cc: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Cc: Andy Gross <agross@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
---

Changes from v1:
 * New patch

 drivers/regulator/qcom_smd-regulator.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c
index 9c6167dd2c8b..b72c693e29ff 100644
--- a/drivers/regulator/qcom_smd-regulator.c
+++ b/drivers/regulator/qcom_smd-regulator.c
@@ -36,9 +36,9 @@ struct qcom_rpm_reg {
 };
 
 struct rpm_regulator_req {
-	u32 key;
-	u32 nbytes;
-	u32 value;
+	__le32 key;
+	__le32 nbytes;
+	__le32 value;
 };
 
 #define RPM_KEY_SWEN	0x6e657773 /* "swen" */
@@ -62,9 +62,9 @@ static int rpm_reg_enable(struct regulator_dev *rdev)
 	struct rpm_regulator_req req;
 	int ret;
 
-	req.key = RPM_KEY_SWEN;
-	req.nbytes = sizeof(u32);
-	req.value = 1;
+	req.key = cpu_to_le32(RPM_KEY_SWEN);
+	req.nbytes = cpu_to_le32(sizeof(u32));
+	req.value = cpu_to_le32(1);
 
 	ret = rpm_reg_write_active(vreg, &req, sizeof(req));
 	if (!ret)
@@ -86,8 +86,8 @@ static int rpm_reg_disable(struct regulator_dev *rdev)
 	struct rpm_regulator_req req;
 	int ret;
 
-	req.key = RPM_KEY_SWEN;
-	req.nbytes = sizeof(u32);
+	req.key = cpu_to_le32(RPM_KEY_SWEN);
+	req.nbytes = cpu_to_le32(sizeof(u32));
 	req.value = 0;
 
 	ret = rpm_reg_write_active(vreg, &req, sizeof(req));
@@ -113,9 +113,9 @@ static int rpm_reg_set_voltage(struct regulator_dev *rdev,
 	struct rpm_regulator_req req;
 	int ret = 0;
 
-	req.key = RPM_KEY_UV;
-	req.nbytes = sizeof(u32);
-	req.value = min_uV;
+	req.key = cpu_to_le32(RPM_KEY_UV);
+	req.nbytes = cpu_to_le32(sizeof(u32));
+	req.value = cpu_to_le32(min_uV);
 
 	ret = rpm_reg_write_active(vreg, &req, sizeof(req));
 	if (!ret)
@@ -129,9 +129,9 @@ static int rpm_reg_set_load(struct regulator_dev *rdev, int load_uA)
 	struct qcom_rpm_reg *vreg = rdev_get_drvdata(rdev);
 	struct rpm_regulator_req req;
 
-	req.key = RPM_KEY_MA;
-	req.nbytes = sizeof(u32);
-	req.value = load_uA;
+	req.key = cpu_to_le32(RPM_KEY_MA);
+	req.nbytes = cpu_to_le32(sizeof(u32));
+	req.value = cpu_to_le32(load_uA);
 
 	return rpm_reg_write_active(vreg, &req, sizeof(req));
 }
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

  parent reply	other threads:[~2015-09-02 22:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-02 22:46 [PATCH v2 0/8] SMEM/SMD/SMD_RPM big endian support + tidying Stephen Boyd
2015-09-02 22:46 ` [PATCH v2 1/8] soc: qcom: Make qcom_smem_get() return a pointer Stephen Boyd
2015-09-03 17:02   ` Bjorn Andersson
2015-09-02 22:46 ` [PATCH v2 2/8] soc: qcom: smem: Handle big endian CPUs Stephen Boyd
2015-09-03 17:02   ` Bjorn Andersson
2015-09-02 22:46 ` [PATCH v2 3/8] soc: qcom: smd: Represent channel layout in structures Stephen Boyd
2015-09-02 22:46 ` [PATCH v2 4/8] soc: qcom: smd: Use __iowrite32_copy() instead of open-coding it Stephen Boyd
2015-09-02 22:46 ` [PATCH v2 5/8] soc: qcom: smd: Remove use of VLAIS Stephen Boyd
2015-09-03 17:02   ` Bjorn Andersson
2015-09-22  1:16   ` Bjorn Andersson
2015-09-22 15:34     ` Andy Gross
2015-09-02 22:46 ` [PATCH v2 6/8] soc: qcom: smd: Handle big endian CPUs Stephen Boyd
2015-09-03 17:02   ` Bjorn Andersson
2015-09-17 21:50   ` [PATCH v3 " Stephen Boyd
2015-09-02 22:46 ` [PATCH v2 7/8] soc: qcom: smd_rpm: " Stephen Boyd
2015-09-03 17:03   ` Bjorn Andersson
2015-09-02 22:46 ` Stephen Boyd [this message]
2015-09-03 17:03   ` [PATCH v2 8/8] regulator: qcom_smd: " Bjorn Andersson
2015-09-04 20:35 ` [PATCH v2 0/8] SMEM/SMD/SMD_RPM big endian support + tidying Andy Gross

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=1441234011-4259-9-git-send-email-sboyd@codeaurora.org \
    --to=sboyd@codeaurora.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).