aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-05-23 06:47:58 -0400
committerMarc Kleine-Budde <mkl@pengutronix.de>2013-06-03 07:13:49 -0400
commit00e4bbc8cd7efac66caa4ce6bcf5f02e944184f6 (patch)
tree57aac83b859b47d0bc4fb444b9b5a39800754b04
parent4c4726faed6cf0c7545ac6523de4cc66acd0a61d (diff)
net: can: use platform_{get,set}_drvdata()
Use the wrapper functions for getting and setting the driver data using platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev, so we can directly pass a struct platform_device. Also, unnecessary dev_set_drvdata() is removed, because the driver core clears the driver data to NULL after device_release or on probe failure. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r--drivers/net/can/bfin_can.c10
-rw-r--r--drivers/net/can/cc770/cc770_isa.c5
-rw-r--r--drivers/net/can/cc770/cc770_platform.c4
-rw-r--r--drivers/net/can/grcan.c5
-rw-r--r--drivers/net/can/mscan/mpc5xxx_can.c10
-rw-r--r--drivers/net/can/sja1000/sja1000_isa.c5
-rw-r--r--drivers/net/can/sja1000/sja1000_of_platform.c6
-rw-r--r--drivers/net/can/sja1000/sja1000_platform.c5
8 files changed, 20 insertions, 30 deletions
diff --git a/drivers/net/can/bfin_can.c b/drivers/net/can/bfin_can.c
index d4a15e82bfc0..a2700d25ff0e 100644
--- a/drivers/net/can/bfin_can.c
+++ b/drivers/net/can/bfin_can.c
@@ -580,7 +580,7 @@ static int bfin_can_probe(struct platform_device *pdev)
580 priv->pin_list = pdata; 580 priv->pin_list = pdata;
581 priv->can.clock.freq = get_sclk(); 581 priv->can.clock.freq = get_sclk();
582 582
583 dev_set_drvdata(&pdev->dev, dev); 583 platform_set_drvdata(pdev, dev);
584 SET_NETDEV_DEV(dev, &pdev->dev); 584 SET_NETDEV_DEV(dev, &pdev->dev);
585 585
586 dev->flags |= IFF_ECHO; /* we support local echo */ 586 dev->flags |= IFF_ECHO; /* we support local echo */
@@ -613,7 +613,7 @@ exit:
613 613
614static int bfin_can_remove(struct platform_device *pdev) 614static int bfin_can_remove(struct platform_device *pdev)
615{ 615{
616 struct net_device *dev = dev_get_drvdata(&pdev->dev); 616 struct net_device *dev = platform_get_drvdata(pdev);
617 struct bfin_can_priv *priv = netdev_priv(dev); 617 struct bfin_can_priv *priv = netdev_priv(dev);
618 struct resource *res; 618 struct resource *res;
619 619
@@ -621,8 +621,6 @@ static int bfin_can_remove(struct platform_device *pdev)
621 621
622 unregister_candev(dev); 622 unregister_candev(dev);
623 623
624 dev_set_drvdata(&pdev->dev, NULL);
625
626 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 624 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
627 release_mem_region(res->start, resource_size(res)); 625 release_mem_region(res->start, resource_size(res));
628 626
@@ -635,7 +633,7 @@ static int bfin_can_remove(struct platform_device *pdev)
635#ifdef CONFIG_PM 633#ifdef CONFIG_PM
636static int bfin_can_suspend(struct platform_device *pdev, pm_message_t mesg) 634static int bfin_can_suspend(struct platform_device *pdev, pm_message_t mesg)
637{ 635{
638 struct net_device *dev = dev_get_drvdata(&pdev->dev); 636 struct net_device *dev = platform_get_drvdata(pdev);
639 struct bfin_can_priv *priv = netdev_priv(dev); 637 struct bfin_can_priv *priv = netdev_priv(dev);
640 struct bfin_can_regs __iomem *reg = priv->membase; 638 struct bfin_can_regs __iomem *reg = priv->membase;
641 int timeout = BFIN_CAN_TIMEOUT; 639 int timeout = BFIN_CAN_TIMEOUT;
@@ -658,7 +656,7 @@ static int bfin_can_suspend(struct platform_device *pdev, pm_message_t mesg)
658 656
659static int bfin_can_resume(struct platform_device *pdev) 657static int bfin_can_resume(struct platform_device *pdev)
660{ 658{
661 struct net_device *dev = dev_get_drvdata(&pdev->dev); 659 struct net_device *dev = platform_get_drvdata(pdev);
662 struct bfin_can_priv *priv = netdev_priv(dev); 660 struct bfin_can_priv *priv = netdev_priv(dev);
663 struct bfin_can_regs __iomem *reg = priv->membase; 661 struct bfin_can_regs __iomem *reg = priv->membase;
664 662
diff --git a/drivers/net/can/cc770/cc770_isa.c b/drivers/net/can/cc770/cc770_isa.c
index 8eaaac81f320..87a47c0cfd49 100644
--- a/drivers/net/can/cc770/cc770_isa.c
+++ b/drivers/net/can/cc770/cc770_isa.c
@@ -265,7 +265,7 @@ static int cc770_isa_probe(struct platform_device *pdev)
265 else 265 else
266 priv->clkout = COR_DEFAULT; 266 priv->clkout = COR_DEFAULT;
267 267
268 dev_set_drvdata(&pdev->dev, dev); 268 platform_set_drvdata(pdev, dev);
269 SET_NETDEV_DEV(dev, &pdev->dev); 269 SET_NETDEV_DEV(dev, &pdev->dev);
270 270
271 err = register_cc770dev(dev); 271 err = register_cc770dev(dev);
@@ -293,12 +293,11 @@ static int cc770_isa_probe(struct platform_device *pdev)
293 293
294static int cc770_isa_remove(struct platform_device *pdev) 294static int cc770_isa_remove(struct platform_device *pdev)
295{ 295{
296 struct net_device *dev = dev_get_drvdata(&pdev->dev); 296 struct net_device *dev = platform_get_drvdata(pdev);
297 struct cc770_priv *priv = netdev_priv(dev); 297 struct cc770_priv *priv = netdev_priv(dev);
298 int idx = pdev->id; 298 int idx = pdev->id;
299 299
300 unregister_cc770dev(dev); 300 unregister_cc770dev(dev);
301 dev_set_drvdata(&pdev->dev, NULL);
302 301
303 if (mem[idx]) { 302 if (mem[idx]) {
304 iounmap(priv->reg_base); 303 iounmap(priv->reg_base);
diff --git a/drivers/net/can/cc770/cc770_platform.c b/drivers/net/can/cc770/cc770_platform.c
index d0f6bfc45aea..034bdd816a60 100644
--- a/drivers/net/can/cc770/cc770_platform.c
+++ b/drivers/net/can/cc770/cc770_platform.c
@@ -216,7 +216,7 @@ static int cc770_platform_probe(struct platform_device *pdev)
216 priv->reg_base, dev->irq, priv->can.clock.freq, 216 priv->reg_base, dev->irq, priv->can.clock.freq,
217 priv->cpu_interface, priv->bus_config, priv->clkout); 217 priv->cpu_interface, priv->bus_config, priv->clkout);
218 218
219 dev_set_drvdata(&pdev->dev, dev); 219 platform_set_drvdata(pdev, dev);
220 SET_NETDEV_DEV(dev, &pdev->dev); 220 SET_NETDEV_DEV(dev, &pdev->dev);
221 221
222 err = register_cc770dev(dev); 222 err = register_cc770dev(dev);
@@ -240,7 +240,7 @@ exit_release_mem:
240 240
241static int cc770_platform_remove(struct platform_device *pdev) 241static int cc770_platform_remove(struct platform_device *pdev)
242{ 242{
243 struct net_device *dev = dev_get_drvdata(&pdev->dev); 243 struct net_device *dev = platform_get_drvdata(pdev);
244 struct cc770_priv *priv = netdev_priv(dev); 244 struct cc770_priv *priv = netdev_priv(dev);
245 struct resource *mem; 245 struct resource *mem;
246 246
diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c
index 9e9d0d628e7b..6aa737a24393 100644
--- a/drivers/net/can/grcan.c
+++ b/drivers/net/can/grcan.c
@@ -1646,7 +1646,7 @@ static int grcan_setup_netdev(struct platform_device *ofdev,
1646 if (err) 1646 if (err)
1647 goto exit_free_candev; 1647 goto exit_free_candev;
1648 1648
1649 dev_set_drvdata(&ofdev->dev, dev); 1649 platform_set_drvdata(ofdev, dev);
1650 1650
1651 /* Reset device to allow bit-timing to be set. No need to call 1651 /* Reset device to allow bit-timing to be set. No need to call
1652 * grcan_reset at this stage. That is done in grcan_open. 1652 * grcan_reset at this stage. That is done in grcan_open.
@@ -1715,13 +1715,12 @@ exit_error:
1715 1715
1716static int grcan_remove(struct platform_device *ofdev) 1716static int grcan_remove(struct platform_device *ofdev)
1717{ 1717{
1718 struct net_device *dev = dev_get_drvdata(&ofdev->dev); 1718 struct net_device *dev = platform_get_drvdata(ofdev);
1719 struct grcan_priv *priv = netdev_priv(dev); 1719 struct grcan_priv *priv = netdev_priv(dev);
1720 1720
1721 unregister_candev(dev); /* Will in turn call grcan_close */ 1721 unregister_candev(dev); /* Will in turn call grcan_close */
1722 1722
1723 irq_dispose_mapping(dev->irq); 1723 irq_dispose_mapping(dev->irq);
1724 dev_set_drvdata(&ofdev->dev, NULL);
1725 netif_napi_del(&priv->napi); 1724 netif_napi_del(&priv->napi);
1726 free_candev(dev); 1725 free_candev(dev);
1727 1726
diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c
index 668850e441dc..5b0ee8ef5885 100644
--- a/drivers/net/can/mscan/mpc5xxx_can.c
+++ b/drivers/net/can/mscan/mpc5xxx_can.c
@@ -302,7 +302,7 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev)
302 goto exit_free_mscan; 302 goto exit_free_mscan;
303 } 303 }
304 304
305 dev_set_drvdata(&ofdev->dev, dev); 305 platform_set_drvdata(ofdev, dev);
306 306
307 dev_info(&ofdev->dev, "MSCAN at 0x%p, irq %d, clock %d Hz\n", 307 dev_info(&ofdev->dev, "MSCAN at 0x%p, irq %d, clock %d Hz\n",
308 priv->reg_base, dev->irq, priv->can.clock.freq); 308 priv->reg_base, dev->irq, priv->can.clock.freq);
@@ -321,11 +321,9 @@ exit_unmap_mem:
321 321
322static int mpc5xxx_can_remove(struct platform_device *ofdev) 322static int mpc5xxx_can_remove(struct platform_device *ofdev)
323{ 323{
324 struct net_device *dev = dev_get_drvdata(&ofdev->dev); 324 struct net_device *dev = platform_get_drvdata(ofdev);
325 struct mscan_priv *priv = netdev_priv(dev); 325 struct mscan_priv *priv = netdev_priv(dev);
326 326
327 dev_set_drvdata(&ofdev->dev, NULL);
328
329 unregister_mscandev(dev); 327 unregister_mscandev(dev);
330 iounmap(priv->reg_base); 328 iounmap(priv->reg_base);
331 irq_dispose_mapping(dev->irq); 329 irq_dispose_mapping(dev->irq);
@@ -338,7 +336,7 @@ static int mpc5xxx_can_remove(struct platform_device *ofdev)
338static struct mscan_regs saved_regs; 336static struct mscan_regs saved_regs;
339static int mpc5xxx_can_suspend(struct platform_device *ofdev, pm_message_t state) 337static int mpc5xxx_can_suspend(struct platform_device *ofdev, pm_message_t state)
340{ 338{
341 struct net_device *dev = dev_get_drvdata(&ofdev->dev); 339 struct net_device *dev = platform_get_drvdata(ofdev);
342 struct mscan_priv *priv = netdev_priv(dev); 340 struct mscan_priv *priv = netdev_priv(dev);
343 struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base; 341 struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base;
344 342
@@ -349,7 +347,7 @@ static int mpc5xxx_can_suspend(struct platform_device *ofdev, pm_message_t state
349 347
350static int mpc5xxx_can_resume(struct platform_device *ofdev) 348static int mpc5xxx_can_resume(struct platform_device *ofdev)
351{ 349{
352 struct net_device *dev = dev_get_drvdata(&ofdev->dev); 350 struct net_device *dev = platform_get_drvdata(ofdev);
353 struct mscan_priv *priv = netdev_priv(dev); 351 struct mscan_priv *priv = netdev_priv(dev);
354 struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base; 352 struct mscan_regs *regs = (struct mscan_regs *)priv->reg_base;
355 353
diff --git a/drivers/net/can/sja1000/sja1000_isa.c b/drivers/net/can/sja1000/sja1000_isa.c
index 5c8da4661489..06a282397fff 100644
--- a/drivers/net/can/sja1000/sja1000_isa.c
+++ b/drivers/net/can/sja1000/sja1000_isa.c
@@ -197,7 +197,7 @@ static int sja1000_isa_probe(struct platform_device *pdev)
197 else 197 else
198 priv->cdr = CDR_DEFAULT; 198 priv->cdr = CDR_DEFAULT;
199 199
200 dev_set_drvdata(&pdev->dev, dev); 200 platform_set_drvdata(pdev, dev);
201 SET_NETDEV_DEV(dev, &pdev->dev); 201 SET_NETDEV_DEV(dev, &pdev->dev);
202 202
203 err = register_sja1000dev(dev); 203 err = register_sja1000dev(dev);
@@ -225,12 +225,11 @@ static int sja1000_isa_probe(struct platform_device *pdev)
225 225
226static int sja1000_isa_remove(struct platform_device *pdev) 226static int sja1000_isa_remove(struct platform_device *pdev)
227{ 227{
228 struct net_device *dev = dev_get_drvdata(&pdev->dev); 228 struct net_device *dev = platform_get_drvdata(pdev);
229 struct sja1000_priv *priv = netdev_priv(dev); 229 struct sja1000_priv *priv = netdev_priv(dev);
230 int idx = pdev->id; 230 int idx = pdev->id;
231 231
232 unregister_sja1000dev(dev); 232 unregister_sja1000dev(dev);
233 dev_set_drvdata(&pdev->dev, NULL);
234 233
235 if (mem[idx]) { 234 if (mem[idx]) {
236 iounmap(priv->reg_base); 235 iounmap(priv->reg_base);
diff --git a/drivers/net/can/sja1000/sja1000_of_platform.c b/drivers/net/can/sja1000/sja1000_of_platform.c
index 8e0c4a001939..31ad33911167 100644
--- a/drivers/net/can/sja1000/sja1000_of_platform.c
+++ b/drivers/net/can/sja1000/sja1000_of_platform.c
@@ -72,13 +72,11 @@ static void sja1000_ofp_write_reg(const struct sja1000_priv *priv,
72 72
73static int sja1000_ofp_remove(struct platform_device *ofdev) 73static int sja1000_ofp_remove(struct platform_device *ofdev)
74{ 74{
75 struct net_device *dev = dev_get_drvdata(&ofdev->dev); 75 struct net_device *dev = platform_get_drvdata(ofdev);
76 struct sja1000_priv *priv = netdev_priv(dev); 76 struct sja1000_priv *priv = netdev_priv(dev);
77 struct device_node *np = ofdev->dev.of_node; 77 struct device_node *np = ofdev->dev.of_node;
78 struct resource res; 78 struct resource res;
79 79
80 dev_set_drvdata(&ofdev->dev, NULL);
81
82 unregister_sja1000dev(dev); 80 unregister_sja1000dev(dev);
83 free_sja1000dev(dev); 81 free_sja1000dev(dev);
84 iounmap(priv->reg_base); 82 iounmap(priv->reg_base);
@@ -181,7 +179,7 @@ static int sja1000_ofp_probe(struct platform_device *ofdev)
181 priv->reg_base, dev->irq, priv->can.clock.freq, 179 priv->reg_base, dev->irq, priv->can.clock.freq,
182 priv->ocr, priv->cdr); 180 priv->ocr, priv->cdr);
183 181
184 dev_set_drvdata(&ofdev->dev, dev); 182 platform_set_drvdata(ofdev, dev);
185 SET_NETDEV_DEV(dev, &ofdev->dev); 183 SET_NETDEV_DEV(dev, &ofdev->dev);
186 184
187 err = register_sja1000dev(dev); 185 err = register_sja1000dev(dev);
diff --git a/drivers/net/can/sja1000/sja1000_platform.c b/drivers/net/can/sja1000/sja1000_platform.c
index 21619bb5b869..8e259c541036 100644
--- a/drivers/net/can/sja1000/sja1000_platform.c
+++ b/drivers/net/can/sja1000/sja1000_platform.c
@@ -135,7 +135,7 @@ static int sp_probe(struct platform_device *pdev)
135 break; 135 break;
136 } 136 }
137 137
138 dev_set_drvdata(&pdev->dev, dev); 138 platform_set_drvdata(pdev, dev);
139 SET_NETDEV_DEV(dev, &pdev->dev); 139 SET_NETDEV_DEV(dev, &pdev->dev);
140 140
141 err = register_sja1000dev(dev); 141 err = register_sja1000dev(dev);
@@ -161,12 +161,11 @@ static int sp_probe(struct platform_device *pdev)
161 161
162static int sp_remove(struct platform_device *pdev) 162static int sp_remove(struct platform_device *pdev)
163{ 163{
164 struct net_device *dev = dev_get_drvdata(&pdev->dev); 164 struct net_device *dev = platform_get_drvdata(pdev);
165 struct sja1000_priv *priv = netdev_priv(dev); 165 struct sja1000_priv *priv = netdev_priv(dev);
166 struct resource *res; 166 struct resource *res;
167 167
168 unregister_sja1000dev(dev); 168 unregister_sja1000dev(dev);
169 dev_set_drvdata(&pdev->dev, NULL);
170 169
171 if (priv->reg_base) 170 if (priv->reg_base)
172 iounmap(priv->reg_base); 171 iounmap(priv->reg_base);