diff options
author | David S. Miller <davem@davemloft.net> | 2014-07-15 20:39:39 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-15 20:39:39 -0400 |
commit | 725b70185d6b4ae73dc563725a95a0c10e242df5 (patch) | |
tree | 35d241f6a643ca85ec9e50a66b5d55e6b984303f /drivers | |
parent | 26c4fdb0528ae7c4be9fbc8a8210f3b410e6b5aa (diff) | |
parent | 5b853ec3494e34eb4882f65ebbcd04b495ff3c85 (diff) |
Merge tag 'linux-can-next-for-3.17-20140715' of git://gitorious.org/linux-can/linux-can-next
Marc Kleine-Budde says:
====================
pull-request: can-next 2014-07-15
this is a pull request of 4 patches for net-next/master.
Prabhakar Lad contributes a patch that converts the c_can driver to use
the devm api. The remaining four patches by Nikita Edward Baruzdin
improve the SJA1000 driver with loopback testing support and introduce
a new testing mode presume ack, for successful transmission even if no
ACK is received.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/can/c_can/c_can_platform.c | 43 | ||||
-rw-r--r-- | drivers/net/can/sja1000/sja1000.c | 27 |
2 files changed, 29 insertions, 41 deletions
diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c index 824108cd9fd5..e29b6d051103 100644 --- a/drivers/net/can/c_can/c_can_platform.c +++ b/drivers/net/can/c_can/c_can_platform.c | |||
@@ -208,40 +208,31 @@ static int c_can_plat_probe(struct platform_device *pdev) | |||
208 | } | 208 | } |
209 | 209 | ||
210 | /* get the appropriate clk */ | 210 | /* get the appropriate clk */ |
211 | clk = clk_get(&pdev->dev, NULL); | 211 | clk = devm_clk_get(&pdev->dev, NULL); |
212 | if (IS_ERR(clk)) { | 212 | if (IS_ERR(clk)) { |
213 | dev_err(&pdev->dev, "no clock defined\n"); | 213 | ret = PTR_ERR(clk); |
214 | ret = -ENODEV; | ||
215 | goto exit; | 214 | goto exit; |
216 | } | 215 | } |
217 | 216 | ||
218 | /* get the platform data */ | 217 | /* get the platform data */ |
219 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
220 | irq = platform_get_irq(pdev, 0); | 218 | irq = platform_get_irq(pdev, 0); |
221 | if (!mem || irq <= 0) { | 219 | if (irq <= 0) { |
222 | ret = -ENODEV; | 220 | ret = -ENODEV; |
223 | goto exit_free_clk; | 221 | goto exit; |
224 | } | ||
225 | |||
226 | if (!request_mem_region(mem->start, resource_size(mem), | ||
227 | KBUILD_MODNAME)) { | ||
228 | dev_err(&pdev->dev, "resource unavailable\n"); | ||
229 | ret = -ENODEV; | ||
230 | goto exit_free_clk; | ||
231 | } | 222 | } |
232 | 223 | ||
233 | addr = ioremap(mem->start, resource_size(mem)); | 224 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
234 | if (!addr) { | 225 | addr = devm_ioremap_resource(&pdev->dev, mem); |
235 | dev_err(&pdev->dev, "failed to map can port\n"); | 226 | if (IS_ERR(addr)) { |
236 | ret = -ENOMEM; | 227 | ret = PTR_ERR(addr); |
237 | goto exit_release_mem; | 228 | goto exit; |
238 | } | 229 | } |
239 | 230 | ||
240 | /* allocate the c_can device */ | 231 | /* allocate the c_can device */ |
241 | dev = alloc_c_can_dev(); | 232 | dev = alloc_c_can_dev(); |
242 | if (!dev) { | 233 | if (!dev) { |
243 | ret = -ENOMEM; | 234 | ret = -ENOMEM; |
244 | goto exit_iounmap; | 235 | goto exit; |
245 | } | 236 | } |
246 | 237 | ||
247 | priv = netdev_priv(dev); | 238 | priv = netdev_priv(dev); |
@@ -321,12 +312,6 @@ static int c_can_plat_probe(struct platform_device *pdev) | |||
321 | 312 | ||
322 | exit_free_device: | 313 | exit_free_device: |
323 | free_c_can_dev(dev); | 314 | free_c_can_dev(dev); |
324 | exit_iounmap: | ||
325 | iounmap(addr); | ||
326 | exit_release_mem: | ||
327 | release_mem_region(mem->start, resource_size(mem)); | ||
328 | exit_free_clk: | ||
329 | clk_put(clk); | ||
330 | exit: | 315 | exit: |
331 | dev_err(&pdev->dev, "probe failed\n"); | 316 | dev_err(&pdev->dev, "probe failed\n"); |
332 | 317 | ||
@@ -336,18 +321,10 @@ exit: | |||
336 | static int c_can_plat_remove(struct platform_device *pdev) | 321 | static int c_can_plat_remove(struct platform_device *pdev) |
337 | { | 322 | { |
338 | struct net_device *dev = platform_get_drvdata(pdev); | 323 | struct net_device *dev = platform_get_drvdata(pdev); |
339 | struct c_can_priv *priv = netdev_priv(dev); | ||
340 | struct resource *mem; | ||
341 | 324 | ||
342 | unregister_c_can_dev(dev); | 325 | unregister_c_can_dev(dev); |
343 | 326 | ||
344 | free_c_can_dev(dev); | 327 | free_c_can_dev(dev); |
345 | iounmap(priv->base); | ||
346 | |||
347 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
348 | release_mem_region(mem->start, resource_size(mem)); | ||
349 | |||
350 | clk_put(priv->priv); | ||
351 | 328 | ||
352 | return 0; | 329 | return 0; |
353 | } | 330 | } |
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c index f31499a32d7d..d1692154ed1b 100644 --- a/drivers/net/can/sja1000/sja1000.c +++ b/drivers/net/can/sja1000/sja1000.c | |||
@@ -141,6 +141,7 @@ static void set_normal_mode(struct net_device *dev) | |||
141 | { | 141 | { |
142 | struct sja1000_priv *priv = netdev_priv(dev); | 142 | struct sja1000_priv *priv = netdev_priv(dev); |
143 | unsigned char status = priv->read_reg(priv, SJA1000_MOD); | 143 | unsigned char status = priv->read_reg(priv, SJA1000_MOD); |
144 | u8 mod_reg_val = 0x00; | ||
144 | int i; | 145 | int i; |
145 | 146 | ||
146 | for (i = 0; i < 100; i++) { | 147 | for (i = 0; i < 100; i++) { |
@@ -158,9 +159,10 @@ static void set_normal_mode(struct net_device *dev) | |||
158 | 159 | ||
159 | /* set chip to normal mode */ | 160 | /* set chip to normal mode */ |
160 | if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) | 161 | if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) |
161 | priv->write_reg(priv, SJA1000_MOD, MOD_LOM); | 162 | mod_reg_val |= MOD_LOM; |
162 | else | 163 | if (priv->can.ctrlmode & CAN_CTRLMODE_PRESUME_ACK) |
163 | priv->write_reg(priv, SJA1000_MOD, 0x00); | 164 | mod_reg_val |= MOD_STM; |
165 | priv->write_reg(priv, SJA1000_MOD, mod_reg_val); | ||
164 | 166 | ||
165 | udelay(10); | 167 | udelay(10); |
166 | 168 | ||
@@ -278,6 +280,7 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb, | |||
278 | uint8_t dlc; | 280 | uint8_t dlc; |
279 | canid_t id; | 281 | canid_t id; |
280 | uint8_t dreg; | 282 | uint8_t dreg; |
283 | u8 cmd_reg_val = 0x00; | ||
281 | int i; | 284 | int i; |
282 | 285 | ||
283 | if (can_dropped_invalid_skb(dev, skb)) | 286 | if (can_dropped_invalid_skb(dev, skb)) |
@@ -312,9 +315,14 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb, | |||
312 | can_put_echo_skb(skb, dev, 0); | 315 | can_put_echo_skb(skb, dev, 0); |
313 | 316 | ||
314 | if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT) | 317 | if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT) |
315 | sja1000_write_cmdreg(priv, CMD_TR | CMD_AT); | 318 | cmd_reg_val |= CMD_AT; |
319 | |||
320 | if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) | ||
321 | cmd_reg_val |= CMD_SRR; | ||
316 | else | 322 | else |
317 | sja1000_write_cmdreg(priv, CMD_TR); | 323 | cmd_reg_val |= CMD_TR; |
324 | |||
325 | sja1000_write_cmdreg(priv, cmd_reg_val); | ||
318 | 326 | ||
319 | return NETDEV_TX_OK; | 327 | return NETDEV_TX_OK; |
320 | } | 328 | } |
@@ -622,9 +630,12 @@ struct net_device *alloc_sja1000dev(int sizeof_priv) | |||
622 | priv->can.do_set_bittiming = sja1000_set_bittiming; | 630 | priv->can.do_set_bittiming = sja1000_set_bittiming; |
623 | priv->can.do_set_mode = sja1000_set_mode; | 631 | priv->can.do_set_mode = sja1000_set_mode; |
624 | priv->can.do_get_berr_counter = sja1000_get_berr_counter; | 632 | priv->can.do_get_berr_counter = sja1000_get_berr_counter; |
625 | priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | | 633 | priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK | |
626 | CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_LISTENONLY | | 634 | CAN_CTRLMODE_LISTENONLY | |
627 | CAN_CTRLMODE_ONE_SHOT; | 635 | CAN_CTRLMODE_3_SAMPLES | |
636 | CAN_CTRLMODE_ONE_SHOT | | ||
637 | CAN_CTRLMODE_BERR_REPORTING | | ||
638 | CAN_CTRLMODE_PRESUME_ACK; | ||
628 | 639 | ||
629 | spin_lock_init(&priv->cmdreg_lock); | 640 | spin_lock_init(&priv->cmdreg_lock); |
630 | 641 | ||