Commit 8788a30c authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Greg Kroah-Hartman

staging: spmi: hisi-spmi-controller: use le32 macros where needed

Instead of manually using bswap_32(), just use the
le32 macros.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/927ac4f981649318dba399e46a1aa429c428cfa3.1597647359.git.mchehab+huawei@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 974e3bdc
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/spmi.h> #include <linux/spmi.h>
#include <linux/spmi.h>
#define SPMI_CONTROLLER_NAME "spmi_controller" #define SPMI_CONTROLLER_NAME "spmi_controller"
...@@ -43,11 +42,6 @@ ...@@ -43,11 +42,6 @@
#define SPMI_APB_SPMI_CMD_TYPE_OFFSET 24 #define SPMI_APB_SPMI_CMD_TYPE_OFFSET 24
#define SPMI_APB_SPMI_CMD_LENGTH_OFFSET 20 #define SPMI_APB_SPMI_CMD_LENGTH_OFFSET 20
#define bswap_32(X) \
((((u32)(X) & 0xff000000) >> 24) | \
(((u32)(X) & 0x00ff0000) >> 8) | \
(((u32)(X) & 0x0000ff00) << 8) | \
(((u32)(X) & 0x000000ff) << 24))
#define SPMI_APB_SPMI_CMD_SLAVEID_OFFSET 16 #define SPMI_APB_SPMI_CMD_SLAVEID_OFFSET 16
#define SPMI_APB_SPMI_CMD_ADDR_OFFSET 0 #define SPMI_APB_SPMI_CMD_ADDR_OFFSET 0
...@@ -179,14 +173,15 @@ static int spmi_read_cmd(struct spmi_controller *ctrl, ...@@ -179,14 +173,15 @@ static int spmi_read_cmd(struct spmi_controller *ctrl,
writel(cmd, spmi_controller->base + chnl_ofst + SPMI_APB_SPMI_CMD_BASE_ADDR); writel(cmd, spmi_controller->base + chnl_ofst + SPMI_APB_SPMI_CMD_BASE_ADDR);
rc = spmi_controller_wait_for_done(spmi_controller, spmi_controller->base, sid, addr); rc = spmi_controller_wait_for_done(spmi_controller,
spmi_controller->base, sid, addr);
if (rc) if (rc)
goto done; goto done;
i = 0; i = 0;
do { do {
data = readl(spmi_controller->base + chnl_ofst + SPMI_SLAVE_OFFSET * sid + SPMI_APB_SPMI_RDATA0_BASE_ADDR + i * SPMI_PER_DATAREG_BYTE); data = readl(spmi_controller->base + chnl_ofst + SPMI_SLAVE_OFFSET * sid + SPMI_APB_SPMI_RDATA0_BASE_ADDR + i * SPMI_PER_DATAREG_BYTE);
data = bswap_32(data); data = be32_to_cpu((__be32)data);
if ((bc - i * SPMI_PER_DATAREG_BYTE) >> 2) { if ((bc - i * SPMI_PER_DATAREG_BYTE) >> 2) {
memcpy(buf, &data, sizeof(data)); memcpy(buf, &data, sizeof(data));
buf += sizeof(data); buf += sizeof(data);
...@@ -210,8 +205,7 @@ static int spmi_write_cmd(struct spmi_controller *ctrl, ...@@ -210,8 +205,7 @@ static int spmi_write_cmd(struct spmi_controller *ctrl,
{ {
struct spmi_controller_dev *spmi_controller = dev_get_drvdata(&ctrl->dev); struct spmi_controller_dev *spmi_controller = dev_get_drvdata(&ctrl->dev);
unsigned long flags; unsigned long flags;
u32 cmd; u32 cmd, data;
u32 data = 0;
int rc; int rc;
u32 chnl_ofst = SPMI_CHANNEL_OFFSET * spmi_controller->channel; u32 chnl_ofst = SPMI_CHANNEL_OFFSET * spmi_controller->channel;
u8 op_code, i; u8 op_code, i;
...@@ -246,7 +240,7 @@ static int spmi_write_cmd(struct spmi_controller *ctrl, ...@@ -246,7 +240,7 @@ static int spmi_write_cmd(struct spmi_controller *ctrl,
i = 0; i = 0;
do { do {
memset(&data, 0, sizeof(data)); data = 0;
if ((bc - i * SPMI_PER_DATAREG_BYTE) >> 2) { if ((bc - i * SPMI_PER_DATAREG_BYTE) >> 2) {
memcpy(&data, buf, sizeof(data)); memcpy(&data, buf, sizeof(data));
buf += sizeof(data); buf += sizeof(data);
...@@ -255,8 +249,8 @@ static int spmi_write_cmd(struct spmi_controller *ctrl, ...@@ -255,8 +249,8 @@ static int spmi_write_cmd(struct spmi_controller *ctrl,
buf += (bc % SPMI_PER_DATAREG_BYTE); buf += (bc % SPMI_PER_DATAREG_BYTE);
} }
data = bswap_32(data); writel((u32)cpu_to_be32(data),
writel(data, spmi_controller->base + chnl_ofst + SPMI_APB_SPMI_WDATA0_BASE_ADDR + SPMI_PER_DATAREG_BYTE * i); spmi_controller->base + chnl_ofst + SPMI_APB_SPMI_WDATA0_BASE_ADDR + SPMI_PER_DATAREG_BYTE * i);
i++; i++;
} while (bc > i * SPMI_PER_DATAREG_BYTE); } while (bc > i * SPMI_PER_DATAREG_BYTE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment