Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Add hotplug support to mcp251x driver

Chip model can now be selected directly by matching the modalias name
(instead of filling the .model field in platform_data), and allows the
module to be auto-loaded. Previous behaviour is of course still supported.

Convert the two in-tree users to this feature (icontrol & zeus).
Tested on an Zeus platform (mcp2515).

Signed-off-by: Marc Zyngier <maz@misterjones.org>
Acked-by: Christian Pellegrin <chripell@fsfe.org>
Cc: Edwin Peer <epeer@tmtservices.co.za>
Acked-by: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Marc Zyngier and committed by
David S. Miller
e446630c 598ed936

+21 -10
+4 -5
arch/arm/mach-pxa/icontrol.c
··· 73 73 74 74 static struct mcp251x_platform_data mcp251x_info = { 75 75 .oscillator_frequency = 16E6, 76 - .model = CAN_MCP251X_MCP2515, 77 76 .board_specific_setup = NULL, 78 77 .power_enable = NULL, 79 78 .transceiver_enable = NULL ··· 80 81 81 82 static struct spi_board_info mcp251x_board_info[] = { 82 83 { 83 - .modalias = "mcp251x", 84 + .modalias = "mcp2515", 84 85 .max_speed_hz = 6500000, 85 86 .bus_num = 3, 86 87 .chip_select = 0, ··· 89 90 .irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ1) 90 91 }, 91 92 { 92 - .modalias = "mcp251x", 93 + .modalias = "mcp2515", 93 94 .max_speed_hz = 6500000, 94 95 .bus_num = 3, 95 96 .chip_select = 1, ··· 98 99 .irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ2) 99 100 }, 100 101 { 101 - .modalias = "mcp251x", 102 + .modalias = "mcp2515", 102 103 .max_speed_hz = 6500000, 103 104 .bus_num = 4, 104 105 .chip_select = 0, ··· 107 108 .irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ3) 108 109 }, 109 110 { 110 - .modalias = "mcp251x", 111 + .modalias = "mcp2515", 111 112 .max_speed_hz = 6500000, 112 113 .bus_num = 4, 113 114 .chip_select = 1,
+1 -3
arch/arm/mach-pxa/zeus.c
··· 414 414 415 415 static struct mcp251x_platform_data zeus_mcp2515_pdata = { 416 416 .oscillator_frequency = 16*1000*1000, 417 - .model = CAN_MCP251X_MCP2515, 418 417 .board_specific_setup = zeus_mcp2515_setup, 419 - .transceiver_enable = zeus_mcp2515_transceiver_enable, 420 418 .power_enable = zeus_mcp2515_transceiver_enable, 421 419 }; 422 420 423 421 static struct spi_board_info zeus_spi_board_info[] = { 424 422 [0] = { 425 - .modalias = "mcp251x", 423 + .modalias = "mcp2515", 426 424 .platform_data = &zeus_mcp2515_pdata, 427 425 .irq = gpio_to_irq(ZEUS_CAN_GPIO), 428 426 .max_speed_hz = 1*1000*1000,
+14
drivers/net/can/mcp251x.c
··· 922 922 struct net_device *net; 923 923 struct mcp251x_priv *priv; 924 924 struct mcp251x_platform_data *pdata = spi->dev.platform_data; 925 + int model = spi_get_device_id(spi)->driver_data; 925 926 int ret = -ENODEV; 926 927 927 928 if (!pdata) 928 929 /* Platform data is required for osc freq */ 929 930 goto error_out; 931 + 932 + if (model) 933 + pdata->model = model; 930 934 931 935 /* Allocate can/net device */ 932 936 net = alloc_candev(sizeof(struct mcp251x_priv), TX_ECHO_SKB_MAX); ··· 1121 1117 #define mcp251x_can_resume NULL 1122 1118 #endif 1123 1119 1120 + static struct spi_device_id mcp251x_id_table[] = { 1121 + { "mcp251x", 0 /* Use pdata.model */ }, 1122 + { "mcp2510", CAN_MCP251X_MCP2510 }, 1123 + { "mcp2515", CAN_MCP251X_MCP2515 }, 1124 + { }, 1125 + }; 1126 + 1127 + MODULE_DEVICE_TABLE(spi, mcp251x_id_table); 1128 + 1124 1129 static struct spi_driver mcp251x_can_driver = { 1125 1130 .driver = { 1126 1131 .name = DEVICE_NAME, ··· 1137 1124 .owner = THIS_MODULE, 1138 1125 }, 1139 1126 1127 + .id_table = mcp251x_id_table, 1140 1128 .probe = mcp251x_can_probe, 1141 1129 .remove = __devexit_p(mcp251x_can_remove), 1142 1130 .suspend = mcp251x_can_suspend,
+2 -2
include/linux/can/platform/mcp251x.h
··· 26 26 struct mcp251x_platform_data { 27 27 unsigned long oscillator_frequency; 28 28 int model; 29 - #define CAN_MCP251X_MCP2510 0 30 - #define CAN_MCP251X_MCP2515 1 29 + #define CAN_MCP251X_MCP2510 0x2510 30 + #define CAN_MCP251X_MCP2515 0x2515 31 31 int (*board_specific_setup)(struct spi_device *spi); 32 32 int (*transceiver_enable)(int enable); 33 33 int (*power_enable) (int enable);