aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/can')
-rw-r--r--drivers/net/can/sja1000/sja1000_platform.c46
1 files changed, 12 insertions, 34 deletions
diff --git a/drivers/net/can/sja1000/sja1000_platform.c b/drivers/net/can/sja1000/sja1000_platform.c
index 943df645b459..50ca27387c4c 100644
--- a/drivers/net/can/sja1000/sja1000_platform.c
+++ b/drivers/net/can/sja1000/sja1000_platform.c
@@ -78,34 +78,26 @@ static int sp_probe(struct platform_device *pdev)
78 pdata = dev_get_platdata(&pdev->dev); 78 pdata = dev_get_platdata(&pdev->dev);
79 if (!pdata) { 79 if (!pdata) {
80 dev_err(&pdev->dev, "No platform data provided!\n"); 80 dev_err(&pdev->dev, "No platform data provided!\n");
81 err = -ENODEV; 81 return -ENODEV;
82 goto exit;
83 } 82 }
84 83
85 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 84 res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
86 res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 85 res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
87 if (!res_mem || !res_irq) { 86 if (!res_mem || !res_irq)
88 err = -ENODEV; 87 return -ENODEV;
89 goto exit;
90 }
91 88
92 if (!request_mem_region(res_mem->start, resource_size(res_mem), 89 if (!devm_request_mem_region(&pdev->dev, res_mem->start,
93 DRV_NAME)) { 90 resource_size(res_mem), DRV_NAME))
94 err = -EBUSY; 91 return -EBUSY;
95 goto exit;
96 }
97 92
98 addr = ioremap_nocache(res_mem->start, resource_size(res_mem)); 93 addr = devm_ioremap_nocache(&pdev->dev, res_mem->start,
99 if (!addr) { 94 resource_size(res_mem));
100 err = -ENOMEM; 95 if (!addr)
101 goto exit_release; 96 return -ENOMEM;
102 }
103 97
104 dev = alloc_sja1000dev(0); 98 dev = alloc_sja1000dev(0);
105 if (!dev) { 99 if (!dev)
106 err = -ENOMEM; 100 return -ENOMEM;
107 goto exit_iounmap;
108 }
109 priv = netdev_priv(dev); 101 priv = netdev_priv(dev);
110 102
111 dev->irq = res_irq->start; 103 dev->irq = res_irq->start;
@@ -150,28 +142,14 @@ static int sp_probe(struct platform_device *pdev)
150 142
151 exit_free: 143 exit_free:
152 free_sja1000dev(dev); 144 free_sja1000dev(dev);
153 exit_iounmap:
154 iounmap(addr);
155 exit_release:
156 release_mem_region(res_mem->start, resource_size(res_mem));
157 exit:
158 return err; 145 return err;
159} 146}
160 147
161static int sp_remove(struct platform_device *pdev) 148static int sp_remove(struct platform_device *pdev)
162{ 149{
163 struct net_device *dev = platform_get_drvdata(pdev); 150 struct net_device *dev = platform_get_drvdata(pdev);
164 struct sja1000_priv *priv = netdev_priv(dev);
165 struct resource *res;
166 151
167 unregister_sja1000dev(dev); 152 unregister_sja1000dev(dev);
168
169 if (priv->reg_base)
170 iounmap(priv->reg_base);
171
172 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
173 release_mem_region(res->start, resource_size(res));
174
175 free_sja1000dev(dev); 153 free_sja1000dev(dev);
176 154
177 return 0; 155 return 0;