Add platform_driver
Subsystems (27)
The following set of patches adds a platform_driver structure, which is much like the pci_driver structure:
struct platform_driver {
int (*probe)(struct platform_device *);
int (*remove)(struct platform_device *);
void (*shutdown)(struct platform_device *);
int (*suspend)(struct platform_device *, pm_message_t state);
int (*resume)(struct platform_device *);
struct device_driver driver;
};The idea behind this is to stop using the struct device_driver suspend/resume fields, and eventually eliminate the other function pointers from within that structure.
Why?
Virtually every other user wraps the device_driver structure in their own structure, which contains function pointers specific to their implementation. For instance, pci_driver contains:
int (*probe) (struct pci_dev *dev, const struct pci_device_id *id);
void (*remove) (struct pci_dev *dev);
int (*suspend) (struct pci_dev *dev, pm_message_t state);
int (*resume) (struct pci_dev *dev);
int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable);
void (*shutdown) (struct pci_dev *dev);and as can be seen, the arguments to these methods are typed according to the bus type.
Hence, the methods in struct device_driver are just adding needless bloat to the kernel. In addition, use of these device_driver methods invariably requires a container_of() manipulation of the struct_device structure, and doing that in every driver is also needless code bloat.
Also, from the type safety aspect, it's better to have methods which are passed the correct type and if they aren't have a compiler warning or build failure.
Hence, the following patches introduce struct platform_driver, and then convert the platform device drivers over to this new model.
Due to the way the conversion is done, unconverted drivers will still continue to work as before... for the time being.
Patches, which are built on top of my previous driver model patch set, follow.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Introduce struct platform_driver. This allows the platform device driver methods to be passed a platform_device structure instead of instead of a plain device structure, and therefore requiring casting in every platform driver.
We introduce this in such a way that any existing platform drivers registered directly via driver_register continue to work as before, thereby allowing a gradual conversion to the new platform_driver methods.
drivers/base/platform.c +73 -0
@@ -20,6 +20,8 @@#include "base.h" +#define to_platform_driver (drv) (container_of((drv), struct platform_driver, driver)) +struct device platform_bus = { .bus_id ="platform" , };
@@ -354,6 +356,77 @@return ERR_PTR (retval); } +static int platform_drv_probe (struct device *_dev) +{ +struct platform_driver *drv =to_platform_driver (_dev->driver); +struct platform_device *dev =to_platform_device (_dev); + +return drv->probe (dev); +} + +static int platform_drv_remove (struct device *_dev) +{ +struct platform_driver *drv =to_platform_driver (_dev->driver); +struct platform_device *dev =to_platform_device (_dev); + +return drv->remove (dev); +} + +static void platform_drv_shutdown (struct device *_dev) +{ +struct platform_driver *drv =to_platform_driver (_dev->driver); +struct platform_device *dev =to_platform_device (_dev); + + drv->shutdown (dev); +} + +static int platform_drv_suspend (struct device *_dev,pm_message_t state) +{ +struct platform_driver *drv =to_platform_driver (_dev->driver); +struct platform_device *dev =to_platform_device (_dev); + +return drv->suspend (dev, state); +} + +static int platform_drv_resume (struct device *_dev) +{ +struct platform_driver *drv =to_platform_driver (_dev->driver); +struct platform_device *dev =to_platform_device (_dev); + +return drv->resume (dev); +} + +/** +* platform_driver_register +* @drv: platform driver structure +*/ +int platform_driver_register (struct platform_driver *drv) +{ + drv->driver.bus = &platform_bus_type; +if (drv->probe) + drv->driver.probe = platform_drv_probe; +if (drv->remove) + drv->driver.remove = platform_drv_remove; +if (drv->shutdown) + drv->driver.shutdown = platform_drv_shutdown; +if (drv->suspend) + drv->driver.suspend = platform_drv_suspend; +if (drv->resume) + drv->driver.resume = platform_drv_resume; +return driver_register (&drv->driver); +} +EXPORT_SYMBOL_GPL (platform_driver_register); + +/** +* platform_driver_unregister +* @drv: platform driver structure +*/ +void platform_driver_unregister (struct platform_driver *drv) +{ +driver_unregister (&drv->driver); +} +EXPORT_SYMBOL_GPL (platform_driver_unregister); +/** * platform_match - bind platform device to platform driver.
include/linux/platform_device.h +15 -0
@@ -43,4 +43,19 @@extern int platform_device_add (struct platform_device *pdev);extern void platform_device_put (struct platform_device *pdev); +struct platform_driver { +int (*probe)(struct platform_device *); +int (*remove)(struct platform_device *); +void (*shutdown)(struct platform_device *); +int (*suspend)(struct platform_device *,pm_message_t state); +int (*resume)(struct platform_device *); +struct device_driver driver; +}; + +extern int platform_driver_register (struct platform_driver *); +extern void platform_driver_unregister (struct platform_driver *); + +#define platform_get_drvdata (_dev) dev_get_drvdata(&(_dev)->dev) +#define platform_set_drvdata (_dev,data) dev_set_drvdata(&(_dev)->dev, (data)) +#endif /* _PLATFORM_DEVICE_H_ */
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Greg KH
Acked-by Greg Kroah-HartmanQuoted 11 lines · Russell King
Introduce struct
platform_driver. This allows the platform device driver methods to be passed aplatform_devicestructure instead of instead of a plain device structure, and therefore requiring casting in every platform driver.We introduce this in such a way that any existing platform drivers registered directly via
driver_registercontinue to work as before, thereby allowing a gradual conversion to the newplatform_drivermethods.Signed-off-by Russell King <[email protected]>
Thanks a lot for doing this work, I really appreciate it and think it is the proper way to move forward (the whole, remove the pointers from the struct driver thing.)
thanks,
greg k-h
Re: [DRIVER MODEL] Convert arch/arm
In reply to Russell KingConvert platform drivers to use struct platform_driver
arch/arm/common/locomo.c +19 -19
@@ -550,9 +550,9 @@u16 LCM_SPIMD ; }; -static int locomo_suspend (struct device *dev,pm_message_t state) +static int locomo_suspend (struct platform_device *dev,pm_message_t state) { -struct locomo *lchip =dev_get_drvdata (dev); +struct locomo *lchip =platform_get_drvdata (dev);struct locomo_save_data *save;unsigned long flags;
@@ -560,7 +560,7 @@if (!save)return -ENOMEM ; - dev->power.saved_state = (void *) save; + dev->dev.power.saved_state = (void *) save;spin_lock_irqsave (&lchip->lock, flags);
@@ -594,14 +594,14 @@return 0 ; } -static int locomo_resume (struct device *dev) +static int locomo_resume (struct platform_device *dev) { -struct locomo *lchip =dev_get_drvdata (dev); +struct locomo *lchip =platform_get_drvdata (dev);struct locomo_save_data *save;unsigned long r;unsigned long flags; - save = (struct locomo_save_data *) dev->power.saved_state; + save = (struct locomo_save_data *) dev->dev.power.saved_state;if (!save)return 0 ;
@@ -760,27 +760,26 @@kfree (lchip); } -static int locomo_probe (struct device *dev) +static int locomo_probe (struct platform_device *dev) { -struct platform_device *pdev =to_platform_device (dev);struct resource *mem;int irq; - mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + mem =platform_get_resource (dev,IORESOURCE_MEM ,0 );if (!mem)return -EINVAL ; - irq =platform_get_irq (pdev,0 ); + irq =platform_get_irq (dev,0 ); -return __locomo_probe (dev, mem, irq); +return __locomo_probe (&dev->dev, mem, irq); } -static int locomo_remove (struct device *dev) +static int locomo_remove (struct platform_device *dev) { -struct locomo *lchip =dev_get_drvdata (dev); +struct locomo *lchip =platform__get_drvdata (dev);if (lchip) {__locomo_remove (lchip); -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (dev,NULL ); }return 0 ;
@@ -792,15 +791,16 @@* the per-machine level, and then have this driver pick * up the registered devices. */ -static struct device_driver locomo_device_driver = { - .name ="locomo" , - .bus = &platform_bus_type, +static struct platform_driver locomo_device_driver = { .probe = locomo_probe, .remove = locomo_remove, #ifdef CONFIG_PM .suspend = locomo_suspend, .resume = locomo_resume, #endif + .driver = { + .name ="locomo" , + }, };/*
@@ -1126,13 +1126,13 @@ {int ret =bus_register (&locomo_bus_type);if (ret ==0 ) -driver_register (&locomo_device_driver); +platform_driver_register (&locomo_device_driver);return ret; } static void __exit locomo_exit(void) { -driver_unregister (&locomo_device_driver); +platform_driver_unregister (&locomo_device_driver);bus_unregister (&locomo_bus_type); }
arch/arm/common/sa1111.c +21 -21
120 lines not on this page · raw message
arch/arm/common/scoop.c +15 -15
@@ -104,9 +104,9 @@ }#ifdef CONFIG_PM -static int scoop_suspend (struct device *dev,pm_message_t state) +static int scoop_suspend (struct platform_device *dev,pm_message_t state) { -struct scoop_dev *sdev =dev_get_drvdata (dev); +struct scoop_dev *sdev =platform_get_drvdata (dev);check_scoop_reg (sdev); sdev->scoop_gpwr =SCOOP_REG (sdev->base,SCOOP_GPWR );
@@ -115,9 +115,9 @@return 0 ; } -static int scoop_resume (struct device *dev) +static int scoop_resume (struct platform_device *dev) { -struct scoop_dev *sdev =dev_get_drvdata (dev); +struct scoop_dev *sdev =platform_get_drvdata (dev);check_scoop_reg (sdev);SCOOP_REG (sdev->base,SCOOP_GPWR ) = sdev->scoop_gpwr;
@@ -129,11 +129,10 @@#define scoop_resume NULL#endif -int __init scoop_probe (struct device *dev) +int __init scoop_probe (struct platform_device *pdev) {struct scoop_dev *devptr;struct scoop_config *inf; -struct platform_device *pdev =to_platform_device (dev);struct resource *mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!mem)
@@ -147,7 +146,7 @@memset (devptr,0 ,sizeof (struct scoop_dev ));spin_lock_init (&devptr->scoop_lock); - inf = dev->platform_data; + inf = pdev->dev.platform_data; devptr->base =ioremap (mem->start, mem->end - mem->start +1 );if (!devptr->base) {
@@ -155,7 +154,7 @@return -ENOMEM ; } -dev_set_drvdata (dev, devptr); +platform_set_drvdata (pdev, devptr);printk ("Sharp Scoop Device found at 0x%08x -> 0x%08x\n" ,(unsigned int )mem->start,(unsigned int )devptr->base);
@@ -170,29 +169,30 @@return 0 ; } -static int scoop_remove (struct device *dev) +static int scoop_remove (struct platform_device *pdev) { -struct scoop_dev *sdev =dev_get_drvdata (dev); +struct scoop_dev *sdev =platform_get_drvdata (pdev);if (sdev) {iounmap (sdev->base);kfree (sdev); -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (pdev,NULL ); }return 0 ; } -static struct device_driver scoop_driver = { - .name ="sharp-scoop" , - .bus = &platform_bus_type, +static struct platform_driver scoop_driver = { .probe = scoop_probe, .remove = scoop_remove, .suspend = scoop_suspend, .resume = scoop_resume, + .driver = { + .name ="sharp-scoop" , + }, };int __init scoop_init (void ) { -return driver_register (&scoop_driver); +return platform_driver_register (&scoop_driver); }subsys_initcall (scoop_init);
arch/arm/mach-pxa/corgi_ssp.c +9 -8
@@ -191,7 +191,7 @@ ssp_machinfo = machinfo; } -static int __init corgi_ssp_probe (struct device *dev) +static int __init corgi_ssp_probe (struct platform_device *dev) {int ret;
@@ -216,7 +216,7 @@return ret; } -static int corgi_ssp_remove (struct device *dev) +static int corgi_ssp_remove (struct platform_device *dev) {ssp_exit (&corgi_ssp_dev);return 0 ;
@@ -222,7 +222,7 @@return 0 ; } -static int corgi_ssp_suspend (struct device *dev,pm_message_t state) +static int corgi_ssp_suspend (struct platform_device *dev,pm_message_t state) {ssp_flush (&corgi_ssp_dev);ssp_save_state (&corgi_ssp_dev,&corgi_ssp_state);
@@ -230,7 +230,7 @@return 0 ; } -static int corgi_ssp_resume (struct device *dev) +static int corgi_ssp_resume (struct platform_device *dev) {GPSR (ssp_machinfo->cs_lcdcon) =GPIO_bit (ssp_machinfo->cs_lcdcon);/* High - Disable LCD Control/Timing Gen */ GPSR (ssp_machinfo->cs_max1111) =GPIO_bit (ssp_machinfo->cs_max1111);/* High - Disable MAX1111*/
@@ -241,18 +241,19 @@return 0 ; } -static struct device_driver corgissp_driver = { - .name ="corgi-ssp" , - .bus = &platform_bus_type, +static struct platform_driver corgissp_driver = { .probe = corgi_ssp_probe, .remove = corgi_ssp_remove, .suspend = corgi_ssp_suspend, .resume = corgi_ssp_resume, + .driver = { + .name ="corgi-ssp" , + }, };int __init corgi_ssp_init (void ) { -return driver_register (&corgissp_driver); +return platform_driver_register (&corgissp_driver); }arch_initcall (corgi_ssp_init);
arch/arm/mach-sa1100/neponset.c +16 -15
@@ -137,7 +137,7 @@ .get_mctrl = neponset_get_mctrl, }; -static int neponset_probe (struct device *dev) +static int neponset_probe (struct platform_device *dev) {sa1100_register_uart_fns (&neponset_port_fns);
@@ -178,27 +178,27 @@/* * LDM power management. */ -static int neponset_suspend (struct device *dev,pm_message_t state) +static int neponset_suspend (struct platform_device *dev,pm_message_t state) {/* * Save state. */ -if (!dev->power.saved_state) - dev->power.saved_state =kmalloc (sizeof (unsigned int ),GFP_KERNEL ); -if (!dev->power.saved_state) +if (!dev->dev.power.saved_state) + dev->dev.power.saved_state =kmalloc (sizeof (unsigned int ),GFP_KERNEL ); +if (!dev->dev.power.saved_state)return -ENOMEM ; - *(unsigned int *)dev->power.saved_state =NCR_0 ; + *(unsigned int *)dev->dev.power.saved_state =NCR_0 ;return 0 ; } -static int neponset_resume (struct device *dev) +static int neponset_resume (struct platform_device *dev) { -if (dev->power.saved_state) { -NCR_0 = *(unsigned int *)dev->power.saved_state; -kfree (dev->power.saved_state); - dev->power.saved_state =NULL ; +if (dev->dev.power.saved_state) { +NCR_0 = *(unsigned int *)dev->dev.power.saved_state; +kfree (dev->dev.power.saved_state); + dev->dev.power.saved_state =NULL ; }return 0 ;
@@ -209,12 +209,13 @@#define neponset_resume NULL#endif -static struct device_driver neponset_device_driver = { - .name ="neponset" , - .bus = &platform_bus_type, +static struct platform_driver neponset_device_driver = { .probe = neponset_probe, .suspend = neponset_suspend, .resume = neponset_resume, + .driver = { + .name ="neponset" , + }, };static struct resource neponset_resources[] = {
@@ -293,7 +294,7 @@static int __init neponset_init (void ) { -driver_register (&neponset_device_driver); +platform_driver_register (&neponset_device_driver);/* * The Neponset is only present on the Assabet machine type.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert arch/um/
In reply to Russell KingConvert platform drivers to use struct platform_driver
arch/um/drivers/net_kern.c +5 -4
@@ -285,9 +285,10 @@ void uml_net_user_timer_expire(unsignedstatic DEFINE_SPINLOCK (devices_lock);static struct list_head devices =LIST_HEAD_INIT (devices); -static struct device_driver uml_net_driver = { - .name =DRIVER_NAME , - .bus = &platform_bus_type, +static struct platform_driver uml_net_driver = { + .driver = { + .name =DRIVER_NAME , + }, };static int driver_registered;
@@ -334,7 +335,7 @@ static int eth_configure(int n, void *in/* sysfs register */ if (!driver_registered) { -driver_register (¨_net_driver); +platform_driver_register (¨_net_driver); driver_registered =1 ; } device->pdev.id = n;
arch/um/drivers/ubd_kern.c +5 -4
@@ -823,9 +823,10 @@ static int ubd_mc_init(void)__initcall (ubd_mc_init); -static struct device_driver ubd_driver = { - .name =DRIVER_NAME , - .bus = &platform_bus_type, +static struct platform_driver ubd_driver = { + .driver = { + .name =DRIVER_NAME , + }, };int ubd_init (void )
@@ -850,7 +851,7 @@ int ubd_init(void)if (register_blkdev (fake_major,"ubd" ))return -1 ; } -driver_register (&ubd_driver); +platform_driver_register (&ubd_driver);for (i =0 ; i <MAX_DEV ; i++)ubd_add (i);return 0 ;
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert arch/xtensa/
In reply to Russell KingConvert platform drivers to use struct platform_driver
arch/xtensa/platform-iss/network.c +5 -4
@@ -648,9 +648,10 @@ void iss_net_user_timer_expire(unsigned } -static struct device_driver iss_net_driver = { - .name =DRIVER_NAME , - .bus = &platform_bus_type, +static struct platform_driver iss_net_driver = { + .driver = { + .name =DRIVER_NAME , + }, };static int driver_registered;
@@ -701,7 +702,7 @@ static int iss_net_configure(int index,/* sysfs register */ if (!driver_registered) { -driver_register (&iss_net_driver); +platform_driver_register (&iss_net_driver); driver_registered =1 ; }
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert ARM s3c2410 drivers
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/char/s3c2410-rtc.c +25 -25
@@ -382,7 +382,7 @@ static struct rtc_ops s3c2410_rtcops = { .proc = s3c2410_rtc_proc, }; -static void s3c2410_rtc_enable (struct device *dev,int en) +static void s3c2410_rtc_enable (struct platform_device *pdev,int en) {unsigned int tmp;
@@ -399,21 +399,21 @@ static void s3c2410_rtc_enable(struct de/* re-enable the device, and check it is ok */ if ((readb (S3C2410_RTCCON ) &S3C2410_RTCCON_RTCEN ) ==0 ){ -dev_info (dev,"rtc disabled, re-enabling\n" ); +dev_info (&pdev->dev,"rtc disabled, re-enabling\n" ); tmp =readb (S3C2410_RTCCON );writeb (tmp |S3C2410_RTCCON_RTCEN ,S3C2410_RTCCON ); }if ((readb (S3C2410_RTCCON ) &S3C2410_RTCCON_CNTSEL )){ -dev_info (dev,"removing S3C2410_RTCCON_CNTSEL\n" ); +dev_info (&pdev->dev,"removing S3C2410_RTCCON_CNTSEL\n" ); tmp =readb (S3C2410_RTCCON );writeb (tmp& ~S3C2410_RTCCON_CNTSEL ,S3C2410_RTCCON ); }if ((readb (S3C2410_RTCCON ) &S3C2410_RTCCON_CLKRST )){ -dev_info (dev,"removing S3C2410_RTCCON_CLKRST\n" ); +dev_info (&pdev->dev,"removing S3C2410_RTCCON_CLKRST\n" ); tmp =readb (S3C2410_RTCCON );writeb (tmp & ~S3C2410_RTCCON_CLKRST ,S3C2410_RTCCON );
@@ -421,7 +421,7 @@ static void s3c2410_rtc_enable(struct de } } -static int s3c2410_rtc_remove (struct device *dev) +static int s3c2410_rtc_remove (struct platform_device *dev) {unregister_rtc (&s3c2410_rtcops);
@@ -438,25 +438,24 @@ static int s3c2410_rtc_remove(struct devreturn 0 ; } -static int s3c2410_rtc_probe (struct device *dev) +static int s3c2410_rtc_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev);struct resource *res;int ret; -pr_debug ("%s: probe=%p, device=%p\n" , __FUNCTION__, pdev, dev); +pr_debug ("%s: probe=%p\n" , __FUNCTION__, pdev);/* find the IRQs */ s3c2410_rtc_tickno =platform_get_irq (pdev,1 );if (s3c2410_rtc_tickno <=0 ) { -dev_err (dev,"no irq for rtc tick\n" ); +dev_err (&pdev->dev,"no irq for rtc tick\n" );return -ENOENT ; } s3c2410_rtc_alarmno =platform_get_irq (pdev,0 );if (s3c2410_rtc_alarmno <=0 ) { -dev_err (dev,"no irq for alarm\n" ); +dev_err (&pdev->dev,"no irq for alarm\n" );return -ENOENT ; }
@@ -467,7 +466,7 @@ static int s3c2410_rtc_probe(struct devi res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (res ==NULL ) { -dev_err (dev,"failed to get memory region resource\n" ); +dev_err (&pdev->dev,"failed to get memory region resource\n" );return -ENOENT ; }
@@ -475,14 +474,14 @@ static int s3c2410_rtc_probe(struct devi pdev->name);if (s3c2410_rtc_mem ==NULL ) { -dev_err (dev,"failed to reserve memory region\n" ); +dev_err (&pdev->dev,"failed to reserve memory region\n" ); ret = -ENOENT ; goto exit_err; } s3c2410_rtc_base =ioremap (res->start, res->end - res->start +1 );if (s3c2410_rtc_base ==NULL ) { -dev_err (dev,"failed ioremap()\n" ); +dev_err (&pdev->dev,"failed ioremap()\n" ); ret = -EINVAL ; goto exit_err; }
@@ -494,7 +493,7 @@ static int s3c2410_rtc_probe(struct devi/* check to see if everything is setup correctly */ -s3c2410_rtc_enable (dev,1 ); +s3c2410_rtc_enable (pdev,1 );pr_debug ("s3c2410_rtc: RTCCON=%02x\n" ,readb (S3C2410_RTCCON ));
@@ -506,7 +505,7 @@ static int s3c2410_rtc_probe(struct devireturn 0 ; exit_err: -dev_err (dev,"error %d during initialisation\n" , ret); +dev_err (&pdev->dev,"error %d during initialisation\n" , ret);return ret; }
@@ -519,7 +518,7 @@ static struct timespec s3c2410_rtc_deltastatic int ticnt_save; -static int s3c2410_rtc_suspend (struct device *dev,pm_message_t state) +static int s3c2410_rtc_suspend (struct platform_device *pdev,pm_message_t state) {struct rtc_time tm;struct timespec time;
@@ -535,19 +534,19 @@s3c2410_rtc_gettime (&tm);rtc_tm_to_time (&tm, &time.tv_sec);save_time_delta (&s3c2410_rtc_delta, &time); -s3c2410_rtc_enable (dev,0 ); +s3c2410_rtc_enable (pdev,0 );return 0 ; } -static int s3c2410_rtc_resume (struct device *dev) +static int s3c2410_rtc_resume (struct platform_device *pdev) {struct rtc_time tm;struct timespec time; time.tv_nsec =0 ; -s3c2410_rtc_enable (dev,1 ); +s3c2410_rtc_enable (pdev,1 );s3c2410_rtc_gettime (&tm);rtc_tm_to_time (&tm, &time.tv_sec);restore_time_delta (&s3c2410_rtc_delta, &time);
@@ -560,14 +559,15 @@ static int s3c2410_rtc_resume(struct dev#define s3c2410_rtc_resume NULL#endif -static struct device_driver s3c2410_rtcdrv = { - .name ="s3c2410-rtc" , - .owner =THIS_MODULE , - .bus = &platform_bus_type, +static struct platform_driver s3c2410_rtcdrv = { .probe = s3c2410_rtc_probe, .remove = s3c2410_rtc_remove, .suspend = s3c2410_rtc_suspend, .resume = s3c2410_rtc_resume, + .driver = { + .name ="s3c2410-rtc" , + .owner =THIS_MODULE , + }, };static char __initdata banner[] ="S3C2410 RTC, (c) 2004 Simtec Electronics\n" ;
@@ -575,12 +575,12 @@ static char __initdata banner[] = "S3C24static int __init s3c2410_rtc_init (void ) {printk (banner); -return driver_register (&s3c2410_rtcdrv); +return platform_driver_register (&s3c2410_rtcdrv); } static void __exit s3c2410_rtc_exit(void) { -driver_unregister (&s3c2410_rtcdrv); +platform_driver_unregister (&s3c2410_rtcdrv); }module_init (s3c2410_rtc_init);
drivers/char/watchdog/s3c2410_wdt.c +15 -15
@@ -347,15 +347,14 @@ static irqreturn_t s3c2410wdt_irq(int ir }/* device interface */ -static int s3c2410wdt_probe (struct device *dev) +static int s3c2410wdt_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev);struct resource *res;int started =0 ;int ret;int size; -DBG ("%s: probe=%p, device=%p\n" , __FUNCTION__, pdev, dev); +DBG ("%s: probe=%p\n" , __FUNCTION__, pdev);/* get the memory region for the watchdog timer */
@@ -386,13 +385,13 @@ static int s3c2410wdt_probe(struct devicreturn -ENOENT ; } - ret =request_irq (res->start, s3c2410wdt_irq,0 , pdev->name, dev); + ret =request_irq (res->start, s3c2410wdt_irq,0 , pdev->name, pdev);if (ret !=0 ) { printk(KERN_INFO PFX "failed to install irq (%d)\n", ret);return ret; } - wdt_clock =clk_get (dev,"watchdog" ); + wdt_clock =clk_get (&pdev->dev,"watchdog" );if (wdt_clock ==NULL ) { printk(KERN_INFO PFX "failed to find watchdog clock source\n");return -ENOENT ;
@@ -430,7 +429,7 @@ static int s3c2410wdt_probe(struct devicreturn 0 ; } -static int s3c2410wdt_remove (struct device *dev) +static int s3c2410wdt_remove (struct platform_device *dev) {if (wdt_mem !=NULL ) {release_resource (wdt_mem);
@@ -454,7 +453,7 @@ static int s3c2410wdt_remove(struct devireturn 0 ; } -static void s3c2410wdt_shutdown (struct device *dev) +static void s3c2410wdt_shutdown (struct platform_device *dev) {s3c2410wdt_stop (); }
@@ -464,7 +463,7 @@ static void s3c2410wdt_shutdown(struct dstatic unsigned long wtcon_save;static unsigned long wtdat_save; -static int s3c2410wdt_suspend (struct device *dev,pm_message_t state) +static int s3c2410wdt_suspend (struct platform_device *dev,pm_message_t state) {/* Save watchdog state, and turn it off. */ wtcon_save =readl (wdt_base +S3C2410_WTCON );
@@ -476,7 +475,7 @@return 0 ; } -static int s3c2410wdt_resume (struct device *dev) +static int s3c2410wdt_resume (struct platform_device *dev) {/* Restore watchdog state. */
@@ -496,15 +495,16 @@ static int s3c2410wdt_resume(struct devi#endif /* CONFIG_PM */ -static struct device_driver s3c2410wdt_driver = { - .owner =THIS_MODULE , - .name ="s3c2410-wdt" , - .bus = &platform_bus_type, +static struct platform_driver s3c2410wdt_driver = { .probe = s3c2410wdt_probe, .remove = s3c2410wdt_remove, .shutdown = s3c2410wdt_shutdown, .suspend = s3c2410wdt_suspend, .resume = s3c2410wdt_resume, + .driver = { + .owner =THIS_MODULE , + .name ="s3c2410-wdt" , + }, };
@@ -513,12 +513,12 @@ static char banner[] __initdata = KERN_Istatic int __init watchdog_init (void ) {printk (banner); -return driver_register (&s3c2410wdt_driver); +return platform_driver_register (&s3c2410wdt_driver); } static void __exit watchdog_exit(void) { -driver_unregister (&s3c2410wdt_driver); +platform_driver_unregister (&s3c2410wdt_driver); }module_init (watchdog_init);
drivers/i2c/busses/i2c-s3c2410.c +36 -35
185 lines not on this page · raw message
drivers/mtd/nand/s3c2410.c +31 -30
159 lines not on this page · raw message
drivers/serial/s3c2410.c +32 -30
170 lines not on this page · raw message
drivers/usb/host/ohci-s3c2410.c +10 -11
@@ -459,16 +459,14 @@/* device driver */ -static int ohci_hcd_s3c2410_drv_probe (struct device *dev) +static int ohci_hcd_s3c2410_drv_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev);return usb_hcd_s3c2410_probe (&ohci_s3c2410_hc_driver, pdev); } -static int ohci_hcd_s3c2410_drv_remove (struct device *dev) +static int ohci_hcd_s3c2410_drv_remove (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev); -struct usb_hcd *hcd =dev_get_drvdata (dev); +struct usb_hcd *hcd =platform_get_drvdata (pdev);usb_hcd_s3c2410_remove (hcd, pdev);return 0 ;
@@ -474,24 +472,25 @@ static int ohci_hcd_s3c2410_drv_remove(sreturn 0 ; } -static struct device_driver ohci_hcd_s3c2410_driver = { - .name ="s3c2410-ohci" , - .owner =THIS_MODULE , - .bus = &platform_bus_type, +static struct platform_driver ohci_hcd_s3c2410_driver = { .probe = ohci_hcd_s3c2410_drv_probe, .remove = ohci_hcd_s3c2410_drv_remove,/*.suspend = ohci_hcd_s3c2410_drv_suspend, */ /*.resume = ohci_hcd_s3c2410_drv_resume, */ + .driver = { + .owner =THIS_MODULE , + .name ="s3c2410-ohci" , + }, };static int __init ohci_hcd_s3c2410_init (void ) { -return driver_register (&ohci_hcd_s3c2410_driver); +return platform_driver_register (&ohci_hcd_s3c2410_driver); } static void __exit ohci_hcd_s3c2410_cleanup (void) { -driver_unregister (&ohci_hcd_s3c2410_driver); +platform_driver_unregister (&ohci_hcd_s3c2410_driver); }module_init (ohci_hcd_s3c2410_init);
drivers/video/s3c2410fb.c +22 -23
131 lines not on this page · raw message
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert ARM SA1100 drivers
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/mfd/mcp-sa11x0.c +1 -2
@@ -138,9 +138,8 @@ .disable = mcp_sa11x0_disable, }; -static int mcp_sa11x0_probe (struct device *dev) +static int mcp_sa11x0_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev);
struct mcp_plat_data *data = pdev->dev.platform_data;
struct mcp *mcp;
int ret;
@@ -165,7 +164,7 @@
mcp->dma_telco_rd = DMA_Ser4MCP1Rd;
mcp->dma_telco_wr = DMA_Ser4MCP1Wr;
- dev_set_drvdata(dev, mcp);
+ platform_set_drvdata(pdev, mcp);
if (machine_is_assabet()) {
ASSABET_BCR_set(ASSABET_BCR_CODEC_RST);
@@ -202,17 +201,17 @@
release:
release_mem_region(0x80060000, 0x60);
- dev_set_drvdata(dev, NULL);
+ platform_set_drvdata(pdev, NULL);
out:
return ret;
}
-static int mcp_sa11x0_remove(struct device *dev) +static int mcp_sa11x0_remove(struct platform_device *dev)
{
- struct mcp *mcp = dev_get_drvdata(dev);
+ struct mcp *mcp = platform_get_drvdata(dev);
- dev_set_drvdata(dev, NULL);
+ platform_set_drvdata(dev, NULL);
mcp_host_unregister(mcp);
release_mem_region(0x80060000, 0x60);
@@ -219,9 +218,9 @@
return 0;
}
-static int mcp_sa11x0_suspend(struct device *dev, pm_message_t state) +static int mcp_sa11x0_suspend(struct platform_device *dev, pm_message_t state)
{
- struct mcp *mcp = dev_get_drvdata(dev);
+ struct mcp *mcp = platform_get_drvdata(dev);
priv(mcp)->mccr0 = Ser4MCCR0;
priv(mcp)->mccr1 = Ser4MCCR1;
@@ -230,9 +229,9 @@
return 0;
}
-static int mcp_sa11x0_resume(struct device *dev) +static int mcp_sa11x0_resume(struct platform_device *dev)
{
- struct mcp *mcp = dev_get_drvdata(dev);
+ struct mcp *mcp = platform_get_drvdata(dev);
Ser4MCCR1 = priv(mcp)->mccr1; Ser4MCCR0 = priv(mcp)->mccr0;
@@ -243,13 +242,14 @@
/*
* The driver for the SA11x0 MCP port.
*/
-static struct device_driver mcp_sa11x0_driver = {
- .name = "sa11x0-mcp",
- .bus = &platform_bus_type,
+static struct platform_driver mcp_sa11x0_driver = {
.probe = mcp_sa11x0_probe,
.remove = mcp_sa11x0_remove,
.suspend = mcp_sa11x0_suspend,
.resume = mcp_sa11x0_resume,
+ .driver = {
+ .name = "sa11x0-mcp",
+ },
};
/*
@@ -257,12 +257,12 @@
*/
static int __init mcp_sa11x0_init(void)
{
- return driver_register(&mcp_sa11x0_driver);
+ return platform_driver_register(&mcp_sa11x0_driver);
}
static void __exit mcp_sa11x0_exit(void)
{
- driver_unregister(&mcp_sa11x0_driver);
+ platform_driver_unregister(&mcp_sa11x0_driver);
}
module_init(mcp_sa11x0_init);
drivers/mtd/maps/sa1100-flash.c +15 -15
@@ -357,9 +357,8 @@static const char *part_probes[] = {"cmdlinepart" ,"RedBoot" ,NULL }; -static int __init sa1100_mtd_probe (struct device *dev) +static int __init sa1100_mtd_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev);struct flash_platform_data *plat = pdev->dev.platform_data;struct mtd_partition *parts;const char *part_type =NULL ;
@@ -403,19 +402,19 @@ info->nr_parts = nr_parts; -dev_set_drvdata (dev, info); +platform_set_drvdata (pdev, info); err =0 ; out:return err; } -static int __exit sa1100_mtd_remove(struct device *dev) +static int __exit sa1100_mtd_remove(struct platform_device *pdev) { -struct sa_info *info =dev_get_drvdata (dev); +struct sa_info *info =platform_get_drvdata (pdev);struct flash_platform_data *plat = dev->platform_data; -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (pdev,NULL );sa1100_destroy (info, plat);return 0 ;
@@ -422,9 +421,9 @@ }#ifdef CONFIG_PM -static int sa1100_mtd_suspend (struct device *dev,pm_message_t state) +static int sa1100_mtd_suspend (struct platform_device *dev,pm_message_t state) { -struct sa_info *info =dev_get_drvdata (dev); +struct sa_info *info =platform_get_drvdata (dev);int ret =0 ;if (info)
@@ -433,9 +432,9 @@return ret; } -static int sa1100_mtd_resume (struct device *dev) +static int sa1100_mtd_resume (struct platform_device *dev) { -struct sa_info *info =dev_get_drvdata (dev); +struct sa_info *info =platform_get_drvdata (dev);if (info) info->mtd->resume (info->mtd);return 0 ;
@@ -453,24 +452,25 @@#define sa1100_mtd_shutdown NULL#endif -static struct device_driver sa1100_mtd_driver = { - .name ="flash" , - .bus = &platform_bus_type, +static struct platform_driver sa1100_mtd_driver = { .probe = sa1100_mtd_probe, .remove =__exit_p (sa1100_mtd_remove), .suspend = sa1100_mtd_suspend, .resume = sa1100_mtd_resume, .shutdown = sa1100_mtd_shutdown, + .driver = { + .name ="flash" , + }, };static int __init sa1100_mtd_init (void ) { -return driver_register (&sa1100_mtd_driver); +return platform_driver_register (&sa1100_mtd_driver); } static void __exit sa1100_mtd_exit(void) { -driver_unregister (&sa1100_mtd_driver); +platform_driver_unregister (&sa1100_mtd_driver); }module_init (sa1100_mtd_init);
drivers/net/irda/sa1100_ir.c +14 -14
@@ -291,9 +291,9 @@/* * Suspend the IrDA interface. */ -static int sa1100_irda_suspend (struct device *_dev,pm_message_t state) +static int sa1100_irda_suspend (struct platform_device *pdev,pm_message_t state) { -struct net_device *dev =dev_get_drvdata (_dev); +struct net_device *dev =platform_get_drvdata (pdev);struct sa1100_irda *si;if (!dev)
@@ -316,9 +316,9 @@/* * Resume the IrDA interface. */ -static int sa1100_irda_resume (struct device *_dev) +static int sa1100_irda_resume (struct platform_device *pdev) { -struct net_device *dev =dev_get_drvdata (_dev); +struct net_device *dev =platform_get_drvdata (pdev);struct sa1100_irda *si;if (!dev)
@@ -886,9 +886,8 @@return io->head ?0 : -ENOMEM ; } -static int sa1100_irda_probe (struct device *_dev) +static int sa1100_irda_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (_dev);struct net_device *dev;struct sa1100_irda *si;unsigned int baudrate_mask;
@@ -967,7 +966,7 @@ err =register_netdev (dev);if (err ==0 ) -dev_set_drvdata (&pdev->dev, dev); +platform_set_drvdata (pdev, dev);if (err) { err_mem_5:
@@ -985,9 +984,9 @@return err; } -static int sa1100_irda_remove (struct device *_dev) +static int sa1100_irda_remove (struct platform_device *pdev) { -struct net_device *dev =dev_get_drvdata (_dev); +struct net_device *dev =platform_get_drvdata (pdev);if (dev) {struct sa1100_irda *si = dev->priv;
@@ -1004,13 +1003,14 @@return 0 ; } -static struct device_driver sa1100ir_driver = { - .name ="sa11x0-ir" , - .bus = &platform_bus_type, +static struct platform_driver sa1100ir_driver = { .probe = sa1100_irda_probe, .remove = sa1100_irda_remove, .suspend = sa1100_irda_suspend, .resume = sa1100_irda_resume, + .driver = { + .name ="sa11x0-ir" , + }, };static int __init sa1100_irda_init (void )
@@ -1023,12 +1023,12 @@if (power_level >3 ) power_level =3 ; -return driver_register (&sa1100ir_driver); +return platform_driver_register (&sa1100ir_driver); } static void __exit sa1100_irda_exit(void) { -driver_unregister (&sa1100ir_driver); +platform_driver_unregister (&sa1100ir_driver); }module_init (sa1100_irda_init);
drivers/serial/sa1100.c +16 -16
@@ -834,9 +834,9 @@ .cons = SA1100_CONSOLE, }; -static int sa1100_serial_suspend (struct device *_dev,pm_message_t state) +static int sa1100_serial_suspend (struct platform_device *dev,pm_message_t state) { -struct sa1100_port *sport =dev_get_drvdata (_dev); +struct sa1100_port *sport =platform_get_drvdata (dev);if (sport)uart_suspend_port (&sa1100_reg, &sport->port);
@@ -844,9 +844,9 @@return 0 ; } -static int sa1100_serial_resume (struct device *_dev) +static int sa1100_serial_resume (struct platform_device *dev) { -struct sa1100_port *sport =dev_get_drvdata (_dev); +struct sa1100_port *sport =platform_get_drvdata (dev);if (sport)uart_resume_port (&sa1100_reg, &sport->port);
@@ -854,9 +854,8 @@return 0 ; } -static int sa1100_serial_probe (struct device *_dev) +static int sa1100_serial_probe (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (_dev);struct resource *res = dev->resource;int i;
@@ -869,9 +868,9 @@if (sa1100_ports[i].port.mapbase != res->start)continue ; - sa1100_ports[i].port.dev = _dev; + sa1100_ports[i].port.dev = &dev->dev;uart_add_one_port (&sa1100_reg, &sa1100_ports[i].port); -dev_set_drvdata (_dev, &sa1100_ports[i]); +platform_set_drvdata (dev, &sa1100_ports[i]);break ; } }
@@ -879,11 +878,11 @@return 0 ; } -static int sa1100_serial_remove (struct device *_dev) +static int sa1100_serial_remove (struct platform_device *pdev) { -struct sa1100_port *sport =dev_get_drvdata (_dev); +struct sa1100_port *sport =platform_get_drvdata (pdev); -dev_set_drvdata (_dev,NULL ); +platform_set_drvdata (pdev,NULL );if (sport)uart_remove_one_port (&sa1100_reg, &sport->port);
@@ -891,13 +890,14 @@return 0 ; } -static struct device_driver sa11x0_serial_driver = { - .name ="sa11x0-uart" , - .bus = &platform_bus_type, +static struct platform_driver sa11x0_serial_driver = { .probe = sa1100_serial_probe, .remove = sa1100_serial_remove, .suspend = sa1100_serial_suspend, .resume = sa1100_serial_resume, + .driver = { + .name ="sa11x0-uart" , + }, };static int __init sa1100_serial_init (void )
@@ -910,7 +910,7 @@ ret =uart_register_driver (&sa1100_reg);if (ret ==0 ) { - ret =driver_register (&sa11x0_serial_driver); + ret =platform_driver_register (&sa11x0_serial_driver);if (ret)uart_unregister_driver (&sa1100_reg); }
@@ -919,7 +919,7 @@ static void __exit sa1100_serial_exit(void) { -driver_unregister (&sa11x0_serial_driver); +platform_driver_unregister (&sa11x0_serial_driver);uart_unregister_driver (&sa1100_reg); }
drivers/video/sa1100fb.c +13 -12
@@ -1309,17 +1309,17 @@* Power management hooks. Note that we won't be called from IRQ context, * unlike the blank functions above, so we may sleep. */ -static int sa1100fb_suspend (struct device *dev,pm_message_t state) +static int sa1100fb_suspend (struct platform_device *dev,pm_message_t state) { -struct sa1100fb_info *fbi =dev_get_drvdata (dev); +struct sa1100fb_info *fbi =platform_get_drvdata (dev);set_ctrlr_state (fbi,C_DISABLE_PM );return 0 ; } -static int sa1100fb_resume (struct device *dev) +static int sa1100fb_resume (struct platform_device *dev) { -struct sa1100fb_info *fbi =dev_get_drvdata (dev); +struct sa1100fb_info *fbi =platform_get_drvdata (dev);set_ctrlr_state (fbi,C_ENABLE_PM );return 0 ;
@@ -1453,7 +1453,7 @@return fbi; } -static int __init sa1100fb_probe (struct device *dev) +static int __init sa1100fb_probe (struct platform_device *pdev) {struct sa1100fb_info *fbi;int ret;
@@ -1461,7 +1461,7 @@if (!request_mem_region (0xb0100000 ,0x10000 ,"LCD" ))return -EBUSY ; - fbi =sa1100fb_init_fbinfo (dev); + fbi =sa1100fb_init_fbinfo (&pdev->dev); ret = -ENOMEM ;if (!fbi) goto failed;
@@ -1489,7 +1489,7 @@*/ sa1100fb_check_var (&fbi->fb.var, &fbi->fb); -dev_set_drvdata (dev, fbi); +platform_set_drvdata (pdev, fbi); ret =register_framebuffer (&fbi->fb);if (ret <0 )
@@ -1506,18 +1506,19 @@return 0 ; failed: -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (pdev,NULL );kfree (fbi);release_mem_region (0xb0100000 ,0x10000 );return ret; } -static struct device_driver sa1100fb_driver = { - .name ="sa11x0-fb" , - .bus = &platform_bus_type, +static struct platform_driver sa1100fb_driver = { .probe = sa1100fb_probe, .suspend = sa1100fb_suspend, .resume = sa1100fb_resume, + .driver = { + .name ="sa11x0-fb" , + }, };int __init sa1100fb_init (void )
@@ -1525,7 +1526,7 @@if (fb_get_options ("sa1100fb" ,NULL ))return -ENODEV ; -return driver_register (&sa1100fb_driver); +return platform_driver_register (&sa1100fb_driver); }int __init sa1100fb_setup (char *options)
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert ARM PXA drivers
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/mmc/pxamci.c +21 -21
@@ -428,9 +428,8 @@return IRQ_HANDLED ; } -static int pxamci_probe (struct device *dev) +static int pxamci_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev);struct mmc_host *mmc;struct pxamci_host *host =NULL ;struct resource *r;
@@ -445,7 +444,7 @@if (!r)return -EBUSY ; - mmc =mmc_alloc_host (sizeof (struct pxamci_host ), dev); + mmc =mmc_alloc_host (sizeof (struct pxamci_host ), &pdev->dev);if (!mmc) { ret = -ENOMEM ; goto out;
@@ -474,7 +473,7 @@ host->pdata->ocr_mask :MMC_VDD_32_33 |MMC_VDD_33_34 ; - host->sg_cpu =dma_alloc_coherent (dev,PAGE_SIZE , &host->sg_dma,GFP_KERNEL ); + host->sg_cpu =dma_alloc_coherent (&pdev->dev,PAGE_SIZE , &host->sg_dma,GFP_KERNEL );if (!host->sg_cpu) { ret = -ENOMEM ; goto out;
@@ -511,10 +510,10 @@if (ret) goto out; -dev_set_drvdata (dev, mmc); +platform_set_drvdata (pdev, mmc);if (host->pdata && host->pdata->init) - host->pdata->init (dev, pxamci_detect_irq, mmc); + host->pdata->init (&pdev->dev, pxamci_detect_irq, mmc);mmc_add_host (mmc);
@@ -527,7 +526,7 @@if (host->base)iounmap (host->base);if (host->sg_cpu) -dma_free_coherent (dev,PAGE_SIZE , host->sg_cpu, host->sg_dma); +dma_free_coherent (&pdev->dev,PAGE_SIZE , host->sg_cpu, host->sg_dma); }if (mmc)mmc_free_host (mmc);
@@ -535,17 +534,17 @@return ret; } -static int pxamci_remove (struct device *dev) +static int pxamci_remove (struct platform_device *pdev) { -struct mmc_host *mmc =dev_get_drvdata (dev); +struct mmc_host *mmc =platform_get_drvdata (pdev); -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (pdev,NULL );if (mmc) {struct pxamci_host *host =mmc_priv (mmc);if (host->pdata && host->pdata->exit) - host->pdata->exit (dev, mmc); + host->pdata->exit (&pdev->dev, mmc);mmc_remove_host (mmc);
@@ -560,7 +559,7 @@free_irq (host->irq, host);pxa_free_dma (host->dma);iounmap (host->base); -dma_free_coherent (dev,PAGE_SIZE , host->sg_cpu, host->sg_dma); +dma_free_coherent (&pdev->dev,PAGE_SIZE , host->sg_cpu, host->sg_dma);release_resource (host->res);
@@ -570,9 +569,9 @@ }#ifdef CONFIG_PM -static int pxamci_suspend (struct device *dev,pm_message_t state) +static int pxamci_suspend (struct platform_device *dev,pm_message_t state) { -struct mmc_host *mmc =dev_get_drvdata (dev); +struct mmc_host *mmc =platform_get_drvdata (dev);int ret =0 ;if (mmc)
@@ -581,9 +580,9 @@return ret; } -static int pxamci_resume (struct device *dev) +static int pxamci_resume (struct platform_device *dev) { -struct mmc_host *mmc =dev_get_drvdata (dev); +struct mmc_host *mmc =platform_get_drvdata (dev);int ret =0 ;if (mmc)
@@ -596,23 +595,24 @@#define pxamci_resume NULL#endif -static struct device_driver pxamci_driver = { - .name =DRIVER_NAME , - .bus = &platform_bus_type, +static struct platform_driver pxamci_driver = { .probe = pxamci_probe, .remove = pxamci_remove, .suspend = pxamci_suspend, .resume = pxamci_resume, + .driver = { + .name =DRIVER_NAME , + }, };static int __init pxamci_init (void ) { -return driver_register (&pxamci_driver); +return platform_driver_register (&pxamci_driver); } static void __exit pxamci_exit(void) { -driver_unregister (&pxamci_driver); +platform_driver_unregister (&pxamci_driver); }module_init (pxamci_init);
drivers/usb/gadget/pxa2xx_udc.c +21 -20
115 lines not on this page · raw message
drivers/usb/host/ohci-pxa27x.c +14 -17
@@ -290,9 +290,8 @@/*-------------------------------------------------------------------------*/ -static int ohci_hcd_pxa27x_drv_probe (struct device *dev) +static int ohci_hcd_pxa27x_drv_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev);int ret;pr_debug ("In ohci_hcd_pxa27x_drv_probe" );
@@ -304,41 +303,39 @@return ret; } -static int ohci_hcd_pxa27x_drv_remove (struct device *dev) +static int ohci_hcd_pxa27x_drv_remove (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev); -struct usb_hcd *hcd =dev_get_drvdata (dev); +struct usb_hcd *hcd =platform_get_drvdata (pdev);usb_hcd_pxa27x_remove (hcd, pdev);return 0 ; } -static int ohci_hcd_pxa27x_drv_suspend (struct device *dev,pm_message_t state) +static int ohci_hcd_pxa27x_drv_suspend (struct platform_device *dev,pm_message_t state) { -// struct platform_device *pdev = to_platform_device(dev); -// struct usb_hcd *hcd = dev_get_drvdata(dev); +// struct usb_hcd *hcd = platform_get_drvdata(dev); printk ("%s: not implemented yet\n" , __FUNCTION__);return 0 ; } -static int ohci_hcd_pxa27x_drv_resume (struct device *dev) +static int ohci_hcd_pxa27x_drv_resume (struct platform_device *dev) { -// struct platform_device *pdev = to_platform_device(dev); -// struct usb_hcd *hcd = dev_get_drvdata(dev); +// struct usb_hcd *hcd = platform_get_drvdata(dev); printk ("%s: not implemented yet\n" , __FUNCTION__);return 0 ; } -static struct device_driver ohci_hcd_pxa27x_driver = { - .name ="pxa27x-ohci" , - .bus = &platform_bus_type, +static struct platform_driver ohci_hcd_pxa27x_driver = { .probe = ohci_hcd_pxa27x_drv_probe, .remove = ohci_hcd_pxa27x_drv_remove, .suspend = ohci_hcd_pxa27x_drv_suspend, - .resume = ohci_hcd_pxa27x_drv_resume, + .resume = ohci_hcd_pxa27x_drv_resume, + .driver = { + .name ="pxa27x-ohci" , + }, };static int __init ohci_hcd_pxa27x_init (void )
@@ -347,12 +344,12 @@ static int __init ohci_hcd_pxa27x_init (pr_debug ("block sizes: ed %d td %d\n" ,sizeof (struct ed ),sizeof (struct td )); -return driver_register (&ohci_hcd_pxa27x_driver); +return platform_driver_register (&ohci_hcd_pxa27x_driver); } static void __exit ohci_hcd_pxa27x_cleanup (void) { -driver_unregister (&ohci_hcd_pxa27x_driver); +platform_driver_unregister (&ohci_hcd_pxa27x_driver); }module_init (ohci_hcd_pxa27x_init);
drivers/video/pxafb.c +26 -25
152 lines not on this page · raw message
sound/arm/pxa2xx-ac97.c +18 -17
@@ -275,9 +275,9 @@return 0 ; } -static int pxa2xx_ac97_suspend (struct device *_dev,pm_message_t state) +static int pxa2xx_ac97_suspend (struct platform_device *dev,pm_message_t state) { -snd_card_t *card =dev_get_drvdata (_dev); +snd_card_t *card =platform_get_drvdata (dev);int ret =0 ;if (card)
@@ -286,9 +286,9 @@return ret; } -static int pxa2xx_ac97_resume (struct device *_dev) +static int pxa2xx_ac97_resume (struct platform_device *dev) { -snd_card_t *card =dev_get_drvdata (_dev); +snd_card_t *card =platform_get_drvdata (dev);int ret =0 ;if (card)
@@ -302,7 +302,7 @@#define pxa2xx_ac97_resume NULL#endif -static int pxa2xx_ac97_probe (struct device *dev) +static int pxa2xx_ac97_probe (struct platform_device *dev) {snd_card_t *card;ac97_bus_t *ac97_bus;
@@ -315,8 +315,8 @@if (!card) goto err; - card->dev = dev; -strncpy (card->driver, dev->driver->name,sizeof (card->driver)); + card->dev = &dev->dev; +strncpy (card->driver, dev->dev.driver->name,sizeof (card->driver)); ret =pxa2xx_pcm_new (card, &pxa2xx_ac97_pcm_client, &pxa2xx_ac97_pcm);if (ret)
@@ -347,13 +347,13 @@snprintf (card->shortname,sizeof (card->shortname),"%s" ,snd_ac97_get_short_name (pxa2xx_ac97_ac97));snprintf (card->longname,sizeof (card->longname), -"%s (%s)" , dev->driver->name, card->mixername); +"%s (%s)" , dev->dev.driver->name, card->mixername);snd_card_set_pm_callback (card, pxa2xx_ac97_do_suspend, pxa2xx_ac97_do_resume,NULL ); ret =snd_card_register (card);if (ret ==0 ) { -dev_set_drvdata (dev, card); +platform_set_drvdata (dev, card);return 0 ; }
@@ -368,13 +368,13 @@return ret; } -static int pxa2xx_ac97_remove (struct device *dev) +static int pxa2xx_ac97_remove (struct platform_device *dev) { -snd_card_t *card =dev_get_drvdata (dev); +snd_card_t *card =platform_get_drvdata (dev);if (card) {snd_card_free (card); -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (dev,NULL );GCR |=GCR_ACLINK_OFF ;free_irq (IRQ_AC97 ,NULL );pxa_set_cken (CKEN2_AC97 ,0 );
@@ -383,23 +383,24 @@return 0 ; } -static struct device_driver pxa2xx_ac97_driver = { - .name ="pxa2xx-ac97" , - .bus = &platform_bus_type, +static struct platform_driver pxa2xx_ac97_driver = { .probe = pxa2xx_ac97_probe, .remove = pxa2xx_ac97_remove, .suspend = pxa2xx_ac97_suspend, .resume = pxa2xx_ac97_resume, + .driver = { + .name ="pxa2xx-ac97" , + }, };static int __init pxa2xx_ac97_init (void ) { -return driver_register (&pxa2xx_ac97_driver); +return platform_driver_register (&pxa2xx_ac97_driver); } static void __exit pxa2xx_ac97_exit(void) { -driver_unregister (&pxa2xx_ac97_driver); +platform_driver_unregister (&pxa2xx_ac97_driver); }module_init (pxa2xx_ac97_init);
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert ARM IMX drivers
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/serial/imx.c +15 -16
@@ -921,9 +921,9 @@ .cons = IMX_CONSOLE, }; -static int serial_imx_suspend (struct device *_dev,pm_message_t state) +static int serial_imx_suspend (struct platform_device *dev,pm_message_t state) { -struct imx_port *sport =dev_get_drvdata (_dev); +struct imx_port *sport =platform_get_drvdata (dev);if (sport)uart_suspend_port (&imx_reg, &sport->port);
@@ -931,9 +931,9 @@return 0 ; } -static int serial_imx_resume (struct device *_dev) +static int serial_imx_resume (struct platform_device *dev) { -struct imx_port *sport =dev_get_drvdata (_dev); +struct imx_port *sport =platform_get_drvdata (dev);if (sport)uart_resume_port (&imx_reg, &sport->port);
@@ -941,21 +941,19 @@return 0 ; } -static int serial_imx_probe (struct device *_dev) +static int serial_imx_probe (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (_dev); - - imx_ports[dev->id].port.dev = _dev; + imx_ports[dev->id].port.dev = &dev->dev;uart_add_one_port (&imx_reg, &imx_ports[dev->id].port); -dev_set_drvdata (_dev, &imx_ports[dev->id]); +platform_set_drvdata (dev, &imx_ports[dev->id]);return 0 ; } -static int serial_imx_remove (struct device *_dev) +static int serial_imx_remove (struct platform_device *dev) { -struct imx_port *sport =dev_get_drvdata (_dev); +struct imx_port *sport =platform_get_drvdata (dev); -dev_set_drvdata (_dev,NULL ); +platform_set_drvdata (dev,NULL );if (sport)uart_remove_one_port (&imx_reg, &sport->port);
@@ -963,14 +961,15 @@return 0 ; } -static struct device_driver serial_imx_driver = { - .name ="imx-uart" , - .bus = &platform_bus_type, +static struct platform_driver serial_imx_driver = { .probe = serial_imx_probe, .remove = serial_imx_remove, .suspend = serial_imx_suspend, .resume = serial_imx_resume, + .driver = { + .name ="imx-uart" , + }, };static int __init imx_serial_init (void )
@@ -985,7 +984,7 @@if (ret)return ret; - ret =driver_register (&serial_imx_driver); + ret =platform_driver_register (&serial_imx_driver);if (ret !=0 )uart_unregister_driver (&imx_reg);
drivers/video/imxfb.c +22 -23
130 lines not on this page · raw message
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert ARM OMAP drivers
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/i2c/chips/isp1301_omap.c +11 -10
@@ -873,26 +873,27 @@ static int otg_init(struct isp1301 *isp)return 0 ; } -static int otg_probe (struct device *dev) +static int otg_probe (struct platform_device *dev) {// struct omap_usb_config *config = dev->platform_data; - otg_dev =to_platform_device (dev); + otg_dev = dev;return 0 ; } -static int otg_remove (struct device *dev) +static int otg_remove (struct platform_device *dev) { otg_dev =0 ;return 0 ; } -struct device_driver omap_otg_driver = { - .owner =THIS_MODULE , - .name ="omap_otg" , - .bus = &platform_bus_type, +struct platform_driver omap_otg_driver = { .probe = otg_probe, - .remove = otg_remove, + .remove = otg_remove, + .driver = { + .owner =THIS_MODULE , + .name ="omap_otg" , + }, };static int otg_bind (struct isp1301 *isp)
@@ -902,7 +903,7 @@ static int otg_bind(struct isp1301 *isp)if (otg_dev)return -EBUSY ; - status =driver_register (&omap_otg_driver); + status =platform_driver_register (&omap_otg_driver);if (status <0 )return status;
@@ -913,7 +914,7 @@ static int otg_bind(struct isp1301 *isp) status = -ENODEV ;if (status <0 ) -driver_unregister (&omap_otg_driver); +platform_driver_unregister (&omap_otg_driver);return status; }
drivers/usb/gadget/omap_udc.c +30 -31
162 lines not on this page · raw message
drivers/usb/host/ohci-omap.c +17 -18
@@ -433,24 +433,22 @@/*-------------------------------------------------------------------------*/ -static int ohci_hcd_omap_drv_probe (struct device *dev) +static int ohci_hcd_omap_drv_probe (struct platform_device *dev) { -return usb_hcd_omap_probe (&ohci_omap_hc_driver, -to_platform_device (dev)); +return usb_hcd_omap_probe (&ohci_omap_hc_driver, dev); } -static int ohci_hcd_omap_drv_remove (struct device *dev) +static int ohci_hcd_omap_drv_remove (struct platform_device *dev) { -struct platform_device *pdev =to_platform_device (dev); -struct usb_hcd *hcd =dev_get_drvdata (dev); +struct usb_hcd *hcd =platform_get_drvdata (dev);struct ohci_hcd *ohci =hcd_to_ohci (hcd); -usb_hcd_omap_remove (hcd, pdev); +usb_hcd_omap_remove (hcd, dev);if (ohci->transceiver) { (void )otg_set_host (ohci->transceiver,0 );put_device (ohci->transceiver->dev); } -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (dev,NULL );return 0 ; }
@@ -459,9 +457,9 @@#ifdef CONFIG_PM -static int ohci_omap_suspend (struct device *dev,pm_message_t message) +static int ohci_omap_suspend (struct platform_device *dev,pm_message_t message) { -struct ohci_hcd *ohci =hcd_to_ohci (dev_get_drvdata (dev)); +struct ohci_hcd *ohci =hcd_to_ohci (platform_get_drvdata (dev));if (time_before (jiffies, ohci->next_statechange))msleep (5 );
@@ -473,9 +471,9 @@return 0 ; } -static int ohci_omap_resume (struct device *dev) +static int ohci_omap_resume (struct platform_device *dev) { -struct ohci_hcd *ohci =hcd_to_ohci (dev_get_drvdata (dev)); +struct ohci_hcd *ohci =hcd_to_ohci (platform_get_drvdata (dev));if (time_before (jiffies, ohci->next_statechange))msleep (5 );
@@ -494,16 +492,17 @@/* * Driver definition to register with the OMAP bus */ -static struct device_driver ohci_hcd_omap_driver = { - .name ="ohci" , - .owner =THIS_MODULE , - .bus = &platform_bus_type, +static struct platform_driver ohci_hcd_omap_driver = { .probe = ohci_hcd_omap_drv_probe, .remove = ohci_hcd_omap_drv_remove, #ifdef CONFIG_PM .suspend = ohci_omap_suspend, .resume = ohci_omap_resume, #endif + .driver = { + .owner =THIS_MODULE , + .name ="ohci" , + }, };static int __init ohci_hcd_omap_init (void )
@@ -515,12 +514,12 @@pr_debug ("%s: block sizes: ed %Zd td %Zd\n" , hcd_name,sizeof (struct ed ),sizeof (struct td )); -return driver_register (&ohci_hcd_omap_driver); +return platform_driver_register (&ohci_hcd_omap_driver); } static void __exit ohci_hcd_omap_cleanup (void) { -driver_unregister (&ohci_hcd_omap_driver); +platform_driver_unregister (&ohci_hcd_omap_driver); }module_init (ohci_hcd_omap_init);
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert ARM Zaurus drivers
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/input/keyboard/corgikbd.c +15 -14
@@ -259,17 +259,17 @@ }#ifdef CONFIG_PM -static int corgikbd_suspend (struct device *dev,pm_message_t state) +static int corgikbd_suspend (struct platform_device *dev,pm_message_t state) { -struct corgikbd *corgikbd =dev_get_drvdata (dev); +struct corgikbd *corgikbd =platform_get_drvdata (dev); corgikbd->suspended =1 ;return 0 ; } -static int corgikbd_resume (struct device *dev) +static int corgikbd_resume (struct platform_device *dev) { -struct corgikbd *corgikbd =dev_get_drvdata (dev); +struct corgikbd *corgikbd =platform_get_drvdata (dev);/* Upon resume, ignore the suspend key for a short while */ corgikbd->suspend_jiffies=jiffies;
@@ -282,7 +282,7 @@#define corgikbd_resume NULL#endif -static int __init corgikbd_probe (struct device *dev) +static int __init corgikbd_probe (struct platform_device *pdev) {struct corgikbd *corgikbd;struct input_dev *input_dev;
@@ -296,7 +296,7 @@return -ENOMEM ; } -dev_set_drvdata (dev, corgikbd); +platform_set_drvdata (pdev, corgikbd); corgikbd->input = input_dev;spin_lock_init (&corgikbd->lock);
@@ -321,7 +321,7 @@ input_dev->id.vendor =0x0001 ; input_dev->id.product =0x0001 ; input_dev->id.version =0x0100 ; - input_dev->cdev.dev = dev; + input_dev->cdev.dev = &pdev->dev; input_dev->private = corgikbd; input_dev->evbit[0 ] =BIT (EV_KEY ) |BIT (EV_REP ) |BIT (EV_PWR ) |BIT (EV_SW );
@@ -356,10 +356,10 @@return 0 ; } -static int corgikbd_remove (struct device *dev) +static int corgikbd_remove (struct platform_device *pdev) {int i; -struct corgikbd *corgikbd =dev_get_drvdata (dev); +struct corgikbd *corgikbd =platform_get_drvdata (pdev);for (i =0 ; i <CORGI_KEY_SENSE_NUM ; i++)free_irq (CORGI_IRQ_GPIO_KEY_SENSE (i), corgikbd);
@@ -374,23 +374,24 @@return 0 ; } -static struct device_driver corgikbd_driver = { - .name ="corgi-keyboard" , - .bus = &platform_bus_type, +static struct platform_driver corgikbd_driver = { .probe = corgikbd_probe, .remove = corgikbd_remove, .suspend = corgikbd_suspend, .resume = corgikbd_resume, + .driver = { + .name ="corgi-keyboard" , + }, };static int __devinit corgikbd_init (void ) { -return driver_register (&corgikbd_driver); +return platform_driver_register (&corgikbd_driver); } static void __exit corgikbd_exit(void) { -driver_unregister (&corgikbd_driver); +platform_driver_unregister (&corgikbd_driver); }module_init (corgikbd_init);
drivers/input/keyboard/spitzkbd.c +15 -14
@@ -309,10 +309,10 @@ }#ifdef CONFIG_PM -static int spitzkbd_suspend (struct device *dev,pm_message_t state) +static int spitzkbd_suspend (struct platform_device *dev,pm_message_t state) {int i; -struct spitzkbd *spitzkbd =dev_get_drvdata (dev); +struct spitzkbd *spitzkbd =platform_get_drvdata (dev); spitzkbd->suspended =1 ;/* Set Strobe lines as inputs - *except* strobe line 0 leave this
@@ -323,10 +323,10 @@return 0 ; } -static int spitzkbd_resume (struct device *dev) +static int spitzkbd_resume (struct platform_device *dev) {int i; -struct spitzkbd *spitzkbd =dev_get_drvdata (dev); +struct spitzkbd *spitzkbd =platform_get_drvdata (dev);for (i =0 ; i <SPITZ_KEY_STROBE_NUM ; i++)pxa_gpio_mode (spitz_strobes[i] |GPIO_OUT |GPIO_DFLT_HIGH );
@@ -342,7 +342,7 @@#define spitzkbd_resume NULL#endif -static int __init spitzkbd_probe (struct device *dev) +static int __init spitzkbd_probe (struct platform_device *dev) {struct spitzkbd *spitzkbd;struct input_dev *input_dev;
@@ -358,7 +358,7 @@return -ENOMEM ; } -dev_set_drvdata (dev, spitzkbd); +platform_set_drvdata (dev, spitzkbd);strcpy (spitzkbd->phys,"spitzkbd/input0" );spin_lock_init (&spitzkbd->lock);
@@ -380,7 +380,7 @@ input_dev->private = spitzkbd; input_dev->name ="Spitz Keyboard" ; input_dev->phys = spitzkbd->phys; - input_dev->cdev.dev = dev; + input_dev->cdev.dev = &dev->dev; input_dev->id.bustype =BUS_HOST ; input_dev->id.vendor =0x0001 ;
@@ -437,10 +437,10 @@return 0 ; } -static int spitzkbd_remove (struct device *dev) +static int spitzkbd_remove (struct platform_device *dev) {int i; -struct spitzkbd *spitzkbd =dev_get_drvdata (dev); +struct spitzkbd *spitzkbd =platform_get_drvdata (dev);for (i =0 ; i <SPITZ_KEY_SENSE_NUM ; i++)free_irq (IRQ_GPIO (spitz_senses[i]), spitzkbd);
@@ -460,23 +460,24 @@return 0 ; } -static struct device_driver spitzkbd_driver = { - .name ="spitz-keyboard" , - .bus = &platform_bus_type, +static struct platform_driver spitzkbd_driver = { .probe = spitzkbd_probe, .remove = spitzkbd_remove, .suspend = spitzkbd_suspend, .resume = spitzkbd_resume, + .driver = { + .name ="spitz-keyboard" , + }, };static int __devinit spitzkbd_init (void ) { -return driver_register (&spitzkbd_driver); +return platform_driver_register (&spitzkbd_driver); } static void __exit spitzkbd_exit(void) { -driver_unregister (&spitzkbd_driver); +platform_driver_unregister (&spitzkbd_driver); }module_init (spitzkbd_init);
drivers/input/touchscreen/corgi_ts.c +5 -6
@@ -231,9 +231,9 @@ }#ifdef CONFIG_PM -static int corgits_suspend (struct device *dev,pm_message_t state) +static int corgits_suspend (struct platform_device *dev,pm_message_t state) { -struct corgi_ts *corgi_ts =dev_get_drvdata (dev); +struct corgi_ts *corgi_ts =platform_get_drvdata (dev);if (corgi_ts->pendown) {del_timer_sync (&corgi_ts->timer);
@@ -248,9 +248,9 @@return 0 ; } -static int corgits_resume (struct device *dev) +static int corgits_resume (struct platform_device *dev) { -struct corgi_ts *corgi_ts =dev_get_drvdata (dev); +struct corgi_ts *corgi_ts =platform_get_drvdata (dev);corgi_ssp_ads7846_putget ((4u <<ADSCTRL_ADR_SH ) |ADSCTRL_STS );/* Enable Falling Edge */
@@ -264,10 +264,9 @@#define corgits_resume NULL#endif -static int __init corgits_probe (struct device *dev) +static int __init corgits_probe (struct platform_device *pdev) {struct corgi_ts *corgi_ts; -struct platform_device *pdev =to_platform_device (dev);struct input_dev *input_dev;int err = -ENOMEM ;
@@ -276,9 +275,9 @@
if (!corgi_ts || !input_dev)
goto fail;
- dev_set_drvdata(dev, corgi_ts);
+ platform_set_drvdata(pdev, corgi_ts);
- corgi_ts->machinfo = dev->platform_data;
+ corgi_ts->machinfo = pdev->dev.platform_data;
corgi_ts->irq_gpio = platform_get_irq(pdev, 0);
if (corgi_ts->irq_gpio < 0) {
@@ -298,7 +297,7 @@
input_dev->id.vendor = 0x0001;
input_dev->id.product = 0x0002;
input_dev->id.version = 0x0100;
- input_dev->cdev.dev = dev;
+ input_dev->cdev.dev = &pdev->dev;
input_dev->private = corgi_ts;
input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
@@ -339,9 +338,9 @@
}
-static int corgits_remove(struct device *dev) +static int corgits_remove(struct platform_device *pdev)
{
- struct corgi_ts *corgi_ts = dev_get_drvdata(dev);
+ struct corgi_ts *corgi_ts = platform_get_drvdata(pdev);
free_irq(corgi_ts->irq_gpio, NULL);
del_timer_sync(&corgi_ts->timer);
@@ -351,23 +350,24 @@
return 0;
}
-static struct device_driver corgits_driver = {
- .name = "corgi-ts",
- .bus = &platform_bus_type,
+static struct platform_driver corgits_driver = {
.probe = corgits_probe,
.remove = corgits_remove,
.suspend = corgits_suspend,
.resume = corgits_resume,
+ .driver = {
+ .name = "corgi-ts",
+ },
};
static int __devinit corgits_init(void)
{
- return driver_register(&corgits_driver);
+ return platform_driver_register(&corgits_driver);
}
static void __exit corgits_exit(void)
{
- driver_unregister(&corgits_driver);
+ platform_driver_unregister(&corgits_driver);
}
module_init(corgits_init);
drivers/video/backlight/corgi_bl.c +11 -10
@@ -73,13 +73,13 @@ }#ifdef CONFIG_PM -static int corgibl_suspend (struct device *dev,pm_message_t state) +static int corgibl_suspend (struct platform_device *dev,pm_message_t state) {corgibl_blank (FB_BLANK_POWERDOWN );return 0 ; } -static int corgibl_resume (struct device *dev) +static int corgibl_resume (struct platform_device *dev) {corgibl_blank (FB_BLANK_UNBLANK );return 0 ;
@@ -137,9 +137,9 @@static struct backlight_device *corgi_backlight_device; -static int __init corgibl_probe (struct device *dev) +static int __init corgibl_probe (struct platform_device *pdev) { -struct corgibl_machinfo *machinfo = dev->platform_data; +struct corgibl_machinfo *machinfo = pdev->dev.platform_data; corgibl_data.max_brightness = machinfo->max_intensity; corgibl_mach_set_intensity = machinfo->set_bl_intensity;
@@ -156,7 +156,7 @@return 0 ; } -static int corgibl_remove (struct device *dev) +static int corgibl_remove (struct platform_device *dev) {backlight_device_unregister (corgi_backlight_device);
@@ -166,23 +166,24 @@return 0 ; } -static struct device_driver corgibl_driver = { - .name ="corgi-bl" , - .bus = &platform_bus_type, +static struct platform_driver corgibl_driver = { .probe = corgibl_probe, .remove = corgibl_remove, .suspend = corgibl_suspend, .resume = corgibl_resume, + .driver = { + .name ="corgi-bl" , + }, };static int __init corgibl_init (void ) { -return driver_register (&corgibl_driver); +return platform_driver_register (&corgibl_driver); } static void __exit corgibl_exit(void) { -driver_unregister (&corgibl_driver); +platform_driver_unregister (&corgibl_driver); }module_init (corgibl_init);
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert MMC drivers
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/mmc/wbsd.c +14 -13
@@ -1932,14 +1932,14 @@* Non-PnP */ -static int __devinit wbsd_probe (struct device * dev) +static int __devinit wbsd_probe (struct platform_device * dev) { -return wbsd_init (dev, io, irq, dma,0 ); +return wbsd_init (&dev->dev, io, irq, dma,0 ); } -static int __devexit wbsd_remove(struct device* dev) +static int __devexit wbsd_remove(struct platform_device* dev) { -wbsd_shutdown (dev,0 ); +wbsd_shutdown (&dev->dev,0 );return 0 ; }
@@ -1983,9 +1983,9 @@#ifdef CONFIG_PM -static int wbsd_suspend (struct device *dev,pm_message_t state) +static int wbsd_suspend (struct platform_device *dev,pm_message_t state) { -struct mmc_host *mmc =dev_get_drvdata (dev); +struct mmc_host *mmc =platform_get_drvdata (dev);struct wbsd_host *host;int ret;
@@ -2005,9 +2005,9 @@return 0 ; } -static int wbsd_resume (struct device *dev) +static int wbsd_resume (struct platform_device *dev) { -struct mmc_host *mmc =dev_get_drvdata (dev); +struct mmc_host *mmc =platform_get_drvdata (dev);struct wbsd_host *host;if (!mmc)
@@ -2038,14 +2038,15 @@ static int wbsd_resume(struct device *destatic struct platform_device *wbsd_device; -static struct device_driver wbsd_driver = { - .name =DRIVER_NAME , - .bus = &platform_bus_type, +static struct platform_driver wbsd_driver = { .probe = wbsd_probe, .remove = wbsd_remove, .suspend = wbsd_suspend, .resume = wbsd_resume, + .driver = { + .name =DRIVER_NAME , + }, };#ifdef CONFIG_PNP
@@ -2085,7 +2086,7 @@ static int __init wbsd_drv_init(void)if (nopnp) { - result =driver_register (&wbsd_driver); + result =platform_driver_register (&wbsd_driver);if (result <0 )return result;
@@ -2111,7 +2112,7 @@ static void __exit wbsd_drv_exit(void) {platform_device_unregister (wbsd_device); -driver_unregister (&wbsd_driver); +platform_driver_unregister (&wbsd_driver); }DBG ("unloaded\n" );
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert MTD drivers
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/mtd/maps/bast-flash.c +13 -18
@@ -63,11 +63,6 @@static const char *probes[] = {"RedBoot" ,"cmdlinepart" ,NULL }; -static struct bast_flash_info *to_bast_info (struct device *dev) -{ -return (struct bast_flash_info *)dev_get_drvdata (dev); -} -static void bast_flash_setrw (int to) {unsigned int val;
@@ -87,11 +82,11 @@local_irq_restore (flags); } -static int bast_flash_remove (struct device *dev) +static int bast_flash_remove (struct platform_device *pdev) { -struct bast_flash_info *info =to_bast_info (dev); +struct bast_flash_info *info =platform_get_drvdata (pdev); -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (pdev,NULL );if (info ==NULL )return 0 ;
@@ -117,9 +112,8 @@return 0 ; } -static int bast_flash_probe (struct device *dev) +static int bast_flash_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev);struct bast_flash_info *info;struct resource *res;int err =0 ;
@@ -132,13 +126,13 @@ }memzero (info,sizeof (*info)); -dev_set_drvdata (dev, info); +platform_set_drvdata (pdev, info); res = pdev->resource;/* assume that the flash has one resource */ info->map.phys = res->start; info->map.size = res->end - res->start +1 ; - info->map.name = dev->bus_id; + info->map.name = pdev->dev.bus_id; info->map.bankwidth =2 ;if (info->map.size >AREA_MAXSIZE )
@@ -200,26 +194,27 @@/* fall through to exit error */ exit_error: -bast_flash_remove (dev); +bast_flash_remove (pdev);return err; } -static struct device_driver bast_flash_driver = { - .name ="bast-nor" , - .bus = &platform_bus_type, +static struct platform_driver bast_flash_driver = { .probe = bast_flash_probe, .remove = bast_flash_remove, + .driver = { + .name ="bast-nor" , + }, };static int __init bast_flash_init (void ) {printk ("BAST NOR-Flash Driver, (c) 2004 Simtec Electronics\n" ); -return driver_register (&bast_flash_driver); +return platform_driver_register (&bast_flash_driver); } static void __exit bast_flash_exit(void) { -driver_unregister (&bast_flash_driver); +platform_driver_unregister (&bast_flash_driver); }module_init (bast_flash_init);
drivers/mtd/maps/integrator-flash.c +11 -12
@@ -67,9 +67,8 @@static const char *probes[] = {"cmdlinepart" ,"RedBoot" ,"afs" ,NULL }; -static int armflash_probe (struct device *_dev) +static int armflash_probe (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (_dev);struct flash_platform_data *plat = dev->dev.platform_data;struct resource *res = dev->resource;unsigned int size = res->end - res->start +1 ;
@@ -138,7 +137,7 @@ }if (err ==0 ) -dev_set_drvdata (&dev->dev, info); +platform_set_drvdata (dev, info);/* * If we got an error, free all resources.
@@ -164,12 +163,11 @@return err; } -static int armflash_remove (struct device *_dev) +static int armflash_remove (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (_dev); -struct armflash_info *info =dev_get_drvdata (&dev->dev); +struct armflash_info *info =platform_get_drvdata (dev); -dev_set_drvdata (&dev->dev,NULL ); +platform_set_drvdata (dev,NULL );if (info) {if (info->mtd) {
@@ -192,21 +190,22 @@ static int armflash_remove(struct devicereturn 0 ; } -static struct device_driver armflash_driver = { - .name ="armflash" , - .bus = &platform_bus_type, +static struct platform_driver armflash_driver = { .probe = armflash_probe, .remove = armflash_remove, + .driver = { + .name ="armflash" , + }, };static int __init armflash_init (void ) { -return driver_register (&armflash_driver); +return platform_driver_register (&armflash_driver); } static void __exit armflash_exit(void) { -driver_unregister (&armflash_driver); +platform_driver_unregister (&armflash_driver); }module_init (armflash_init);
drivers/mtd/maps/ixp2000.c +12 -13
@@ -111,13 +111,12 @@ } -static int ixp2000_flash_remove (struct device *_dev) +static int ixp2000_flash_remove (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (_dev);struct flash_platform_data *plat = dev->dev.platform_data; -struct ixp2000_flash_info *info =dev_get_drvdata (&dev->dev); +struct ixp2000_flash_info *info =platform_get_drvdata (dev); -dev_set_drvdata (&dev->dev,NULL ); +platform_set_drvdata (dev,NULL );if (!info)return 0 ;
@@ -144,10 +143,9 @@ } -static int ixp2000_flash_probe (struct device *_dev) +static int ixp2000_flash_probe (struct platform_device *dev) {static const char *probes[] = {"RedBoot" ,"cmdlinepart" ,NULL }; -struct platform_device *dev =to_platform_device (_dev);struct ixp2000_flash_data *ixp_data = dev->dev.platform_data;struct flash_platform_data *plat;struct ixp2000_flash_info *info;
@@ -178,7 +176,7 @@ }memzero (info,sizeof (struct ixp2000_flash_info )); -dev_set_drvdata (&dev->dev, info); +platform_set_drvdata (dev, info);/* * Tell the MTD layer we're not 1:1 mapped so that it does
@@ -249,7 +247,7 @@return 0 ; Error: -ixp2000_flash_remove (_dev); +ixp2000_flash_remove (dev);return err; }
@@ -253,21 +251,22 @@ Error:return err; } -static struct device_driver ixp2000_flash_driver = { - .name ="IXP2000-Flash" , - .bus = &platform_bus_type, +static struct platform_driver ixp2000_flash_driver = { .probe = &ixp2000_flash_probe, .remove = &ixp2000_flash_remove + .driver = { + .name ="IXP2000-Flash" , + }, };static int __init ixp2000_flash_init (void ) { -return driver_register (&ixp2000_flash_driver); +return platform_driver_register (&ixp2000_flash_driver); } static void __exit ixp2000_flash_exit(void) { -driver_unregister (&ixp2000_flash_driver); +platform_driver_unregister (&ixp2000_flash_driver); }module_init (ixp2000_flash_init);
drivers/mtd/maps/ixp4xx.c +12 -13
@@ -99,14 +99,13 @@static const char *probes[] = {"RedBoot" ,"cmdlinepart" ,NULL }; -static int ixp4xx_flash_remove (struct device *_dev) +static int ixp4xx_flash_remove (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (_dev);struct flash_platform_data *plat = dev->dev.platform_data; -struct ixp4xx_flash_info *info =dev_get_drvdata (&dev->dev); +struct ixp4xx_flash_info *info =platform_get_drvdata (dev);map_word d; -dev_set_drvdata (&dev->dev,NULL ); +platform_set_drvdata (dev,NULL );if (!info)return 0 ;
@@ -141,9 +140,8 @@return 0 ; } -static int ixp4xx_flash_probe (struct device *_dev) +static int ixp4xx_flash_probe (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (_dev);struct flash_platform_data *plat = dev->dev.platform_data;struct ixp4xx_flash_info *info;int err =-1 ;
@@ -164,7 +162,7 @@ }memzero (info,sizeof (struct ixp4xx_flash_info )); -dev_set_drvdata (&dev->dev, info); +platform_set_drvdata (dev, info);/* * Enable flash write
@@ -231,7 +229,7 @@return 0 ; Error: -ixp4xx_flash_remove (_dev); +ixp4xx_flash_remove (dev);return err; }
@@ -235,21 +233,22 @@ Error:return err; } -static struct device_driver ixp4xx_flash_driver = { - .name ="IXP4XX-Flash" , - .bus = &platform_bus_type, +static struct platform_driver ixp4xx_flash_driver = { .probe = ixp4xx_flash_probe, .remove = ixp4xx_flash_remove, + .driver = { + .name ="IXP4XX-Flash" , + }, };static int __init ixp4xx_flash_init (void ) { -return driver_register (&ixp4xx_flash_driver); +return platform_driver_register (&ixp4xx_flash_driver); } static void __exit ixp4xx_flash_exit(void) { -driver_unregister (&ixp4xx_flash_driver); +platform_driver_unregister (&ixp4xx_flash_driver); }
drivers/mtd/maps/omap_nor.c +11 -12
@@ -70,11 +70,10 @@ } } -static int __devinit omapflash_probe (struct device *dev) +static int __devinit omapflash_probe (struct platform_device *pdev) {int err;struct omapflash_info *info; -struct platform_device *pdev =to_platform_device (dev);struct flash_platform_data *pdata = pdev->dev.platform_data;struct resource *res = pdev->resource;unsigned long size = res->end - res->start +1 ;
@@ -119,7 +118,7 @@#endif add_mtd_device (info->mtd); -dev_set_drvdata (&pdev->dev, info); +platform_set_drvdata (pdev, info);return 0 ;
@@ -133,12 +132,11 @@return err; } -static int __devexit omapflash_remove(struct device *dev) +static int __devexit omapflash_remove(struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev); -struct omapflash_info *info =dev_get_drvdata (&pdev->dev); +struct omapflash_info *info =platform_get_drvdata (pdev); -dev_set_drvdata (&pdev->dev,NULL ); +platform_set_drvdata (pdev,NULL );if (info) {if (info->parts) {
@@ -155,21 +153,22 @@ static int __devexit omapflash_remove(streturn 0 ; } -static struct device_driver omapflash_driver = { - .name ="omapflash" , - .bus = &platform_bus_type, +static struct platform_driver omapflash_driver = { .probe = omapflash_probe, .remove =__devexit_p (omapflash_remove), + .driver = { + .name ="omapflash" , + }, };static int __init omapflash_init (void ) { -return driver_register (&omapflash_driver); +return platform_driver_register (&omapflash_driver); } static void __exit omapflash_exit(void) { -driver_unregister (&omapflash_driver); +platform_driver_unregister (&omapflash_driver); }module_init (omapflash_init);
drivers/mtd/maps/plat-ram.c +20 -20
@@ -56,9 +56,9 @@* device private data to struct platram_info conversion */ -static inline struct platram_info *to_platram_info (struct device *dev) +static inline struct platram_info *to_platram_info (struct platform_device *dev) { -return (struct platram_info *)dev_get_drvdata (dev); +return (struct platram_info *)platform_get_drvdata (dev); }/* platram_setrw
@@ -83,13 +83,13 @@* called to remove the device from the driver's control */ -static int platram_remove (struct device *dev) +static int platram_remove (struct platform_device *pdev) { -struct platram_info *info =to_platram_info (dev); +struct platram_info *info =to_platram_info (pdev); -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (pdev,NULL ); -dev_dbg (dev,"removing device\n" ); +dev_dbg (&pdev->dev,"removing device\n" );if (info ==NULL )return 0 ;
@@ -130,9 +130,8 @@* driver is found. */ -static int platram_probe (struct device *dev) +static int platram_probe (struct platform_device *pdev) { -struct platform_device *pd =to_platform_device (dev);struct platdata_mtd_ram *pdata;struct platram_info *info;struct resource *res;
@@ -140,13 +139,13 @@dev_dbg (dev,"probe entered\n" ); -if (dev->platform_data ==NULL ) { +if (pdev->dev.platform_data ==NULL ) {dev_err (dev,"no platform data supplied\n" ); err = -ENOENT ; goto exit_error; } - pdata = dev->platform_data; + pdata = pdev->dev.platform_data; info =kmalloc (sizeof (*info),GFP_KERNEL );if (info ==NULL ) {
@@ -156,7 +155,7 @@ }memset (info,0 ,sizeof (*info)); -dev_set_drvdata (dev, info); +platform_set_drvdata (pdev, info); info->dev = dev; info->pdata = pdata;
@@ -171,7 +170,7 @@ goto exit_free; } -dev_dbg (dev,"got platform resource %p (0x%lx)\n" , res, res->start); +dev_dbg (&pdev->dev,"got platform resource %p (0x%lx)\n" , res, res->start);/* setup map parameters */
@@ -182,7 +181,7 @@/* register our usage of the memory area */ - info->area =request_mem_region (res->start, info->map.size, pd->name); + info->area =request_mem_region (res->start, info->map.size, pdev->name);if (info->area ==NULL ) {dev_err (dev,"failed to request memory region\n" ); err = -EIO ;
@@ -241,11 +240,11 @@ err = -ENOMEM ; } -dev_info (dev,"registered mtd device\n" ); +dev_info (&pdev->dev,"registered mtd device\n" );return err; exit_free: -platram_remove (dev); +platram_remove (pdev); exit_error:return err; }
@@ -252,11 +251,12 @@ static int platram_probe(struct device */* device driver info */ -static struct device_driver platram_driver = { - .name ="mtd-ram" , - .bus = &platform_bus_type, +static struct platform_driver platram_driver = { .probe = platram_probe, .remove = platram_remove, + .driver = { + .name ="mtd-ram" , + }, };/* module init/exit */
@@ -264,12 +264,12 @@ static struct device_driver platram_drivstatic int __init platram_init (void ) {printk ("Generic platform RAM MTD, (c) 2004 Simtec Electronics\n" ); -return driver_register (&platram_driver); +return platform_driver_register (&platram_driver); } static void __exit platram_exit(void) { -driver_unregister (&platram_driver); +platform_driver_unregister (&platram_driver); }module_init (platram_init);
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert serial drivers
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/serial/8250.c +16 -15
@@ -2311,9 +2311,9 @@* list is terminated with a zero flags entry, which means we expect * all entries to have at least UPF_BOOT_AUTOCONF set. */ -static int __devinit serial8250_probe (struct device *dev) +static int __devinit serial8250_probe (struct platform_device *dev) { -struct plat_serial8250_port *p = dev->platform_data; +struct plat_serial8250_port *p = dev->dev.platform_data;struct uart_port port;int ret, i;
@@ -2329,12 +2329,12 @@ port.flags = p->flags; port.mapbase = p->mapbase; port.hub6 = p->hub6; - port.dev = dev; + port.dev = &dev->dev;if (share_irqs) port.flags |=UPF_SHARE_IRQ ; ret =serial8250_register_port (&port);if (ret <0 ) { -dev_err (dev,"unable to register port at index %d " +dev_err (&dev->dev,"unable to register port at index %d " "(IO%lx MEM%lx IRQ%d): %d\n" , i, p->iobase, p->mapbase, p->irq, ret); }
@@ -2345,14 +2345,14 @@/* * Remove serial ports registered against a platform device. */ -static int __devexit serial8250_remove(struct device *dev) +static int __devexit serial8250_remove(struct platform_device *dev) {int i;for (i =0 ; i <UART_NR ; i++) {struct uart_8250_port *up = &serial8250_ports[i]; -if (up->port.dev == dev) +if (up->port.dev == &dev->dev)serial8250_unregister_port (i); }return 0 ;
@@ -2358,28 +2358,28 @@return 0 ; } -static int serial8250_suspend (struct device *dev,pm_message_t state) +static int serial8250_suspend (struct platform_device *dev,pm_message_t state) {int i;for (i =0 ; i <UART_NR ; i++) {struct uart_8250_port *up = &serial8250_ports[i]; -if (up->port.type !=PORT_UNKNOWN && up->port.dev == dev) +if (up->port.type !=PORT_UNKNOWN && up->port.dev == &dev->dev)uart_suspend_port (&serial8250_reg, &up->port); }return 0 ; } -static int serial8250_resume (struct device *dev) +static int serial8250_resume (struct platform_device *dev) {int i;for (i =0 ; i <UART_NR ; i++) {struct uart_8250_port *up = &serial8250_ports[i]; -if (up->port.type !=PORT_UNKNOWN && up->port.dev == dev) +if (up->port.type !=PORT_UNKNOWN && up->port.dev == &dev->dev)uart_resume_port (&serial8250_reg, &up->port); }
@@ -2386,13 +2386,14 @@return 0 ; } -static struct device_driver serial8250_isa_driver = { - .name ="serial8250" , - .bus = &platform_bus_type, +static struct platform_driver serial8250_isa_driver = { .probe = serial8250_probe, .remove =__devexit_p (serial8250_remove), .suspend = serial8250_suspend, .resume = serial8250_resume, + .driver = { + .name ="serial8250" , + }, };/*
@@ -2538,7 +2539,7 @@serial8250_register_ports (&serial8250_reg, &serial8250_isa_devs->dev); - ret =driver_register (&serial8250_isa_driver); + ret =platform_driver_register (&serial8250_isa_driver);if (ret ==0 ) goto out;
@@ -2560,7 +2561,7 @@*/ serial8250_isa_devs =NULL ; -driver_unregister (&serial8250_isa_driver); +platform_driver_unregister (&serial8250_isa_driver);platform_device_unregister (isa_dev);uart_unregister_driver (&serial8250_reg);
drivers/serial/mpc52xx_uart.c +16 -16
@@ -717,10 +717,9 @@/* ======================================================================== */ static int __devinit -mpc52xx_uart_probe (struct device *dev) +mpc52xx_uart_probe (struct platform_device *dev) { -struct platform_device *pdev =to_platform_device (dev); -struct resource *res = pdev->resource; +struct resource *res = dev->resource;struct uart_port *port =NULL ;int i, idx, ret;
@@ -761,17 +760,17 @@/* Add the port to the uart sub-system */ ret =uart_add_one_port (&mpc52xx_uart_driver, port);if (!ret) -dev_set_drvdata (dev, (void *)port); +platform_set_drvdata (dev, (void *)port);return ret; }static int -mpc52xx_uart_remove (struct device *dev) +mpc52xx_uart_remove (struct platform_device *dev) { -struct uart_port *port = (struct uart_port *)dev_get_drvdata (dev); +struct uart_port *port = (struct uart_port *)platform_get_drvdata (dev); -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (dev,NULL );if (port)uart_remove_one_port (&mpc52xx_uart_driver, port);
@@ -781,9 +780,9 @@#ifdef CONFIG_PM static int -mpc52xx_uart_suspend (struct device *dev,pm_message_t state) +mpc52xx_uart_suspend (struct platform_device *dev,pm_message_t state) { -struct uart_port *port = (struct uart_port *)dev_get_drvdata (dev); +struct uart_port *port = (struct uart_port *)platform_get_drvdata (dev);if (sport)uart_suspend_port (&mpc52xx_uart_driver, port);
@@ -792,9 +791,9 @@ }static int -mpc52xx_uart_resume (struct device *dev) +mpc52xx_uart_resume (struct platform_device *dev) { -struct uart_port *port = (struct uart_port *)dev_get_drvdata (dev); +struct uart_port *port = (struct uart_port *)platform_get_drvdata (dev);if (port)uart_resume_port (&mpc52xx_uart_driver, port);
@@ -803,15 +802,16 @@ }#endif -static struct device_driver mpc52xx_uart_platform_driver = { - .name ="mpc52xx-psc" , - .bus = &platform_bus_type, +static struct platform_driver mpc52xx_uart_platform_driver = { .probe = mpc52xx_uart_probe, .remove = mpc52xx_uart_remove, #ifdef CONFIG_PM .suspend = mpc52xx_uart_suspend, .resume = mpc52xx_uart_resume, #endif + .driver = { + .name ="mpc52xx-psc" , + }, };
@@ -828,7 +828,7 @@ ret =uart_register_driver (&mpc52xx_uart_driver);if (ret ==0 ) { - ret =driver_register (&mpc52xx_uart_platform_driver); + ret =platform_driver_register (&mpc52xx_uart_platform_driver);if (ret)uart_unregister_driver (&mpc52xx_uart_driver); }
@@ -839,7 +839,7 @@ static void __exitmpc52xx_uart_exit (void ) { -driver_unregister (&mpc52xx_uart_platform_driver); +platform_driver_unregister (&mpc52xx_uart_platform_driver);uart_unregister_driver (&mpc52xx_uart_driver); }
drivers/serial/mpsc.c +31 -34
132 lines not on this page · raw message
drivers/serial/pxa.c +16 -17
@@ -805,9 +805,9 @@ .cons = PXA_CONSOLE, }; -static int serial_pxa_suspend (struct device *_dev,pm_message_t state) +static int serial_pxa_suspend (struct platform_device *dev,pm_message_t state) { -struct uart_pxa_port *sport =dev_get_drvdata (_dev); +struct uart_pxa_port *sport =platform_get_drvdata (dev);if (sport)uart_suspend_port (&serial_pxa_reg, &sport->port);
@@ -815,9 +815,9 @@return 0 ; } -static int serial_pxa_resume (struct device *_dev) +static int serial_pxa_resume (struct platform_device *dev) { -struct uart_pxa_port *sport =dev_get_drvdata (_dev); +struct uart_pxa_port *sport =platform_get_drvdata (dev);if (sport)uart_resume_port (&serial_pxa_reg, &sport->port);
@@ -825,21 +825,19 @@return 0 ; } -static int serial_pxa_probe (struct device *_dev) +static int serial_pxa_probe (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (_dev); - - serial_pxa_ports[dev->id].port.dev = _dev; + serial_pxa_ports[dev->id].port.dev = &dev->dev;uart_add_one_port (&serial_pxa_reg, &serial_pxa_ports[dev->id].port); -dev_set_drvdata (_dev, &serial_pxa_ports[dev->id]); +platform_set_drvdata (dev, &serial_pxa_ports[dev->id]);return 0 ; } -static int serial_pxa_remove (struct device *_dev) +static int serial_pxa_remove (struct platform_device *dev) { -struct uart_pxa_port *sport =dev_get_drvdata (_dev); +struct uart_pxa_port *sport =platform_get_drvdata (dev); -dev_set_drvdata (_dev,NULL ); +platform_set_drvdata (dev,NULL );if (sport)uart_remove_one_port (&serial_pxa_reg, &sport->port);
@@ -847,14 +845,15 @@return 0 ; } -static struct device_driver serial_pxa_driver = { - .name ="pxa2xx-uart" , - .bus = &platform_bus_type, +static struct platform_driver serial_pxa_driver = { .probe = serial_pxa_probe, .remove = serial_pxa_remove, .suspend = serial_pxa_suspend, .resume = serial_pxa_resume, + .driver = { + .name ="pxa2xx-uart" , + }, };int __init serial_pxa_init (void )
@@ -865,7 +864,7 @@if (ret !=0 )return ret; - ret =driver_register (&serial_pxa_driver); + ret =platform_driver_register (&serial_pxa_driver);if (ret !=0 )uart_unregister_driver (&serial_pxa_reg);
@@ -874,7 +873,7 @@ void __exit serial_pxa_exit(void) { -driver_unregister (&serial_pxa_driver); +platform_driver_unregister (&serial_pxa_driver);uart_unregister_driver (&serial_pxa_reg); }
drivers/serial/vr41xx_siu.c +14 -13
@@ -924,7 +924,7 @@ .cons = SERIAL_VR41XX_CONSOLE, }; -static int siu_probe (struct device *dev) +static int siu_probe (struct platform_device *dev) {struct uart_port *port;int num, i, retval;
@@ -941,7 +941,7 @@for (i =0 ; i < num; i++) { port = &siu_uart_ports[i]; port->ops = &siu_uart_ops; - port->dev = dev; + port->dev = &dev->dev; retval =uart_add_one_port (&siu_uart_driver, port);if (retval <0 ) {
@@ -958,14 +958,14 @@return 0 ; } -static int siu_remove (struct device *dev) +static int siu_remove (struct platform_device *dev) {struct uart_port *port;int i;for (i =0 ; i < siu_uart_driver.nr; i++) { port = &siu_uart_ports[i]; -if (port->dev == dev) { +if (port->dev == &dev->dev) {uart_remove_one_port (&siu_uart_driver, port); port->dev =NULL ; }
@@ -976,7 +976,7 @@return 0 ; } -static int siu_suspend (struct device *dev,pm_message_t state) +static int siu_suspend (struct platform_device *dev,pm_message_t state) {struct uart_port *port;int i;
@@ -984,7 +984,7 @@for (i =0 ; i < siu_uart_driver.nr; i++) { port = &siu_uart_ports[i];if ((port->type ==PORT_VR41XX_SIU || - port->type ==PORT_VR41XX_DSIU ) && port->dev == dev) + port->type ==PORT_VR41XX_DSIU ) && port->dev == &dev->dev)uart_suspend_port (&siu_uart_driver, port); }
@@ -992,7 +992,7 @@return 0 ; } -static int siu_resume (struct device *dev) +static int siu_resume (struct platform_device *dev) {struct uart_port *port;int i;
@@ -1000,7 +1000,7 @@for (i =0 ; i < siu_uart_driver.nr; i++) { port = &siu_uart_ports[i];if ((port->type ==PORT_VR41XX_SIU || - port->type ==PORT_VR41XX_DSIU ) && port->dev == dev) + port->type ==PORT_VR41XX_DSIU ) && port->dev == &dev->dev)uart_resume_port (&siu_uart_driver, port); }
@@ -1009,13 +1009,14 @@static struct platform_device *siu_platform_device; -static struct device_driver siu_device_driver = { - .name ="SIU" , - .bus = &platform_bus_type, +static struct platform_driver siu_device_driver = { .probe = siu_probe, .remove = siu_remove, .suspend = siu_suspend, .resume = siu_resume, + .driver = { + .name ="SIU" , + }, };static int __devinit vr41xx_siu_init (void )
@@ -1026,7 +1027,7 @@if (IS_ERR (siu_platform_device))return PTR_ERR (siu_platform_device); - retval =driver_register (&siu_device_driver); + retval =platform_driver_register (&siu_device_driver);if (retval <0 )platform_device_unregister (siu_platform_device);
@@ -1035,7 +1036,7 @@ static void __devexit vr41xx_siu_exit(void) { -driver_unregister (&siu_device_driver); +platform_driver_unregister (&siu_device_driver);platform_device_unregister (siu_platform_device); }
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert i2c drivers
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/hwmon/hdaps.c +11 -10
@@ -284,7 +284,7 @@/* Device model stuff */ -static int hdaps_probe (struct device *dev) +static int hdaps_probe (struct platform_device *dev) {int ret;
@@ -296,17 +296,18 @@return 0 ; } -static int hdaps_resume (struct device *dev) +static int hdaps_resume (struct platform_device *dev) {return hdaps_device_init (); } -static struct device_driver hdaps_driver = { - .name ="hdaps" , - .bus = &platform_bus_type, - .owner =THIS_MODULE , +static struct platform_driver hdaps_driver = { .probe = hdaps_probe, - .resume = hdaps_resume + .resume = hdaps_resume, + .driver = { + .name ="hdaps" , + .owner =THIS_MODULE , + }, };/* Input class stuff */
@@ -550,7 +551,7 @@ goto out; } - ret =driver_register (&hdaps_driver); + ret =platform_driver_register (&hdaps_driver);if (ret) goto out_region;
@@ -583,7 +584,7 @@ out_device:platform_device_unregister (pdev); out_driver: -driver_unregister (&hdaps_driver); +platform_driver_unregister (&hdaps_driver); out_region:release_region (HDAPS_LOW_PORT ,HDAPS_NR_PORTS ); out:
@@ -597,7 +598,7 @@input_unregister_device (&hdaps_idev);sysfs_remove_group (&pdev->dev.kobj, &hdaps_attribute_group);platform_device_unregister (pdev); -driver_unregister (&hdaps_driver); +platform_driver_unregister (&hdaps_driver);release_region (HDAPS_LOW_PORT ,HDAPS_NR_PORTS );printk (KERN_INFO "hdaps: driver unloaded.\n" );
drivers/i2c/busses/i2c-iop3xx.c +12 -13
@@ -405,10 +405,9 @@ };static int -iop3xx_i2c_remove (struct device *device) +iop3xx_i2c_remove (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (device); -struct i2c_adapter *padapter =dev_get_drvdata (&pdev->dev); +struct i2c_adapter *padapter =platform_get_drvdata (pdev);struct i2c_algo_iop3xx_data *adapter_data = (struct i2c_algo_iop3xx_data *)padapter->algo_data;struct resource *res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -426,15 +425,14 @@kfree (adapter_data);kfree (padapter); -dev_set_drvdata (&pdev->dev,NULL ); +platform_set_drvdata (pdev,NULL );return 0 ; }static int -iop3xx_i2c_probe (struct device *dev) +iop3xx_i2c_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev);struct resource *res;int ret;struct i2c_adapter *new_adapter;
@@ -499,7 +497,7 @@iop3xx_i2c_set_slave_addr (adapter_data);iop3xx_i2c_enable (adapter_data); -dev_set_drvdata (&pdev->dev, new_adapter); +platform_set_drvdata (pdev, new_adapter); new_adapter->algo_data = adapter_data;i2c_add_adapter (new_adapter);
@@ -523,24 +521,25 @@ out: } -static struct device_driver iop3xx_i2c_driver = { - .owner =THIS_MODULE , - .name ="IOP3xx-I2C" , - .bus = &platform_bus_type, +static struct platform_driver iop3xx_i2c_driver = { .probe = iop3xx_i2c_probe, .remove = iop3xx_i2c_remove + .driver = { + .owner =THIS_MODULE , + .name ="IOP3xx-I2C" , + }, };static int __init i2c_iop3xx_init (void ) { -return driver_register (&iop3xx_i2c_driver); +return platform_driver_register (&iop3xx_i2c_driver); } static void __exiti2c_iop3xx_exit (void ) { -driver_unregister (&iop3xx_i2c_driver); +platform_driver_unregister (&iop3xx_i2c_driver);return ; }
drivers/i2c/busses/i2c-ixp2000.c +12 -13
@@ -86,12 +86,11 @@struct i2c_algo_bit_data algo_data; }; -static int ixp2000_i2c_remove (struct device *dev) +static int ixp2000_i2c_remove (struct platform_device *plat_dev) { -struct platform_device *plat_dev =to_platform_device (dev); -struct ixp2000_i2c_data *drv_data =dev_get_drvdata (&plat_dev->dev); +struct ixp2000_i2c_data *drv_data =platform_get_drvdata (plat_dev); -dev_set_drvdata (&plat_dev->dev,NULL ); +platform_set_drvdata (plat_dev,NULL );i2c_bit_del_bus (&drv_data->adapter);
@@ -100,10 +99,9 @@return 0 ; } -static int ixp2000_i2c_probe (struct device *dev) +static int ixp2000_i2c_probe (struct platform_device *plat_dev) {int err; -struct platform_device *plat_dev =to_platform_device (dev);struct ixp2000_i2c_pins *gpio = plat_dev->dev.platform_data;struct ixp2000_i2c_data *drv_data =kzalloc (sizeof (struct ixp2000_i2c_data ),GFP_KERNEL );
@@ -139,7 +137,7 @@return err; } -dev_set_drvdata (&plat_dev->dev, drv_data); +platform_set_drvdata (plat_dev, drv_data);return 0 ; }
@@ -144,22 +142,23 @@ static int ixp2000_i2c_probe(struct devireturn 0 ; } -static struct device_driver ixp2000_i2c_driver = { - .owner =THIS_MODULE , - .name ="IXP2000-I2C" , - .bus = &platform_bus_type, +static struct platform_driver ixp2000_i2c_driver = { .probe = ixp2000_i2c_probe, .remove = ixp2000_i2c_remove, + .driver = { + .name ="IXP2000-I2C" , + .owner =THIS_MODULE , + }, };static int __init ixp2000_i2c_init (void ) { -return driver_register (&ixp2000_i2c_driver); +return platform_driver_register (&ixp2000_i2c_driver); } static void __exit ixp2000_i2c_exit(void) { -driver_unregister (&ixp2000_i2c_driver); +platform_driver_unregister (&ixp2000_i2c_driver); }module_init (ixp2000_i2c_init);
drivers/i2c/busses/i2c-ixp4xx.c +12 -13
@@ -87,12 +87,11 @@struct i2c_algo_bit_data algo_data; }; -static int ixp4xx_i2c_remove (struct device *dev) +static int ixp4xx_i2c_remove (struct platform_device *plat_dev) { -struct platform_device *plat_dev =to_platform_device (dev); -struct ixp4xx_i2c_data *drv_data =dev_get_drvdata (&plat_dev->dev); +struct ixp4xx_i2c_data *drv_data =platform_get_drvdata (plat_dev); -dev_set_drvdata (&plat_dev->dev,NULL ); +platform_set_drvdata (plat_dev,NULL );i2c_bit_del_bus (&drv_data->adapter);
@@ -101,10 +100,9 @@return 0 ; } -static int ixp4xx_i2c_probe (struct device *dev) +static int ixp4xx_i2c_probe (struct platform_device *plat_dev) {int err; -struct platform_device *plat_dev =to_platform_device (dev);struct ixp4xx_i2c_pins *gpio = plat_dev->dev.platform_data;struct ixp4xx_i2c_data *drv_data =kzalloc (sizeof (struct ixp4xx_i2c_data ),GFP_KERNEL );
@@ -148,7 +146,7 @@return err; } -dev_set_drvdata (&plat_dev->dev, drv_data); +platform_set_drvdata (plat_dev, drv_data);return 0 ; }
@@ -153,22 +151,23 @@ static int ixp4xx_i2c_probe(struct devicreturn 0 ; } -static struct device_driver ixp4xx_i2c_driver = { - .owner =THIS_MODULE , - .name ="IXP4XX-I2C" , - .bus = &platform_bus_type, +static struct platform_driver ixp4xx_i2c_driver = { .probe = ixp4xx_i2c_probe, .remove = ixp4xx_i2c_remove, + .driver = { + .name ="IXP4XX-I2C" , + .owner =THIS_MODULE , + }, };static int __init ixp4xx_i2c_init (void ) { -return driver_register (&ixp4xx_i2c_driver); +return platform_driver_register (&ixp4xx_i2c_driver); } static void __exit ixp4xx_i2c_exit(void) { -driver_unregister (&ixp4xx_i2c_driver); +platform_driver_unregister (&ixp4xx_i2c_driver); }module_init (ixp4xx_i2c_init);
drivers/i2c/busses/i2c-mpc.c +12 -12
@@ -288,11 +288,10 @@ .retries = 1 }; -static int fsl_i2c_probe (struct device *device) +static int fsl_i2c_probe (struct platform_device *pdev) {int result =0 ;struct mpc_i2c *i2c; -struct platform_device *pdev =to_platform_device (device);struct fsl_i2c_platform_data *pdata;struct resource *r =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -323,7 +322,7 @@ }mpc_i2c_setclock (i2c); -dev_set_drvdata (device, i2c); +platform_set_drvdata (pdev, i2c); i2c->adap = mpc_ops;i2c_set_adapdata (&i2c->adap, i2c);
@@ -345,12 +344,12 @@return result; }; -static int fsl_i2c_remove (struct device *device) +static int fsl_i2c_remove (struct platform_device *pdev) { -struct mpc_i2c *i2c =dev_get_drvdata (device); +struct mpc_i2c *i2c =platform_get_drvdata (pdev);i2c_del_adapter (&i2c->adap); -dev_set_drvdata (device,NULL ); +platform_set_drvdata (pdev,NULL );if (i2c->irq !=0 )free_irq (i2c->irq, i2c);
@@ -361,22 +360,23 @@ static int fsl_i2c_remove(struct device };/* Structure for a device driver */ -static struct device_driver fsl_i2c_driver = { - .owner =THIS_MODULE , - .name ="fsl-i2c" , - .bus = &platform_bus_type, +static struct platform_driver fsl_i2c_driver = { .probe = fsl_i2c_probe, .remove = fsl_i2c_remove, + .driver = { + .owner =THIS_MODULE , + .name ="fsl-i2c" , + }, };static int __init fsl_i2c_init (void ) { -return driver_register (&fsl_i2c_driver); +return platform_driver_register (&fsl_i2c_driver); } static void __exit fsl_i2c_exit(void) { -driver_unregister (&fsl_i2c_driver); +platform_driver_unregister (&fsl_i2c_driver); }module_init (fsl_i2c_init);
drivers/i2c/busses/i2c-mv64xxx.c +12 -12
@@ -492,11 +492,10 @@ }static int __devinit -mv64xxx_i2c_probe (struct device *dev) +mv64xxx_i2c_probe (struct platform_device *pd) { -struct platform_device *pd =to_platform_device (dev);struct mv64xxx_i2c_data *drv_data; -struct mv64xxx_i2c_pdata *pdata = dev->platform_data; +struct mv64xxx_i2c_pdata *pdata = pd->dev.platform_data;int rc;if ((pd->id !=0 ) || !pdata)
@@ -526,7 +525,7 @@ drv_data->adapter.class =I2C_CLASS_HWMON ; drv_data->adapter.timeout = pdata->timeout; drv_data->adapter.retries = pdata->retries; -dev_set_drvdata (dev, drv_data); +platform_set_drvdata (pd, drv_data);i2c_set_adapdata (&drv_data->adapter, drv_data); if (request_irq(drv_data->irq, mv64xxx_i2c_intr, 0,
@@ -555,9 +554,9 @@ } static int __devexit -mv64xxx_i2c_remove (struct device *dev) +mv64xxx_i2c_remove (struct platform_device *dev) { -struct mv64xxx_i2c_data *drv_data =dev_get_drvdata (dev); +struct mv64xxx_i2c_data *drv_data =platform_get_drvdata (dev);int rc; rc =i2c_del_adapter (&drv_data->adapter);
@@ -568,24 +567,25 @@ mv64xxx_i2c_remove(struct device *dev)return rc; } -static struct device_driver mv64xxx_i2c_driver = { - .owner =THIS_MODULE , - .name =MV64XXX_I2C_CTLR_NAME , - .bus = &platform_bus_type, +static struct platform_driver mv64xxx_i2c_driver = { .probe = mv64xxx_i2c_probe, .remove = mv64xxx_i2c_remove, + .driver = { + .owner =THIS_MODULE , + .name =MV64XXX_I2C_CTLR_NAME , + }, };static int __init mv64xxx_i2c_init (void ) { -return driver_register (&mv64xxx_i2c_driver); +return platform_driver_register (&mv64xxx_i2c_driver); } static void __exitmv64xxx_i2c_exit (void ) { -driver_unregister (&mv64xxx_i2c_driver); +platform_driver_unregister (&mv64xxx_i2c_driver); }module_init (mv64xxx_i2c_init);
drivers/i2c/busses/i2c-pxa.c +13 -12
@@ -936,10 +936,10 @@ }, }; -static int i2c_pxa_probe (struct device *dev) +static int i2c_pxa_probe (struct platform_device *dev) {struct pxa_i2c *i2c = &i2c_pxa; -struct i2c_pxa_platform_data *plat = dev->platform_data; +struct i2c_pxa_platform_data *plat = dev->dev.platform_data;int ret;#ifdef CONFIG_PXA27x
@@ -968,7 +968,7 @@i2c_pxa_reset (i2c); i2c->adap.algo_data = i2c; - i2c->adap.dev.parent = dev; + i2c->adap.dev.parent = &dev->dev; ret =i2c_add_adapter (&i2c->adap);if (ret <0 ) {
@@ -976,7 +976,7 @@ goto err_irq; } -dev_set_drvdata (dev, i2c); +platform_set_drvdata (dev, i2c);#ifdef CONFIG_I2C_PXA_SLAVE printk(KERN_INFO "I2C: %s: PXA I2C adapter, slave address %d\n",
@@ -993,11 +993,11 @@return ret; } -static int i2c_pxa_remove (struct device *dev) +static int i2c_pxa_remove (struct platform_device *dev) { -struct pxa_i2c *i2c =dev_get_drvdata (dev); +struct pxa_i2c *i2c =platform_get_drvdata (dev); -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (dev,NULL );i2c_del_adapter (&i2c->adap);free_irq (IRQ_I2C , i2c);
@@ -1006,21 +1006,22 @@ static int i2c_pxa_remove(struct devicereturn 0 ; } -static struct device_driver i2c_pxa_driver = { - .name ="pxa2xx-i2c" , - .bus = &platform_bus_type, +static struct platform_driver i2c_pxa_driver = { .probe = i2c_pxa_probe, .remove = i2c_pxa_remove, + .driver = { + .name ="pxa2xx-i2c" , + }, };static int __init i2c_adap_pxa_init (void ) { -return driver_register (&i2c_pxa_driver); +return platform_driver_register (&i2c_pxa_driver); }static void i2c_adap_pxa_exit (void ) { -return driver_unregister (&i2c_pxa_driver); +return platform_driver_unregister (&i2c_pxa_driver); }module_init (i2c_adap_pxa_init);
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert network drivers
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/net/depca.c +10 -9
@@ -398,13 +398,14 @@ };#endif -static int depca_isa_probe (struct device *); +static int depca_isa_probe (struct platform_device *); -static struct device_driver depca_isa_driver = { - .name = depca_string, - .bus = &platform_bus_type, +static struct platform_driver depca_isa_driver = { .probe = depca_isa_probe, .remove =__devexit_p (depca_device_remove), + .driver = { + .name = depca_string, + }, };/*
@@ -1525,7 +1526,7 @@return adapter; } -static int __init depca_isa_probe (struct device *device) +static int __init depca_isa_probe (struct platform_device *device) {struct net_device *dev;struct depca_private *lp;
@@ -1533,7 +1534,7 @@enum depca_type adapter = unknown;int status =0 ; - ioaddr = (u_long ) device->platform_data; + ioaddr = (u_long ) device->dev.platform_data;if ((status =depca_common_init (ioaddr, &dev))) goto out;
@@ -1553,7 +1554,7 @@ lp->adapter = adapter; lp->mem_start = mem_start; -if ((status =depca_hw_init (dev, device))) +if ((status =depca_hw_init (dev, &device->dev))) goto out_free;return 0 ;
@@ -2082,7 +2083,7 @@ static int __init depca_module_init (voi#ifdef CONFIG_EISA err |=eisa_driver_register (&depca_eisa_driver);#endif - err |=driver_register (&depca_isa_driver); + err |=platform_driver_register (&depca_isa_driver);depca_platform_probe ();return err;
@@ -2097,7 +2098,7 @@ static void __exit depca_module_exit (vo#ifdef CONFIG_EISA eisa_driver_unregister (&depca_eisa_driver);#endif -driver_unregister (&depca_isa_driver); +platform_driver_unregister (&depca_isa_driver);for (i =0 ; depca_io_ports[i].iobase; i++) {if (depca_io_ports[i].device) {
drivers/net/dm9000.c +17 -18
@@ -149,7 +149,7 @@ } board_info_t;/* function declaration ------------------------------------- */ -static int dm9000_probe (struct device *); +static int dm9000_probe (struct platform_device *);static int dm9000_open (struct net_device *);static int dm9000_start_xmit (struct sk_buff *,struct net_device *);static int dm9000_stop (struct net_device *);
@@ -379,9 +379,8 @@* Search DM9000 board, allocate space and register it */ static int -dm9000_probe (struct device *dev) +dm9000_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev);struct dm9000_plat_data *pdata = pdev->dev.platform_data;struct board_info *db;/* Point a board information structure */ struct net_device *ndev;
@@ -399,7 +398,7 @@ }SET_MODULE_OWNER (ndev); -SET_NETDEV_DEV (ndev, dev); +SET_NETDEV_DEV (ndev, &pdev->dev);PRINTK2 ("dm9000_probe()" );
@@ -570,7 +569,7 @@printk ("%s: Invalid ethernet MAC address. Please " "set using ifconfig\n" , ndev->name); -dev_set_drvdata (dev, ndev); +platform_set_drvdata (pdev, ndev); ret =register_netdev (ndev);if (ret ==0 ) {
@@ -1141,9 +1140,9 @@ }static int -dm9000_drv_suspend (struct device *dev,pm_message_t state) +dm9000_drv_suspend (struct platform_device *dev,pm_message_t state) { -struct net_device *ndev =dev_get_drvdata (dev); +struct net_device *ndev =platform_get_drvdata (dev);if (ndev) {if (netif_running (ndev)) {
@@ -1155,9 +1154,9 @@ }static int -dm9000_drv_resume (struct device *dev) +dm9000_drv_resume (struct platform_device *dev) { -struct net_device *ndev =dev_get_drvdata (dev); +struct net_device *ndev =platform_get_drvdata (dev);board_info_t *db = (board_info_t *) ndev->priv;if (ndev) {
@@ -1173,12 +1172,11 @@ }static int -dm9000_drv_remove (struct device *dev) +dm9000_drv_remove (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev); -struct net_device *ndev =dev_get_drvdata (dev); +struct net_device *ndev =platform_get_drvdata (pdev); -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (pdev,NULL );unregister_netdev (ndev);dm9000_release_board (pdev, (board_info_t *) ndev->priv);
@@ -1189,13 +1187,14 @@return 0 ; } -static struct device_driver dm9000_driver = { - .name ="dm9000" , - .bus = &platform_bus_type, +static struct platform_driver dm9000_driver = { .probe = dm9000_probe, .remove = dm9000_drv_remove, .suspend = dm9000_drv_suspend, .resume = dm9000_drv_resume, + .driver = { + .name ="dm9000" , + }, }; static int __init
@@ -1203,13 +1202,13 @@ {printk (KERN_INFO "%s Ethernet Driver\n" ,CARDNAME ); -return driver_register (&dm9000_driver);/* search board and register */ +return platform_driver_register (&dm9000_driver);/* search board and register */ } static void __exitdm9000_cleanup (void ) { -driver_unregister (&dm9000_driver); +platform_driver_unregister (&dm9000_driver); }module_init (dm9000_init);
drivers/net/gianfar.c +14 -14
@@ -127,8 +127,8 @@static void adjust_link (struct net_device *dev);static void init_registers (struct net_device *dev);static int init_phy (struct net_device *dev); -static int gfar_probe (struct device *device); -static int gfar_remove (struct device *device); +static int gfar_probe (struct platform_device *pdev); +static int gfar_remove (struct platform_device *pdev);static void free_skb_resources (struct gfar_private *priv);static void gfar_set_multi (struct net_device *dev);static void gfar_set_hash_for_addr (struct net_device *dev,u8 *addr);
@@ -157,12 +157,11 @@/* Set up the ethernet device structure, private data, * and anything else we need before we start */ -static int gfar_probe (struct device *device) +static int gfar_probe (struct platform_device *pdev) {u32 tempval;struct net_device *dev =NULL ;struct gfar_private *priv =NULL ; -struct platform_device *pdev =to_platform_device (device);struct gianfar_platform_data *einfo;struct resource *r;int idx;
@@ -209,7 +208,7 @@spin_lock_init (&priv->lock); -dev_set_drvdata (device, dev); +platform_set_drvdata (pdev, dev);/* Stop the DMA engine now, in case it was running before */ /* (The firmware could have used it, and left it running). */
@@ -246,7 +245,7 @@ dev->base_addr = (unsigned long ) (priv->regs);SET_MODULE_OWNER (dev); -SET_NETDEV_DEV (dev, device); +SET_NETDEV_DEV (dev, &pdev->dev);/* Fill in the dev structure */ dev->open = gfar_enet_open;
@@ -378,12 +377,12 @@return err; } -static int gfar_remove (struct device *device) +static int gfar_remove (struct platform_device *pdev) { -struct net_device *dev =dev_get_drvdata (device); +struct net_device *dev =platform_get_drvdata (pdev);struct gfar_private *priv =netdev_priv (dev); -dev_set_drvdata (device,NULL ); +platform_set_drvdata (pdev,NULL );iounmap ((void *) priv->regs);free_netdev (dev);
@@ -1862,11 +1861,12 @@ static irqreturn_t gfar_error(int irq, v }/* Structure for a device driver */ -static struct device_driver gfar_driver = { - .name ="fsl-gianfar" , - .bus = &platform_bus_type, +static struct platform_driver gfar_driver = { .probe = gfar_probe, .remove = gfar_remove, + .driver = { + .name ="fsl-gianfar" , + }, };static int __init gfar_init (void )
@@ -1876,7 +1876,7 @@if (err)return err; - err =driver_register (&gfar_driver); + err =platform_driver_register (&gfar_driver);if (err)gfar_mdio_exit ();
@@ -1886,7 +1886,7 @@ static void __exit gfar_exit(void) { -driver_unregister (&gfar_driver); +platform_driver_unregister (&gfar_driver);gfar_mdio_exit (); }
drivers/net/irda/smsc-ircc2.c +14 -13
@@ -214,14 +214,15 @@/* Power Management */ -static int smsc_ircc_suspend (struct device *dev,pm_message_t state); -static int smsc_ircc_resume (struct device *dev); +static int smsc_ircc_suspend (struct platform_device *dev,pm_message_t state); +static int smsc_ircc_resume (struct platform_device *dev); -static struct device_driver smsc_ircc_driver = { - .name =SMSC_IRCC2_DRIVER_NAME , - .bus = &platform_bus_type, +static struct platform_driver smsc_ircc_driver = { .suspend = smsc_ircc_suspend, .resume = smsc_ircc_resume, + .driver = { + .name =SMSC_IRCC2_DRIVER_NAME , + }, };/* Transceivers for SMSC-ircc */
@@ -346,7 +347,7 @@IRDA_DEBUG (1 ,"%s\n" , __FUNCTION__); - ret =driver_register (&smsc_ircc_driver); + ret =platform_driver_register (&smsc_ircc_driver);if (ret) {IRDA_ERROR ("%s, Can't register driver!\n" , driver_name);return ret;
@@ -378,7 +379,7 @@ }if (ret) -driver_unregister (&smsc_ircc_driver); +platform_driver_unregister (&smsc_ircc_driver);return ret; }
@@ -491,7 +492,7 @@ err =PTR_ERR (self->pldev); goto err_out5; } -dev_set_drvdata (&self->pldev->dev, self); +platform_set_drvdata (self->pldev, self);IRDA_MESSAGE ("IrDA: Registered device %s\n" , dev->name); dev_count++;
@@ -1685,9 +1686,9 @@return 0 ; } -static int smsc_ircc_suspend (struct device *dev,pm_message_t state) +static int smsc_ircc_suspend (struct platform_device *dev,pm_message_t state) { -struct smsc_ircc_cb *self =dev_get_drvdata (dev); +struct smsc_ircc_cb *self =platform_get_drvdata (dev);if (!self->io.suspended) {IRDA_DEBUG (1 ,"%s, Suspending\n" , driver_name);
@@ -1706,9 +1707,9 @@return 0 ; } -static int smsc_ircc_resume (struct device *dev) +static int smsc_ircc_resume (struct platform_device *dev) { -struct smsc_ircc_cb *self =dev_get_drvdata (dev); +struct smsc_ircc_cb *self =platform_get_drvdata (dev);if (self->io.suspended) {IRDA_DEBUG (1 ,"%s, Waking up\n" , driver_name);
@@ -1788,7 +1789,7 @@smsc_ircc_close (dev_self[i]); } -driver_unregister (&smsc_ircc_driver); +platform_driver_unregister (&smsc_ircc_driver); }/*
drivers/net/jazzsonic.c +11 -10
@@ -194,7 +194,7 @@* Probe for a SONIC ethernet controller on a Mips Jazz board. * Actually probing is superfluous but we're paranoid. */ -static int __init jazz_sonic_probe (struct device *device) +static int __init jazz_sonic_probe (struct platform_device *pdev) {struct net_device *dev;struct sonic_local *lp;
@@ -212,8 +212,8 @@return -ENOMEM ; lp =netdev_priv (dev); - lp->device = device; -SET_NETDEV_DEV (dev, device); + lp->device = &pdev->dev; +SET_NETDEV_DEV (dev, &pdev->dev);SET_MODULE_OWNER (dev);netdev_boot_setup_check (dev);
@@ -264,9 +264,9 @@#include "sonic.c" -static int __devexit jazz_sonic_device_remove (struct device *device) +static int __devexit jazz_sonic_device_remove (struct platform_device *pdev) { -struct net_device *dev = device->driver_data; +struct net_device *dev =platform_get_drvdata (pdev);struct sonic_local * lp =netdev_priv (dev);unregister_netdev (dev);
@@ -278,18 +278,19 @@ static int __devexit jazz_sonic_device_rreturn 0 ; } -static struct device_driver jazz_sonic_driver = { - .name = jazz_sonic_string, - .bus = &platform_bus_type, +static struct platform_driver jazz_sonic_driver = { .probe = jazz_sonic_probe, .remove =__devexit_p (jazz_sonic_device_remove), + .driver = { + .name = jazz_sonic_string, + }, };static int __init jazz_sonic_init_module (void ) {int err; -if ((err =driver_register (&jazz_sonic_driver))) { +if ((err =platform_driver_register (&jazz_sonic_driver))) {printk (KERN_ERR "Driver registration failed\n" );return err; }
@@ -313,7 +314,7 @@ static int __init jazz_sonic_init_module static void __exit jazz_sonic_cleanup_module(void) { -driver_unregister (&jazz_sonic_driver); +platform_driver_unregister (&jazz_sonic_driver);if (jazz_sonic_device) {platform_device_unregister (jazz_sonic_device);
drivers/net/macsonic.c +11 -10
@@ -525,7 +525,7 @@return macsonic_init (dev); } -static int __init mac_sonic_probe (struct device *device) +static int __init mac_sonic_probe (struct platform_device *device) {struct net_device *dev;struct sonic_local *lp;
@@ -537,8 +537,8 @@return -ENOMEM ; lp =netdev_priv (dev); - lp->device = device; -SET_NETDEV_DEV (dev, device); + lp->device = &device->dev; +SET_NETDEV_DEV (dev, &device->dev);SET_MODULE_OWNER (dev);/* This will catch fatal stuff like -ENOMEM as well as success */
@@ -579,9 +579,9 @@#include "sonic.c" -static int __devexit mac_sonic_device_remove (struct device *device) +static int __devexit mac_sonic_device_remove (struct platform_device *device) { -struct net_device *dev = device->driver_data; +struct net_device *dev =platform_get_drvdata (device);struct sonic_local * lp =netdev_priv (dev);unregister_netdev (dev);
@@ -592,18 +592,19 @@ static int __devexit mac_sonic_device_rereturn 0 ; } -static struct device_driver mac_sonic_driver = { - .name = mac_sonic_string, - .bus = &platform_bus_type, +static struct platform_driver mac_sonic_driver = { .probe = mac_sonic_probe, .remove =__devexit_p (mac_sonic_device_remove), + .driver = { + .name = mac_sonic_string, + }, };static int __init mac_sonic_init_module (void ) {int err; -if ((err =driver_register (&mac_sonic_driver))) { +if ((err =platform_driver_register (&mac_sonic_driver))) {printk (KERN_ERR "Driver registration failed\n" );return err; }
@@ -628,7 +629,7 @@ static int __init mac_sonic_init_module( static void __exit mac_sonic_cleanup_module(void) { -driver_unregister (&mac_sonic_driver); +platform_driver_unregister (&mac_sonic_driver);if (mac_sonic_device) {platform_device_unregister (mac_sonic_device);
drivers/net/mv643xx_eth.c +20 -20
@@ -1387,9 +1387,8 @@* Input : struct device * * Output : -ENOMEM if failed , 0 if success */ -static int mv643xx_eth_probe (struct device *ddev) +static int mv643xx_eth_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (ddev);struct mv643xx_eth_platform_data *pd;int port_num = pdev->id;struct mv643xx_private *mp;
@@ -1402,7 +1401,7 @@if (!dev)return -ENOMEM ; -dev_set_drvdata (ddev, dev); +platform_set_drvdata (pdev, dev); mp =netdev_priv (dev);
@@ -1546,21 +1545,20 @@return err; } -static int mv643xx_eth_remove (struct device *ddev) +static int mv643xx_eth_remove (struct platform_device *pdev) { -struct net_device *dev =dev_get_drvdata (ddev); +struct net_device *dev =platform_get_drvdata (pdev);unregister_netdev (dev);flush_scheduled_work ();free_netdev (dev); -dev_set_drvdata (ddev,NULL ); +platform_set_drvdata (pdev,NULL );return 0 ; } -static int mv643xx_eth_shared_probe (struct device *ddev) +static int mv643xx_eth_shared_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (ddev);struct resource *res;printk (KERN_NOTICE "MV-643xx 10/100/1000 Ethernet Driver\n" );
@@ -1578,7 +1576,7 @@ } -static int mv643xx_eth_shared_remove (struct device *ddev) +static int mv643xx_eth_shared_remove (struct platform_device *pdev) {iounmap (mv643xx_eth_shared_base); mv643xx_eth_shared_base =NULL ;
@@ -1586,18 +1584,20 @@ static int mv643xx_eth_shared_remove(strreturn 0 ; } -static struct device_driver mv643xx_eth_driver = { - .name =MV643XX_ETH_NAME , - .bus = &platform_bus_type, +static struct platform_driver mv643xx_eth_driver = { .probe = mv643xx_eth_probe, .remove = mv643xx_eth_remove, + .driver = { + .name =MV643XX_ETH_NAME , + }, }; -static struct device_driver mv643xx_eth_shared_driver = { - .name =MV643XX_ETH_SHARED_NAME , - .bus = &platform_bus_type, +static struct platform_driver mv643xx_eth_shared_driver = { .probe = mv643xx_eth_shared_probe, .remove = mv643xx_eth_shared_remove, + .driver = { + .name =MV643XX_ETH_SHARED_NAME , + }, };/*
@@ -1613,11 +1613,11 @@ static int __init mv643xx_init_module(vo {int rc; - rc =driver_register (&mv643xx_eth_shared_driver); + rc =platform_driver_register (&mv643xx_eth_shared_driver);if (!rc) { - rc =driver_register (&mv643xx_eth_driver); + rc =platform_driver_register (&mv643xx_eth_driver);if (rc) -driver_unregister (&mv643xx_eth_shared_driver); +platform_driver_unregister (&mv643xx_eth_shared_driver); }return rc; }
@@ -1633,8 +1633,8 @@ static int __init mv643xx_init_module(vo*/ static void __exit mv643xx_cleanup_module(void) { -driver_unregister (&mv643xx_eth_driver); -driver_unregister (&mv643xx_eth_shared_driver); +platform_driver_unregister (&mv643xx_eth_driver); +platform_driver_unregister (&mv643xx_eth_shared_driver); }module_init (mv643xx_init_module);
drivers/net/smc91x.c +18 -20
@@ -2183,9 +2183,8 @@* 0 --> there is a device * anything else, error */ -static int smc_drv_probe (struct device *dev) +static int smc_drv_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev);struct net_device *ndev;struct resource *res;unsigned int __iomem *addr;
@@ -2212,7 +2211,7 @@ goto out_release_io; }SET_MODULE_OWNER (ndev); -SET_NETDEV_DEV (ndev, dev); +SET_NETDEV_DEV (ndev, &pdev->dev); ndev->dma = (unsigned char )-1 ; ndev->irq =platform_get_irq (pdev,0 );
@@ -2233,7 +2232,7 @@ goto out_release_attrib; } -dev_set_drvdata (dev, ndev); +platform_set_drvdata (pdev, ndev); ret =smc_probe (ndev, addr);if (ret !=0 ) goto out_iounmap;
@@ -2249,7 +2248,7 @@return 0 ; out_iounmap: -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (pdev,NULL );iounmap (addr); out_release_attrib:smc_release_attrib (pdev);
@@ -2263,14 +2262,13 @@return ret; } -static int smc_drv_remove (struct device *dev) +static int smc_drv_remove (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev); -struct net_device *ndev =dev_get_drvdata (dev); +struct net_device *ndev =platform_get_drvdata (pdev);struct smc_local *lp =netdev_priv (ndev);struct resource *res; -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (pdev,NULL );unregister_netdev (ndev);
@@ -2295,9 +2293,9 @@return 0 ; } -static int smc_drv_suspend (struct device *dev,pm_message_t state) +static int smc_drv_suspend (struct platform_device *dev,pm_message_t state) { -struct net_device *ndev =dev_get_drvdata (dev); +struct net_device *ndev =platform_get_drvdata (dev);if (ndev) {if (netif_running (ndev)) {
@@ -2309,14 +2307,13 @@return 0 ; } -static int smc_drv_resume (struct device *dev) +static int smc_drv_resume (struct platform_device *dev) { -struct platform_device *pdev =to_platform_device (dev); -struct net_device *ndev =dev_get_drvdata (dev); +struct net_device *ndev =platform_get_drvdata (dev);if (ndev) {struct smc_local *lp =netdev_priv (ndev); -smc_enable_device (pdev); +smc_enable_device (dev);if (netif_running (ndev)) {smc_reset (ndev);smc_enable (ndev);
@@ -2328,13 +2325,14 @@return 0 ; } -static struct device_driver smc_driver = { - .name =CARDNAME , - .bus = &platform_bus_type, +static struct platform_driver smc_driver = { .probe = smc_drv_probe, .remove = smc_drv_remove, .suspend = smc_drv_suspend, .resume = smc_drv_resume, + .driver = { + .name =CARDNAME , + }, };static int __init smc_init (void )
@@ -2348,12 +2346,12 @@#endif #endif -return driver_register (&smc_driver); +return platform_driver_register (&smc_driver); } static void __exit smc_cleanup(void) { -driver_unregister (&smc_driver); +platform_driver_unregister (&smc_driver); }module_init (smc_init);
drivers/net/tokenring/proteon.c +9 -8
@@ -344,9 +344,10 @@ module_param_array(dma, int, NULL, 0);static struct platform_device *proteon_dev[ISATR_MAX_ADAPTERS ]; -static struct device_driver proteon_driver = { - .name ="proteon" , - .bus = &platform_bus_type, +static struct platform_driver proteon_driver = { + .driver = { + .name ="proteon" , + }, };static int __init proteon_init (void )
@@ -355,7 +356,7 @@ static int __init proteon_init(void)struct platform_device *pdev;int i, num =0 , err =0 ; - err =driver_register (&proteon_driver); + err =platform_driver_register (&proteon_driver);if (err)return err;
@@ -372,7 +373,7 @@ err =setup_card (dev, &pdev->dev);if (!err) { proteon_dev[i] = pdev; -dev_set_drvdata (&pdev->dev, dev); +platform_set_drvdata (pdev, dev); ++num; }else {platform_device_unregister (pdev);
@@ -399,17 +400,17 @@if (!pdev)continue ; - dev =dev_get_drvdata (&pdev->dev); + dev =platform_get_drvdata (pdev);unregister_netdev (dev);release_region (dev->base_addr,PROTEON_IO_EXTENT );free_irq (dev->irq, dev);free_dma (dev->dma);tmsdev_term (dev);free_netdev (dev); -dev_set_drvdata (&pdev->dev,NULL ); +platform_set_drvdata (pdev,NULL );platform_device_unregister (pdev); } -driver_unregister (&proteon_driver); +platform_driver_unregister (&proteon_driver); }module_init (proteon_init);
drivers/net/tokenring/skisa.c +9 -8
@@ -354,9 +354,10 @@ module_param_array(dma, int, NULL, 0);static struct platform_device *sk_isa_dev[ISATR_MAX_ADAPTERS ]; -static struct device_driver sk_isa_driver = { - .name ="skisa" , - .bus = &platform_bus_type, +static struct platform_driver sk_isa_driver = { + .driver = { + .name ="skisa" , + }, };static int __init sk_isa_init (void )
@@ -365,7 +366,7 @@ static int __init sk_isa_init(void)struct platform_device *pdev;int i, num =0 , err =0 ; - err =driver_register (&sk_isa_driver); + err =platform_driver_register (&sk_isa_driver);if (err)return err;
@@ -382,7 +383,7 @@ err =setup_card (dev, &pdev->dev);if (!err) { sk_isa_dev[i] = pdev; -dev_set_drvdata (&sk_isa_dev[i]->dev, dev); +platform_set_drvdata (sk_isa_dev[i], dev); ++num; }else {platform_device_unregister (pdev);
@@ -409,17 +410,17 @@if (!pdev)continue ; - dev =dev_get_drvdata (&pdev->dev); + dev =platform_get_drvdata (pdev);unregister_netdev (dev);release_region (dev->base_addr,SK_ISA_IO_EXTENT );free_irq (dev->irq, dev);free_dma (dev->dma);tmsdev_term (dev);free_netdev (dev); -dev_set_drvdata (&pdev->dev,NULL ); +platform_set_drvdata (pdev,NULL );platform_device_unregister (pdev); } -driver_unregister (&sk_isa_driver); +platform_driver_unregister (&sk_isa_driver); }module_init (sk_isa_init);
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert input drivers
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/input/serio/i8042.c +10 -9
@@ -912,7 +912,7 @@* Here we try to restore the original BIOS settings */ -static int i8042_suspend (struct device *dev,pm_message_t state) +static int i8042_suspend (struct platform_device *dev,pm_message_t state) {del_timer_sync (&i8042_timer);i8042_controller_reset ();
@@ -925,7 +925,7 @@* Here we try to reset everything back to a state in which suspended */ -static int i8042_resume (struct device *dev) +static int i8042_resume (struct platform_device *dev) {int i;
@@ -964,7 +964,7 @@* because otherwise BIOSes will be confused. */ -static void i8042_shutdown (struct device *dev) +static void i8042_shutdown (struct platform_device *dev) {i8042_controller_cleanup (); }
@@ -969,12 +969,13 @@i8042_controller_cleanup (); } -static struct device_driver i8042_driver = { - .name ="i8042" , - .bus = &platform_bus_type, +static struct platform_driver i8042_driver = { .suspend = i8042_suspend, .resume = i8042_resume, .shutdown = i8042_shutdown, + .driver = { + .name ="i8042" , + }, };static int __init i8042_create_kbd_port (void )
@@ -1078,7 +1079,7 @@ goto err_platform_exit; } - err =driver_register (&i8042_driver); + err =platform_driver_register (&i8042_driver);if (err) goto err_controller_cleanup;
@@ -1126,7 +1127,7 @@ err_unregister_device:platform_device_unregister (i8042_platform_device); err_unregister_driver: -driver_unregister (&i8042_driver); +platform_driver_unregister (&i8042_driver); err_controller_cleanup:i8042_controller_cleanup (); err_platform_exit:
@@ -1148,7 +1149,7 @@del_timer_sync (&i8042_timer);platform_device_unregister (i8042_platform_device); -driver_unregister (&i8042_driver); +platform_driver_unregister (&i8042_driver);i8042_platform_exit ();
drivers/input/serio/rpckbd.c +11 -10
@@ -107,7 +107,7 @@* Allocate and initialize serio structure for subsequent registration * with serio core. */ -static int __devinit rpckbd_probe (struct device *dev) +static int __devinit rpckbd_probe (struct platform_device *dev) {struct serio *serio;
@@ -120,37 +120,38 @@ serio->write = rpckbd_write; serio->open = rpckbd_open; serio->close = rpckbd_close; - serio->dev.parent = dev; + serio->dev.parent = &dev->dev;strlcpy (serio->name,"RiscPC PS/2 kbd port" ,sizeof (serio->name));strlcpy (serio->phys,"rpckbd/serio0" ,sizeof (serio->phys)); -dev_set_drvdata (dev, serio); +platform_set_drvdata (dev, serio);serio_register_port (serio);return 0 ; } -static int __devexit rpckbd_remove(struct device *dev) +static int __devexit rpckbd_remove(struct platform_device *dev) { -struct serio *serio =dev_get_drvdata (dev); +struct serio *serio =platform_get_drvdata (dev);serio_unregister_port (serio);return 0 ; } -static struct device_driver rpckbd_driver = { - .name ="kart" , - .bus = &platform_bus_type, +static struct platform_driver rpckbd_driver = { .probe = rpckbd_probe, .remove =__devexit_p (rpckbd_remove), + .driver = { + .name ="kart" , + }, };static int __init rpckbd_init (void ) { -return driver_register (&rpckbd_driver); +return platform_driver_register (&rpckbd_driver); } static void __exit rpckbd_exit(void) { -driver_unregister (&rpckbd_driver); +platform_driver_unregister (&rpckbd_driver); }module_init (rpckbd_init);
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert USB drivers
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/usb/gadget/dummy_hcd.c +39 -37
@@ -897,7 +897,7 @@#endif } -static int dummy_udc_probe (struct device *dev) +static int dummy_udc_probe (struct platform_device *dev) {struct dummy *dum = the_controller;int rc;
@@ -910,7 +910,7 @@ dum->gadget.is_otg = (dummy_to_hcd (dum)->self.otg_port !=0 );strcpy (dum->gadget.dev.bus_id,"gadget" ); - dum->gadget.dev.parent = dev; + dum->gadget.dev.parent = &dev->dev; dum->gadget.dev.release = dummy_gadget_release; rc =device_register (&dum->gadget.dev);if (rc <0 )
@@ -920,26 +920,26 @@usb_bus_get (&dummy_to_hcd (dum)->self);#endif -dev_set_drvdata (dev, dum); +platform_set_drvdata (dev, dum);device_create_file (&dum->gadget.dev, &dev_attr_function);return rc; } -static int dummy_udc_remove (struct device *dev) +static int dummy_udc_remove (struct platform_device *dev) { -struct dummy *dum =dev_get_drvdata (dev); +struct dummy *dum =platform_get_drvdata (dev); -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (dev,NULL );device_remove_file (&dum->gadget.dev, &dev_attr_function);device_unregister (&dum->gadget.dev);return 0 ; } -static int dummy_udc_suspend (struct device *dev,pm_message_t state) +static int dummy_udc_suspend (struct platform_device *dev,pm_message_t state) { -struct dummy *dum =dev_get_drvdata (dev); +struct dummy *dum =platform_get_drvdata (dev); -dev_dbg (dev,"%s\n" , __FUNCTION__); +dev_dbg (&dev->dev,"%s\n" , __FUNCTION__);spin_lock_irq (&dum->lock); dum->udc_suspended =1 ;set_link_state (dum);
@@ -950,29 +950,30 @@return 0 ; } -static int dummy_udc_resume (struct device *dev) +static int dummy_udc_resume (struct platform_device *dev) { -struct dummy *dum =dev_get_drvdata (dev); +struct dummy *dum =platform_get_drvdata (dev); -dev_dbg (dev,"%s\n" , __FUNCTION__); +dev_dbg (&dev->dev,"%s\n" , __FUNCTION__);spin_lock_irq (&dum->lock); dum->udc_suspended =0 ;set_link_state (dum);spin_unlock_irq (&dum->lock); - dev->power.power_state =PMSG_ON ; + dev->dev.power.power_state =PMSG_ON ;usb_hcd_poll_rh_status (dummy_to_hcd (dum));return 0 ; } -static struct device_driver dummy_udc_driver = { - .name = (char *) gadget_name, - .owner =THIS_MODULE , - .bus = &platform_bus_type, +static struct platform_driver dummy_udc_driver = { .probe = dummy_udc_probe, .remove = dummy_udc_remove, .suspend = dummy_udc_suspend, .resume = dummy_udc_resume, + .driver = { + .name = (char *) gadget_name, + .owner =THIS_MODULE , + }, };/*-------------------------------------------------------------------------*/
@@ -1899,14 +1900,14 @@ .bus_resume = dummy_bus_resume, }; -static int dummy_hcd_probe (struct device *dev) +static int dummy_hcd_probe (struct platform_device *dev) {struct usb_hcd *hcd;int retval;dev_info (dev,"%s, driver " DRIVER_VERSION "\n" , driver_desc); - hcd =usb_create_hcd (&dummy_hcd, dev, dev->bus_id); + hcd =usb_create_hcd (&dummy_hcd, &dev->dev, dev->dev.bus_id);if (!hcd)return -ENOMEM ; the_controller =hcd_to_dummy (hcd);
@@ -1919,34 +1920,34 @@return retval; } -static int dummy_hcd_remove (struct device *dev) +static int dummy_hcd_remove (struct platform_device *dev) {struct usb_hcd *hcd; - hcd =dev_get_drvdata (dev); + hcd =platform_get_drvdata (dev);usb_remove_hcd (hcd);usb_put_hcd (hcd); the_controller =NULL ;return 0 ; } -static int dummy_hcd_suspend (struct device *dev,pm_message_t state) +static int dummy_hcd_suspend (struct platform_device *dev,pm_message_t state) {struct usb_hcd *hcd; -dev_dbg (dev,"%s\n" , __FUNCTION__); - hcd =dev_get_drvdata (dev); +dev_dbg (&dev->dev,"%s\n" , __FUNCTION__); + hcd =platform_get_drvdata (dev); hcd->state =HC_STATE_SUSPENDED ;return 0 ; } -static int dummy_hcd_resume (struct device *dev) +static int dummy_hcd_resume (struct platform_device *dev) {struct usb_hcd *hcd; -dev_dbg (dev,"%s\n" , __FUNCTION__); - hcd =dev_get_drvdata (dev); +dev_dbg (&dev->dev,"%s\n" , __FUNCTION__); + hcd =platform_get_drvdata (dev); hcd->state =HC_STATE_RUNNING ;usb_hcd_poll_rh_status (hcd);
@@ -1953,14 +1954,15 @@return 0 ; } -static struct device_driver dummy_hcd_driver = { - .name = (char *) driver_name, - .owner =THIS_MODULE , - .bus = &platform_bus_type, +static struct platform_driver dummy_hcd_driver = { .probe = dummy_hcd_probe, .remove = dummy_hcd_remove, .suspend = dummy_hcd_suspend, .resume = dummy_hcd_resume, + .driver = { + .name = (char *) driver_name, + .owner =THIS_MODULE , + }, };/*-------------------------------------------------------------------------*/
@@ -1996,11 +1998,11 @@if (usb_disabled ())return -ENODEV ; - retval =driver_register (&dummy_hcd_driver); + retval =platform_driver_register (&dummy_hcd_driver);if (retval <0 )return retval; - retval =driver_register (&dummy_udc_driver); + retval =platform_driver_register (&dummy_udc_driver);if (retval <0 ) goto err_register_udc_driver;
@@ -2016,9 +2018,9 @@ err_register_udc:platform_device_unregister (&the_hcd_pdev); err_register_hcd: -driver_unregister (&dummy_udc_driver); +platform_driver_unregister (&dummy_udc_driver); err_register_udc_driver: -driver_unregister (&dummy_hcd_driver); +platform_driver_unregister (&dummy_hcd_driver);return retval; }module_init (init);
@@ -2028,6 +2030,6 @@platform_device_unregister (&the_udc_pdev);platform_device_unregister (&the_hcd_pdev); -driver_unregister (&dummy_udc_driver); -driver_unregister (&dummy_hcd_driver); +platform_driver_unregister (&dummy_udc_driver); +platform_driver_unregister (&dummy_hcd_driver); }module_exit (cleanup);
drivers/usb/gadget/lh7a40x_udc.c +16 -15
@@ -2085,21 +2085,21 @@/* * probe - binds to the platform device */ -static int lh7a40x_udc_probe (struct device *_dev) +static int lh7a40x_udc_probe (struct platform_device *pdev) {struct lh7a40x_udc *dev = &memory;int retval; -DEBUG ("%s: %p\n" , __FUNCTION__, _dev); +DEBUG ("%s: %p\n" , __FUNCTION__, pdev);spin_lock_init (&dev->lock); - dev->dev = _dev; + dev->dev = &pdev->dev;device_initialize (&dev->gadget.dev); - dev->gadget.dev.parent = _dev; + dev->gadget.dev.parent = &pdev->dev; the_controller = dev; -dev_set_drvdata (_dev, dev); +platform_set_drvdata (pdev, dev);udc_disable (dev);udc_reinit (dev);
@@ -2119,11 +2119,11 @@return retval; } -static int lh7a40x_udc_remove (struct device *_dev) +static int lh7a40x_udc_remove (struct platform_device *pdev) { -struct lh7a40x_udc *dev = _dev->driver_data; +struct lh7a40x_udc *dev =platform_get_drvdata (pdev); -DEBUG ("%s: %p\n" , __FUNCTION__, dev); +DEBUG ("%s: %p\n" , __FUNCTION__, pdev);udc_disable (dev);remove_proc_files ();
@@ -2131,7 +2131,7 @@free_irq (IRQ_USBINTR , dev); -dev_set_drvdata (_dev,0 ); +platform_set_drvdata (pdev,0 ); the_controller =0 ;
@@ -2140,26 +2140,27 @@/*-------------------------------------------------------------------------*/ -static struct device_driver udc_driver = { - .name = (char *)driver_name, - .owner =THIS_MODULE , - .bus = &platform_bus_type, +static struct platform_driver udc_driver = { .probe = lh7a40x_udc_probe, .remove = lh7a40x_udc_remove/* FIXME power management support */ /* .suspend = ... disable UDC */ /* .resume = ... re-enable UDC */ + .driver = { + .name = (char *)driver_name, + .owner =THIS_MODULE , + }, };static int __init udc_init (void ) {DEBUG ("%s: %s version %s\n" , __FUNCTION__, driver_name,DRIVER_VERSION ); -return driver_register (&udc_driver); +return platform_driver_register (&udc_driver); } static void __exit udc_exit(void) { -driver_unregister (&udc_driver); +platform_driver_unregister (&udc_driver); }module_init (udc_init);
drivers/usb/host/isp116x-hcd.c +17 -20
@@ -1633,17 +1633,15 @@/*----------------------------------------------------------------*/ -static int __init_or_module isp116x_remove(struct device *dev) +static int __init_or_module isp116x_remove(struct platform_device *pdev) { -struct usb_hcd *hcd =dev_get_drvdata (dev); +struct usb_hcd *hcd =platform_get_drvdata (pdev);struct isp116x *isp116x; -struct platform_device *pdev;struct resource *res;if (!hcd)return 0 ; isp116x =hcd_to_isp116x (hcd); - pdev = container_of(dev, struct platform_device, dev);remove_debug_file (isp116x);usb_remove_hcd (hcd);
@@ -1660,18 +1658,16 @@#define resource_len (r) (((r)->end - (r)->start) + 1) -static int __init isp116x_probe (struct device *dev) +static int __init isp116x_probe (struct platform_device *pdev) {struct usb_hcd *hcd;struct isp116x *isp116x; -struct platform_device *pdev;struct resource *addr, *data;void __iomem *addr_reg;void __iomem *data_reg;int irq;int ret =0 ; - pdev = container_of(dev, struct platform_device, dev);if (pdev->num_resources <3 ) { ret = -ENODEV ; goto err1;
@@ -1685,7 +1681,7 @@ goto err1; } -if (dev->dma_mask) { +if (pdev->dev.dma_mask) {DBG ("DMA not supported\n" ); ret = -EINVAL ; goto err1;
@@ -1711,7 +1707,7 @@ static int __init isp116x_probe(struct d }/* allocate and initialize hcd */ - hcd =usb_create_hcd (&isp116x_hc_driver, dev, dev->bus_id); + hcd =usb_create_hcd (&isp116x_hc_driver, &pdev->dev, pdev->dev.bus_id);if (!hcd) { ret = -ENOMEM ; goto err5;
@@ -1723,7 +1719,7 @@ isp116x->addr_reg = addr_reg;spin_lock_init (&isp116x->lock);INIT_LIST_HEAD (&isp116x->async); - isp116x->board = dev->platform_data; + isp116x->board = pdev->dev.platform_data;if (!isp116x->board) {ERR ("Platform data structure not initialized\n" );
@@ -1764,13 +1760,13 @@/* Suspend of platform device */ -static int isp116x_suspend (struct device *dev,pm_message_t state) +static int isp116x_suspend (struct platform_device *dev,pm_message_t state) {int ret =0 ;VDBG ("%s: state %x\n" , __func__, state); - dev->power.power_state = state; + dev->dev.power.power_state = state;return ret; }
@@ -1778,13 +1774,13 @@/* Resume platform device */ -static int isp116x_resume (struct device *dev) +static int isp116x_resume (struct platform_device *dev) {int ret =0 ; -VDBG ("%s: state %x\n" , __func__, dev->power.power_state); +VDBG ("%s: state %x\n" , __func__, dev->dev.power.power_state); - dev->power.power_state =PMSG_ON ; + dev->dev.power.power_state =PMSG_ON ;return ret; }
@@ -1796,13 +1792,14 @@#endif -static struct device_driver isp116x_driver = { - .name = (char *)hcd_name, - .bus = &platform_bus_type, +static struct platform_driver isp116x_driver = { .probe = isp116x_probe, .remove = isp116x_remove, .suspend = isp116x_suspend, .resume = isp116x_resume, + .driver = { + .name = (char *)hcd_name, + }, };/*-----------------------------------------------------------------*/
@@ -1813,14 +1810,14 @@return -ENODEV ;INFO ("driver %s, %s\n" , hcd_name,DRIVER_VERSION ); -return driver_register (&isp116x_driver); +return platform_driver_register (&isp116x_driver); }module_init (isp116x_init); static void __exit isp116x_cleanup(void) { -driver_unregister (&isp116x_driver); +platform_driver_unregister (&isp116x_driver); }module_exit (isp116x_cleanup);
unchanged:
drivers/usb/host/sl811-hcd.c +7 -7
@@ -1829,16 +1829,16 @@/* this driver is exported so sl811_cs can depend on it */ -struct device_driver sl811h_driver = { - .name = (char *) hcd_name, - .bus = &platform_bus_type, - .owner =THIS_MODULE , - +struct platform_driver sl811h_driver = { .probe = sl811h_probe, .remove =__devexit_p (sl811h_remove), .suspend = sl811h_suspend, .resume = sl811h_resume, + .driver = { + .name = (char *) hcd_name, + .owner =THIS_MODULE , + }, };EXPORT_SYMBOL (sl811h_driver);
@@ -1851,11 +1851,11 @@INFO ("driver %s, %s\n" , hcd_name,DRIVER_VERSION ); -return driver_register (&sl811h_driver); +return platform_driver_register (&sl811h_driver); }module_init (sl811h_init); static void __exit sl811h_cleanup(void) { -driver_unregister (&sl811h_driver); +platform_driver_unregister (&sl811h_driver); }module_exit (sl811h_cleanup);
drivers/usb/host/ohci-au1xxx.c +14 -17
@@ -225,9 +225,8 @@/*-------------------------------------------------------------------------*/ -static int ohci_hcd_au1xxx_drv_probe (struct device *dev) +static int ohci_hcd_au1xxx_drv_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev);int ret;pr_debug ("In ohci_hcd_au1xxx_drv_probe" );
@@ -239,39 +238,37 @@return ret; } -static int ohci_hcd_au1xxx_drv_remove (struct device *dev) +static int ohci_hcd_au1xxx_drv_remove (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev); -struct usb_hcd *hcd =dev_get_drvdata (dev); +struct usb_hcd *hcd =platform_get_drvdata (pdev);usb_hcd_au1xxx_remove (hcd, pdev);return 0 ; }/*TBD*/ -/*static int ohci_hcd_au1xxx_drv_suspend(struct device *dev) +/*static int ohci_hcd_au1xxx_drv_suspend(struct platform_device *dev) { -struct platform_device *pdev = to_platform_device(dev); -struct usb_hcd *hcd = dev_get_drvdata(dev); +struct usb_hcd *hcd = platform_get_drvdata(dev); return 0; } -static int ohci_hcd_au1xxx_drv_resume(struct device *dev) +static int ohci_hcd_au1xxx_drv_resume(struct platform_device *dev) { -struct platform_device *pdev = to_platform_device(dev); -struct usb_hcd *hcd = dev_get_drvdata(dev); +struct usb_hcd *hcd = platform_get_drvdata(dev); return 0; } */ -static struct device_driver ohci_hcd_au1xxx_driver = { - .name ="au1xxx-ohci" , - .owner =THIS_MODULE , - .bus = &platform_bus_type, +static struct platform_driver ohci_hcd_au1xxx_driver = { .probe = ohci_hcd_au1xxx_drv_probe, .remove = ohci_hcd_au1xxx_drv_remove,/*.suspend = ohci_hcd_au1xxx_drv_suspend, */ /*.resume = ohci_hcd_au1xxx_drv_resume, */ + .driver = { + .name ="au1xxx-ohci" , + .owner =THIS_MODULE , + }, };static int __init ohci_hcd_au1xxx_init (void )
@@ -280,12 +277,12 @@pr_debug ("block sizes: ed %d td %d\n" ,sizeof (struct ed ),sizeof (struct td )); -return driver_register (&ohci_hcd_au1xxx_driver); +return platform_driver_register (&ohci_hcd_au1xxx_driver); } static void __exit ohci_hcd_au1xxx_cleanup (void) { -driver_unregister (&ohci_hcd_au1xxx_driver); +platform_driver_unregister (&ohci_hcd_au1xxx_driver); }module_init (ohci_hcd_au1xxx_init);
drivers/usb/host/ohci-lh7a404.c +14 -17
@@ -204,9 +204,8 @@/*-------------------------------------------------------------------------*/ -static int ohci_hcd_lh7a404_drv_probe (struct device *dev) +static int ohci_hcd_lh7a404_drv_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev);int ret;pr_debug ("In ohci_hcd_lh7a404_drv_probe" );
@@ -218,40 +217,38 @@return ret; } -static int ohci_hcd_lh7a404_drv_remove (struct device *dev) +static int ohci_hcd_lh7a404_drv_remove (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev); -struct usb_hcd *hcd =dev_get_drvdata (dev); +struct usb_hcd *hcd =platform_get_drvdata (dev);usb_hcd_lh7a404_remove (hcd, pdev);return 0 ; }/*TBD*/ -/*static int ohci_hcd_lh7a404_drv_suspend(struct device *dev) +/*static int ohci_hcd_lh7a404_drv_suspend(struct platform_device *dev) { -struct platform_device *pdev = to_platform_device(dev); -struct usb_hcd *hcd = dev_get_drvdata(dev); +struct usb_hcd *hcd = platform_get_drvdata(dev); return 0; } -static int ohci_hcd_lh7a404_drv_resume(struct device *dev) +static int ohci_hcd_lh7a404_drv_resume(struct platform_device *dev) { -struct platform_device *pdev = to_platform_device(dev); -struct usb_hcd *hcd = dev_get_drvdata(dev); +struct usb_hcd *hcd = platform_get_drvdata(dev); return 0; } */ -static struct device_driver ohci_hcd_lh7a404_driver = { - .name ="lh7a404-ohci" , - .owner =THIS_MODULE , - .bus = &platform_bus_type, +static struct platform_driver ohci_hcd_lh7a404_driver = { .probe = ohci_hcd_lh7a404_drv_probe, .remove = ohci_hcd_lh7a404_drv_remove,/*.suspend = ohci_hcd_lh7a404_drv_suspend, */ /*.resume = ohci_hcd_lh7a404_drv_resume, */ + .driver = { + .name ="lh7a404-ohci" , + .owner =THIS_MODULE , + }, };static int __init ohci_hcd_lh7a404_init (void )
@@ -260,12 +257,12 @@pr_debug ("block sizes: ed %d td %d\n" ,sizeof (struct ed ),sizeof (struct td )); -return driver_register (&ohci_hcd_lh7a404_driver); +return platform_driver_register (&ohci_hcd_lh7a404_driver); } static void __exit ohci_hcd_lh7a404_cleanup (void) { -driver_unregister (&ohci_hcd_lh7a404_driver); +platform_driver_unregister (&ohci_hcd_lh7a404_driver); }module_init (ohci_hcd_lh7a404_init);
drivers/usb/host/ohci-ppc-soc.c +10 -11
@@ -172,9 +172,8 @@ .start_port_reset = ohci_start_port_reset, }; -static int ohci_hcd_ppc_soc_drv_probe (struct device *dev) +static int ohci_hcd_ppc_soc_drv_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev);int ret;if (usb_disabled ())
@@ -184,25 +183,25 @@return ret; } -static int ohci_hcd_ppc_soc_drv_remove (struct device *dev) +static int ohci_hcd_ppc_soc_drv_remove (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev); -struct usb_hcd *hcd =dev_get_drvdata (dev); +struct usb_hcd *hcd =platform_get_drvdata (dev);usb_hcd_ppc_soc_remove (hcd, pdev);return 0 ; } -static struct device_driver ohci_hcd_ppc_soc_driver = { - .name ="ppc-soc-ohci" , - .owner =THIS_MODULE , - .bus = &platform_bus_type, +static struct platform_driver ohci_hcd_ppc_soc_driver = { .probe = ohci_hcd_ppc_soc_drv_probe, .remove = ohci_hcd_ppc_soc_drv_remove, #ifdef CONFIG_PM /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/ /*.resume = ohci_hcd_ppc_soc_drv_resume,*/ #endif + .driver = { + .name ="ppc-soc-ohci" , + .owner =THIS_MODULE , + }, };static int __init ohci_hcd_ppc_soc_init (void )
@@ -211,12 +210,12 @@pr_debug ("block sizes: ed %d td %d\n" ,sizeof (struct ed ),sizeof (struct td )); -return driver_register (&ohci_hcd_ppc_soc_driver); +return platform_driver_register (&ohci_hcd_ppc_soc_driver); } static void __exit ohci_hcd_ppc_soc_cleanup(void) { -driver_unregister (&ohci_hcd_ppc_soc_driver); +platform_driver_unregister (&ohci_hcd_ppc_soc_driver); }module_init (ohci_hcd_ppc_soc_init);
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert video drivers
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/video/s1d13xxxfb.c +23 -24
@@ -504,10 +504,9 @@static int -s1d13xxxfb_remove (struct device *dev) +s1d13xxxfb_remove (struct platform_device *pdev) { -struct fb_info *info =dev_get_drvdata (dev); -struct platform_device *pdev =to_platform_device (dev); +struct fb_info *info =platform_get_drvdata (pdev);struct s1d13xxxfb_par *par =NULL ;if (info) {
@@ -535,9 +534,8 @@ }static int __devinit -s1d13xxxfb_probe (struct device *dev) +s1d13xxxfb_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (dev);struct s1d13xxxfb_par *default_par;struct fb_info *info;struct s1d13xxxfb_pdata *pdata =NULL ;
@@ -549,8 +547,8 @@printk (KERN_INFO "Epson S1D13XXX FB Driver\n" );/* enable platform-dependent hardware glue, if any */ -if (dev->platform_data) - pdata = dev->platform_data; +if (pdev->dev.platform_data) + pdata = pdev->dev.platform_data;if (pdata && pdata->platform_init_video) pdata->platform_init_video ();
@@ -573,14 +571,14 @@if (!request_mem_region (pdev->resource[0 ].start, pdev->resource[0 ].end - pdev->resource[0 ].start +1 ,"s1d13xxxfb mem" )) { -dev_dbg (dev,"request_mem_region failed\n" ); +dev_dbg (&pdev->dev,"request_mem_region failed\n" ); ret = -EBUSY ; goto bail; }if (!request_mem_region (pdev->resource[1 ].start, pdev->resource[1 ].end - pdev->resource[1 ].start +1 ,"s1d13xxxfb regs" )) { -dev_dbg (dev,"request_mem_region failed\n" ); +dev_dbg (&pdev->dev,"request_mem_region failed\n" ); ret = -EBUSY ; goto bail; }
@@ -641,7 +639,7 @@ goto bail; } -dev_set_drvdata (&pdev->dev, info); +platform_set_drvdata (pdev, info);printk (KERN_INFO "fb%d: %s frame buffer device\n" , info->node, info->fix.id);
@@ -649,15 +647,15 @@return 0 ; bail: -s1d13xxxfb_remove (dev); +s1d13xxxfb_remove (pdev);return ret; }#ifdef CONFIG_PM -static int s1d13xxxfb_suspend (struct device *dev,pm_message_t state) +static int s1d13xxxfb_suspend (struct platform_device *dev,pm_message_t state) { -struct fb_info *info =dev_get_drvdata (dev); +struct fb_info *info =platform_get_drvdata (dev);struct s1d13xxxfb_par *s1dfb = info->par;struct s1d13xxxfb_pdata *pdata =NULL ;
@@ -665,8 +663,8 @@lcd_enable (s1dfb,0 );crt_enable (s1dfb,0 ); -if (dev->platform_data) - pdata = dev->platform_data; +if (dev->dev.platform_data) + pdata = dev->dev.platform_data;#if 0 if (!s1dfb->disp_save)
@@ -702,9 +700,9 @@return 0 ; } -static int s1d13xxxfb_resume (struct device *dev) +static int s1d13xxxfb_resume (struct platform_device *dev) { -struct fb_info *info =dev_get_drvdata (dev); +struct fb_info *info =platform_get_drvdata (dev);struct s1d13xxxfb_par *s1dfb = info->par;struct s1d13xxxfb_pdata *pdata =NULL ;
@@ -715,8 +713,8 @@while ((s1d13xxxfb_readreg (s1dfb,S1DREG_PS_STATUS ) &0x01 ))udelay (10 ); -if (dev->platform_data) - pdata = dev->platform_data; +if (dev->dev.platform_data) + pdata = dev->dev.platform_data;if (s1dfb->regs_save) {/* will write RO regs, *should* get away with it :) */
@@ -742,15 +740,16 @@ }#endif /* CONFIG_PM */ -static struct device_driver s1d13xxxfb_driver = { - .name =S1D_DEVICENAME , - .bus = &platform_bus_type, +static struct platform_driver s1d13xxxfb_driver = { .probe = s1d13xxxfb_probe, .remove = s1d13xxxfb_remove, #ifdef CONFIG_PM .suspend = s1d13xxxfb_suspend, .resume = s1d13xxxfb_resume #endif + .driver = { + .name =S1D_DEVICENAME , + }, };
@@ -760,14 +759,14 @@if (fb_get_options ("s1d13xxxfb" ,NULL ))return -ENODEV ; -return driver_register (&s1d13xxxfb_driver); +return platform_driver_register (&s1d13xxxfb_driver); } static void __exits1d13xxxfb_exit (void ) { -driver_unregister (&s1d13xxxfb_driver); +platform_driver_unregister (&s1d13xxxfb_driver); }module_init (s1d13xxxfb_init);
drivers/video/w100fb.c +23 -23
111 lines not on this page · raw message
drivers/video/acornfb.c +7 -6
@@ -1280,7 +1280,7 @@printk ("acornfb: freed %dK memory\n" , mb_freed); } -static int __init acornfb_probe (struct device *dev) +static int __init acornfb_probe (struct platform_device *dev) {unsigned long size;u_int h_sync, v_sync;
@@ -1293,7 +1293,7 @@acornfb_init_fbinfo (); - current_par.dev = dev; + current_par.dev = &dev->dev;if (current_par.montype ==-1 ) current_par.montype =acornfb_detect_monitortype ();
@@ -1454,15 +1454,16 @@return 0 ; } -static struct device_driver acornfb_driver = { - .name ="acornfb" , - .bus = &platform_bus_type, +static struct platform_driver acornfb_driver = { .probe = acornfb_probe, + .driver = { + .name ="acornfb" , + }, };static int __init acornfb_init (void ) { -return driver_register (&acornfb_driver); +return platform_driver_register (&acornfb_driver); }module_init (acornfb_init);
drivers/video/arcfb.c +11 -11
@@ -515,9 +515,8 @@ .fb_ioctl = arcfb_ioctl, }; -static int __init arcfb_probe (struct device *device) +static int __init arcfb_probe (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (device);struct fb_info *info;int retval = -ENOMEM ;int videomemorysize;
@@ -560,7 +559,7 @@ retval =register_framebuffer (info);if (retval <0 ) goto err1; -dev_set_drvdata (&dev->dev, info); +platform_set_drvdata (dev, info);if (irq) { par->irq = irq; if (request_irq(par->irq, &arcfb_interrupt, SA_SHIRQ,
@@ -601,9 +600,9 @@return retval; } -static int arcfb_remove (struct device *device) +static int arcfb_remove (struct platform_device *dev) { -struct fb_info *info =dev_get_drvdata (device); +struct fb_info *info =platform_get_drvdata (dev);if (info) {unregister_framebuffer (info);
@@ -613,11 +612,12 @@return 0 ; } -static struct device_driver arcfb_driver = { - .name ="arcfb" , - .bus = &platform_bus_type, +static struct platform_driver arcfb_driver = { .probe = arcfb_probe, .remove = arcfb_remove, + .driver = { + .name ="arcfb" , + }, };static struct platform_device *arcfb_device;
@@ -629,7 +630,7 @@if (!arcfb_enable)return -ENXIO ; - ret =driver_register (&arcfb_driver); + ret =platform_driver_register (&arcfb_driver);if (!ret) { arcfb_device =platform_device_alloc ("arcfb" ,0 );if (arcfb_device) {
@@ -639,7 +639,7 @@ }if (ret) {platform_device_put (arcfb_device); -driver_unregister (&arcfb_driver); +platform_driver_unregister (&arcfb_driver); } }return ret;
@@ -649,7 +649,7 @@ static void __exit arcfb_exit(void) {platform_device_unregister (arcfb_device); -driver_unregister (&arcfb_driver); +platform_driver_unregister (&arcfb_driver); }module_param (num_cols, ulong,0 );
drivers/video/dnfb.c +8 -8
@@ -228,9 +228,8 @@* Initialization */ -static int __devinit dnfb_probe (struct device *device) +static int __devinit dnfb_probe (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (device);struct fb_info *info;int err =0 ;
@@ -258,7 +257,7 @@framebuffer_release (info);return err; } -dev_set_drvdata (&dev->dev, info); +platform_set_drvdata (dev, info);/* now we have registered we can safely setup the hardware */ out_8 (AP_CONTROL_3A ,RESET_CREG );
@@ -272,10 +271,11 @@return err; } -static struct device_driver dnfb_driver = { - .name ="dnfb" , - .bus = &platform_bus_type, +static struct platform_driver dnfb_driver = { .probe = dnfb_probe, + .driver = { + .name ="dnfb" , + }, };static struct platform_device dnfb_device = {
@@ -289,12 +289,12 @@if (fb_get_options ("dnfb" ,NULL ))return -ENODEV ; - ret =driver_register (&dnfb_driver); + ret =platform_driver_register (&dnfb_driver);if (!ret) { ret =platform_device_register (&dnfb_device);if (ret) -driver_unregister (&dnfb_driver); +platform_driver_unregister (&dnfb_driver); }return ret; }
drivers/video/epson1355fb.c +12 -12
@@ -610,9 +610,9 @@ { } -static int epson1355fb_remove (struct device *device) +static int epson1355fb_remove (struct platform_device *dev) { -struct fb_info *info =dev_get_drvdata (device); +struct fb_info *info =platform_get_drvdata (dev);struct epson1355_par *par = info->par;backlight_enable (0 );
@@ -633,9 +633,8 @@return 0 ; } -int __init epson1355fb_probe (struct device *device) +int __init epson1355fb_probe (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (device);struct epson1355_par *default_par;struct fb_info *info;u8 revision;
@@ -714,7 +713,7 @@/* * Our driver data. */ -dev_set_drvdata (&dev->dev, info); +platform_set_drvdata (dev, info);printk (KERN_INFO "fb%d: %s frame buffer device\n" , info->node, info->fix.id);
@@ -722,15 +721,16 @@return 0 ; bail: -epson1355fb_remove (device); +epson1355fb_remove (dev);return rc; } -static struct device_driver epson1355fb_driver = { - .name ="epson1355fb" , - .bus = &platform_bus_type, +static struct platform_driver epson1355fb_driver = { .probe = epson1355fb_probe, .remove = epson1355fb_remove, + .driver = { + .name ="epson1355fb" , + }, };static struct platform_device epson1355fb_device = {
@@ -748,11 +748,11 @@if (fb_get_options ("epson1355fb" ,NULL ))return -ENODEV ; - ret =driver_register (&epson1355fb_driver); + ret =platform_driver_register (&epson1355fb_driver);if (!ret) { ret =platform_device_register (&epson1355fb_device);if (ret) -driver_unregister (&epson1355fb_driver); +platform_driver_unregister (&epson1355fb_driver); }return ret; }
@@ -763,7 +763,7 @@ static void __exit epson1355fb_exit(void) {platform_device_unregister (&epson1355fb_device); -driver_unregister (&epson1355fb_driver); +platform_driver_unregister (&epson1355fb_driver); }/* ------------------------------------------------------------------------- */
drivers/video/gbefb.c +12 -13
@@ -1106,12 +1106,11 @@return 0 ; } -static int __init gbefb_probe (struct device *dev) +static int __init gbefb_probe (struct platform_device *p_dev) {int i, ret =0 ;struct fb_info *info;struct gbefb_par *par; -struct platform_device *p_dev =to_platform_device (dev);#ifndef MODULE char *options =NULL ;#endif
@@ -1205,8 +1204,8 @@ goto out_gbe_unmap; } -dev_set_drvdata (&p_dev->dev, info); -gbefb_create_sysfs (dev); +platform_set_drvdata (p_dev, info); +gbefb_create_sysfs (&p_dev->dev); printk(KERN_INFO "fb%d: %s rev %d @ 0x%08x using %dkB memory\n", info->node, info->fix.id, gbe_revision, (unsigned) GBE_BASE,
@@ -1232,10 +1231,9 @@return ret; } -static int __devexit gbefb_remove(struct device* dev) +static int __devexit gbefb_remove(struct platform_device* p_dev) { -struct platform_device *p_dev =to_platform_device (dev); -struct fb_info *info =dev_get_drvdata (&p_dev->dev); +struct fb_info *info =platform_get_drvdata (p_dev);unregister_framebuffer (info);gbe_turn_off ();
@@ -1253,11 +1251,12 @@return 0 ; } -static struct device_driver gbefb_driver = { - .name ="gbefb" , - .bus = &platform_bus_type, +static struct platform_driver gbefb_driver = { .probe = gbefb_probe, .remove =__devexit_p (gbefb_remove), + .driver = { + .name ="gbefb" , + }, };static struct platform_device *gbefb_device;
@@ -1264,7 +1263,7 @@int __init gbefb_init (void ) { -int ret =driver_register (&gbefb_driver); +int ret =platform_driver_register (&gbefb_driver);if (!ret) { gbefb_device =platform_device_alloc ("gbefb" ,0 );if (gbefb_device) {
@@ -1274,16 +1273,16 @@ }if (ret) {platform_device_put (gbefb_device); -driver_unregister (&gbefb_driver); +platform_driver_unregister (&gbefb_driver); } }return ret; } void __exit gbefb_exit(void) {platform_device_unregister (gbefb_device); -driver_unregister (&gbefb_driver); +platform_driver_unregister (&gbefb_driver); }module_init (gbefb_init);
drivers/video/q40fb.c +7 -7
@@ -87,9 +87,8 @@ .fb_cursor = soft_cursor, }; -static int __init q40fb_probe (struct device *device) +static int __init q40fb_probe (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (device);struct fb_info *info;if (!MACH_IS_Q40 )
@@ -129,10 +128,11 @@return 0 ; } -static struct device_driver q40fb_driver = { - .name ="q40fb" , - .bus = &platform_bus_type, +static struct platform_driver q40fb_driver = { .probe = q40fb_probe, + .driver = { + .name ="q40fb" , + }, };static struct platform_device q40fb_device = {
@@ -146,12 +146,12 @@if (fb_get_options ("q40fb" ,NULL ))return -ENODEV ; - ret =driver_register (&q40fb_driver); + ret =platform_driver_register (&q40fb_driver);if (!ret) { ret =platform_device_register (&q40fb_device);if (ret) -driver_unregister (&q40fb_driver); +platform_driver_unregister (&q40fb_driver); }return ret; }
drivers/video/sgivwfb.c +11 -11
@@ -751,9 +751,8 @@/* * Initialisation */ -static int __init sgivwfb_probe (struct device *device) +static int __init sgivwfb_probe (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (device);struct sgivw_par *par;struct fb_info *info;char *monitor;
@@ -814,7 +813,7 @@ goto fail_register_framebuffer; } -dev_set_drvdata (&dev->dev, info); +platform_set_drvdata (dev, info);printk (KERN_INFO "fb%d: SGI DBE frame buffer device, using %ldK of video memory at %#lx\n" , info->node, sgivwfb_mem_size >>10 , sgivwfb_mem_phys);
@@ -832,9 +831,9 @@return -ENXIO ; } -static int sgivwfb_remove (struct device *device) +static int sgivwfb_remove (struct platform_device *dev) { -struct fb_info *info =dev_get_drvdata (device); +struct fb_info *info =platform_get_drvdata (dev);if (info) {struct sgivw_par *par = info->par;
@@ -848,11 +847,12 @@return 0 ; } -static struct device_driver sgivwfb_driver = { - .name ="sgivwfb" , - .bus = &platform_bus_type, +static struct platform_driver sgivwfb_driver = { .probe = sgivwfb_probe, .remove = sgivwfb_remove, + .driver = { + .name ="sgivwfb" , + }, };static struct platform_device *sgivwfb_device;
@@ -868,15 +868,15 @@return -ENODEV ;sgivwfb_setup (option);#endif - ret =driver_register (&sgivwfb_driver); + ret =platform_driver_register (&sgivwfb_driver);if (!ret) { sgivwfb_device =platform_device_alloc ("sgivwfb" ,0 );if (sgivwfb_device) { ret =platform_device_add (sgivwfb_device); }else ret = -ENOMEM ;if (ret) { -driver_unregister (&sgivwfb_driver); +platform_driver_unregister (&sgivwfb_driver);platform_device_put (sgivwfb_device); } }
@@ -891,7 +891,7 @@ static void __exit sgivwfb_exit(void) {platform_device_unregister (sgivwfb_device); -driver_unregister (&sgivwfb_driver); +platform_driver_unregister (&sgivwfb_driver); }module_exit (sgivwfb_exit);
drivers/video/vesafb.c +7 -7
@@ -252,9 +252,8 @@return 0 ; } -static int __init vesafb_probe (struct device *device) +static int __init vesafb_probe (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (device);struct fb_info *info;int i, err;unsigned int size_vmode;
@@ -487,10 +486,11 @@return err; } -static struct device_driver vesafb_driver = { - .name ="vesafb" , - .bus = &platform_bus_type, +static struct platform_driver vesafb_driver = { .probe = vesafb_probe, + .driver = { + .name ="vesafb" , + }, };static struct platform_device vesafb_device = {
@@ -505,12 +505,12 @@/* ignore error return of fb_get_options */ fb_get_options ("vesafb" , &option);vesafb_setup (option); - ret =driver_register (&vesafb_driver); + ret =platform_driver_register (&vesafb_driver);if (!ret) { ret =platform_device_register (&vesafb_device);if (ret) -driver_unregister (&vesafb_driver); +platform_driver_unregister (&vesafb_driver); }return ret; }
drivers/video/vfb.c +11 -11
@@ -404,9 +404,8 @@// This is called when the reference count goes to zero. } -static int __init vfb_probe (struct device *device) +static int __init vfb_probe (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (device);struct fb_info *info;int retval = -ENOMEM ;
@@ -448,7 +447,7 @@ retval =register_framebuffer (info);if (retval <0 ) goto err2; -dev_set_drvdata (&dev->dev, info); +platform_set_drvdata (dev, info); printk(KERN_INFO "fb%d: Virtual frame buffer device, using %ldK of video memory\n",
@@ -463,9 +462,9 @@return retval; } -static int vfb_remove (struct device *device) +static int vfb_remove (struct platform_device *dev) { -struct fb_info *info =dev_get_drvdata (device); +struct fb_info *info =platform_get_drvdata (dev);if (info) {unregister_framebuffer (info);
@@ -475,11 +474,12 @@return 0 ; } -static struct device_driver vfb_driver = { - .name ="vfb" , - .bus = &platform_bus_type, +static struct platform_driver vfb_driver = { .probe = vfb_probe, .remove = vfb_remove, + .driver = { + .name ="vfb" , + }, };static struct platform_device vfb_device = {
@@ -505,12 +505,12 @@if (!vfb_enable)return -ENXIO ; - ret =driver_register (&vfb_driver); + ret =platform_driver_register (&vfb_driver);if (!ret) { ret =platform_device_register (&vfb_device);if (ret) -driver_unregister (&vfb_driver); +platform_driver_unregister (&vfb_driver); }return ret; }
@@ -521,7 +521,7 @@ static void __exit vfb_exit(void) {platform_device_unregister (&vfb_device); -driver_unregister (&vfb_driver); +platform_driver_unregister (&vfb_driver); }module_exit (vfb_exit);
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert miscellaneous char drivers
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/char/sonypi.c +10 -9
@@ -1168,7 +1168,7 @@#ifdef CONFIG_PM static int old_camera_power; -static int sonypi_suspend (struct device *dev,pm_message_t state) +static int sonypi_suspend (struct platform_device *dev,pm_message_t state) { old_camera_power = sonypi_device.camera_power;sonypi_disable ();
@@ -1176,7 +1176,7 @@return 0 ; } -static int sonypi_resume (struct device *dev) +static int sonypi_resume (struct platform_device *dev) {sonypi_enable (old_camera_power);return 0 ;
@@ -1183,7 +1183,7 @@ }#endif -static void sonypi_shutdown (struct device *dev) +static void sonypi_shutdown (struct platform_device *dev) {sonypi_disable (); }
@@ -1188,14 +1188,15 @@sonypi_disable (); } -static struct device_driver sonypi_driver = { - .name ="sonypi" , - .bus = &platform_bus_type, +static struct platform_driver sonypi_driver = { #ifdef CONFIG_PM .suspend = sonypi_suspend, .resume = sonypi_resume, #endif .shutdown = sonypi_shutdown, + .driver = { + .name ="sonypi" , + }, };static int __devinit sonypi_create_input_devices (void )
@@ -1455,20 +1456,20 @@if (!dmi_check_system (sonypi_dmi_table))return -ENODEV ; - ret =driver_register (&sonypi_driver); + ret =platform_driver_register (&sonypi_driver);if (ret)return ret; ret =sonypi_probe ();if (ret) -driver_unregister (&sonypi_driver); +platform_driver_unregister (&sonypi_driver);return ret; } static void __exit sonypi_exit(void) { -driver_unregister (&sonypi_driver); +platform_driver_unregister (&sonypi_driver);sonypi_remove (); }
drivers/char/tb0219.c +8 -7
@@ -283,7 +283,7 @@vr41xx_set_irq_level (TB0219_PCI_SLOT3_PIN ,IRQ_LEVEL_LOW ); } -static int tb0219_probe (struct device *dev) +static int tb0219_probe (struct platform_device *dev) {int retval;
@@ -319,7 +319,7 @@return 0 ; } -static int tb0219_remove (struct device *dev) +static int tb0219_remove (struct platform_device *dev) { _machine_restart = old_machine_restart;
@@ -333,11 +333,12 @@ static int tb0219_remove(struct device *static struct platform_device *tb0219_platform_device; -static struct device_driver tb0219_device_driver = { - .name ="TB0219" , - .bus = &platform_bus_type, +static struct platform_driver tb0219_device_driver = { .probe = tb0219_probe, .remove = tb0219_remove, + .driver = { + .name ="TB0219" , + }, };static int __devinit tanbac_tb0219_init (void )
@@ -348,7 +349,7 @@ static int __devinit tanbac_tb0219_init(if (IS_ERR (tb0219_platform_device))return PTR_ERR (tb0219_platform_device); - retval =driver_register (&tb0219_device_driver); + retval =platform_driver_register (&tb0219_device_driver);if (retval <0 )platform_device_unregister (tb0219_platform_device);
@@ -357,7 +358,7 @@ static int __devinit tanbac_tb0219_init( static void __devexit tanbac_tb0219_exit(void) { -driver_unregister (&tb0219_device_driver); +platform_driver_unregister (&tb0219_device_driver);platform_device_unregister (tb0219_platform_device); }
drivers/char/vr41xx_giu.c +8 -7
@@ -613,7 +613,7 @@ .release = gpio_release, }; -static int giu_probe (struct device *dev) +static int giu_probe (struct platform_device *dev) {unsigned long start, size, flags =0 ;unsigned int nr_pins =0 ;
@@ -697,7 +697,7 @@return cascade_irq (GIUINT_IRQ , giu_get_irq); } -static int giu_remove (struct device *dev) +static int giu_remove (struct platform_device *dev) {iounmap (giu_base);
@@ -710,11 +710,12 @@ static int giu_remove(struct device *devstatic struct platform_device *giu_platform_device; -static struct device_driver giu_device_driver = { - .name ="GIU" , - .bus = &platform_bus_type, +static struct platform_driver giu_device_driver = { .probe = giu_probe, .remove = giu_remove, + .driver = { + .name ="GIU" , + }, };static int __devinit vr41xx_giu_init (void )
@@ -725,7 +726,7 @@ static int __devinit vr41xx_giu_init(voiif (IS_ERR (giu_platform_device))return PTR_ERR (giu_platform_device); - retval =driver_register (&giu_device_driver); + retval =platform_driver_register (&giu_device_driver);if (retval <0 )platform_device_unregister (giu_platform_device);
@@ -734,7 +735,7 @@ static int __devinit vr41xx_giu_init(voi static void __devexit vr41xx_giu_exit(void) { -driver_unregister (&giu_device_driver); +platform_driver_unregister (&giu_device_driver);platform_device_unregister (giu_platform_device); }
drivers/char/vr41xx_rtc.c +8 -9
@@ -560,13 +560,11 @@ .fops = &rtc_fops, }; -static int rtc_probe (struct device *dev) +static int rtc_probe (struct platform_device *pdev) { -struct platform_device *pdev;unsigned int irq;int retval; - pdev =to_platform_device (dev);if (pdev->num_resources !=2 )return -EBUSY ;
@@ -635,7 +633,7 @@return 0 ; } -static int rtc_remove (struct device *dev) +static int rtc_remove (struct platform_device *dev) {int retval;
@@ -655,11 +653,12 @@ static int rtc_remove(struct device *devstatic struct platform_device *rtc_platform_device; -static struct device_driver rtc_device_driver = { - .name = rtc_name, - .bus = &platform_bus_type, +static struct platform_driver rtc_device_driver = { .probe = rtc_probe, .remove = rtc_remove, + .driver = { + .name = rtc_name, + }, };static int __devinit vr41xx_rtc_init (void )
@@ -691,7 +690,7 @@ static int __devinit vr41xx_rtc_init(voiif (IS_ERR (rtc_platform_device))return PTR_ERR (rtc_platform_device); - retval =driver_register (&rtc_device_driver); + retval =platform_driver_register (&rtc_device_driver);if (retval <0 )platform_device_unregister (rtc_platform_device);
@@ -700,7 +699,7 @@ static int __devinit vr41xx_rtc_init(voi static void __devexit vr41xx_rtc_exit(void) { -driver_unregister (&rtc_device_driver); +platform_driver_unregister (&rtc_device_driver);platform_device_unregister (rtc_platform_device); }
drivers/char/watchdog/mv64x60_wdt.c +10 -10
@@ -182,10 +182,9 @@ .fops = &mv64x60_wdt_fops, }; -static int __devinit mv64x60_wdt_probe (struct device *dev) +static int __devinit mv64x60_wdt_probe (struct platform_device *dev) { -struct platform_device *pd =to_platform_device (dev); -struct mv64x60_wdt_pdata *pdata = pd->dev.platform_data; +struct mv64x60_wdt_pdata *pdata = dev->dev.platform_data;int bus_clk =133 ; mv64x60_wdt_timeout =10 ;
@@ -202,7 +201,7 @@return misc_register (&mv64x60_wdt_miscdev); } -static int __devexit mv64x60_wdt_remove(struct device *dev) +static int __devexit mv64x60_wdt_remove(struct platform_device *dev) {misc_deregister (&mv64x60_wdt_miscdev);
@@ -212,12 +211,13 @@ static int __devexit mv64x60_wdt_remove(return 0 ; } -static struct device_driver mv64x60_wdt_driver = { - .owner =THIS_MODULE , - .name = MV64x60_WDT_NAME, - .bus = &platform_bus_type, +static struct platform_driver mv64x60_wdt_driver = { .probe = mv64x60_wdt_probe, .remove =__devexit_p (mv64x60_wdt_remove), + .driver = { + .owner =THIS_MODULE , + .name = MV64x60_WDT_NAME, + }, };static struct platform_device *mv64x60_wdt_dev;
@@ -235,14 +235,14 @@ static int __init mv64x60_wdt_init(void) goto out; } - ret =driver_register (&mv64x60_wdt_driver); + ret =platform_driver_register (&mv64x60_wdt_driver); out:return ret; } static void __exit mv64x60_wdt_exit(void) { -driver_unregister (&mv64x60_wdt_driver); +platform_driver_unregister (&mv64x60_wdt_driver);platform_device_unregister (mv64x60_wdt_dev); }
drivers/char/watchdog/mpcore_wdt.c +15 -15
@@ -139,7 +139,7 @@*/ static int mpcore_wdt_open (struct inode *inode,struct file *file) { -struct mpcore_wdt *wdt =dev_get_drvdata (&mpcore_wdt_dev->dev); +struct mpcore_wdt *wdt =platform_get_drvdata (mpcore_wdt_dev);if (test_and_set_bit (0 , &wdt->timer_alive))return -EBUSY ;
@@ -291,9 +291,9 @@* System shutdown handler. Turn off the watchdog if we're * restarting or halting the system. */ -static void mpcore_wdt_shutdown (struct device *_dev) +static void mpcore_wdt_shutdown (struct platform_device *dev) { -struct mpcore_wdt *wdt =dev_get_drvdata (_dev); +struct mpcore_wdt *wdt =platform_get_drvdata (dev);if (system_state ==SYSTEM_RESTART || system_state ==SYSTEM_HALT )mpcore_wdt_stop (wdt);
@@ -317,9 +317,8 @@ .fops = &mpcore_wdt_fops, }; -static int __devinit mpcore_wdt_probe (struct device *_dev) +static int __devinit mpcore_wdt_probe (struct platform_device *dev) { -struct platform_device *dev =to_platform_device (_dev);struct mpcore_wdt *wdt;struct resource *res;int ret;
@@ -364,7 +363,7 @@ }mpcore_wdt_stop (wdt); -dev_set_drvdata (&dev->dev, wdt); +platform_set_drvdata (&dev->dev, wdt); mpcore_wdt_dev = dev;return 0 ;
@@ -379,11 +378,11 @@return ret; } -static int __devexit mpcore_wdt_remove(struct device *dev) +static int __devexit mpcore_wdt_remove(struct platform_device *dev) { -struct mpcore_wdt *wdt =dev_get_drvdata (dev); +struct mpcore_wdt *wdt =platform_get_drvdata (dev); -dev_set_drvdata (dev,NULL ); +platform_set_drvdata (dev,NULL );misc_deregister (&mpcore_wdt_miscdev);
@@ -395,13 +394,14 @@ static int __devexit mpcore_wdt_remove(sreturn 0 ; } -static struct device_driver mpcore_wdt_driver = { - .owner =THIS_MODULE , - .name ="mpcore_wdt" , - .bus = &platform_bus_type, +static struct platform_driver mpcore_wdt_driver = { .probe = mpcore_wdt_probe, .remove =__devexit_p (mpcore_wdt_remove), .shutdown = mpcore_wdt_shutdown, + .driver = { + .owner =THIS_MODULE , + .name ="mpcore_wdt" , + }, };static char banner[]__initdata =KERN_INFO "MPcore Watchdog Timer: 0.1. mpcore_noboot=%d mpcore_margin=%d sec (nowayout= %d)\n" ;
@@ -420,12 +420,12 @@ static int __init mpcore_wdt_init(void)printk (banner, mpcore_noboot, mpcore_margin, nowayout); -return driver_register (&mpcore_wdt_driver); +return platform_driver_register (&mpcore_wdt_driver); } static void __exit mpcore_wdt_exit(void) { -driver_unregister (&mpcore_wdt_driver); +platform_driver_unregister (&mpcore_wdt_driver); }module_init (mpcore_wdt_init);
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert drivers/misc/hdpuftrs
In reply to Russell KingConvert platform drivers to use struct platform_driver
drivers/misc/hdpuftrs/hdpu_cpustate.c +10 -10
@@ -27,8 +27,8 @@#define SKY_CPUSTATE_VERSION "1.1" -static int hdpu_cpustate_probe (struct device *ddev); -static int hdpu_cpustate_remove (struct device *ddev); +static int hdpu_cpustate_probe (struct platform_device *pdev); +static int hdpu_cpustate_remove (struct platform_device *pdev);struct cpustate_t cpustate;
@@ -159,11 +159,12 @@return len; } -static struct device_driver hdpu_cpustate_driver = { - .name =HDPU_CPUSTATE_NAME , - .bus = &platform_bus_type, +static struct platform_driver hdpu_cpustate_driver = { .probe = hdpu_cpustate_probe, .remove = hdpu_cpustate_remove, + .driver = { + .name =HDPU_CPUSTATE_NAME , + }, };/*
@@ -188,9 +189,8 @@ &cpustate_fops }; -static int hdpu_cpustate_probe (struct device *ddev) +static int hdpu_cpustate_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (ddev);struct resource *res;struct proc_dir_entry *proc_de;int ret;
@@ -218,7 +218,7 @@return 0 ; } -static int hdpu_cpustate_remove (struct device *ddev) +static int hdpu_cpustate_remove (struct platform_device *pdev) { cpustate.set_addr =NULL ;
@@ -233,13 +233,13 @@static int __init cpustate_init (void ) {int rc; - rc =driver_register (&hdpu_cpustate_driver); + rc =platform_driver_register (&hdpu_cpustate_driver);return rc; } static void __exit cpustate_exit(void) { -driver_unregister (&hdpu_cpustate_driver); +platform_driver_unregister (&hdpu_cpustate_driver); }module_init (cpustate_init);
drivers/misc/hdpuftrs/hdpu_nexus.c +10 -10
@@ -23,19 +23,20 @@#include <linux/platform_device.h> -static int hdpu_nexus_probe (struct device *ddev); -static int hdpu_nexus_remove (struct device *ddev); +static int hdpu_nexus_probe (struct platform_device *pdev); +static int hdpu_nexus_remove (struct platform_device *pdev);static struct proc_dir_entry *hdpu_slot_id;static struct proc_dir_entry *hdpu_chassis_id;static int slot_id =-1 ;static int chassis_id =-1 ; -static struct device_driver hdpu_nexus_driver = { - .name =HDPU_NEXUS_NAME , - .bus = &platform_bus_type, +static struct platform_driver hdpu_nexus_driver = { .probe = hdpu_nexus_probe, .remove = hdpu_nexus_remove, + .driver = { + .name =HDPU_NEXUS_NAME , + }, }; int hdpu_slot_id_read(char *buffer, char **buffer_location, off_t offset,
@@ -56,9 +57,8 @@return sprintf (buffer,"%d\n" , chassis_id); } -static int hdpu_nexus_probe (struct device *ddev) +static int hdpu_nexus_probe (struct platform_device *pdev) { -struct platform_device *pdev =to_platform_device (ddev);struct resource *res; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -81,7 +81,7 @@return 0 ; } -static int hdpu_nexus_remove (struct device *ddev) +static int hdpu_nexus_remove (struct platform_device *pdev) { slot_id =-1 ; chassis_id =-1 ;
@@ -95,13 +95,13 @@static int __init nexus_init (void ) {int rc; - rc =driver_register (&hdpu_nexus_driver); + rc =platform_driver_register (&hdpu_nexus_driver);return rc; } static void __exit nexus_exit(void) { -driver_unregister (&hdpu_nexus_driver); +platform_driver_unregister (&hdpu_nexus_driver); }module_init (nexus_init);
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core
Re: [DRIVER MODEL] Convert ALSA
In reply to Russell KingConvert platform drivers to use struct platform_driver
unchanged:
sound/core/init.c +4 -3
@@ -683,13 +683,14 @@#endif /* initialized in sound.c */ -struct device_driver snd_generic_driver = { - .name =SND_GENERIC_NAME , - .bus = &platform_bus_type, +struct platform_driver snd_generic_driver = { #ifdef CONFIG_PM .suspend = snd_generic_suspend, .resume = snd_generic_resume, #endif + .driver = { + .name =SND_GENERIC_NAME , + }, };void snd_generic_device_release (struct device *dev)
unchanged:
sound/core/sound.c +3 -3
@@ -329,7 +329,7 @@ int __exit snd_minor_info_done(void)*/ #ifdef CONFIG_SND_GENERIC_DRIVER -extern struct device_driver snd_generic_driver; +extern struct platform_driver snd_generic_driver;#endif static int __init alsa_sound_init (void )
@@ -359,7 +359,7 @@ static int __init alsa_sound_init(void) }snd_info_minor_register ();#ifdef CONFIG_SND_GENERIC_DRIVER -driver_register (&snd_generic_driver); +platform_driver_register (&snd_generic_driver);#endif for (controlnum =0 ; controlnum < cards_limit; controlnum++)devfs_mk_cdev (MKDEV (major, controlnum<<5 ),S_IFCHR | device_mode,"snd/controlC%d" , controlnum);
@@ -377,7 +377,7 @@ static void __exit alsa_sound_exit(void)devfs_remove ("snd/controlC%d" , controlnum);#ifdef CONFIG_SND_GENERIC_DRIVER -driver_unregister (&snd_generic_driver); +platform_driver_unregister (&snd_generic_driver);#endif snd_info_minor_unregister ();snd_info_done ();
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of: 2.6 Serial core