Commit 3ae5eaec authored by Russell King's avatar Russell King Committed by Russell King
Browse files

[DRIVER MODEL] Convert platform drivers to use struct platform_driver



This allows us to eliminate the casts in the drivers, and eventually
remove the use of the device_driver function pointer methods for
platform device drivers.
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 00d3dcdd
......@@ -550,9 +550,9 @@ struct locomo_save_data {
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 @@ static int locomo_suspend(struct device *dev, pm_message_t state)
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 @@ static int locomo_suspend(struct device *dev, pm_message_t state)
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 @@ static void __locomo_remove(struct locomo *lchip)
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 @@ static int locomo_remove(struct device *dev)
* 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 @@ static int __init locomo_init(void)
{
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);
}
......
......@@ -801,9 +801,9 @@ struct sa1111_save_data {
#ifdef CONFIG_PM
static int sa1111_suspend(struct device *dev, pm_message_t state)
static int sa1111_suspend(struct platform_device *dev, pm_message_t state)
{
struct sa1111 *sachip = dev_get_drvdata(dev);
struct sa1111 *sachip = platform_get_drvdata(dev);
struct sa1111_save_data *save;
unsigned long flags;
unsigned int val;
......@@ -812,7 +812,7 @@ static int sa1111_suspend(struct device *dev, pm_message_t state)
save = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
if (!save)
return -ENOMEM;
dev->power.saved_state = save;
dev->dev.power.saved_state = save;
spin_lock_irqsave(&sachip->lock, flags);
......@@ -859,14 +859,14 @@ static int sa1111_suspend(struct device *dev, pm_message_t state)
* restored by their respective drivers, and must be called
* via LDM after this function.
*/
static int sa1111_resume(struct device *dev)
static int sa1111_resume(struct platform_device *dev)
{
struct sa1111 *sachip = dev_get_drvdata(dev);
struct sa1111 *sachip = platform_get_drvdata(dev);
struct sa1111_save_data *save;
unsigned long flags, id;
void __iomem *base;
save = (struct sa1111_save_data *)dev->power.saved_state;
save = (struct sa1111_save_data *)dev->dev.power.saved_state;
if (!save)
return 0;
......@@ -879,7 +879,7 @@ static int sa1111_resume(struct device *dev)
id = sa1111_readl(sachip->base + SA1111_SKID);
if ((id & SKID_ID_MASK) != SKID_SA1111_ID) {
__sa1111_remove(sachip);
dev_set_drvdata(dev, NULL);
platform_set_drvdata(dev, NULL);
kfree(save);
return 0;
}
......@@ -911,7 +911,7 @@ static int sa1111_resume(struct device *dev)
spin_unlock_irqrestore(&sachip->lock, flags);
dev->power.saved_state = NULL;
dev->dev.power.saved_state = NULL;
kfree(save);
return 0;
......@@ -922,9 +922,8 @@ static int sa1111_resume(struct device *dev)
#define sa1111_resume NULL
#endif
static int sa1111_probe(struct device *dev)
static int sa1111_probe(struct platform_device *pdev)
{
struct platform_device *pdev = to_platform_device(dev);
struct resource *mem;
int irq;
......@@ -933,20 +932,20 @@ static int sa1111_probe(struct device *dev)
return -EINVAL;
irq = platform_get_irq(pdev, 0);
return __sa1111_probe(dev, mem, irq);
return __sa1111_probe(&pdev->dev, mem, irq);
}
static int sa1111_remove(struct device *dev)
static int sa1111_remove(struct platform_device *pdev)
{
struct sa1111 *sachip = dev_get_drvdata(dev);
struct sa1111 *sachip = platform_get_drvdata(pdev);
if (sachip) {
__sa1111_remove(sachip);
dev_set_drvdata(dev, NULL);
platform_set_drvdata(pdev, NULL);
#ifdef CONFIG_PM
kfree(dev->power.saved_state);
dev->power.saved_state = NULL;
kfree(pdev->dev.power.saved_state);
pdev->dev.power.saved_state = NULL;
#endif
}
......@@ -962,13 +961,14 @@ static int sa1111_remove(struct device *dev)
* We also need to handle the SDRAM configuration for
* PXA250/SA1110 machine classes.
*/
static struct device_driver sa1111_device_driver = {
.name = "sa1111",
.bus = &platform_bus_type,
static struct platform_driver sa1111_device_driver = {
.probe = sa1111_probe,
.remove = sa1111_remove,
.suspend = sa1111_suspend,
.resume = sa1111_resume,
.driver = {
.name = "sa1111",
},
};
/*
......@@ -1256,13 +1256,13 @@ static int __init sa1111_init(void)
{
int ret = bus_register(&sa1111_bus_type);
if (ret == 0)
driver_register(&sa1111_device_driver);
platform_driver_register(&sa1111_device_driver);
return ret;
}
static void __exit sa1111_exit(void)
{
driver_unregister(&sa1111_device_driver);
platform_driver_unregister(&sa1111_device_driver);
bus_unregister(&sa1111_bus_type);
}
......
......@@ -98,9 +98,9 @@ static void check_scoop_reg(struct scoop_dev *sdev)
}
#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);
......@@ -109,9 +109,9 @@ static int scoop_suspend(struct device *dev, pm_message_t state)
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;
......@@ -123,11 +123,10 @@ static int scoop_resume(struct device *dev)
#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)
......@@ -141,7 +140,7 @@ int __init scoop_probe(struct device *dev)
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) {
......@@ -149,7 +148,7 @@ int __init scoop_probe(struct device *dev)
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);
......@@ -164,29 +163,30 @@ int __init scoop_probe(struct device *dev)
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);
......@@ -191,7 +191,7 @@ void __init corgi_ssp_set_machinfo(struct corgissp_machinfo *machinfo)
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,13 +216,13 @@ static int __init corgi_ssp_probe(struct device *dev)
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;
}
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 @@ static int corgi_ssp_suspend(struct device *dev, pm_message_t state)
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 @@ static int corgi_ssp_resume(struct device *dev)
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);
......@@ -137,7 +137,7 @@ static struct sa1100_port_fns neponset_port_fns __initdata = {
.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 @@ static int neponset_probe(struct device *dev)
/*
* 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 @@ static int neponset_resume(struct device *dev)
#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 struct platform_device *devices[] __initdata = {
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.
......
......@@ -284,9 +284,10 @@ void uml_net_user_timer_expire(unsigned long _conn)
static 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;
......@@ -333,7 +334,7 @@ static int eth_configure(int n, void *init, char *mac,
/* sysfs register */
if (!driver_registered) {
driver_register(&uml_net_driver);
platform_driver_register(&uml_net_driver);
driver_registered = 1;
}
device->pdev.id = n;
......
......@@ -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;
......
......@@ -648,9 +648,10 @@ void iss_net_user_timer_expire(unsigned long _conn)
}
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, char *init)
/* sysfs register */
if (!driver_registered) {
driver_register(&iss_net_driver);
platform_driver_register(&iss_net_driver);
driver_registered = 1;
}
......
......@@ -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 device *dev, int en)
/* 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 device *dev, int en)
}
}
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 device *dev)
return 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 device *dev)
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 device *dev)
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 device *dev)