net/sb1250: setup the pdevice within the soc code
Subsystems (3)
RFC 1/1 net/sb1250: setup the pdevice within the soc code
doing it within the driver does not look good.
---
Ralf, if you fine with then I'm gonna to post it at netdev.
arch/mips/sibyte/sb1250/setup.c | 55 ++++++++++++++++++ drivers/net/sb1250-mac.c | 120 +-------------------------------------- 2 files changed, 56 insertions(+), 119 deletions(-)
arch/mips/sibyte/sb1250/setup.c +55 -0
@@ -18,6 +18,7 @@#include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> +#include <linux/platform_device.h> #include <linux/reboot.h> #include <linux/string.h>
@@ -245,3 +246,57 @@ void __init sb1250_setup(void)machine_restart (NULL ); } } + +#define sb1250_dev_struct (num) \ + static struct resource sb1250_res##num = { \ + .name = "SB1250 MAC " __stringify(num), \ + .flags = IORESOURCE_MEM, \ + .start = A_MAC_CHANNEL_BASE(num), \ + .end = A_MAC_CHANNEL_BASE(num + 1) -1, \ + };\ + static struct platform_device sb1250_dev##num = { \ + .name = "sb1250-mac", \ + .id = num, \ + .resource = &sb1250_res##num, \ + .num_resources = 1, \ + } + +sb1250_dev_struct (0 ); +sb1250_dev_struct (1 ); +sb1250_dev_struct (2 ); +sb1250_dev_struct (3 ); + +static struct platform_device *sb1250_devs[]__initdata = { + &sb1250_dev0, + &sb1250_dev1, + &sb1250_dev2, + &sb1250_dev3, +}; + +static int __init sb1250_device_init (void ) +{ +int ret; + +/* Set the number of available units based on the SOC type. */ +switch (soc_type) { +case K_SYS_SOC_TYPE_BCM1250 : +case K_SYS_SOC_TYPE_BCM1250_ALT : + ret =platform_add_devices (sb1250_devs,3 ); +break ; +case K_SYS_SOC_TYPE_BCM1120 : +case K_SYS_SOC_TYPE_BCM1125 : +case K_SYS_SOC_TYPE_BCM1125H : +case K_SYS_SOC_TYPE_BCM1250_ALT2 :/* Hybrid */ + ret =platform_add_devices (sb1250_devs,2 ); +break ; +case K_SYS_SOC_TYPE_BCM1x55: +case K_SYS_SOC_TYPE_BCM1x80: + ret =platform_add_devices (sb1250_devs,4 ); +break ; +default : + ret = -ENODEV ; +break ; + } +return ret; +} +device_initcall (sb1250_device_init);
drivers/net/sb1250-mac.c +1 -119
142 lines not on this page · raw message
Signature · 1 line
1.6.6.1
Quoted 8 lines · Sebastian Andrzej Siewior
doing it within the driver does not look good.
Signed-off-by Sebastian Andrzej Siewior <[email protected]>---
Ralf, if you fine with then I'm gonna to post it at netdev.arch/mips/sibyte/sb1250/setup.c | 55 ++++++++++++++++++ drivers/net/sb1250-mac.c | 120 +--------------------------------------
Almost. The idea is right but the driver is also being used by the BCM1480-based platforms. So either arch/mips/sibyte/bcm1480/setup.c needs the same changes or - and better - you change arch/mips/sibyte/swarm/platform.c instead. Despite the swarm in the path name that file is being used also for all other currently supported Sibyte platforms.
Ralf
doing it within the driver does not look good.
--- arch/mips/sibyte/swarm/platform.c | 54 +++++++++++++++++ drivers/net/sb1250-mac.c | 120 +------------------------------------ 2 files changed, 55 insertions(+), 119 deletions(-)
arch/mips/sibyte/swarm/platform.c +54 -0
@@ -83,3 +83,57 @@ static int __init swarm_pata_init(void)device_initcall (swarm_pata_init);#endif /* defined(CONFIG_SIBYTE_SWARM) || defined(CONFIG_SIBYTE_LITTLESUR) */ + +#define sb1250_dev_struct (num) \ + static struct resource sb1250_res##num = { \ + .name = "SB1250 MAC " __stringify(num), \ + .flags = IORESOURCE_MEM, \ + .start = A_MAC_CHANNEL_BASE(num), \ + .end = A_MAC_CHANNEL_BASE(num + 1) -1, \ + };\ + static struct platform_device sb1250_dev##num = { \ + .name = "sb1250-mac", \ + .id = num, \ + .resource = &sb1250_res##num, \ + .num_resources = 1, \ + } + +sb1250_dev_struct (0 ); +sb1250_dev_struct (1 ); +sb1250_dev_struct (2 ); +sb1250_dev_struct (3 ); + +static struct platform_device *sb1250_devs[]__initdata = { + &sb1250_dev0, + &sb1250_dev1, + &sb1250_dev2, + &sb1250_dev3, +}; + +static int __init sb1250_device_init (void ) +{ +int ret; + +/* Set the number of available units based on the SOC type. */ +switch (soc_type) { +case K_SYS_SOC_TYPE_BCM1250 : +case K_SYS_SOC_TYPE_BCM1250_ALT : + ret =platform_add_devices (sb1250_devs,3 ); +break ; +case K_SYS_SOC_TYPE_BCM1120 : +case K_SYS_SOC_TYPE_BCM1125 : +case K_SYS_SOC_TYPE_BCM1125H : +case K_SYS_SOC_TYPE_BCM1250_ALT2 :/* Hybrid */ + ret =platform_add_devices (sb1250_devs,2 ); +break ; +case K_SYS_SOC_TYPE_BCM1x55: +case K_SYS_SOC_TYPE_BCM1x80: + ret =platform_add_devices (sb1250_devs,4 ); +break ; +default : + ret = -ENODEV ; +break ; + } +return ret; +} +device_initcall (sb1250_device_init);
drivers/net/sb1250-mac.c +1 -119
142 lines not on this page · raw message
Signature · 1 line
1.6.6.1
Ralf Baechle
Acked-byQuoted 1 line · Sebastian Andrzej Siewior
doing it within the driver does not look good.
And surely isn't how platform devices were meat to be used.
Quoted 1 line
Signed-off-by Sebastian Andrzej Siewior <[email protected]>
Go ahead:
Thanks!
Ralf
PATCH 1/1 net/sb1250: setup the pdevice within the soc code
doing it within the driver does not look good.
And surely isn't how platform devices were meat to be used.
--- arch/mips/sibyte/swarm/platform.c | 54 +++++++++++++++++ drivers/net/sb1250-mac.c | 120 +------------------------------------ 2 files changed, 55 insertions(+), 119 deletions(-)
arch/mips/sibyte/swarm/platform.c +54 -0
@@ -83,3 +83,57 @@ static int __init swarm_pata_init(void)device_initcall (swarm_pata_init);#endif /* defined(CONFIG_SIBYTE_SWARM) || defined(CONFIG_SIBYTE_LITTLESUR) */ + +#define sb1250_dev_struct (num) \ + static struct resource sb1250_res##num = { \ + .name = "SB1250 MAC " __stringify(num), \ + .flags = IORESOURCE_MEM, \ + .start = A_MAC_CHANNEL_BASE(num), \ + .end = A_MAC_CHANNEL_BASE(num + 1) -1, \ + };\ + static struct platform_device sb1250_dev##num = { \ + .name = "sb1250-mac", \ + .id = num, \ + .resource = &sb1250_res##num, \ + .num_resources = 1, \ + } + +sb1250_dev_struct (0 ); +sb1250_dev_struct (1 ); +sb1250_dev_struct (2 ); +sb1250_dev_struct (3 ); + +static struct platform_device *sb1250_devs[]__initdata = { + &sb1250_dev0, + &sb1250_dev1, + &sb1250_dev2, + &sb1250_dev3, +}; + +static int __init sb1250_device_init (void ) +{ +int ret; + +/* Set the number of available units based on the SOC type. */ +switch (soc_type) { +case K_SYS_SOC_TYPE_BCM1250 : +case K_SYS_SOC_TYPE_BCM1250_ALT : + ret =platform_add_devices (sb1250_devs,3 ); +break ; +case K_SYS_SOC_TYPE_BCM1120 : +case K_SYS_SOC_TYPE_BCM1125 : +case K_SYS_SOC_TYPE_BCM1125H : +case K_SYS_SOC_TYPE_BCM1250_ALT2 :/* Hybrid */ + ret =platform_add_devices (sb1250_devs,2 ); +break ; +case K_SYS_SOC_TYPE_BCM1x55: +case K_SYS_SOC_TYPE_BCM1x80: + ret =platform_add_devices (sb1250_devs,4 ); +break ; +default : + ret = -ENODEV ; +break ; + } +return ret; +} +device_initcall (sb1250_device_init);
drivers/net/sb1250-mac.c +1 -119
142 lines not on this page · raw message
Signature · 1 line
1.6.6.1
From: Sebastian Andrzej Siewior <[email protected]>
Date: Mon, 26 Apr 2010 23:07:44 +0200
Quoted 5 lines
doing it within the driver does not look good.
And surely isn't how platform devices were meat to be used.Acked-by Ralf Baechle <[email protected]>Signed-off-by Sebastian Andrzej Siewior <[email protected]>
Applied to net-next-2.6, thanks.
Maciej W. Rozycki
Acked-byQuoted 9 lines · Ralf Baechle
Quoted 1 line
doing it within the driver does not look good.
And surely isn't how platform devices were meat to be used.
Quoted 1 line
Signed-off-by Sebastian Andrzej Siewior <[email protected]>Go ahead:
Acked-by Ralf Baechle <[email protected]>
That was the long-term plan back when the driver was updated to its
current form. Thanks for pushing this forward.
Maciej