* [PATCH] Add hotplug support to mcp251x driver
@ 2010-03-29 18:57 ` Marc Zyngier
0 siblings, 0 replies; 7+ messages in thread
From: Marc Zyngier @ 2010-03-29 18:57 UTC (permalink / raw)
To: netdev, socketcan-core, linux-arm-kernel; +Cc: Edwin Peer
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>
---
arch/arm/mach-pxa/icontrol.c | 9 ++++-----
arch/arm/mach-pxa/zeus.c | 4 +---
drivers/net/can/mcp251x.c | 14 ++++++++++++++
include/linux/can/platform/mcp251x.h | 4 ++--
4 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-pxa/icontrol.c b/arch/arm/mach-pxa/icontrol.c
index 771137f..5ccb0ce 100644
--- a/arch/arm/mach-pxa/icontrol.c
+++ b/arch/arm/mach-pxa/icontrol.c
@@ -73,7 +73,6 @@ static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
static struct mcp251x_platform_data mcp251x_info = {
.oscillator_frequency = 16E6,
- .model = CAN_MCP251X_MCP2515,
.board_specific_setup = NULL,
.power_enable = NULL,
.transceiver_enable = NULL
@@ -81,7 +80,7 @@ static struct mcp251x_platform_data mcp251x_info = {
static struct spi_board_info mcp251x_board_info[] = {
{
- .modalias = "mcp251x",
+ .modalias = "mcp2515",
.max_speed_hz = 6500000,
.bus_num = 3,
.chip_select = 0,
@@ -90,7 +89,7 @@ static struct spi_board_info mcp251x_board_info[] = {
.irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ1)
},
{
- .modalias = "mcp251x",
+ .modalias = "mcp2515",
.max_speed_hz = 6500000,
.bus_num = 3,
.chip_select = 1,
@@ -99,7 +98,7 @@ static struct spi_board_info mcp251x_board_info[] = {
.irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ2)
},
{
- .modalias = "mcp251x",
+ .modalias = "mcp2515",
.max_speed_hz = 6500000,
.bus_num = 4,
.chip_select = 0,
@@ -108,7 +107,7 @@ static struct spi_board_info mcp251x_board_info[] = {
.irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ3)
},
{
- .modalias = "mcp251x",
+ .modalias = "mcp2515",
.max_speed_hz = 6500000,
.bus_num = 4,
.chip_select = 1,
diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c
index 39896d8..dbd2569 100644
--- a/arch/arm/mach-pxa/zeus.c
+++ b/arch/arm/mach-pxa/zeus.c
@@ -414,15 +414,13 @@ static int zeus_mcp2515_transceiver_enable(int enable)
static struct mcp251x_platform_data zeus_mcp2515_pdata = {
.oscillator_frequency = 16*1000*1000,
- .model = CAN_MCP251X_MCP2515,
.board_specific_setup = zeus_mcp2515_setup,
- .transceiver_enable = zeus_mcp2515_transceiver_enable,
.power_enable = zeus_mcp2515_transceiver_enable,
};
static struct spi_board_info zeus_spi_board_info[] = {
[0] = {
- .modalias = "mcp251x",
+ .modalias = "mcp2515",
.platform_data = &zeus_mcp2515_pdata,
.irq = gpio_to_irq(ZEUS_CAN_GPIO),
.max_speed_hz = 1*1000*1000,
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index f8cc168..f521579 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)
struct net_device *net;
struct mcp251x_priv *priv;
struct mcp251x_platform_data *pdata = spi->dev.platform_data;
+ int model = spi_get_device_id(spi)->driver_data;
int ret = -ENODEV;
if (!pdata)
/* Platform data is required for osc freq */
goto error_out;
+ if (model)
+ pdata->model = model;
+
/* Allocate can/net device */
net = alloc_candev(sizeof(struct mcp251x_priv), TX_ECHO_SKB_MAX);
if (!net) {
@@ -1117,6 +1121,15 @@ static int mcp251x_can_resume(struct spi_device *spi)
#define mcp251x_can_resume NULL
#endif
+static struct spi_device_id mcp251x_id_table[] = {
+ { "mcp251x", 0 /* Use pdata.model */ },
+ { "mcp2510", CAN_MCP251X_MCP2510 },
+ { "mcp2515", CAN_MCP251X_MCP2515 },
+ { },
+};
+
+MODULE_DEVICE_TABLE(spi, mcp251x_id_table);
+
static struct spi_driver mcp251x_can_driver = {
.driver = {
.name = DEVICE_NAME,
@@ -1124,6 +1137,7 @@ static struct spi_driver mcp251x_can_driver = {
.owner = THIS_MODULE,
},
+ .id_table = mcp251x_id_table,
.probe = mcp251x_can_probe,
.remove = __devexit_p(mcp251x_can_remove),
.suspend = mcp251x_can_suspend,
diff --git a/include/linux/can/platform/mcp251x.h b/include/linux/can/platform/mcp251x.h
index 1448177..dba2826 100644
--- a/include/linux/can/platform/mcp251x.h
+++ b/include/linux/can/platform/mcp251x.h
@@ -26,8 +26,8 @@
struct mcp251x_platform_data {
unsigned long oscillator_frequency;
int model;
-#define CAN_MCP251X_MCP2510 0
-#define CAN_MCP251X_MCP2515 1
+#define CAN_MCP251X_MCP2510 0x2510
+#define CAN_MCP251X_MCP2515 0x2515
int (*board_specific_setup)(struct spi_device *spi);
int (*transceiver_enable)(int enable);
int (*power_enable) (int enable);
--
1.7.0.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] Add hotplug support to mcp251x driver
@ 2010-03-29 18:57 ` Marc Zyngier
0 siblings, 0 replies; 7+ messages in thread
From: Marc Zyngier @ 2010-03-29 18:57 UTC (permalink / raw)
To: linux-arm-kernel
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>
---
arch/arm/mach-pxa/icontrol.c | 9 ++++-----
arch/arm/mach-pxa/zeus.c | 4 +---
drivers/net/can/mcp251x.c | 14 ++++++++++++++
include/linux/can/platform/mcp251x.h | 4 ++--
4 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-pxa/icontrol.c b/arch/arm/mach-pxa/icontrol.c
index 771137f..5ccb0ce 100644
--- a/arch/arm/mach-pxa/icontrol.c
+++ b/arch/arm/mach-pxa/icontrol.c
@@ -73,7 +73,6 @@ static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
static struct mcp251x_platform_data mcp251x_info = {
.oscillator_frequency = 16E6,
- .model = CAN_MCP251X_MCP2515,
.board_specific_setup = NULL,
.power_enable = NULL,
.transceiver_enable = NULL
@@ -81,7 +80,7 @@ static struct mcp251x_platform_data mcp251x_info = {
static struct spi_board_info mcp251x_board_info[] = {
{
- .modalias = "mcp251x",
+ .modalias = "mcp2515",
.max_speed_hz = 6500000,
.bus_num = 3,
.chip_select = 0,
@@ -90,7 +89,7 @@ static struct spi_board_info mcp251x_board_info[] = {
.irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ1)
},
{
- .modalias = "mcp251x",
+ .modalias = "mcp2515",
.max_speed_hz = 6500000,
.bus_num = 3,
.chip_select = 1,
@@ -99,7 +98,7 @@ static struct spi_board_info mcp251x_board_info[] = {
.irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ2)
},
{
- .modalias = "mcp251x",
+ .modalias = "mcp2515",
.max_speed_hz = 6500000,
.bus_num = 4,
.chip_select = 0,
@@ -108,7 +107,7 @@ static struct spi_board_info mcp251x_board_info[] = {
.irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ3)
},
{
- .modalias = "mcp251x",
+ .modalias = "mcp2515",
.max_speed_hz = 6500000,
.bus_num = 4,
.chip_select = 1,
diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c
index 39896d8..dbd2569 100644
--- a/arch/arm/mach-pxa/zeus.c
+++ b/arch/arm/mach-pxa/zeus.c
@@ -414,15 +414,13 @@ static int zeus_mcp2515_transceiver_enable(int enable)
static struct mcp251x_platform_data zeus_mcp2515_pdata = {
.oscillator_frequency = 16*1000*1000,
- .model = CAN_MCP251X_MCP2515,
.board_specific_setup = zeus_mcp2515_setup,
- .transceiver_enable = zeus_mcp2515_transceiver_enable,
.power_enable = zeus_mcp2515_transceiver_enable,
};
static struct spi_board_info zeus_spi_board_info[] = {
[0] = {
- .modalias = "mcp251x",
+ .modalias = "mcp2515",
.platform_data = &zeus_mcp2515_pdata,
.irq = gpio_to_irq(ZEUS_CAN_GPIO),
.max_speed_hz = 1*1000*1000,
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index f8cc168..f521579 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)
struct net_device *net;
struct mcp251x_priv *priv;
struct mcp251x_platform_data *pdata = spi->dev.platform_data;
+ int model = spi_get_device_id(spi)->driver_data;
int ret = -ENODEV;
if (!pdata)
/* Platform data is required for osc freq */
goto error_out;
+ if (model)
+ pdata->model = model;
+
/* Allocate can/net device */
net = alloc_candev(sizeof(struct mcp251x_priv), TX_ECHO_SKB_MAX);
if (!net) {
@@ -1117,6 +1121,15 @@ static int mcp251x_can_resume(struct spi_device *spi)
#define mcp251x_can_resume NULL
#endif
+static struct spi_device_id mcp251x_id_table[] = {
+ { "mcp251x", 0 /* Use pdata.model */ },
+ { "mcp2510", CAN_MCP251X_MCP2510 },
+ { "mcp2515", CAN_MCP251X_MCP2515 },
+ { },
+};
+
+MODULE_DEVICE_TABLE(spi, mcp251x_id_table);
+
static struct spi_driver mcp251x_can_driver = {
.driver = {
.name = DEVICE_NAME,
@@ -1124,6 +1137,7 @@ static struct spi_driver mcp251x_can_driver = {
.owner = THIS_MODULE,
},
+ .id_table = mcp251x_id_table,
.probe = mcp251x_can_probe,
.remove = __devexit_p(mcp251x_can_remove),
.suspend = mcp251x_can_suspend,
diff --git a/include/linux/can/platform/mcp251x.h b/include/linux/can/platform/mcp251x.h
index 1448177..dba2826 100644
--- a/include/linux/can/platform/mcp251x.h
+++ b/include/linux/can/platform/mcp251x.h
@@ -26,8 +26,8 @@
struct mcp251x_platform_data {
unsigned long oscillator_frequency;
int model;
-#define CAN_MCP251X_MCP2510 0
-#define CAN_MCP251X_MCP2515 1
+#define CAN_MCP251X_MCP2510 0x2510
+#define CAN_MCP251X_MCP2515 0x2515
int (*board_specific_setup)(struct spi_device *spi);
int (*transceiver_enable)(int enable);
int (*power_enable) (int enable);
--
1.7.0.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Add hotplug support to mcp251x driver
2010-03-29 18:57 ` Marc Zyngier
@ 2010-03-30 7:23 ` Wolfgang Grandegger
-1 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Grandegger @ 2010-03-30 7:23 UTC (permalink / raw)
To: Marc Zyngier
Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
netdev-u79uwXL29TY76Z2rM5mHXA, Edwin Peer,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
Marc Zyngier wrote:
> 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-20xNzvSXLT6hUMvJH42dtQ@public.gmane.org>
> Acked-by: Christian Pellegrin <chripell-VaTbYqLCNhc@public.gmane.org>
> Cc: Edwin Peer <epeer-edQ+oOd84Ub6AMQ9O9Cv5/d9D2ou9A/h@public.gmane.org>
Acked-by: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
for the Socket-CAN part.
Wolfgang.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Add hotplug support to mcp251x driver
@ 2010-03-30 7:23 ` Wolfgang Grandegger
0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Grandegger @ 2010-03-30 7:23 UTC (permalink / raw)
To: linux-arm-kernel
Marc Zyngier wrote:
> 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>
for the Socket-CAN part.
Wolfgang.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add hotplug support to mcp251x driver
2010-03-29 5:34 ` christian pellegrin
@ 2010-03-29 8:15 ` Wolfgang Grandegger
0 siblings, 0 replies; 7+ messages in thread
From: Wolfgang Grandegger @ 2010-03-29 8:15 UTC (permalink / raw)
To: christian pellegrin
Cc: Marc Zyngier, SocketCAN Core Mailing List, Edwin Peer, linux-kernel
christian pellegrin wrote:
> Hi, it looks ok to me. Can you resend the patch to
> socketcan-core@lists.berlios.de ml too? We try to keep the version
> there synchronized as much as possible to that in mainline.
To get it accepted for mainline, it should go through the netdev mailing
list.
Wolfgang.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Add hotplug support to mcp251x driver
2010-03-28 16:45 Marc Zyngier
@ 2010-03-29 5:34 ` christian pellegrin
2010-03-29 8:15 ` Wolfgang Grandegger
0 siblings, 1 reply; 7+ messages in thread
From: christian pellegrin @ 2010-03-29 5:34 UTC (permalink / raw)
To: Marc Zyngier, SocketCAN Core Mailing List; +Cc: linux-kernel, Edwin Peer
Hi, it looks ok to me. Can you resend the patch to
socketcan-core@lists.berlios.de ml too? We try to keep the version
there synchronized as much as possible to that in mainline.
Thanks,
Acked-by: Christian Pellegrin <chripell@fsfe.org>
On Sun, Mar 28, 2010 at 6:45 PM, Marc Zyngier <maz@misterjones.org> wrote:
> 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>
> Cc: Edwin Peer <epeer@tmtservices.co.za>
> Cc: Christian Pellegrin <chripell@fsfe.org>
> ---
> arch/arm/mach-pxa/icontrol.c | 9 ++++-----
> arch/arm/mach-pxa/zeus.c | 4 +---
> drivers/net/can/mcp251x.c | 14 ++++++++++++++
> include/linux/can/platform/mcp251x.h | 4 ++--
> 4 files changed, 21 insertions(+), 10 deletions(-)
>
> diff --git a/arch/arm/mach-pxa/icontrol.c b/arch/arm/mach-pxa/icontrol.c
> index 771137f..5ccb0ce 100644
> --- a/arch/arm/mach-pxa/icontrol.c
> +++ b/arch/arm/mach-pxa/icontrol.c
> @@ -73,7 +73,6 @@ static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
>
> static struct mcp251x_platform_data mcp251x_info = {
> .oscillator_frequency = 16E6,
> - .model = CAN_MCP251X_MCP2515,
> .board_specific_setup = NULL,
> .power_enable = NULL,
> .transceiver_enable = NULL
> @@ -81,7 +80,7 @@ static struct mcp251x_platform_data mcp251x_info = {
>
> static struct spi_board_info mcp251x_board_info[] = {
> {
> - .modalias = "mcp251x",
> + .modalias = "mcp2515",
> .max_speed_hz = 6500000,
> .bus_num = 3,
> .chip_select = 0,
> @@ -90,7 +89,7 @@ static struct spi_board_info mcp251x_board_info[] = {
> .irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ1)
> },
> {
> - .modalias = "mcp251x",
> + .modalias = "mcp2515",
> .max_speed_hz = 6500000,
> .bus_num = 3,
> .chip_select = 1,
> @@ -99,7 +98,7 @@ static struct spi_board_info mcp251x_board_info[] = {
> .irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ2)
> },
> {
> - .modalias = "mcp251x",
> + .modalias = "mcp2515",
> .max_speed_hz = 6500000,
> .bus_num = 4,
> .chip_select = 0,
> @@ -108,7 +107,7 @@ static struct spi_board_info mcp251x_board_info[] = {
> .irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ3)
> },
> {
> - .modalias = "mcp251x",
> + .modalias = "mcp2515",
> .max_speed_hz = 6500000,
> .bus_num = 4,
> .chip_select = 1,
> diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c
> index 39896d8..dbd2569 100644
> --- a/arch/arm/mach-pxa/zeus.c
> +++ b/arch/arm/mach-pxa/zeus.c
> @@ -414,15 +414,13 @@ static int zeus_mcp2515_transceiver_enable(int enable)
>
> static struct mcp251x_platform_data zeus_mcp2515_pdata = {
> .oscillator_frequency = 16*1000*1000,
> - .model = CAN_MCP251X_MCP2515,
> .board_specific_setup = zeus_mcp2515_setup,
> - .transceiver_enable = zeus_mcp2515_transceiver_enable,
> .power_enable = zeus_mcp2515_transceiver_enable,
> };
>
> static struct spi_board_info zeus_spi_board_info[] = {
> [0] = {
> - .modalias = "mcp251x",
> + .modalias = "mcp2515",
> .platform_data = &zeus_mcp2515_pdata,
> .irq = gpio_to_irq(ZEUS_CAN_GPIO),
> .max_speed_hz = 1*1000*1000,
> diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
> index f8cc168..f521579 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)
> struct net_device *net;
> struct mcp251x_priv *priv;
> struct mcp251x_platform_data *pdata = spi->dev.platform_data;
> + int model = spi_get_device_id(spi)->driver_data;
> int ret = -ENODEV;
>
> if (!pdata)
> /* Platform data is required for osc freq */
> goto error_out;
>
> + if (model)
> + pdata->model = model;
> +
> /* Allocate can/net device */
> net = alloc_candev(sizeof(struct mcp251x_priv), TX_ECHO_SKB_MAX);
> if (!net) {
> @@ -1117,6 +1121,15 @@ static int mcp251x_can_resume(struct spi_device *spi)
> #define mcp251x_can_resume NULL
> #endif
>
> +static struct spi_device_id mcp251x_id_table[] = {
> + { "mcp251x", 0 /* Use pdata.model */ },
> + { "mcp2510", CAN_MCP251X_MCP2510 },
> + { "mcp2515", CAN_MCP251X_MCP2515 },
> + { },
> +};
> +
> +MODULE_DEVICE_TABLE(spi, mcp251x_id_table);
> +
> static struct spi_driver mcp251x_can_driver = {
> .driver = {
> .name = DEVICE_NAME,
> @@ -1124,6 +1137,7 @@ static struct spi_driver mcp251x_can_driver = {
> .owner = THIS_MODULE,
> },
>
> + .id_table = mcp251x_id_table,
> .probe = mcp251x_can_probe,
> .remove = __devexit_p(mcp251x_can_remove),
> .suspend = mcp251x_can_suspend,
> diff --git a/include/linux/can/platform/mcp251x.h b/include/linux/can/platform/mcp251x.h
> index 1448177..dba2826 100644
> --- a/include/linux/can/platform/mcp251x.h
> +++ b/include/linux/can/platform/mcp251x.h
> @@ -26,8 +26,8 @@
> struct mcp251x_platform_data {
> unsigned long oscillator_frequency;
> int model;
> -#define CAN_MCP251X_MCP2510 0
> -#define CAN_MCP251X_MCP2515 1
> +#define CAN_MCP251X_MCP2510 0x2510
> +#define CAN_MCP251X_MCP2515 0x2515
> int (*board_specific_setup)(struct spi_device *spi);
> int (*transceiver_enable)(int enable);
> int (*power_enable) (int enable);
> --
> 1.7.0.3
>
>
--
Christian Pellegrin, see http://www.evolware.org/chri/
"Real Programmers don't play tennis, or any other sport which requires
you to change clothes. Mountain climbing is OK, and Real Programmers
wear their climbing boots to work in case a mountain should suddenly
spring up in the middle of the computer room."
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] Add hotplug support to mcp251x driver
@ 2010-03-28 16:45 Marc Zyngier
2010-03-29 5:34 ` christian pellegrin
0 siblings, 1 reply; 7+ messages in thread
From: Marc Zyngier @ 2010-03-28 16:45 UTC (permalink / raw)
Cc: linux-kernel, Edwin Peer, Christian Pellegrin
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>
Cc: Edwin Peer <epeer@tmtservices.co.za>
Cc: Christian Pellegrin <chripell@fsfe.org>
---
arch/arm/mach-pxa/icontrol.c | 9 ++++-----
arch/arm/mach-pxa/zeus.c | 4 +---
drivers/net/can/mcp251x.c | 14 ++++++++++++++
include/linux/can/platform/mcp251x.h | 4 ++--
4 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-pxa/icontrol.c b/arch/arm/mach-pxa/icontrol.c
index 771137f..5ccb0ce 100644
--- a/arch/arm/mach-pxa/icontrol.c
+++ b/arch/arm/mach-pxa/icontrol.c
@@ -73,7 +73,6 @@ static struct pxa2xx_spi_chip mcp251x_chip_info4 = {
static struct mcp251x_platform_data mcp251x_info = {
.oscillator_frequency = 16E6,
- .model = CAN_MCP251X_MCP2515,
.board_specific_setup = NULL,
.power_enable = NULL,
.transceiver_enable = NULL
@@ -81,7 +80,7 @@ static struct mcp251x_platform_data mcp251x_info = {
static struct spi_board_info mcp251x_board_info[] = {
{
- .modalias = "mcp251x",
+ .modalias = "mcp2515",
.max_speed_hz = 6500000,
.bus_num = 3,
.chip_select = 0,
@@ -90,7 +89,7 @@ static struct spi_board_info mcp251x_board_info[] = {
.irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ1)
},
{
- .modalias = "mcp251x",
+ .modalias = "mcp2515",
.max_speed_hz = 6500000,
.bus_num = 3,
.chip_select = 1,
@@ -99,7 +98,7 @@ static struct spi_board_info mcp251x_board_info[] = {
.irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ2)
},
{
- .modalias = "mcp251x",
+ .modalias = "mcp2515",
.max_speed_hz = 6500000,
.bus_num = 4,
.chip_select = 0,
@@ -108,7 +107,7 @@ static struct spi_board_info mcp251x_board_info[] = {
.irq = gpio_to_irq(ICONTROL_MCP251x_nIRQ3)
},
{
- .modalias = "mcp251x",
+ .modalias = "mcp2515",
.max_speed_hz = 6500000,
.bus_num = 4,
.chip_select = 1,
diff --git a/arch/arm/mach-pxa/zeus.c b/arch/arm/mach-pxa/zeus.c
index 39896d8..dbd2569 100644
--- a/arch/arm/mach-pxa/zeus.c
+++ b/arch/arm/mach-pxa/zeus.c
@@ -414,15 +414,13 @@ static int zeus_mcp2515_transceiver_enable(int enable)
static struct mcp251x_platform_data zeus_mcp2515_pdata = {
.oscillator_frequency = 16*1000*1000,
- .model = CAN_MCP251X_MCP2515,
.board_specific_setup = zeus_mcp2515_setup,
- .transceiver_enable = zeus_mcp2515_transceiver_enable,
.power_enable = zeus_mcp2515_transceiver_enable,
};
static struct spi_board_info zeus_spi_board_info[] = {
[0] = {
- .modalias = "mcp251x",
+ .modalias = "mcp2515",
.platform_data = &zeus_mcp2515_pdata,
.irq = gpio_to_irq(ZEUS_CAN_GPIO),
.max_speed_hz = 1*1000*1000,
diff --git a/drivers/net/can/mcp251x.c b/drivers/net/can/mcp251x.c
index f8cc168..f521579 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)
struct net_device *net;
struct mcp251x_priv *priv;
struct mcp251x_platform_data *pdata = spi->dev.platform_data;
+ int model = spi_get_device_id(spi)->driver_data;
int ret = -ENODEV;
if (!pdata)
/* Platform data is required for osc freq */
goto error_out;
+ if (model)
+ pdata->model = model;
+
/* Allocate can/net device */
net = alloc_candev(sizeof(struct mcp251x_priv), TX_ECHO_SKB_MAX);
if (!net) {
@@ -1117,6 +1121,15 @@ static int mcp251x_can_resume(struct spi_device *spi)
#define mcp251x_can_resume NULL
#endif
+static struct spi_device_id mcp251x_id_table[] = {
+ { "mcp251x", 0 /* Use pdata.model */ },
+ { "mcp2510", CAN_MCP251X_MCP2510 },
+ { "mcp2515", CAN_MCP251X_MCP2515 },
+ { },
+};
+
+MODULE_DEVICE_TABLE(spi, mcp251x_id_table);
+
static struct spi_driver mcp251x_can_driver = {
.driver = {
.name = DEVICE_NAME,
@@ -1124,6 +1137,7 @@ static struct spi_driver mcp251x_can_driver = {
.owner = THIS_MODULE,
},
+ .id_table = mcp251x_id_table,
.probe = mcp251x_can_probe,
.remove = __devexit_p(mcp251x_can_remove),
.suspend = mcp251x_can_suspend,
diff --git a/include/linux/can/platform/mcp251x.h b/include/linux/can/platform/mcp251x.h
index 1448177..dba2826 100644
--- a/include/linux/can/platform/mcp251x.h
+++ b/include/linux/can/platform/mcp251x.h
@@ -26,8 +26,8 @@
struct mcp251x_platform_data {
unsigned long oscillator_frequency;
int model;
-#define CAN_MCP251X_MCP2510 0
-#define CAN_MCP251X_MCP2515 1
+#define CAN_MCP251X_MCP2510 0x2510
+#define CAN_MCP251X_MCP2515 0x2515
int (*board_specific_setup)(struct spi_device *spi);
int (*transceiver_enable)(int enable);
int (*power_enable) (int enable);
--
1.7.0.3
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-03-30 7:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-29 18:57 [PATCH] Add hotplug support to mcp251x driver Marc Zyngier
2010-03-29 18:57 ` Marc Zyngier
[not found] ` <1269889076-5611-1-git-send-email-maz-20xNzvSXLT6hUMvJH42dtQ@public.gmane.org>
2010-03-30 7:23 ` Wolfgang Grandegger
2010-03-30 7:23 ` Wolfgang Grandegger
-- strict thread matches above, loose matches on Subject: below --
2010-03-28 16:45 Marc Zyngier
2010-03-29 5:34 ` christian pellegrin
2010-03-29 8:15 ` Wolfgang Grandegger
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.