Commit 725b7018 authored by David S. Miller's avatar David S. Miller

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 26c4fdb0 5b853ec3
...@@ -208,40 +208,31 @@ static int c_can_plat_probe(struct platform_device *pdev) ...@@ -208,40 +208,31 @@ static int c_can_plat_probe(struct platform_device *pdev)
} }
/* get the appropriate clk */ /* get the appropriate clk */
clk = clk_get(&pdev->dev, NULL); clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
dev_err(&pdev->dev, "no clock defined\n"); ret = PTR_ERR(clk);
ret = -ENODEV;
goto exit; goto exit;
} }
/* get the platform data */ /* get the platform data */
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (!mem || irq <= 0) { if (irq <= 0) {
ret = -ENODEV; ret = -ENODEV;
goto exit_free_clk; goto exit;
}
if (!request_mem_region(mem->start, resource_size(mem),
KBUILD_MODNAME)) {
dev_err(&pdev->dev, "resource unavailable\n");
ret = -ENODEV;
goto exit_free_clk;
} }
addr = ioremap(mem->start, resource_size(mem)); mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!addr) { addr = devm_ioremap_resource(&pdev->dev, mem);
dev_err(&pdev->dev, "failed to map can port\n"); if (IS_ERR(addr)) {
ret = -ENOMEM; ret = PTR_ERR(addr);
goto exit_release_mem; goto exit;
} }
/* allocate the c_can device */ /* allocate the c_can device */
dev = alloc_c_can_dev(); dev = alloc_c_can_dev();
if (!dev) { if (!dev) {
ret = -ENOMEM; ret = -ENOMEM;
goto exit_iounmap; goto exit;
} }
priv = netdev_priv(dev); priv = netdev_priv(dev);
...@@ -321,12 +312,6 @@ static int c_can_plat_probe(struct platform_device *pdev) ...@@ -321,12 +312,6 @@ static int c_can_plat_probe(struct platform_device *pdev)
exit_free_device: exit_free_device:
free_c_can_dev(dev); free_c_can_dev(dev);
exit_iounmap:
iounmap(addr);
exit_release_mem:
release_mem_region(mem->start, resource_size(mem));
exit_free_clk:
clk_put(clk);
exit: exit:
dev_err(&pdev->dev, "probe failed\n"); dev_err(&pdev->dev, "probe failed\n");
...@@ -336,18 +321,10 @@ static int c_can_plat_probe(struct platform_device *pdev) ...@@ -336,18 +321,10 @@ static int c_can_plat_probe(struct platform_device *pdev)
static int c_can_plat_remove(struct platform_device *pdev) static int c_can_plat_remove(struct platform_device *pdev)
{ {
struct net_device *dev = platform_get_drvdata(pdev); struct net_device *dev = platform_get_drvdata(pdev);
struct c_can_priv *priv = netdev_priv(dev);
struct resource *mem;
unregister_c_can_dev(dev); unregister_c_can_dev(dev);
free_c_can_dev(dev); free_c_can_dev(dev);
iounmap(priv->base);
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(mem->start, resource_size(mem));
clk_put(priv->priv);
return 0; return 0;
} }
......
...@@ -141,6 +141,7 @@ static void set_normal_mode(struct net_device *dev) ...@@ -141,6 +141,7 @@ static void set_normal_mode(struct net_device *dev)
{ {
struct sja1000_priv *priv = netdev_priv(dev); struct sja1000_priv *priv = netdev_priv(dev);
unsigned char status = priv->read_reg(priv, SJA1000_MOD); unsigned char status = priv->read_reg(priv, SJA1000_MOD);
u8 mod_reg_val = 0x00;
int i; int i;
for (i = 0; i < 100; i++) { for (i = 0; i < 100; i++) {
...@@ -158,9 +159,10 @@ static void set_normal_mode(struct net_device *dev) ...@@ -158,9 +159,10 @@ static void set_normal_mode(struct net_device *dev)
/* set chip to normal mode */ /* set chip to normal mode */
if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY)
priv->write_reg(priv, SJA1000_MOD, MOD_LOM); mod_reg_val |= MOD_LOM;
else if (priv->can.ctrlmode & CAN_CTRLMODE_PRESUME_ACK)
priv->write_reg(priv, SJA1000_MOD, 0x00); mod_reg_val |= MOD_STM;
priv->write_reg(priv, SJA1000_MOD, mod_reg_val);
udelay(10); udelay(10);
...@@ -278,6 +280,7 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb, ...@@ -278,6 +280,7 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb,
uint8_t dlc; uint8_t dlc;
canid_t id; canid_t id;
uint8_t dreg; uint8_t dreg;
u8 cmd_reg_val = 0x00;
int i; int i;
if (can_dropped_invalid_skb(dev, skb)) if (can_dropped_invalid_skb(dev, skb))
...@@ -312,9 +315,14 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb, ...@@ -312,9 +315,14 @@ static netdev_tx_t sja1000_start_xmit(struct sk_buff *skb,
can_put_echo_skb(skb, dev, 0); can_put_echo_skb(skb, dev, 0);
if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT) if (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT)
sja1000_write_cmdreg(priv, CMD_TR | CMD_AT); cmd_reg_val |= CMD_AT;
if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK)
cmd_reg_val |= CMD_SRR;
else else
sja1000_write_cmdreg(priv, CMD_TR); cmd_reg_val |= CMD_TR;
sja1000_write_cmdreg(priv, cmd_reg_val);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
...@@ -622,9 +630,12 @@ struct net_device *alloc_sja1000dev(int sizeof_priv) ...@@ -622,9 +630,12 @@ struct net_device *alloc_sja1000dev(int sizeof_priv)
priv->can.do_set_bittiming = sja1000_set_bittiming; priv->can.do_set_bittiming = sja1000_set_bittiming;
priv->can.do_set_mode = sja1000_set_mode; priv->can.do_set_mode = sja1000_set_mode;
priv->can.do_get_berr_counter = sja1000_get_berr_counter; priv->can.do_get_berr_counter = sja1000_get_berr_counter;
priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | priv->can.ctrlmode_supported = CAN_CTRLMODE_LOOPBACK |
CAN_CTRLMODE_BERR_REPORTING | CAN_CTRLMODE_LISTENONLY | CAN_CTRLMODE_LISTENONLY |
CAN_CTRLMODE_ONE_SHOT; CAN_CTRLMODE_3_SAMPLES |
CAN_CTRLMODE_ONE_SHOT |
CAN_CTRLMODE_BERR_REPORTING |
CAN_CTRLMODE_PRESUME_ACK;
spin_lock_init(&priv->cmdreg_lock); spin_lock_init(&priv->cmdreg_lock);
......
...@@ -92,11 +92,12 @@ struct can_ctrlmode { ...@@ -92,11 +92,12 @@ struct can_ctrlmode {
}; };
#define CAN_CTRLMODE_LOOPBACK 0x01 /* Loopback mode */ #define CAN_CTRLMODE_LOOPBACK 0x01 /* Loopback mode */
#define CAN_CTRLMODE_LISTENONLY 0x02 /* Listen-only mode */ #define CAN_CTRLMODE_LISTENONLY 0x02 /* Listen-only mode */
#define CAN_CTRLMODE_3_SAMPLES 0x04 /* Triple sampling mode */ #define CAN_CTRLMODE_3_SAMPLES 0x04 /* Triple sampling mode */
#define CAN_CTRLMODE_ONE_SHOT 0x08 /* One-Shot mode */ #define CAN_CTRLMODE_ONE_SHOT 0x08 /* One-Shot mode */
#define CAN_CTRLMODE_BERR_REPORTING 0x10 /* Bus-error reporting */ #define CAN_CTRLMODE_BERR_REPORTING 0x10 /* Bus-error reporting */
#define CAN_CTRLMODE_FD 0x20 /* CAN FD mode */ #define CAN_CTRLMODE_FD 0x20 /* CAN FD mode */
#define CAN_CTRLMODE_PRESUME_ACK 0x40 /* Ignore missing CAN ACKs */
/* /*
* CAN device statistics * CAN device statistics
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment