diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2009-11-04 07:52:56 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-08 03:43:14 -0500 |
commit | 2951d64e70652bb11636a5a1f1f2ea295a043f94 (patch) | |
tree | 73edf0289c3c7863830d197c0771904e56f5b4d6 /drivers/net/fsl_pq_mdio.c | |
parent | e0d087af725b09358336098a6b57bb7f90f96175 (diff) |
fsl_pq_mdio: Fix compiler/sparse warnings (part 1)
commit 1d2397d742b7a2b39b2f09dd9da3b9d1463f55e9 ("fsl_pq_mdio: Add
Suport for etsec2.0 devices") introduced the following warnings:
CHECK fsl_pq_mdio.c
fsl_pq_mdio.c:287:22: warning: incorrect type in initializer (different base types)
fsl_pq_mdio.c:287:22: expected unknown type 11 const *__mptr
fsl_pq_mdio.c:287:22: got unsigned long long [unsigned] [assigned] [usertype] addr
fsl_pq_mdio.c:287:19: warning: incorrect type in assignment (different base types)
fsl_pq_mdio.c:287:19: expected unsigned long long [unsigned] [usertype] ioremap_miimcfg
fsl_pq_mdio.c:287:19: got struct fsl_pq_mdio *<noident>
CC fsl_pq_mdio.o
fsl_pq_mdio.c: In function 'fsl_pq_mdio_probe':
fsl_pq_mdio.c:287: warning: initialization makes pointer from integer without a cast
fsl_pq_mdio.c:287: warning: assignment makes integer from pointer without a cast
These warnings are not easy to fix without ugly __force casts. So,
instead of introducing the casts, rework the code to substitute an
offset from an already mapped area. This makes the code a lot simpler
and less duplicated.
Plus, from now on we don't actually map reserved registers on
non-etsec2.0 devices, so we have more chances to catch programming
errors.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/fsl_pq_mdio.c')
-rw-r--r-- | drivers/net/fsl_pq_mdio.c | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c index 4065b7c01ecb..fb8c8d9dcf29 100644 --- a/drivers/net/fsl_pq_mdio.c +++ b/drivers/net/fsl_pq_mdio.c | |||
@@ -262,10 +262,11 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev, | |||
262 | struct device_node *np = ofdev->node; | 262 | struct device_node *np = ofdev->node; |
263 | struct device_node *tbi; | 263 | struct device_node *tbi; |
264 | struct fsl_pq_mdio __iomem *regs = NULL; | 264 | struct fsl_pq_mdio __iomem *regs = NULL; |
265 | void __iomem *map; | ||
265 | u32 __iomem *tbipa; | 266 | u32 __iomem *tbipa; |
266 | struct mii_bus *new_bus; | 267 | struct mii_bus *new_bus; |
267 | int tbiaddr = -1; | 268 | int tbiaddr = -1; |
268 | u64 addr = 0, size = 0, ioremap_miimcfg = 0; | 269 | u64 addr = 0, size = 0; |
269 | int err = 0; | 270 | int err = 0; |
270 | 271 | ||
271 | new_bus = mdiobus_alloc(); | 272 | new_bus = mdiobus_alloc(); |
@@ -279,28 +280,20 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev, | |||
279 | fsl_pq_mdio_bus_name(new_bus->id, np); | 280 | fsl_pq_mdio_bus_name(new_bus->id, np); |
280 | 281 | ||
281 | /* Set the PHY base address */ | 282 | /* Set the PHY base address */ |
282 | if (of_device_is_compatible(np,"fsl,gianfar-mdio") || | 283 | addr = of_translate_address(np, of_get_address(np, 0, &size, NULL)); |
283 | of_device_is_compatible(np, "fsl,gianfar-tbi") || | 284 | map = ioremap(addr, size); |
284 | of_device_is_compatible(np, "fsl,ucc-mdio") || | 285 | if (!map) { |
285 | of_device_is_compatible(np,"ucc_geth_phy" )) { | ||
286 | addr = of_translate_address(np, of_get_address(np, 0, &size, NULL)); | ||
287 | ioremap_miimcfg = container_of(addr, struct fsl_pq_mdio, miimcfg); | ||
288 | regs = ioremap(ioremap_miimcfg, size + | ||
289 | offsetof(struct fsl_pq_mdio, miimcfg)); | ||
290 | } else if (of_device_is_compatible(np,"fsl,etsec2-mdio") || | ||
291 | of_device_is_compatible(np, "fsl,etsec2-tbi")) { | ||
292 | addr = of_translate_address(np, of_get_address(np, 0, &size, NULL)); | ||
293 | regs = ioremap(addr, size); | ||
294 | } else { | ||
295 | err = -EINVAL; | ||
296 | goto err_free_bus; | ||
297 | } | ||
298 | |||
299 | if (NULL == regs) { | ||
300 | err = -ENOMEM; | 286 | err = -ENOMEM; |
301 | goto err_free_bus; | 287 | goto err_free_bus; |
302 | } | 288 | } |
303 | 289 | ||
290 | if (of_device_is_compatible(np, "fsl,gianfar-mdio") || | ||
291 | of_device_is_compatible(np, "fsl,gianfar-tbi") || | ||
292 | of_device_is_compatible(np, "fsl,ucc-mdio") || | ||
293 | of_device_is_compatible(np, "ucc_geth_phy")) | ||
294 | map -= offsetof(struct fsl_pq_mdio, miimcfg); | ||
295 | regs = map; | ||
296 | |||
304 | new_bus->priv = (void __force *)regs; | 297 | new_bus->priv = (void __force *)regs; |
305 | 298 | ||
306 | new_bus->irq = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL); | 299 | new_bus->irq = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL); |