aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2018-04-02 19:17:01 -0400
committerDavid S. Miller <davem@davemloft.net>2018-04-04 11:15:27 -0400
commit861690d0543949633c97ebe9b2fcd55c27b9bda4 (patch)
tree1c332e26df66bf8e24fea9a2f1dcf7f17c0d74e6
parent3848ec5dc82ce648a84ed10021ce2562fdac7c6a (diff)
net: dsa: b53: Fix sparse warnings in b53_mmap.c
sparse complains about the following warnings: drivers/net/dsa/b53/b53_mmap.c:33:31: warning: incorrect type in initializer (different address spaces) drivers/net/dsa/b53/b53_mmap.c:33:31: expected unsigned char [noderef] [usertype] <asn:2>*regs drivers/net/dsa/b53/b53_mmap.c:33:31: got void *priv and indeed, while what we are doing is functional, we are dereferencing a void * pointer into a void __iomem * which is not great. Just use the defined b53_mmap_priv structure which holds our register base and use that. Fixes: 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch") Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/dsa/b53/b53_mmap.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/drivers/net/dsa/b53/b53_mmap.c b/drivers/net/dsa/b53/b53_mmap.c
index ef63d24fef81..c628d0980c0b 100644
--- a/drivers/net/dsa/b53/b53_mmap.c
+++ b/drivers/net/dsa/b53/b53_mmap.c
@@ -30,7 +30,8 @@ struct b53_mmap_priv {
30 30
31static int b53_mmap_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val) 31static int b53_mmap_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val)
32{ 32{
33 u8 __iomem *regs = dev->priv; 33 struct b53_mmap_priv *priv = dev->priv;
34 void __iomem *regs = priv->regs;
34 35
35 *val = readb(regs + (page << 8) + reg); 36 *val = readb(regs + (page << 8) + reg);
36 37
@@ -39,7 +40,8 @@ static int b53_mmap_read8(struct b53_device *dev, u8 page, u8 reg, u8 *val)
39 40
40static int b53_mmap_read16(struct b53_device *dev, u8 page, u8 reg, u16 *val) 41static int b53_mmap_read16(struct b53_device *dev, u8 page, u8 reg, u16 *val)
41{ 42{
42 u8 __iomem *regs = dev->priv; 43 struct b53_mmap_priv *priv = dev->priv;
44 void __iomem *regs = priv->regs;
43 45
44 if (WARN_ON(reg % 2)) 46 if (WARN_ON(reg % 2))
45 return -EINVAL; 47 return -EINVAL;
@@ -54,7 +56,8 @@ static int b53_mmap_read16(struct b53_device *dev, u8 page, u8 reg, u16 *val)
54 56
55static int b53_mmap_read32(struct b53_device *dev, u8 page, u8 reg, u32 *val) 57static int b53_mmap_read32(struct b53_device *dev, u8 page, u8 reg, u32 *val)
56{ 58{
57 u8 __iomem *regs = dev->priv; 59 struct b53_mmap_priv *priv = dev->priv;
60 void __iomem *regs = priv->regs;
58 61
59 if (WARN_ON(reg % 4)) 62 if (WARN_ON(reg % 4))
60 return -EINVAL; 63 return -EINVAL;
@@ -69,7 +72,8 @@ static int b53_mmap_read32(struct b53_device *dev, u8 page, u8 reg, u32 *val)
69 72
70static int b53_mmap_read48(struct b53_device *dev, u8 page, u8 reg, u64 *val) 73static int b53_mmap_read48(struct b53_device *dev, u8 page, u8 reg, u64 *val)
71{ 74{
72 u8 __iomem *regs = dev->priv; 75 struct b53_mmap_priv *priv = dev->priv;
76 void __iomem *regs = priv->regs;
73 77
74 if (WARN_ON(reg % 2)) 78 if (WARN_ON(reg % 2))
75 return -EINVAL; 79 return -EINVAL;
@@ -107,7 +111,8 @@ static int b53_mmap_read48(struct b53_device *dev, u8 page, u8 reg, u64 *val)
107 111
108static int b53_mmap_read64(struct b53_device *dev, u8 page, u8 reg, u64 *val) 112static int b53_mmap_read64(struct b53_device *dev, u8 page, u8 reg, u64 *val)
109{ 113{
110 u8 __iomem *regs = dev->priv; 114 struct b53_mmap_priv *priv = dev->priv;
115 void __iomem *regs = priv->regs;
111 u32 hi, lo; 116 u32 hi, lo;
112 117
113 if (WARN_ON(reg % 4)) 118 if (WARN_ON(reg % 4))
@@ -128,7 +133,8 @@ static int b53_mmap_read64(struct b53_device *dev, u8 page, u8 reg, u64 *val)
128 133
129static int b53_mmap_write8(struct b53_device *dev, u8 page, u8 reg, u8 value) 134static int b53_mmap_write8(struct b53_device *dev, u8 page, u8 reg, u8 value)
130{ 135{
131 u8 __iomem *regs = dev->priv; 136 struct b53_mmap_priv *priv = dev->priv;
137 void __iomem *regs = priv->regs;
132 138
133 writeb(value, regs + (page << 8) + reg); 139 writeb(value, regs + (page << 8) + reg);
134 140
@@ -138,7 +144,8 @@ static int b53_mmap_write8(struct b53_device *dev, u8 page, u8 reg, u8 value)
138static int b53_mmap_write16(struct b53_device *dev, u8 page, u8 reg, 144static int b53_mmap_write16(struct b53_device *dev, u8 page, u8 reg,
139 u16 value) 145 u16 value)
140{ 146{
141 u8 __iomem *regs = dev->priv; 147 struct b53_mmap_priv *priv = dev->priv;
148 void __iomem *regs = priv->regs;
142 149
143 if (WARN_ON(reg % 2)) 150 if (WARN_ON(reg % 2))
144 return -EINVAL; 151 return -EINVAL;
@@ -154,7 +161,8 @@ static int b53_mmap_write16(struct b53_device *dev, u8 page, u8 reg,
154static int b53_mmap_write32(struct b53_device *dev, u8 page, u8 reg, 161static int b53_mmap_write32(struct b53_device *dev, u8 page, u8 reg,
155 u32 value) 162 u32 value)
156{ 163{
157 u8 __iomem *regs = dev->priv; 164 struct b53_mmap_priv *priv = dev->priv;
165 void __iomem *regs = priv->regs;
158 166
159 if (WARN_ON(reg % 4)) 167 if (WARN_ON(reg % 4))
160 return -EINVAL; 168 return -EINVAL;
@@ -223,12 +231,19 @@ static const struct b53_io_ops b53_mmap_ops = {
223static int b53_mmap_probe(struct platform_device *pdev) 231static int b53_mmap_probe(struct platform_device *pdev)
224{ 232{
225 struct b53_platform_data *pdata = pdev->dev.platform_data; 233 struct b53_platform_data *pdata = pdev->dev.platform_data;
234 struct b53_mmap_priv *priv;
226 struct b53_device *dev; 235 struct b53_device *dev;
227 236
228 if (!pdata) 237 if (!pdata)
229 return -EINVAL; 238 return -EINVAL;
230 239
231 dev = b53_switch_alloc(&pdev->dev, &b53_mmap_ops, pdata->regs); 240 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
241 if (!priv)
242 return -ENOMEM;
243
244 priv->regs = pdata->regs;
245
246 dev = b53_switch_alloc(&pdev->dev, &b53_mmap_ops, priv);
232 if (!dev) 247 if (!dev)
233 return -ENOMEM; 248 return -ENOMEM;
234 249