Commit 55e7f6ab authored by Arnd Bergmann's avatar Arnd Bergmann Committed by David S. Miller

dsa: b53: fix big-endian register access

The b53 dsa register access confusingly uses __raw register accessors
when both the CPU and the device are big-endian, but it uses little-
endian accessors when the same device is used from a little-endian
CPU, which makes no sense.

This uses normal accessors in device-endianess all the time, which
will work in all four combinations of register and CPU endianess,
and it will have the same barrier semantics in all cases.

This also seems to take care of a (false positive) warning I'm getting:

drivers/net/dsa/b53/b53_mmap.c: In function 'b53_mmap_read64':
drivers/net/dsa/b53/b53_mmap.c:109:10: error: 'hi' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  *val = ((u64)hi << 32) | lo;

I originally planned to submit another patch for that warning
and did this one as a preparation cleanup, but it does seem to be
sufficient by itself.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0d227a86
...@@ -45,9 +45,8 @@ static int b53_mmap_read16(struct b53_device *dev, u8 page, u8 reg, u16 *val) ...@@ -45,9 +45,8 @@ static int b53_mmap_read16(struct b53_device *dev, u8 page, u8 reg, u16 *val)
if (WARN_ON(reg % 2)) if (WARN_ON(reg % 2))
return -EINVAL; return -EINVAL;
if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) && dev->pdata && if (dev->pdata && dev->pdata->big_endian)
dev->pdata->big_endian) *val = ioread16be(regs + (page << 8) + reg);
*val = __raw_readw(regs + (page << 8) + reg);
else else
*val = readw(regs + (page << 8) + reg); *val = readw(regs + (page << 8) + reg);
...@@ -61,9 +60,8 @@ static int b53_mmap_read32(struct b53_device *dev, u8 page, u8 reg, u32 *val) ...@@ -61,9 +60,8 @@ static int b53_mmap_read32(struct b53_device *dev, u8 page, u8 reg, u32 *val)
if (WARN_ON(reg % 4)) if (WARN_ON(reg % 4))
return -EINVAL; return -EINVAL;
if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) && dev->pdata && if (dev->pdata && dev->pdata->big_endian)
dev->pdata->big_endian) *val = ioread32be(regs + (page << 8) + reg);
*val = __raw_readl(regs + (page << 8) + reg);
else else
*val = readl(regs + (page << 8) + reg); *val = readl(regs + (page << 8) + reg);
...@@ -128,9 +126,8 @@ static int b53_mmap_write16(struct b53_device *dev, u8 page, u8 reg, ...@@ -128,9 +126,8 @@ static int b53_mmap_write16(struct b53_device *dev, u8 page, u8 reg,
if (WARN_ON(reg % 2)) if (WARN_ON(reg % 2))
return -EINVAL; return -EINVAL;
if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) && dev->pdata && if (dev->pdata && dev->pdata->big_endian)
dev->pdata->big_endian) iowrite16be(value, regs + (page << 8) + reg);
__raw_writew(value, regs + (page << 8) + reg);
else else
writew(value, regs + (page << 8) + reg); writew(value, regs + (page << 8) + reg);
...@@ -145,9 +142,8 @@ static int b53_mmap_write32(struct b53_device *dev, u8 page, u8 reg, ...@@ -145,9 +142,8 @@ static int b53_mmap_write32(struct b53_device *dev, u8 page, u8 reg,
if (WARN_ON(reg % 4)) if (WARN_ON(reg % 4))
return -EINVAL; return -EINVAL;
if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) && dev->pdata && if (dev->pdata && dev->pdata->big_endian)
dev->pdata->big_endian) iowrite32be(value, regs + (page << 8) + reg);
__raw_writel(value, regs + (page << 8) + reg);
else else
writel(value, regs + (page << 8) + reg); writel(value, regs + (page << 8) + reg);
......
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