Assorted conversions to the new platform device interface
Subsystems (3)
cover Assorted conversions to the new platform device interface
Hi Andrew,
The following patches attempt to convert bunch of drivers to the new platform device interface so that later we can drop platform_device_register_simple() interface.
I tried CCing authors or maintainers of the core in question earlier, these are the ones I did not get any freedback on so they must be perfect ;)
I wonder if you could add these to -mm for now.
Thanks!
--
Dmitry
PATCH 1/6 hdaps: convert to the new platform device interface
hdaps: convert to the new platform device interface
Do not use platform_device_register_simple() as it is going away, extend ->probe() and ->remove() functions so manual binding and unbinding will work with this driver.
---
drivers/hwmon/hdaps.c | 198 +++++++++++++++++++++++++++----------------------- 1 files changed, 107 insertions(+), 91 deletions(-)
drivers/hwmon/hdaps.c +107 -91
@@ -36,7 +36,7 @@#include <asm/io.h> #define HDAPS_LOW_PORT 0x1600/* first port used by hdaps */ -#define HDAPS_NR_PORTS 0x30/* number of ports: 0x1600 - 0x162f */ +#define HDAPS_HI_PORT 0x162f/* last port used by hdaps */ #define HDAPS_PORT_STATE 0x1611/* device state */ #define HDAPS_PORT_YPOS 0x1612/* y-axis position */
@@ -62,6 +62,12 @@#define HDAPS_INPUT_FUZZ 4/* input event threshold */ #define HDAPS_INPUT_FLAT 4 +static struct resource __initdata hdaps_iores = { + .flags =IORESOURCE_IO , + .start =HDAPS_LOW_PORT , + .end =HDAPS_HI_PORT , +}; +static struct timer_list hdaps_timer;static struct platform_device *pdev;static struct input_dev *hdaps_idev;
@@ -284,34 +290,6 @@ out: } -/* Device model stuff */ - -static int hdaps_probe (struct platform_device *dev) -{ -int ret; - - ret =hdaps_device_init (); -if (ret) -return ret; - -printk (KERN_INFO "hdaps: device successfully initialized.\n" ); -return 0 ; -} - -static int hdaps_resume (struct platform_device *dev) -{ -return hdaps_device_init (); -} - -static struct platform_driver hdaps_driver = { - .probe = hdaps_probe, - .resume = hdaps_resume, - .driver = { - .name ="hdaps" , - .owner =THIS_MODULE , - }, -}; -/* * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_sem. */
@@ -320,13 +298,13 @@ static void hdaps_calibrate(void)__hdaps_read_pair (HDAPS_PORT_XPOS ,HDAPS_PORT_YPOS , &rest_x, &rest_y); } -static void hdaps_mousedev_poll (unsigned long unused) +static void hdaps_inputdev_poll (unsigned long unused) {int x, y;/* Cannot sleep. Try nonblockingly. If we fail, try again later. */ if (down_trylock (&hdaps_sem)) { -mod_timer (&hdaps_timer,jiffies +HDAPS_POLL_PERIOD ); +mod_timer (&hdaps_timer, jiffies +HDAPS_POLL_PERIOD );return ; }
@@ -339,7 +317,7 @@ static void hdaps_mousedev_poll(unsignedmod_timer (&hdaps_timer, jiffies +HDAPS_POLL_PERIOD ); -out: + out:up (&hdaps_sem); }
@@ -473,6 +451,80 @@ static struct attribute_group hdaps_attr .attrs = hdaps_attributes, }; +/* Device model stuff */ + +static int __devinit hdaps_probe (struct platform_device *dev) +{ +int error; + +/* initial calibrate for the input device */ +hdaps_calibrate (); + + hdaps_idev =input_allocate_device (); +if (!hdaps_idev) +return -ENOMEM ; + +/* initialize the input class */ + hdaps_idev->name ="hdaps" ; + hdaps_idev->phys ="hdaps/input0" ; + hdaps_idev->cdev.dev = &dev->dev; + hdaps_idev->evbit[0 ] =BIT (EV_ABS ); +input_set_abs_params (hdaps_idev,ABS_X , +-256 ,256 ,HDAPS_INPUT_FUZZ ,HDAPS_INPUT_FLAT ); +input_set_abs_params (hdaps_idev,ABS_Y , +-256 ,256 ,HDAPS_INPUT_FUZZ ,HDAPS_INPUT_FLAT ); + + error =sysfs_create_group (&pdev->dev.kobj, &hdaps_attribute_group); +if (error) + goto err_free_input_dev; + + error =hdaps_device_init (); +if (error) + goto err_sysfs_remove_group; + + error =input_register_device (hdaps_idev); +if (error) + goto err_sysfs_remove_group; + +/* start up our timer for the input device */ +init_timer (&hdaps_timer); + hdaps_timer.function = hdaps_inputdev_poll; + hdaps_timer.expires = jiffies +HDAPS_POLL_PERIOD ; +add_timer (&hdaps_timer); + +return 0 ; + + err_free_input_dev: +input_free_device (hdaps_idev); + err_sysfs_remove_group: +sysfs_remove_group (&dev->dev.kobj, &hdaps_attribute_group); +return error; +} + +static int __devexit hdaps_remove(struct platform_device *dev) +{ +del_timer_sync (&hdaps_timer); +input_unregister_device (hdaps_idev); +sysfs_remove_group (&pdev->dev.kobj, &hdaps_attribute_group); + +return 0 ; +} + +static int hdaps_resume (struct platform_device *dev) +{ +return hdaps_device_init (); +} + +static struct platform_driver hdaps_driver = { + .driver = { + .name ="hdaps" , + .owner =THIS_MODULE , + }, + .probe = hdaps_probe, + .remove =__devexit_p (hdaps_remove), + .resume = hdaps_resume, +}; +/* Module stuff */
@@ -511,7 +563,7 @@ static int hdaps_dmi_match_invert(structstatic int __init hdaps_init (void ) { -int ret; +int error;/* Note that DMI_MATCH(...,"ThinkPad T42") will match "ThinkPad T42p" */ struct dmi_system_id hdaps_whitelist[] = {
@@ -532,79 +584,43 @@ static int __init hdaps_init(void)if (!dmi_check_system (hdaps_whitelist)) {printk (KERN_WARNING "hdaps: supported laptop not found!\n" ); - ret = -ENXIO ; - goto out; +return -ENODEV ; } -if (!request_region (HDAPS_LOW_PORT ,HDAPS_NR_PORTS ,"hdaps" )) { - ret = -ENXIO ; - goto out; + error =platform_driver_register (&hdaps_driver); +if (error) +return error; + + pdev =platform_device_alloc ("hdaps" ,-1 ); +if (!pdev) { + error = -ENOMEM ; + goto err_unregister_driver; } - ret =platform_driver_register (&hdaps_driver); -if (ret) - goto out_region; - - pdev =platform_device_register_simple ("hdaps" ,-1 ,NULL ,0 ); -if (IS_ERR (pdev)) { - ret =PTR_ERR (pdev); - goto out_driver; - } - - ret =sysfs_create_group (&pdev->dev.kobj, &hdaps_attribute_group); -if (ret) - goto out_device; - - hdaps_idev =input_allocate_device (); -if (!hdaps_idev) { - ret = -ENOMEM ; - goto out_group; - } - -/* initial calibrate for the input device */ -hdaps_calibrate (); - -/* initialize the input class */ - hdaps_idev->name ="hdaps" ; - hdaps_idev->cdev.dev = &pdev->dev; - hdaps_idev->evbit[0 ] =BIT (EV_ABS ); -input_set_abs_params (hdaps_idev,ABS_X , --256 ,256 ,HDAPS_INPUT_FUZZ ,HDAPS_INPUT_FLAT ); -input_set_abs_params (hdaps_idev,ABS_Y , --256 ,256 ,HDAPS_INPUT_FUZZ ,HDAPS_INPUT_FLAT ); - -input_register_device (hdaps_idev); - -/* start up our timer for the input device */ -init_timer (&hdaps_timer); - hdaps_timer.function = hdaps_mousedev_poll; - hdaps_timer.expires = jiffies +HDAPS_POLL_PERIOD ; -add_timer (&hdaps_timer); + error =platform_device_add_resources (pdev, &hdaps_iores,1 ); +if (error) + goto err_free_device; + + error =platform_device_add (pdev); +if (error) + goto err_free_device;printk (KERN_INFO "hdaps: driver successfully loaded.\n" );return 0 ; -out_group: -sysfs_remove_group (&pdev->dev.kobj, &hdaps_attribute_group); -out_device: -platform_device_unregister (pdev); -out_driver: + err_free_device: +platform_device_put (pdev); + err_unregister_driver:platform_driver_unregister (&hdaps_driver); -out_region: -release_region (HDAPS_LOW_PORT ,HDAPS_NR_PORTS ); -out: -printk (KERN_WARNING "hdaps: driver init failed (ret=%d)!\n" , ret); -return ret; + +printk (KERN_WARNING "hdaps: driver init failed (error=%d)!\n" , error); +return error; } static void __exit hdaps_exit(void) { -del_timer_sync (&hdaps_timer); -input_unregister_device (hdaps_idev); -sysfs_remove_group (&pdev->dev.kobj, &hdaps_attribute_group);platform_device_unregister (pdev);platform_driver_unregister (&hdaps_driver); -release_region (HDAPS_LOW_PORT ,HDAPS_NR_PORTS );printk (KERN_INFO "hdaps: driver unloaded.\n" ); }
PATCH 2/6 vr41xx: convert to the new platform device interface
In reply to Dmitry Torokhovvr41xx: convert to the new platform device interface
The patch does the following for v441xx seris drivers:
- stop using platform_device_register_simple() as it is going away
- mark ->probe() and ->remove() methods as __devinit and __devexit respectively
- initialize "owner" field in driver structure so there is a link from /sys/modules to the driver
- mark *_init() and *_exit() functions as __init and __exit
---
drivers/char/vr41xx_giu.c | 19 +++++++++++++------ drivers/char/vr41xx_rtc.c | 30 ++++++++++++++++++++---------- drivers/serial/vr41xx_siu.c | 24 +++++++++++++++--------- 3 files changed, 48 insertions(+), 25 deletions(-)
drivers/char/vr41xx_rtc.c +20 -10
@@ -558,7 +558,7 @@ static struct miscdevice rtc_miscdevice .fops = &rtc_fops, }; -static int rtc_probe (struct platform_device *pdev) +static int __devinit rtc_probe (struct platform_device *pdev) {unsigned int irq;int retval;
@@ -631,7 +631,7 @@ static int rtc_probe(struct platform_devreturn 0 ; } -static int rtc_remove (struct platform_device *dev) +static int __devexit rtc_remove(struct platform_device *dev) {int retval;
@@ -653,13 +653,14 @@ static struct platform_device *rtc_platfstatic struct platform_driver rtc_device_driver = { .probe = rtc_probe, - .remove = rtc_remove, + .remove =__devexit_p (rtc_remove), .driver = { .name = rtc_name, + .owner =THIS_MODULE , }, }; -static int __devinit vr41xx_rtc_init (void ) +static int __init vr41xx_rtc_init (void ) {int retval;
@@ -684,10 +685,20 @@ static int __devinit vr41xx_rtc_init(voibreak ; } - rtc_platform_device =platform_device_register_simple ("RTC" ,-1 , - rtc_resource,ARRAY_SIZE (rtc_resource)); -if (IS_ERR (rtc_platform_device)) -return PTR_ERR (rtc_platform_device); + rtc_platform_device =platform_device_alloc ("RTC" ,-1 ); +if (!rtc_platform_device) +return -ENOMEM ; + + retval =platform_device_add_resources (rtc_platform_device, + rtc_resource,ARRAY_SIZE (rtc_resource)); + +if (retval ==0 ) + retval =platform_device_add (rtc_platform_device); + +if (retval <0 ) { +platform_device_put (rtc_platform_device); +return retval; + } retval =platform_driver_register (&rtc_device_driver);if (retval <0 )
@@ -696,10 +707,9 @@ static int __devinit vr41xx_rtc_init(voireturn retval; } -static void __devexit vr41xx_rtc_exit(void) +static void __exit vr41xx_rtc_exit(void) {platform_driver_unregister (&rtc_device_driver); -platform_device_unregister (rtc_platform_device); }
drivers/char/vr41xx_giu.c +13 -6
@@ -613,7 +613,7 @@ static struct file_operations gpio_fops .release = gpio_release, }; -static int giu_probe (struct platform_device *dev) +static int __devinit giu_probe (struct platform_device *dev) {unsigned long start, size, flags =0 ;unsigned int nr_pins =0 ;
@@ -697,7 +697,7 @@ static int giu_probe(struct platform_devreturn cascade_irq (GIUINT_IRQ , giu_get_irq); } -static int giu_remove (struct platform_device *dev) +static int __devexit giu_remove(struct platform_device *dev) {iounmap (giu_base);
@@ -712,9 +712,10 @@ static struct platform_device *giu_platfstatic struct platform_driver giu_device_driver = { .probe = giu_probe, - .remove = giu_remove, + .remove =__devexit_p (giu_remove), .driver = { .name ="GIU" , + .owner =THIS_MODULE , }, };
@@ -722,9 +723,15 @@ static int __init vr41xx_giu_init(void) {int retval; - giu_platform_device =platform_device_register_simple ("GIU" ,-1 ,NULL ,0 ); -if (IS_ERR (giu_platform_device)) -return PTR_ERR (giu_platform_device); + giu_platform_device =platform_device_alloc ("GIU" ,-1 ); +if (!giu_platform_device) +return -ENOMEM ; + + retval =platform_device_add (giu_platform_device); +if (retval <0 ) { +platform_device_put (giu_platform_device); +return retval; + } retval =platform_driver_register (&giu_device_driver);if (retval <0 )
drivers/serial/vr41xx_siu.c +15 -9
@@ -919,7 +919,7 @@ static struct uart_driver siu_uart_drive .cons = SERIAL_VR41XX_CONSOLE, }; -static int siu_probe (struct platform_device *dev) +static int __devinit siu_probe (struct platform_device *dev) {struct uart_port *port;int num, i, retval;
@@ -953,7 +953,7 @@ static int siu_probe(struct platform_devreturn 0 ; } -static int siu_remove (struct platform_device *dev) +static int __devexit siu_remove(struct platform_device *dev) {struct uart_port *port;int i;
@@ -1006,21 +1006,28 @@ static struct platform_device *siu_platfstatic struct platform_driver siu_device_driver = { .probe = siu_probe, - .remove = siu_remove, + .remove =__devexit_p (siu_remove), .suspend = siu_suspend, .resume = siu_resume, .driver = { .name ="SIU" , + .owner =THIS_MODULE , }, }; -static int __devinit vr41xx_siu_init (void ) +static int __init vr41xx_siu_init (void ) {int retval; - siu_platform_device =platform_device_register_simple ("SIU" ,-1 ,NULL ,0 ); -if (IS_ERR (siu_platform_device)) -return PTR_ERR (siu_platform_device); + siu_platform_device =platform_device_alloc ("SIU" ,-1 ); +if (!siu_platform_device) +return -ENOMEM ; + + retval =platform_device_add (siu_platform_device); +if (retval <0 ) { +platform_device_put (siu_platform_device); +return retval; + } retval =platform_driver_register (&siu_device_driver);if (retval <0 )
@@ -1029,10 +1036,9 @@ static int __devinit vr41xx_siu_init(voireturn retval; } -static void __devexit vr41xx_siu_exit(void) +static void __exit vr41xx_siu_exit(void) {platform_driver_unregister (&siu_device_driver); -platform_device_unregister (siu_platform_device); }
PATCH 3/6 mv64x600_wdt: convert to the new platform device interface
In reply to Dmitry Torokhovmv64x600_wdt: convert to the new platform device interface Do not use platform_device_register_simple() as it is going away.
---
drivers/char/watchdog/mv64x60_wdt.c | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-)
drivers/char/watchdog/mv64x60_wdt.c +15 -5
@@ -228,15 +228,25 @@ static int __init mv64x60_wdt_init(void)printk (KERN_INFO "MV64x60 watchdog driver\n" ); - mv64x60_wdt_dev =platform_device_register_simple (MV64x60_WDT_NAME, --1 ,NULL ,0 ); -if (IS_ERR (mv64x60_wdt_dev)) { - ret =PTR_ERR (mv64x60_wdt_dev); + mv64x60_wdt_dev =platform_device_alloc (MV64x60_WDT_NAME,-1 ); +if (!mv64x60_wdt_dev) { + ret = -ENOMEM ; + goto out; + } + + ret =platform_device_add (mv64x60_wdt_dev); +if (ret) { +platform_device_put (mv64x60_wdt_dev); goto out; } ret =platform_driver_register (&mv64x60_wdt_driver); - out: +if (ret) { +platform_device_unregister (mv64x60_wdt_dev); + goto out; + } + + out:return ret; }
PATCH 4/6 tb0219: convert to the new platform device interface
In reply to Dmitry Torokhovtb0219: convert to the new platform device interface
Do not use platform_device_register_simple() as it is going away.
---
drivers/char/tb0219.c | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-)
drivers/char/tb0219.c +15 -9
@@ -283,7 +283,7 @@ static void tb0219_pci_irq_init(void)vr41xx_set_irq_level (TB0219_PCI_SLOT3_PIN ,IRQ_LEVEL_LOW ); } -static int tb0219_probe (struct platform_device *dev) +static int __devinit tb0219_probe (struct platform_device *dev) {int retval;
@@ -319,7 +319,7 @@ static int tb0219_probe(struct platform_return 0 ; } -static int tb0219_remove (struct platform_device *dev) +static int __devexit tb0219_remove(struct platform_device *dev) { _machine_restart = old_machine_restart;
@@ -335,19 +335,26 @@ static struct platform_device *tb0219_plstatic struct platform_driver tb0219_device_driver = { .probe = tb0219_probe, - .remove = tb0219_remove, + .remove =__devexit_p (tb0219_remove), .driver = { .name ="TB0219" , + .owner =THIS_MODULE , }, }; -static int __devinit tanbac_tb0219_init (void ) +static int __init tanbac_tb0219_init (void ) {int retval; - tb0219_platform_device =platform_device_register_simple ("TB0219" ,-1 ,NULL ,0 ); -if (IS_ERR (tb0219_platform_device)) -return PTR_ERR (tb0219_platform_device); + tb0219_platform_device =platform_device_alloc ("TB0219" ,-1 ); +if (!tb0219_platform_device) +return -ENOMEM ; + + retval =platform_device_add (tb0219_platform_device); +if (retval <0 ) { +platform_device_put (tb0219_platform_device); +return retval; + } retval =platform_driver_register (&tb0219_device_driver);if (retval <0 )
@@ -356,10 +363,9 @@ static int __devinit tanbac_tb0219_init(return retval; } -static void __devexit tanbac_tb0219_exit(void) +static void __exit tanbac_tb0219_exit(void) {platform_driver_unregister (&tb0219_device_driver); -platform_device_unregister (tb0219_platform_device); }
PATCH 5/6 dcdbas: convert to the new platform device interface
In reply to Dmitry Torokhovdcdbas: convert to the new platform device interface
Do not use platform_device_register_simple() as it is going away, define dcdbas_driver and implement ->probe() and ->remove() functions so manual binding and unbinding will work with this driver.
Also switch to using attribute_group when creating sysfs attributes and make sure to check and handle errors; explicitely remove attributes when detaching driver.
---
drivers/firmware/dcdbas.c | 110 ++++++++++++++++++++++++++++++++++++---------- 1 files changed, 87 insertions(+), 23 deletions(-)
drivers/firmware/dcdbas.c +87 -23
@@ -530,30 +530,27 @@ static DCDBAS_DEV_ATTR_RW(host_control_astatic DCDBAS_DEV_ATTR_RW (host_control_smi_type);static DCDBAS_DEV_ATTR_RW (host_control_on_shutdown); -static struct device_attribute *dcdbas_dev_attrs[] = { - &dev_attr_smi_data_buf_size, - &dev_attr_smi_data_buf_phys_addr, - &dev_attr_smi_request, - &dev_attr_host_control_action, - &dev_attr_host_control_smi_type, - &dev_attr_host_control_on_shutdown, +static struct attribute *dcdbas_dev_attrs[] = { + &dev_attr_smi_data_buf_size.attr, + &dev_attr_smi_data_buf_phys_addr.attr, + &dev_attr_smi_request.attr, + &dev_attr_host_control_action.attr, + &dev_attr_host_control_smi_type.attr, + &dev_attr_host_control_on_shutdown.attr,NULL }; -/** -* dcdbas_init: initialize driver -*/ -static int __init dcdbas_init (void ) +static struct attribute_group dcdbas_attr_group = { + .attrs = dcdbas_dev_attrs, +}; + +static int __devinit dcdbas_probe (struct platform_device *dev) { -int i; +int i, error; host_control_action =HC_ACTION_NONE ; host_control_smi_type =HC_SMITYPE_NONE ; - dcdbas_pdev =platform_device_register_simple (DRIVER_NAME ,-1 ,NULL ,0 ); -if (IS_ERR (dcdbas_pdev)) -return PTR_ERR (dcdbas_pdev); -/* * BIOS SMI calls require buffer addresses be in 32-bit address space. * This is done by setting the DMA mask below.
@@ -561,19 +558,79 @@ static int __init dcdbas_init(void) dcdbas_pdev->dev.coherent_dma_mask =DMA_32BIT_MASK ; dcdbas_pdev->dev.dma_mask = &dcdbas_pdev->dev.coherent_dma_mask; + error =sysfs_create_group (&dev->dev.kobj, &dcdbas_attr_group); +if (error) +return error; + +for (i =0 ; dcdbas_bin_attrs[i]; i++) { + error =sysfs_create_bin_file (&dev->dev.kobj, + dcdbas_bin_attrs[i]); +if (error) { +while (--i >=0 ) +sysfs_remove_bin_file (&dev->dev.kobj, + dcdbas_bin_attrs[i]); +sysfs_create_group (&dev->dev.kobj, &dcdbas_attr_group); +return error; + } + } +register_reboot_notifier (&dcdbas_reboot_nb); +dev_info (&dev->dev,"%s (version %s)\n" , +DRIVER_DESCRIPTION ,DRIVER_VERSION ); + +return 0 ; +} + +static int __devexit dcdbas_remove(struct platform_device *dev) +{ +int i; + +unregister_reboot_notifier (&dcdbas_reboot_nb);for (i =0 ; dcdbas_bin_attrs[i]; i++) -sysfs_create_bin_file (&dcdbas_pdev->dev.kobj, - dcdbas_bin_attrs[i]); +sysfs_remove_bin_file (&dev->dev.kobj, dcdbas_bin_attrs[i]); +sysfs_remove_group (&dev->dev.kobj, &dcdbas_attr_group); -for (i =0 ; dcdbas_dev_attrs[i]; i++) -device_create_file (&dcdbas_pdev->dev, dcdbas_dev_attrs[i]); +return 0 ; +} -dev_info (&dcdbas_pdev->dev,"%s (version %s)\n" , -DRIVER_DESCRIPTION ,DRIVER_VERSION ); +static struct platform_driver dcdbas_driver = { + .driver = { + .name =DRIVER_NAME , + .owner =THIS_MODULE , + }, + .probe = dcdbas_probe, + .remove =__devexit_p (dcdbas_remove), +}; + +/** +* dcdbas_init: initialize driver +*/ +static int __init dcdbas_init (void ) +{ +int error; + + error =platform_driver_register (&dcdbas_driver); +if (error) +return error; + + dcdbas_pdev =platform_device_alloc (DRIVER_NAME ,-1 ); +if (!dcdbas_pdev) { + error = -ENOMEM ; + goto err_unregister_driver; + } + + error =platform_device_add (dcdbas_pdev); +if (error) + goto err_free_device;return 0 ; + + err_free_device: +platform_device_put (dcdbas_pdev); + err_unregister_driver: +platform_driver_unregister (&dcdbas_driver); +return error; }/**
@@ -582,7 +639,14 @@ static int __init dcdbas_init(void) static void __exit dcdbas_exit(void) {platform_device_unregister (dcdbas_pdev); -unregister_reboot_notifier (&dcdbas_reboot_nb); +platform_driver_unregister (&dcdbas_driver); + +/* +* We have to free the buffer here instead of dcdbas_remove +* because only in module exit function we can be sure that +* all sysfs attributes belonging to this module have been +* released. +*/ smi_data_buf_free (); }
PATCH 6/6 serial8250: convert to the new platform device interface
In reply to Dmitry Torokhovserial8250: convert to the new platform device interface
Do not use platform_device_register_simple() as it is going away. Also set up driver's owner to create link driver->module in sysfs.
---
drivers/serial/8250.c | 30 ++++++++++++++++++++---------- 1 files changed, 20 insertions(+), 10 deletions(-)
drivers/serial/8250.c +20 -10
@@ -2453,6 +2453,7 @@ static struct platform_driver serial8250 .resume = serial8250_resume, .driver = { .name = "serial8250", + .owner = THIS_MODULE, }, };
@@ -2593,21 +2594,30 @@ static int __init serial8250_init(void)if (ret) goto out; - serial8250_isa_devs =platform_device_register_simple ("serial8250" , -PLAT8250_DEV_LEGACY ,NULL ,0 ); -if (IS_ERR (serial8250_isa_devs)) { - ret =PTR_ERR (serial8250_isa_devs); - goto unreg; + ret =platform_driver_register (&serial8250_isa_driver); +if (ret) + goto unreg_uart_drv; + + serial8250_isa_devs =platform_device_alloc ("serial8250" , +PLAT8250_DEV_LEGACY ); +if (!serial8250_isa_devs) { + ret = -ENOMEM ; + goto unreg_plat_drv; } + ret =platform_device_add (serial8250_isa_devs); +if (ret) + goto put_dev; +serial8250_register_ports (&serial8250_reg, &serial8250_isa_devs->dev); - ret =platform_driver_register (&serial8250_isa_driver); -if (ret ==0 ) - goto out; + goto out; -platform_device_unregister (serial8250_isa_devs); - unreg: + put_dev: +platform_device_put (serial8250_isa_devs); + unreg_plat_drv: +platform_driver_unregister (&serial8250_isa_driver); + unreg_uart_drv:uart_unregister_driver (&serial8250_reg); out:return ret;
Re: [patch 6/6] serial8250: convert to the new platform device interface
This patch is breaking arch/ppc & arch/powerpc usage of 8250.c. The issue appears to be with the order in which platform_driver_register() is called vs platform_device_add().
arch/powerpc/kernel/legacy_serial.c registers an 8250 device on the platform bus before 8250_init() gets called.
Changing the order of platform_driver_register() vs platform_device_add() fixes the issue. I'm still not sure what the correct solution to this is. Ideas? comments?
- kumar
Quoted 71 lines · Dmitry Torokhov
serial8250: convert to the new platform device interface
Do not use
platform_device_register_simple()as it is going away. Also set up driver's owner to create linkdriver->modulein sysfs.Signed-off-by Dmitry Torokhov <[email protected]>---
drivers/serial/8250.c | 30 ++++++++++++++++++++---------- 1 files changed, 20 insertions(+), 10 deletions(-)Index: work/drivers/serial/8250.c
===================================================================drivers/serial/8250.c +20
-10@@ -2453,6 +2453,7 @@ static struct platform_driver serial8250 .resume = serial8250_resume, .driver = { .name = "serial8250", + .owner = THIS_MODULE, }, };@@ -2593,21 +2594,30 @@ static int __init serial8250_init(void)if (ret) goto out; - serial8250_isa_devs =platform_device_register_simple ("serial8250" , -PLAT8250_DEV_LEGACY ,NULL ,0 ); -if (IS_ERR (serial8250_isa_devs)) { - ret =PTR_ERR (serial8250_isa_devs); - goto unreg; + ret =platform_driver_register (&serial8250_isa_driver); +if (ret) + goto unreg_uart_drv; + + serial8250_isa_devs =platform_device_alloc ("serial8250" , +PLAT8250_DEV_LEGACY ); +if (!serial8250_isa_devs) { + ret = -ENOMEM ; + goto unreg_plat_drv; } + ret =platform_device_add (serial8250_isa_devs); +if (ret) + goto put_dev; +serial8250_register_ports (&serial8250_reg, &serial8250_isa_devs- >dev); - ret =platform_driver_register (&serial8250_isa_driver); -if (ret ==0 ) - goto out; + goto out; -platform_device_unregister (serial8250_isa_devs); - unreg: + put_dev: +platform_device_put (serial8250_isa_devs); + unreg_plat_drv: +platform_driver_unregister (&serial8250_isa_driver); + unreg_uart_drv:uart_unregister_driver (&serial8250_reg); out:drivers/serial/8250.c +0
-1return ret; -To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Re: [patch 6/6] serial8250: convert to the new platform device interface
Quoted 10 lines · Kumar Gala
This patch is breaking
arch/ppc&arch/powerpcusage of 8250.c. The issue appears to be with the order in whichplatform_driver_register() is called vsplatform_device_add().
arch/powerpc/kernel/legacy_serial.cregisters an 8250 device on the platform bus before 8250_init() gets called.Changing the order of
platform_driver_register()vsplatform_device_add()fixes the issue. I'm still not sure what the correct solution to this is. Ideas? comments?
Mea Culpa - should've spotted that - that patch is actually rather broken. platform_driver_register() can't be moved from where it initially was.
drivers/serial/8250.c +5 -8
@@ -2595,15 +2595,11 @@ static int __init serial8250_init(void)if (ret) goto out; - ret =platform_driver_register (&serial8250_isa_driver); -if (ret) - goto unreg_uart_drv; - serial8250_isa_devs =platform_device_alloc ("serial8250" ,PLAT8250_DEV_LEGACY );if (!serial8250_isa_devs) { ret = -ENOMEM ; - goto unreg_plat_drv; + goto unreg_uart_drv; } ret =platform_device_add (serial8250_isa_devs);
@@ -2612,12 +2608,13 @@ static int __init serial8250_init(void)serial8250_register_ports (&serial8250_reg, &serial8250_isa_devs->dev); - goto out; + ret =platform_driver_register (&serial8250_isa_driver); +if (ret ==0 ) + goto out; +platform_device_del (serial8250_isa_devs); put_dev:platform_device_put (serial8250_isa_devs); - unreg_plat_drv: -platform_driver_unregister (&serial8250_isa_driver); unreg_uart_drv:uart_unregister_driver (&serial8250_reg); out:
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [patch 6/6] serial8250: convert to the new platform device interface
Quoted 8 lines · Russell King
Quoted 7 lines · Kumar Gala
This patch is breaking
arch/ppc&arch/powerpcusage of 8250.c. The issue appears to be with the order in whichplatform_driver_register() is called vsplatform_device_add().
arch/powerpc/kernel/legacy_serial.cregisters an 8250 device on the platform bus before 8250_init() gets called.
Quoted 7 lines
Quoted 3 lines
Changing the order of
platform_driver_register()vsplatform_device_add()fixes the issue. I'm still not sure what the correct solution to this is. Ideas? comments?Mea Culpa - should've spotted that - that patch is actually rather broken.
platform_driver_register()can't be moved from where it initially was.
This seems to fix my issue on arch/powerpc and arch/ppc, please push to Linus ASAP.
thanks
- kumar
Quoted 40 lines
drivers/serial/8250.c +5
-8@@ -2595,15 +2595,11 @@ static int __init serial8250_init(void)if (ret) goto out; - ret =platform_driver_register (&serial8250_isa_driver); -if (ret) - goto unreg_uart_drv; - serial8250_isa_devs =platform_device_alloc ("serial8250" ,PLAT8250_DEV_LEGACY );if (!serial8250_isa_devs) { ret = -ENOMEM ; - goto unreg_plat_drv; + goto unreg_uart_drv; } ret =platform_device_add (serial8250_isa_devs);@@ -2612,12 +2608,13 @@ static int __init serial8250_init(void)serial8250_register_ports (&serial8250_reg, &serial8250_isa_devs->dev); - goto out; + ret =platform_driver_register (&serial8250_isa_driver); +if (ret ==0 ) + goto out; +platform_device_del (serial8250_isa_devs); put_dev:platform_device_put (serial8250_isa_devs); - unreg_plat_drv: -platform_driver_unregister (&serial8250_isa_driver); unreg_uart_drv:uart_unregister_driver (&serial8250_reg); out:
Re: [patch 6/6] serial8250: convert to the new platform device interface
Quoted 14 lines · Kumar Gala
Quoted 12 lines · Russell King
Quoted 10 lines · Kumar Gala
This patch is breaking
arch/ppc&arch/powerpcusage of 8250.c. The issue appears to be with the order in whichplatform_driver_register() is called vsplatform_device_add().
arch/powerpc/kernel/legacy_serial.cregisters an 8250 device on the platform bus before 8250_init() gets called.Changing the order of
platform_driver_register()vsplatform_device_add()fixes the issue. I'm still not sure what the correct solution to this is. Ideas? comments?
Quoted 6 lines
Quoted 3 lines
Mea Culpa - should've spotted that - that patch is actually rather broken.
platform_driver_register()can't be moved from where it initially was.This seems to fix my issue on
arch/powerpcandarch/ppc, please push to Linus ASAP.
This patch fixes problems on omap too.
Tony
Re: [patch 6/6] serial8250: convert to the new platform device interface
In reply to Kumar GalaQuoted 6 lines · Kumar Gala
Quoted 3 lines
Mea Culpa - should've spotted that - that patch is actually rather broken.
platform_driver_register()can't be moved from where it initially was.This seems to fix my issue on
arch/powerpcandarch/ppc, please push to Linus ASAP.
This fixes also my pseries, p270. Too bad, the 8250 depends on CONFIG_ISA now which is not selectable for CONFIG_PPC_PSERIES. Is this patch the way to go for ppc64?
arch/powerpc/Kconfig +1 -1
@@ -712,7 +712,7 @@ menu "Bus options" config ISA bool "Support for ISA-bus hardware" - depends on PPC_PREP || PPC_CHRP + depends on PPC_PREP || PPC_CHRP || PPC_PSERIES select PPC_I8259 help Find out whether you have ISA slots on your motherboard. ISA is the
Signature · 2 lines
short story of a lazy sysadmin: alias appserv=wotan
Re: [patch 6/6] serial8250: convert to the new platform device interface
Quoted 11 lines · Olaf Hering
Quoted 6 lines · Kumar Gala
Quoted 3 lines
Mea Culpa - should've spotted that - that patch is actually rather broken.
platform_driver_register()can't be moved from where it initially was.This seems to fix my issue on
arch/powerpcandarch/ppc, please push to Linus ASAP.This fixes also my pseries, p270. Too bad, the 8250 depends on
CONFIG_ISAnow which is not selectable forCONFIG_PPC_PSERIES. Is this patch the way to go for ppc64?
8250 does not depend on ISA - at least not in mainline. If it did depend on ISA, that would be completely wrong.
ISA should be set if you have ISA slots on your motherboard (as the help says). The presence of 8250 devices does not depend on whether you have ISA slots or not.
Patch rejected.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [patch 6/6] serial8250: convert to the new platform device interface
Quoted 2 lines · Russell King
8250 does not depend on ISA - at least not in mainline. If it did depend on ISA, that would be completely wrong.
Maybe something else is busted, cant get serial output without such change.
Signature · 2 lines
short story of a lazy sysadmin: alias appserv=wotan
Re: [patch 6/6] serial8250: convert to the new platform device interface
In reply to Olaf HeringQuoted 8 lines · Olaf Hering
Quoted 6 lines · Kumar Gala
Quoted 3 lines
Mea Culpa - should've spotted that - that patch is actually rather broken.
platform_driver_register()can't be moved from where it initially was.This seems to fix my issue on
arch/powerpcandarch/ppc, please push to Linus ASAP.
older pSeries systems with serial ports dont get any console output after recent changes. CONFIG_ISA does not make sense for CONFIG_PPC_PSERIES because it enables lots of old drivers.
Instead, remove the dependency on CONFIG_ISA from the serial port discovery code.
arch/powerpc/kernel/legacy_serial.c | 4 ---- 1 files changed, 4 deletions(-)
arch/powerpc/kernel/legacy_serial.c +0 -4
@@ -134,7 +134,6 @@ static int __init add_legacy_soc_port(streturn add_legacy_port (np,-1 ,UPIO_MEM , addr, addr,NO_IRQ , flags); } -#ifdef CONFIG_ISA static int __init add_legacy_isa_port (struct device_node *np,struct device_node *isa_brg) {
@@ -168,7 +167,6 @@ static int __init add_legacy_isa_port(streturn add_legacy_port (np, index,UPIO_PORT , reg[1 ], taddr,NO_IRQ ,UPF_BOOT_AUTOCONF ); } -#endif #ifdef CONFIG_PCI static int __init add_legacy_pci_port(struct device_node *np,
@@ -276,7 +274,6 @@ void __init find_legacy_serial_ports(voiof_node_put (soc); } -#ifdef CONFIG_ISA /* First fill our array with ISA ports */ for (np =NULL ; (np =of_find_node_by_type (np,"serial" ));) {struct device_node *isa =of_get_parent (np);
@@ -287,7 +284,6 @@ void __init find_legacy_serial_ports(voi }of_node_put (isa); } -#endif #ifdef CONFIG_PCI /* Next, try to locate PCI ports */
Signature · 2 lines
short story of a lazy sysadmin: alias appserv=wotan
Re: [patch 6/6] serial8250: convert to the new platform device interface
In reply to Kumar GalaQuoted 9 lines · Kumar Gala
Quoted 5 lines · Russell King
On Mon, Jan 16, 2006 at 04:27:17PM -0600, Kumar Gala wrote:
Mea Culpa - should've spotted that - that patch is actually rather broken.
platform_driver_register()can't be moved from where it initially was.This seems to fix my issue on
arch/powerpcandarch/ppc, please push to Linus ASAP.
Ditto for ML403 (Virtex), thanks
g.
Quoted 52 lines
Quoted 32 lines
drivers/serial/8250.c +3
-6@@ -2595,15 +2595,11 @@ static int __init serial8250_init(void)if (ret) goto out; - ret =platform_driver_register (&serial8250_isa_driver); -if (ret) - goto unreg_uart_drv; - serial8250_isa_devs =platform_device_alloc ("serial8250" ,PLAT8250_DEV_LEGACY );if (!serial8250_isa_devs) { ret = -ENOMEM ; - goto unreg_plat_drv; + goto unreg_uart_drv; } ret =platform_device_add (serial8250_isa_devs);@@ -2612,12 +2608,13 @@ static int __init serial8250_init(void)serial8250_register_ports (&serial8250_reg, &serial8250_isa_devs->dev); - goto out; + ret =platform_driver_register (&serial8250_isa_driver); +if (ret ==0 )drivers/serial/8250.c static int __init serial8250_init(void) · line 2620
Quoted 10 lines
drivers/serial/8250.c +2
-2+ goto out; +platform_device_del (serial8250_isa_devs); put_dev:platform_device_put (serial8250_isa_devs); - unreg_plat_drv: -platform_driver_unregister (&serial8250_isa_driver); unreg_uart_drv:uart_unregister_driver (&serial8250_reg); out:-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/