diff options
author | Marc Zyngier <maz@misterjones.org> | 2010-03-29 04:57:56 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-03-31 02:51:09 -0400 |
commit | e446630c960946b5c1762e4eadb618becef599e7 (patch) | |
tree | 7dc73fc57fd1d38f309b208b6dadfddf248cb05f /drivers | |
parent | 598ed9367a36ee1fd4ae3271a54a3547a33975a5 (diff) |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/can/mcp251x.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c index f8cc168ec76c..f521579f5adb 100644 --- a/drivers/net/can/mcp251x.c +++ b/drivers/net/can/mcp251x.c | |||
@@ -922,12 +922,16 @@ static int __devinit mcp251x_can_probe(struct spi_device *spi) | |||
922 | struct net_device *net; | 922 | struct net_device *net; |
923 | struct mcp251x_priv *priv; | 923 | struct mcp251x_priv *priv; |
924 | struct mcp251x_platform_data *pdata = spi->dev.platform_data; | 924 | struct mcp251x_platform_data *pdata = spi->dev.platform_data; |
925 | int model = spi_get_device_id(spi)->driver_data; | ||
925 | int ret = -ENODEV; | 926 | int ret = -ENODEV; |
926 | 927 | ||
927 | if (!pdata) | 928 | if (!pdata) |
928 | /* Platform data is required for osc freq */ | 929 | /* Platform data is required for osc freq */ |
929 | goto error_out; | 930 | goto error_out; |
930 | 931 | ||
932 | if (model) | ||
933 | pdata->model = model; | ||
934 | |||
931 | /* Allocate can/net device */ | 935 | /* Allocate can/net device */ |
932 | net = alloc_candev(sizeof(struct mcp251x_priv), TX_ECHO_SKB_MAX); | 936 | net = alloc_candev(sizeof(struct mcp251x_priv), TX_ECHO_SKB_MAX); |
933 | if (!net) { | 937 | if (!net) { |
@@ -1117,6 +1121,15 @@ static int mcp251x_can_resume(struct spi_device *spi) | |||
1117 | #define mcp251x_can_resume NULL | 1121 | #define mcp251x_can_resume NULL |
1118 | #endif | 1122 | #endif |
1119 | 1123 | ||
1124 | static struct spi_device_id mcp251x_id_table[] = { | ||
1125 | { "mcp251x", 0 /* Use pdata.model */ }, | ||
1126 | { "mcp2510", CAN_MCP251X_MCP2510 }, | ||
1127 | { "mcp2515", CAN_MCP251X_MCP2515 }, | ||
1128 | { }, | ||
1129 | }; | ||
1130 | |||
1131 | MODULE_DEVICE_TABLE(spi, mcp251x_id_table); | ||
1132 | |||
1120 | static struct spi_driver mcp251x_can_driver = { | 1133 | static struct spi_driver mcp251x_can_driver = { |
1121 | .driver = { | 1134 | .driver = { |
1122 | .name = DEVICE_NAME, | 1135 | .name = DEVICE_NAME, |
@@ -1124,6 +1137,7 @@ static struct spi_driver mcp251x_can_driver = { | |||
1124 | .owner = THIS_MODULE, | 1137 | .owner = THIS_MODULE, |
1125 | }, | 1138 | }, |
1126 | 1139 | ||
1140 | .id_table = mcp251x_id_table, | ||
1127 | .probe = mcp251x_can_probe, | 1141 | .probe = mcp251x_can_probe, |
1128 | .remove = __devexit_p(mcp251x_can_remove), | 1142 | .remove = __devexit_p(mcp251x_can_remove), |
1129 | .suspend = mcp251x_can_suspend, | 1143 | .suspend = mcp251x_can_suspend, |