aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can/mcp251x.c
diff options
context:
space:
mode:
authorChristian Pellegrin <chripell@fsfe.org>2010-01-14 02:08:34 -0500
committerDavid S. Miller <davem@davemloft.net>2010-01-15 04:39:17 -0500
commitad72c347e56bf3a0231b9d686e17764157d2961c (patch)
tree4db03a0abae50edfaf996f43e3f717a57b776fbd /drivers/net/can/mcp251x.c
parent1954dc11776ef8c06263ba4cd21bf4d25c79a19c (diff)
can: Proper ctrlmode handling for CAN devices
This patch adds error checking of ctrlmode values for CAN devices. As an example all availabe bits are implemented in the mcp251x driver. Signed-off-by: Christian Pellegrin <chripell@fsfe.org> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/can/mcp251x.c')
-rw-r--r--drivers/net/can/mcp251x.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index afa2fa45fed9..bbe186b5a0ed 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -539,9 +539,14 @@ static void mcp251x_set_normal_mode(struct spi_device *spi)
539 if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) { 539 if (priv->can.ctrlmode & CAN_CTRLMODE_LOOPBACK) {
540 /* Put device into loopback mode */ 540 /* Put device into loopback mode */
541 mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_LOOPBACK); 541 mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_LOOPBACK);
542 } else if (priv->can.ctrlmode & CAN_CTRLMODE_LISTENONLY) {
543 /* Put device into listen-only mode */
544 mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_LISTEN_ONLY);
542 } else { 545 } else {
543 /* Put device into normal mode */ 546 /* Put device into normal mode */
544 mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_NORMAL); 547 mcp251x_write_reg(spi, CANCTRL, CANCTRL_REQOP_NORMAL |
548 (priv->can.ctrlmode & CAN_CTRLMODE_ONE_SHOT ?
549 CANCTRL_OSM : 0));
545 550
546 /* Wait for the device to enter normal mode */ 551 /* Wait for the device to enter normal mode */
547 timeout = jiffies + HZ; 552 timeout = jiffies + HZ;
@@ -948,6 +953,10 @@ static int __devinit mcp251x_can_probe(struct spi_device *spi)
948 priv->can.bittiming_const = &mcp251x_bittiming_const; 953 priv->can.bittiming_const = &mcp251x_bittiming_const;
949 priv->can.do_set_mode = mcp251x_do_set_mode; 954 priv->can.do_set_mode = mcp251x_do_set_mode;
950 priv->can.clock.freq = pdata->oscillator_frequency / 2; 955 priv->can.clock.freq = pdata->oscillator_frequency / 2;
956 priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
957 CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY;
958 if (pdata->model == CAN_MCP251X_MCP2515)
959 priv->can.ctrlmode_supported |= CAN_CTRLMODE_ONE_SHOT;
951 priv->net = net; 960 priv->net = net;
952 dev_set_drvdata(&spi->dev, priv); 961 dev_set_drvdata(&spi->dev, priv);
953 962