From 3ae5eaec1d2d9c0cf53745352e7d4b152810ba24 Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 9 Nov 2005 22:32:44 +0000 Subject: [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: Russell King Acked-by: Greg Kroah-Hartman --- drivers/mmc/pxamci.c | 42 +++++++++++++++++++++--------------------- drivers/mmc/wbsd.c | 27 ++++++++++++++------------- 2 files changed, 35 insertions(+), 34 deletions(-) (limited to 'drivers/mmc') diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c index f31e247b2cbe..ee8f8a0420d1 100644 --- a/drivers/mmc/pxamci.c +++ b/drivers/mmc/pxamci.c @@ -428,9 +428,8 @@ static irqreturn_t pxamci_detect_irq(int irq, void *devid, struct pt_regs *regs) 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 @@ static int pxamci_probe(struct device *dev) 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 @@ static int pxamci_probe(struct device *dev) 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 @@ static int pxamci_probe(struct device *dev) 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 @@ static int pxamci_probe(struct device *dev) 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 @@ static int pxamci_probe(struct device *dev) 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 @@ static int pxamci_remove(struct device *dev) 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 @@ static int pxamci_remove(struct device *dev) } #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 @@ static int pxamci_suspend(struct device *dev, pm_message_t state) 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 @@ static int pxamci_resume(struct device *dev) #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); diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c index e954b8354fef..ea23a31fac90 100644 --- a/drivers/mmc/wbsd.c +++ b/drivers/mmc/wbsd.c @@ -1932,14 +1932,14 @@ static void __devexit wbsd_shutdown(struct device* dev, int pnp) * 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 @@ static void __devexit wbsd_pnp_remove(struct pnp_dev * dev) #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 @@ static int wbsd_suspend(struct device *dev, pm_message_t state) 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 *dev) static 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"); -- cgit v1.2.2