Skip to content

Commit

Permalink
xfmc: Fix mcdp6000_read_reg and mcdp6000_modify_reg functions
Browse files Browse the repository at this point in the history
Fix mcdp6000_read_reg and mcdp6000_modify_reg functions

Signed-off-by: Rajesh Gugulothu <gugulothu.rajesh@xilinx.com>
  • Loading branch information
Rajesh Gugulothu committed Feb 4, 2022
1 parent 1625998 commit 1963d05
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions dp/xfmc/mcdp6000.c
Expand Up @@ -15,6 +15,11 @@
#include <linux/regmap.h>
#include <linux/slab.h>

#define SWAP_BYTES(u32Value) ((u32Value & 0x000000FF) << 24)\
|((u32Value & 0x0000FF00) << 8) \
|((u32Value & 0x00FF0000) >> 8) \
|((u32Value & 0xFF000000) >> 24)

/**************************** Type Definitions *******************************/

struct reg_8 {
Expand Down Expand Up @@ -64,13 +69,9 @@ static inline int mcdp6000_read_reg(struct mcdp6000 *priv, u16 addr, u32 *val)
if (err < 0)
dev_dbg(&priv->client->dev, "mcdp6000 :regmap_read failed\n");

for (i = 0; i < 4; i++) {
temp = (value >> (i * 8));
data <<= 8;
data |= temp;
}
value = SWAP_BYTES(value);

*val = data;
*val = value;

return err;
}
Expand All @@ -97,7 +98,8 @@ static inline int mcdp6000_modify_reg(struct mcdp6000 *priv, u16 addr, u32 val,

/* update */
data |= (val & mask);
dev_dbg(&priv->client->dev, " %x",data);
data = SWAP_BYTES(data);

err |= mcdp6000_write_reg(priv, addr, data);

return err;
Expand Down

0 comments on commit 1963d05

Please sign in to comment.