aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can/mcp251x.c
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2010-10-18 09:00:18 -0400
committerMarc Kleine-Budde <mkl@pengutronix.de>2010-10-18 09:16:08 -0400
commitf1f8c6cbe6f08f93ac2a4ca19625891d8a82b7f8 (patch)
tree0ed97a9e3ed0414f69a7ad65778ee4dbeb282642 /drivers/net/can/mcp251x.c
parentd3cd15657516141adce387810be8cb377baf020e (diff)
can: mcp251x: Don't use pdata->model for chip selection anymore
Since commit e446630c960946b5c1762e4eadb618becef599e7, i.e. v2.6.35-rc1, the mcp251x chip model can be selected via the modalias member in the struct spi_board_info. The driver stores the actual model in the struct mcp251x_platform_data. From the driver point of view the platform_data should be read only. Since all in-tree users of the mcp251x have already been converted to the modalias method, this patch moves the "model" member from the struct mcp251x_platform_data to the driver's private data structure. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Cc: Christian Pellegrin <chripell@fsfe.org> Cc: Marc Zyngier <maz@misterjones.org>
Diffstat (limited to 'drivers/net/can/mcp251x.c')
-rw-r--r--drivers/net/can/mcp251x.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index f5e2edd09ce4..0386bed43551 100644
--- a/drivers/net/can/mcp251x.c
+++ b/drivers/net/can/mcp251x.c
@@ -38,14 +38,14 @@
38 * static struct mcp251x_platform_data mcp251x_info = { 38 * static struct mcp251x_platform_data mcp251x_info = {
39 * .oscillator_frequency = 8000000, 39 * .oscillator_frequency = 8000000,
40 * .board_specific_setup = &mcp251x_setup, 40 * .board_specific_setup = &mcp251x_setup,
41 * .model = CAN_MCP251X_MCP2510,
42 * .power_enable = mcp251x_power_enable, 41 * .power_enable = mcp251x_power_enable,
43 * .transceiver_enable = NULL, 42 * .transceiver_enable = NULL,
44 * }; 43 * };
45 * 44 *
46 * static struct spi_board_info spi_board_info[] = { 45 * static struct spi_board_info spi_board_info[] = {
47 * { 46 * {
48 * .modalias = "mcp251x", 47 * .modalias = "mcp2510",
48 * // or "mcp2515" depending on your controller
49 * .platform_data = &mcp251x_info, 49 * .platform_data = &mcp251x_info,
50 * .irq = IRQ_EINT13, 50 * .irq = IRQ_EINT13,
51 * .max_speed_hz = 2*1000*1000, 51 * .max_speed_hz = 2*1000*1000,
@@ -224,10 +224,16 @@ static struct can_bittiming_const mcp251x_bittiming_const = {
224 .brp_inc = 1, 224 .brp_inc = 1,
225}; 225};
226 226
227enum mcp251x_model {
228 CAN_MCP251X_MCP2510 = 0x2510,
229 CAN_MCP251X_MCP2515 = 0x2515,
230};
231
227struct mcp251x_priv { 232struct mcp251x_priv {
228 struct can_priv can; 233 struct can_priv can;
229 struct net_device *net; 234 struct net_device *net;
230 struct spi_device *spi; 235 struct spi_device *spi;
236 enum mcp251x_model model;
231 237
232 struct mutex mcp_lock; /* SPI device lock */ 238 struct mutex mcp_lock; /* SPI device lock */
233 239
@@ -362,10 +368,9 @@ static void mcp251x_write_bits(struct spi_device *spi, u8 reg,
362static void mcp251x_hw_tx_frame(struct spi_device *spi, u8 *buf, 368static void mcp251x_hw_tx_frame(struct spi_device *spi, u8 *buf,
363 int len, int tx_buf_idx) 369 int len, int tx_buf_idx)
364{ 370{
365 struct mcp251x_platform_data *pdata = spi->dev.platform_data;
366 struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); 371 struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
367 372
368 if (pdata->model == CAN_MCP251X_MCP2510) { 373 if (priv->model == CAN_MCP251X_MCP2510) {
369 int i; 374 int i;
370 375
371 for (i = 1; i < TXBDAT_OFF + len; i++) 376 for (i = 1; i < TXBDAT_OFF + len; i++)
@@ -408,9 +413,8 @@ static void mcp251x_hw_rx_frame(struct spi_device *spi, u8 *buf,
408 int buf_idx) 413 int buf_idx)
409{ 414{
410 struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev); 415 struct mcp251x_priv *priv = dev_get_drvdata(&spi->dev);
411 struct mcp251x_platform_data *pdata = spi->dev.platform_data;
412 416
413 if (pdata->model == CAN_MCP251X_MCP2510) { 417 if (priv->model == CAN_MCP251X_MCP2510) {
414 int i, len; 418 int i, len;
415 419
416 for (i = 1; i < RXBDAT_OFF; i++) 420 for (i = 1; i < RXBDAT_OFF; i++)
@@ -951,16 +955,12 @@ static int __devinit mcp251x_can_probe(struct spi_device *spi)
951 struct net_device *net; 955 struct net_device *net;
952 struct mcp251x_priv *priv; 956 struct mcp251x_priv *priv;
953 struct mcp251x_platform_data *pdata = spi->dev.platform_data; 957 struct mcp251x_platform_data *pdata = spi->dev.platform_data;
954 int model = spi_get_device_id(spi)->driver_data;
955 int ret = -ENODEV; 958 int ret = -ENODEV;
956 959
957 if (!pdata) 960 if (!pdata)
958 /* Platform data is required for osc freq */ 961 /* Platform data is required for osc freq */
959 goto error_out; 962 goto error_out;
960 963
961 if (model)
962 pdata->model = model;
963
964 /* Allocate can/net device */ 964 /* Allocate can/net device */
965 net = alloc_candev(sizeof(struct mcp251x_priv), TX_ECHO_SKB_MAX); 965 net = alloc_candev(sizeof(struct mcp251x_priv), TX_ECHO_SKB_MAX);
966 if (!net) { 966 if (!net) {
@@ -977,6 +977,7 @@ static int __devinit mcp251x_can_probe(struct spi_device *spi)
977 priv->can.clock.freq = pdata->oscillator_frequency / 2; 977 priv->can.clock.freq = pdata->oscillator_frequency / 2;
978 priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES | 978 priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES |
979 CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY; 979 CAN_CTRLMODE_LOOPBACK | CAN_CTRLMODE_LISTENONLY;
980 priv->model = spi_get_device_id(spi)->driver_data;
980 priv->net = net; 981 priv->net = net;
981 dev_set_drvdata(&spi->dev, priv); 982 dev_set_drvdata(&spi->dev, priv);
982 983
@@ -1150,8 +1151,7 @@ static int mcp251x_can_resume(struct spi_device *spi)
1150#define mcp251x_can_resume NULL 1151#define mcp251x_can_resume NULL
1151#endif 1152#endif
1152 1153
1153static struct spi_device_id mcp251x_id_table[] = { 1154static const struct spi_device_id mcp251x_id_table[] = {
1154 { "mcp251x", 0 /* Use pdata.model */ },
1155 { "mcp2510", CAN_MCP251X_MCP2510 }, 1155 { "mcp2510", CAN_MCP251X_MCP2510 },
1156 { "mcp2515", CAN_MCP251X_MCP2515 }, 1156 { "mcp2515", CAN_MCP251X_MCP2515 },
1157 { }, 1157 { },