2005-11-05 18:11:29

by Russell King

[permalink] [raw]
Subject: [DRIVER MODEL] Add platform_driver

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.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core


2005-11-05 18:13:05

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert arch/arm

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff -u b/arch/arm/common/locomo.c b/arch/arm/common/locomo.c
--- b/arch/arm/common/locomo.c
+++ b/arch/arm/common/locomo.c
@@ -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);
}

diff -u b/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
--- b/arch/arm/common/sa1111.c
+++ b/arch/arm/common/sa1111.c
@@ -801,9 +801,9 @@

#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 @@
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 @@
* 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 @@
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 @@

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 @@
#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 @@
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 @@
* 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 @@
{
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);
}

diff -u b/arch/arm/common/scoop.c b/arch/arm/common/scoop.c
--- b/arch/arm/common/scoop.c
+++ b/arch/arm/common/scoop.c
@@ -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);
diff -u b/arch/arm/mach-pxa/corgi_ssp.c b/arch/arm/mach-pxa/corgi_ssp.c
--- b/arch/arm/mach-pxa/corgi_ssp.c
+++ b/arch/arm/mach-pxa/corgi_ssp.c
@@ -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);
diff -u b/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c
--- b/arch/arm/mach-sa1100/neponset.c
+++ b/arch/arm/mach-sa1100/neponset.c
@@ -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.


--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:12:23

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Add platform_driver

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.

Signed-off-by: Russell King <[email protected]>

diff -u b/drivers/base/platform.c b/drivers/base/platform.c
--- b/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -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.
diff -u b/include/linux/platform_device.h b/include/linux/platform_device.h
--- b/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -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_ */


--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:13:53

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert arch/um/

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -285,9 +285,10 @@ void uml_net_user_timer_expire(unsigned
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;

@@ -334,7 +335,7 @@ static int eth_configure(int n, void *in

/* sysfs register */
if (!driver_registered) {
- driver_register(&uml_net_driver);
+ platform_driver_register(&uml_net_driver);
driver_registered = 1;
}
device->pdev.id = n;
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -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;


--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:14:20

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert arch/xtensa/

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

--- a/arch/xtensa/platform-iss/network.c
+++ b/arch/xtensa/platform-iss/network.c
@@ -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;
}



--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:15:26

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert ARM SA1100 drivers

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff -u b/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c
--- b/drivers/mfd/mcp-sa11x0.c
+++ b/drivers/mfd/mcp-sa11x0.c
@@ -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);
diff -u b/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c
--- b/drivers/mtd/maps/sa1100-flash.c
+++ b/drivers/mtd/maps/sa1100-flash.c
@@ -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);
diff -u b/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
--- b/drivers/net/irda/sa1100_ir.c
+++ b/drivers/net/irda/sa1100_ir.c
@@ -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);
diff -u b/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
--- b/drivers/serial/sa1100.c
+++ b/drivers/serial/sa1100.c
@@ -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);
}

diff -u b/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c
--- b/drivers/video/sa1100fb.c
+++ b/drivers/video/sa1100fb.c
@@ -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)


--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:14:55

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert ARM s3c2410 drivers

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff --git a/drivers/char/s3c2410-rtc.c b/drivers/char/s3c2410-rtc.c
--- a/drivers/char/s3c2410-rtc.c
+++ b/drivers/char/s3c2410-rtc.c
@@ -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 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 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 devi
return 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_delta

static 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[] = "S3C24
static 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);
diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c
--- a/drivers/char/watchdog/s3c2410_wdt.c
+++ b/drivers/char/watchdog/s3c2410_wdt.c
@@ -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 devic
return -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 devic
return 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 devi
return 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 d
static 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_I
static 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);
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -760,24 +760,23 @@ static void s3c24xx_i2c_free(struct s3c2
* called by the bus driver when a suitable device is found
*/

-static int s3c24xx_i2c_probe(struct device *dev)
+static int s3c24xx_i2c_probe(struct platform_device *pdev)
{
- struct platform_device *pdev = to_platform_device(dev);
struct s3c24xx_i2c *i2c = &s3c24xx_i2c;
struct resource *res;
int ret;

/* find the clock and enable it */

- i2c->dev = dev;
- i2c->clk = clk_get(dev, "i2c");
+ i2c->dev = &pdev->dev;
+ i2c->clk = clk_get(&pdev->dev, "i2c");
if (IS_ERR(i2c->clk)) {
- dev_err(dev, "cannot get clock\n");
+ dev_err(&pdev->dev, "cannot get clock\n");
ret = -ENOENT;
goto out;
}

- dev_dbg(dev, "clock source %p\n", i2c->clk);
+ dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk);

clk_use(i2c->clk);
clk_enable(i2c->clk);
@@ -786,7 +785,7 @@ static int s3c24xx_i2c_probe(struct devi

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res == NULL) {
- dev_err(dev, "cannot find IO resource\n");
+ dev_err(&pdev->dev, "cannot find IO resource\n");
ret = -ENOENT;
goto out;
}
@@ -795,7 +794,7 @@ static int s3c24xx_i2c_probe(struct devi
pdev->name);

if (i2c->ioarea == NULL) {
- dev_err(dev, "cannot request IO\n");
+ dev_err(&pdev->dev, "cannot request IO\n");
ret = -ENXIO;
goto out;
}
@@ -803,17 +802,17 @@ static int s3c24xx_i2c_probe(struct devi
i2c->regs = ioremap(res->start, (res->end-res->start)+1);

if (i2c->regs == NULL) {
- dev_err(dev, "cannot map IO\n");
+ dev_err(&pdev->dev, "cannot map IO\n");
ret = -ENXIO;
goto out;
}

- dev_dbg(dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res);
+ dev_dbg(&pdev->dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res);

/* setup info block for the i2c core */

i2c->adap.algo_data = i2c;
- i2c->adap.dev.parent = dev;
+ i2c->adap.dev.parent = &pdev->dev;

/* initialise the i2c controller */

@@ -827,7 +826,7 @@ static int s3c24xx_i2c_probe(struct devi

res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (res == NULL) {
- dev_err(dev, "cannot find IRQ\n");
+ dev_err(&pdev->dev, "cannot find IRQ\n");
ret = -ENOENT;
goto out;
}
@@ -836,23 +835,23 @@ static int s3c24xx_i2c_probe(struct devi
pdev->name, i2c);

if (ret != 0) {
- dev_err(dev, "cannot claim IRQ\n");
+ dev_err(&pdev->dev, "cannot claim IRQ\n");
goto out;
}

i2c->irq = res;

- dev_dbg(dev, "irq resource %p (%ld)\n", res, res->start);
+ dev_dbg(&pdev->dev, "irq resource %p (%ld)\n", res, res->start);

ret = i2c_add_adapter(&i2c->adap);
if (ret < 0) {
- dev_err(dev, "failed to add bus to i2c core\n");
+ dev_err(&pdev->dev, "failed to add bus to i2c core\n");
goto out;
}

- dev_set_drvdata(dev, i2c);
+ platform_set_drvdata(pdev, i2c);

- dev_info(dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id);
+ dev_info(&pdev->dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id);

out:
if (ret < 0)
@@ -866,22 +865,22 @@ static int s3c24xx_i2c_probe(struct devi
* called when device is removed from the bus
*/

-static int s3c24xx_i2c_remove(struct device *dev)
+static int s3c24xx_i2c_remove(struct platform_device *pdev)
{
- struct s3c24xx_i2c *i2c = dev_get_drvdata(dev);
+ struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);

if (i2c != NULL) {
s3c24xx_i2c_free(i2c);
- dev_set_drvdata(dev, NULL);
+ platform_set_drvdata(pdev, NULL);
}

return 0;
}

#ifdef CONFIG_PM
-static int s3c24xx_i2c_resume(struct device *dev)
+static int s3c24xx_i2c_resume(struct platform_device *dev)
{
- struct s3c24xx_i2c *i2c = dev_get_drvdata(dev);
+ struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);

if (i2c != NULL)
s3c24xx_i2c_init(i2c);
@@ -895,42 +894,44 @@ static int s3c24xx_i2c_resume(struct dev

/* device driver for platform bus bits */

-static struct device_driver s3c2410_i2c_driver = {
- .owner = THIS_MODULE,
- .name = "s3c2410-i2c",
- .bus = &platform_bus_type,
+static struct platform_driver s3c2410_i2c_driver = {
.probe = s3c24xx_i2c_probe,
.remove = s3c24xx_i2c_remove,
.resume = s3c24xx_i2c_resume,
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "s3c2410-i2c",
+ },
};

-static struct device_driver s3c2440_i2c_driver = {
- .owner = THIS_MODULE,
- .name = "s3c2440-i2c",
- .bus = &platform_bus_type,
+static struct platform_driver s3c2440_i2c_driver = {
.probe = s3c24xx_i2c_probe,
.remove = s3c24xx_i2c_remove,
.resume = s3c24xx_i2c_resume,
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "s3c2440-i2c",
+ },
};

static int __init i2c_adap_s3c_init(void)
{
int ret;

- ret = driver_register(&s3c2410_i2c_driver);
+ ret = platform_driver_register(&s3c2410_i2c_driver);
if (ret == 0) {
- ret = driver_register(&s3c2440_i2c_driver);
+ ret = platform_driver_register(&s3c2440_i2c_driver);
if (ret)
- driver_unregister(&s3c2410_i2c_driver);
+ platform_driver_unregister(&s3c2410_i2c_driver);
}

return ret;
}

static void __exit i2c_adap_s3c_exit(void)
{
- driver_unregister(&s3c2410_i2c_driver);
- driver_unregister(&s3c2440_i2c_driver);
+ platform_driver_unregister(&s3c2410_i2c_driver);
+ platform_driver_unregister(&s3c2440_i2c_driver);
}

module_init(i2c_adap_s3c_init);
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -124,14 +124,14 @@ static struct s3c2410_nand_info *s3c2410
return s3c2410_nand_mtd_toours(mtd)->info;
}

-static struct s3c2410_nand_info *to_nand_info(struct device *dev)
+static struct s3c2410_nand_info *to_nand_info(struct platform_device *dev)
{
- return dev_get_drvdata(dev);
+ return platform_get_drvdata(dev);
}

-static struct s3c2410_platform_nand *to_nand_plat(struct device *dev)
+static struct s3c2410_platform_nand *to_nand_plat(struct platform_device *dev)
{
- return dev->platform_data;
+ return dev->dev.platform_data;
}

/* timing calculations */
@@ -164,9 +164,9 @@ static int s3c2410_nand_calc_rate(int wa
/* controller setup */

static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,
- struct device *dev)
+ struct platform_device *pdev)
{
- struct s3c2410_platform_nand *plat = to_nand_plat(dev);
+ struct s3c2410_platform_nand *plat = to_nand_plat(pdev);
unsigned int tacls, twrph0, twrph1;
unsigned long clkrate = clk_get_rate(info->clk);
unsigned long cfg;
@@ -427,11 +427,11 @@ static void s3c2410_nand_write_buf(struc

/* device management functions */

-static int s3c2410_nand_remove(struct device *dev)
+static int s3c2410_nand_remove(struct platform_device *pdev)
{
- struct s3c2410_nand_info *info = to_nand_info(dev);
+ struct s3c2410_nand_info *info = to_nand_info(pdev);

- dev_set_drvdata(dev, NULL);
+ platform_set_drvdata(pdev, NULL);

if (info == NULL)
return 0;
@@ -559,10 +559,9 @@ static void s3c2410_nand_init_chip(struc
* nand layer to look for devices
*/

-static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
+static int s3c24xx_nand_probe(struct platform_device *pdev, int is_s3c2440)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct s3c2410_platform_nand *plat = to_nand_plat(dev);
+ struct s3c2410_platform_nand *plat = to_nand_plat(pdev);
struct s3c2410_nand_info *info;
struct s3c2410_nand_mtd *nmtd;
struct s3c2410_nand_set *sets;
@@ -572,7 +571,7 @@ static int s3c24xx_nand_probe(struct dev
int nr_sets;
int setno;

- pr_debug("s3c2410_nand_probe(%p)\n", dev);
+ pr_debug("s3c2410_nand_probe(%p)\n", pdev);

info = kmalloc(sizeof(*info), GFP_KERNEL);
if (info == NULL) {
@@ -582,14 +581,14 @@ static int s3c24xx_nand_probe(struct dev
}

memzero(info, sizeof(*info));
- dev_set_drvdata(dev, info);
+ platform_set_drvdata(pdev, info);

spin_lock_init(&info->controller.lock);
init_waitqueue_head(&info->controller.wq);

/* get the clock source and enable it */

- info->clk = clk_get(dev, "nand");
+ info->clk = clk_get(&pdev->dev, "nand");
if (IS_ERR(info->clk)) {
printk(KERN_ERR PFX "failed to get clock");
err = -ENOENT;
@@ -613,7 +612,7 @@ static int s3c24xx_nand_probe(struct dev
goto exit_error;
}

- info->device = dev;
+ info->device = &pdev->dev;
info->platform = plat;
info->regs = ioremap(res->start, size);
info->is_s3c2440 = is_s3c2440;
@@ -628,7 +627,7 @@ static int s3c24xx_nand_probe(struct dev

/* initialise the hardware */

- err = s3c2410_nand_inithw(info, dev);
+ err = s3c2410_nand_inithw(info, pdev);
if (err != 0)
goto exit_error;

@@ -674,7 +673,7 @@ static int s3c24xx_nand_probe(struct dev
return 0;

exit_error:
- s3c2410_nand_remove(dev);
+ s3c2410_nand_remove(pdev);

if (err == 0)
err = -EINVAL;
@@ -683,42 +682,44 @@ static int s3c24xx_nand_probe(struct dev

/* driver device registration */

-static int s3c2410_nand_probe(struct device *dev)
+static int s3c2410_nand_probe(struct platform_device *dev)
{
return s3c24xx_nand_probe(dev, 0);
}

-static int s3c2440_nand_probe(struct device *dev)
+static int s3c2440_nand_probe(struct platform_device *dev)
{
return s3c24xx_nand_probe(dev, 1);
}

-static struct device_driver s3c2410_nand_driver = {
- .name = "s3c2410-nand",
- .bus = &platform_bus_type,
+static struct platform_driver s3c2410_nand_driver = {
.probe = s3c2410_nand_probe,
.remove = s3c2410_nand_remove,
+ .driver = {
+ .name = "s3c2410-nand",
+ },
};

-static struct device_driver s3c2440_nand_driver = {
- .name = "s3c2440-nand",
- .bus = &platform_bus_type,
+static struct platform_driver s3c2440_nand_driver = {
.probe = s3c2440_nand_probe,
.remove = s3c2410_nand_remove,
+ .driver = {
+ .name = "s3c2440-nand",
+ },
};

static int __init s3c2410_nand_init(void)
{
printk("S3C24XX NAND Driver, (c) 2004 Simtec Electronics\n");

- driver_register(&s3c2440_nand_driver);
- return driver_register(&s3c2410_nand_driver);
+ platform_driver_register(&s3c2440_nand_driver);
+ return platform_driver_register(&s3c2410_nand_driver);
}

static void __exit s3c2410_nand_exit(void)
{
- driver_unregister(&s3c2440_nand_driver);
- driver_unregister(&s3c2410_nand_driver);
+ platform_driver_unregister(&s3c2440_nand_driver);
+ platform_driver_unregister(&s3c2410_nand_driver);
}

module_init(s3c2410_nand_init);
diff -u b/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
--- b/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -1092,14 +1092,13 @@

static int probe_index = 0;

-static int s3c24xx_serial_probe(struct device *_dev,
+static int s3c24xx_serial_probe(struct platform_device *dev,
struct s3c24xx_uart_info *info)
{
struct s3c24xx_uart_port *ourport;
- struct platform_device *dev = to_platform_device(_dev);
int ret;

- dbg("s3c24xx_serial_probe(%p, %p) %d\n", _dev, info, probe_index);
+ dbg("s3c24xx_serial_probe(%p, %p) %d\n", dev, info, probe_index);

ourport = &s3c24xx_serial_ports[probe_index];
probe_index++;
@@ -1112,7 +1111,7 @@

dbg("%s: adding port\n", __FUNCTION__);
uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
- dev_set_drvdata(_dev, &ourport->port);
+ platform_set_drvdata(dev, &ourport->port);

return 0;

@@ -1120,9 +1119,9 @@
return ret;
}

-static int s3c24xx_serial_remove(struct device *_dev)
+static int s3c24xx_serial_remove(struct platform_device *dev)
{
- struct uart_port *port = s3c24xx_dev_to_port(_dev);
+ struct uart_port *port = s3c24xx_dev_to_port(&dev->dev);

if (port)
uart_remove_one_port(&s3c24xx_uart_drv, port);
@@ -1134,9 +1133,9 @@

#ifdef CONFIG_PM

-static int s3c24xx_serial_suspend(struct device *dev, pm_message_t state)
+static int s3c24xx_serial_suspend(struct platform_device *dev, pm_message_t state)
{
- struct uart_port *port = s3c24xx_dev_to_port(dev);
+ struct uart_port *port = s3c24xx_dev_to_port(&dev->dev);

if (port)
uart_suspend_port(&s3c24xx_uart_drv, port);
@@ -1144,9 +1143,9 @@
return 0;
}

-static int s3c24xx_serial_resume(struct device *dev)
+static int s3c24xx_serial_resume(struct platform_device *dev)
{
- struct uart_port *port = s3c24xx_dev_to_port(dev);
+ struct uart_port *port = s3c24xx_dev_to_port(&dev->dev);
struct s3c24xx_uart_port *ourport = to_ourport(port);

if (port) {
@@ -1165,11 +1164,11 @@
#define s3c24xx_serial_resume NULL
#endif

-static int s3c24xx_serial_init(struct device_driver *drv,
+static int s3c24xx_serial_init(struct platform_driver *drv,
struct s3c24xx_uart_info *info)
{
dbg("s3c24xx_serial_init(%p,%p)\n", drv, info);
- return driver_register(drv);
+ return platform_driver_register(drv);
}


@@ -1228,19 +1227,20 @@
.reset_port = s3c2400_serial_resetport,
};

-static int s3c2400_serial_probe(struct device *dev)
+static int s3c2400_serial_probe(struct platform_device *dev)
{
return s3c24xx_serial_probe(dev, &s3c2400_uart_inf);
}

-static struct device_driver s3c2400_serial_drv = {
- .name = "s3c2400-uart",
- .owner = THIS_MODULE,
- .bus = &platform_bus_type,
+static struct platform_driver s3c2400_serial_drv = {
.probe = s3c2400_serial_probe,
.remove = s3c24xx_serial_remove,
.suspend = s3c24xx_serial_suspend,
.resume = s3c24xx_serial_resume,
+ .driver = {
+ .name = "s3c2400-uart",
+ .owner = THIS_MODULE,
+ },
};

static inline int s3c2400_serial_init(void)
@@ -1250,7 +1250,7 @@

static inline void s3c2400_serial_exit(void)
{
- driver_unregister(&s3c2400_serial_drv);
+ platform_driver_unregister(&s3c2400_serial_drv);
}

#define s3c2400_uart_inf_at &s3c2400_uart_inf
@@ -1332,19 +1332,20 @@

/* device management */

-static int s3c2410_serial_probe(struct device *dev)
+static int s3c2410_serial_probe(struct platform_device *dev)
{
return s3c24xx_serial_probe(dev, &s3c2410_uart_inf);
}

-static struct device_driver s3c2410_serial_drv = {
- .name = "s3c2410-uart",
- .owner = THIS_MODULE,
- .bus = &platform_bus_type,
+static struct platform_driver s3c2410_serial_drv = {
.probe = s3c2410_serial_probe,
.remove = s3c24xx_serial_remove,
.suspend = s3c24xx_serial_suspend,
.resume = s3c24xx_serial_resume,
+ .driver = {
+ .name = "s3c2410-uart",
+ .owner = THIS_MODULE,
+ },
};

static inline int s3c2410_serial_init(void)
@@ -1354,7 +1355,7 @@

static inline void s3c2410_serial_exit(void)
{
- driver_unregister(&s3c2410_serial_drv);
+ platform_driver_unregister(&s3c2410_serial_drv);
}

#define s3c2410_uart_inf_at &s3c2410_uart_inf
@@ -1493,20 +1494,21 @@

/* device management */

-static int s3c2440_serial_probe(struct device *dev)
+static int s3c2440_serial_probe(struct platform_device *dev)
{
dbg("s3c2440_serial_probe: dev=%p\n", dev);
return s3c24xx_serial_probe(dev, &s3c2440_uart_inf);
}

-static struct device_driver s3c2440_serial_drv = {
- .name = "s3c2440-uart",
- .owner = THIS_MODULE,
- .bus = &platform_bus_type,
+static struct platform_driver s3c2440_serial_drv = {
.probe = s3c2440_serial_probe,
.remove = s3c24xx_serial_remove,
.suspend = s3c24xx_serial_suspend,
.resume = s3c24xx_serial_resume,
+ .driver = {
+ .name = "s3c2440-uart",
+ .owner = THIS_MODULE,
+ },
};


@@ -1517,7 +1519,7 @@

static inline void s3c2440_serial_exit(void)
{
- driver_unregister(&s3c2440_serial_drv);
+ platform_driver_unregister(&s3c2440_serial_drv);
}

#define s3c2440_uart_inf_at &s3c2440_uart_inf
diff -u b/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
--- b/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -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(s
return 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);
diff -u b/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c
--- b/drivers/video/s3c2410fb.c
+++ b/drivers/video/s3c2410fb.c
@@ -635,19 +635,18 @@ static irqreturn_t s3c2410fb_irq(int irq

static char driver_name[]="s3c2410fb";

-int __init s3c2410fb_probe(struct device *dev)
+int __init s3c2410fb_probe(struct platform_device *pdev)
{
struct s3c2410fb_info *info;
struct fb_info *fbinfo;
- struct platform_device *pdev = to_platform_device(dev);
struct s3c2410fb_hw *mregs;
int ret;
int irq;
int i;

- mach_info = dev->platform_data;
+ mach_info = pdev->dev.platform_data;
if (mach_info == NULL) {
- dev_err(dev,"no platform data for lcd, cannot attach\n");
+ dev_err(&pdev->dev,"no platform data for lcd, cannot attach\n");
return -EINVAL;
}

@@ -655,11 +654,11 @@ int __init s3c2410fb_probe(struct device

irq = platform_get_irq(pdev, 0);
if (irq < 0) {
- dev_err(dev, "no irq for device\n");
+ dev_err(&pdev->dev, "no irq for device\n");
return -ENOENT;
}

- fbinfo = framebuffer_alloc(sizeof(struct s3c2410fb_info), dev);
+ fbinfo = framebuffer_alloc(sizeof(struct s3c2410fb_info), &pdev->dev);
if (!fbinfo) {
return -ENOMEM;
}
@@ -667,7 +666,7 @@

info = fbinfo->par;
info->fb = fbinfo;
- dev_set_drvdata(dev, fbinfo);
+ platform_set_drvdata(pdev, fbinfo);

s3c2410fb_init_registers(info);

@@ -677,7 +676,7 @@

memcpy(&info->regs, &mach_info->regs, sizeof(info->regs));

- info->mach_info = dev->platform_data;
+ info->mach_info = pdev->dev.platform_data;

fbinfo->fix.type = FB_TYPE_PACKED_PIXELS;
fbinfo->fix.type_aux = 0;
@@ -736,7 +735,7 @@ int __init s3c2410fb_probe(struct device

ret = request_irq(irq, s3c2410fb_irq, SA_INTERRUPT, pdev->name, info);
if (ret) {
- dev_err(dev, "cannot get irq %d - err %d\n", irq, ret);
+ dev_err(&pdev->dev, "cannot get irq %d - err %d\n", irq, ret);
ret = -EBUSY;
goto release_mem;
}
@@ -774,7 +773,7 @@
}

/* create device files */
- device_create_file(dev, &dev_attr_debug);
+ device_create_file(&pdev->dev, &dev_attr_debug);

printk(KERN_INFO "fb%d: %s frame buffer device\n",
fbinfo->node, fbinfo->fix.id);
@@ -817,10 +816,9 @@
/*
* Cleanup
*/
-static int s3c2410fb_remove(struct device *dev)
+static int s3c2410fb_remove(struct platform_device *pdev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct fb_info *fbinfo = dev_get_drvdata(dev);
+ struct fb_info *fbinfo = platform_get_drvdata(pdev);
struct s3c2410fb_info *info = fbinfo->par;
int irq;

@@ -848,9 +846,9 @@

/* suspend and resume support for the lcd controller */

-static int s3c2410fb_suspend(struct device *dev, pm_message_t state)
+static int s3c2410fb_suspend(struct platform_device *dev, pm_message_t state)
{
- struct fb_info *fbinfo = dev_get_drvdata(dev);
+ struct fb_info *fbinfo = platform_get_drvdata(dev);
struct s3c2410fb_info *info = fbinfo->par;

s3c2410fb_stop_lcd();
@@ -865,9 +863,9 @@
return 0;
}

-static int s3c2410fb_resume(struct device *dev)
+static int s3c2410fb_resume(struct platform_device *dev)
{
- struct fb_info *fbinfo = dev_get_drvdata(dev);
+ struct fb_info *fbinfo = platform_get_drvdata(dev);
struct s3c2410fb_info *info = fbinfo->par;

clk_enable(info->clk);
@@ -883,23 +881,24 @@ static int s3c2410fb_resume(struct devic
#define s3c2410fb_resume NULL
#endif

-static struct device_driver s3c2410fb_driver = {
- .name = "s3c2410-lcd",
- .bus = &platform_bus_type,
+static struct platform_driver s3c2410fb_driver = {
.probe = s3c2410fb_probe,
+ .remove = s3c2410fb_remove,
.suspend = s3c2410fb_suspend,
.resume = s3c2410fb_resume,
- .remove = s3c2410fb_remove
+ .driver = {
+ .name = "s3c2410-lcd",
+ },
};

int __devinit s3c2410fb_init(void)
{
- return driver_register(&s3c2410fb_driver);
+ return platform_driver_register(&s3c2410fb_driver);
}

static void __exit s3c2410fb_cleanup(void)
{
- driver_unregister(&s3c2410fb_driver);
+ platform_driver_unregister(&s3c2410fb_driver);
}



--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:15:52

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert ARM PXA drivers

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff -u b/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c
--- b/drivers/mmc/pxamci.c
+++ b/drivers/mmc/pxamci.c
@@ -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);
diff -u b/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
--- b/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -2433,7 +2433,7 @@
/*
* probe - binds to the platform device
*/
-static int __init pxa2xx_udc_probe(struct device *_dev)
+static int __init pxa2xx_udc_probe(struct platform_device *pdev)
{
struct pxa2xx_udc *dev = &memory;
int retval, out_dma = 1;
@@ -2496,19 +2496,19 @@
#endif

/* other non-static parts of init */
- dev->dev = _dev;
- dev->mach = _dev->platform_data;
+ dev->dev = &pdev->dev;
+ dev->mach = pdev->dev.platform_data;

init_timer(&dev->timer);
dev->timer.function = udc_watchdog;
dev->timer.data = (unsigned long) dev;

device_initialize(&dev->gadget.dev);
- dev->gadget.dev.parent = _dev;
- dev->gadget.dev.dma_mask = _dev->dma_mask;
+ dev->gadget.dev.parent = &pdev->dev;
+ dev->gadget.dev.dma_mask = pdev->dev.dma_mask;

the_controller = dev;
- dev_set_drvdata(_dev, dev);
+ platform_set_drvdata(pdev, dev);

udc_disable(dev);
udc_reinit(dev);
@@ -2560,7 +2560,7 @@
return 0;
}

-static void pxa2xx_udc_shutdown(struct device *_dev)
+static void pxa2xx_udc_shutdown(struct platform_device *_dev)
{
pullup_off();
}
@@ -2565,9 +2565,9 @@
pullup_off();
}

-static int __exit pxa2xx_udc_remove(struct device *_dev)
+static int __exit pxa2xx_udc_remove(struct platform_device *pdev)
{
- struct pxa2xx_udc *dev = dev_get_drvdata(_dev);
+ struct pxa2xx_udc *dev = platform_get_drvdata(pdev);

udc_disable(dev);
remove_proc_files();
@@ -2581,7 +2581,7 @@
free_irq(LUBBOCK_USB_DISC_IRQ, dev);
free_irq(LUBBOCK_USB_IRQ, dev);
}
- dev_set_drvdata(_dev, NULL);
+ platform_set_drvdata(pdev, NULL);
the_controller = NULL;
return 0;
}
@@ -2602,9 +2602,9 @@
* VBUS IRQs should probably be ignored so that the PXA device just acts
* "dead" to USB hosts until system resume.
*/
-static int pxa2xx_udc_suspend(struct device *dev, pm_message_t state)
+static int pxa2xx_udc_suspend(struct platform_device *dev, pm_message_t state)
{
- struct pxa2xx_udc *udc = dev_get_drvdata(dev);
+ struct pxa2xx_udc *udc = platform_get_drvdata(dev);

if (!udc->mach->udc_command)
WARN("USB host won't detect disconnect!\n");
@@ -2613,9 +2613,9 @@
return 0;
}

-static int pxa2xx_udc_resume(struct device *dev)
+static int pxa2xx_udc_resume(struct platform_device *dev)
{
- struct pxa2xx_udc *udc = dev_get_drvdata(dev);
+ struct pxa2xx_udc *udc = platform_get_drvdata(dev);

pullup(udc, 1);

@@ -2629,27 +2629,28 @@

/*-------------------------------------------------------------------------*/

-static struct device_driver udc_driver = {
- .name = "pxa2xx-udc",
- .owner = THIS_MODULE,
- .bus = &platform_bus_type,
+static struct platform_driver udc_driver = {
.probe = pxa2xx_udc_probe,
.shutdown = pxa2xx_udc_shutdown,
.remove = __exit_p(pxa2xx_udc_remove),
.suspend = pxa2xx_udc_suspend,
.resume = pxa2xx_udc_resume,
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "pxa2xx-udc",
+ },
};

static int __init udc_init(void)
{
printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION);
- return driver_register(&udc_driver);
+ return platform_driver_register(&udc_driver);
}
module_init(udc_init);

static void __exit udc_exit(void)
{
- driver_unregister(&udc_driver);
+ platform_driver_unregister(&udc_driver);
}
module_exit(udc_exit);

diff -u b/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
--- b/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -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);
diff -u b/drivers/video/pxafb.c b/drivers/video/pxafb.c
--- b/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -981,17 +981,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 pxafb_suspend(struct device *dev, pm_message_t state)
+static int pxafb_suspend(struct platform_device *dev, pm_message_t state)
{
- struct pxafb_info *fbi = dev_get_drvdata(dev);
+ struct pxafb_info *fbi = platform_get_drvdata(dev);

set_ctrlr_state(fbi, C_DISABLE_PM);
return 0;
}

-static int pxafb_resume(struct device *dev)
+static int pxafb_resume(struct platform_device *dev)
{
- struct pxafb_info *fbi = dev_get_drvdata(dev);
+ struct pxafb_info *fbi = platform_get_drvdata(dev);

set_ctrlr_state(fbi, C_ENABLE_PM);
return 0;
@@ -1269,7 +1269,7 @@
}
#endif

-int __init pxafb_probe(struct device *dev)
+int __init pxafb_probe(struct platform_device *dev)
{
struct pxafb_info *fbi;
struct pxafb_mach_info *inf;
@@ -1277,14 +1277,14 @@

dev_dbg(dev, "pxafb_probe\n");

- inf = dev->platform_data;
+ inf = dev->dev.platform_data;
ret = -ENOMEM;
fbi = NULL;
if (!inf)
goto failed;

#ifdef CONFIG_FB_PXA_PARAMETERS
- ret = pxafb_parse_options(dev, g_options);
+ ret = pxafb_parse_options(&dev->dev, g_options);
if (ret < 0)
goto failed;
#endif
@@ -1294,28 +1294,28 @@
* a warning is given. */

if (inf->lccr0 & LCCR0_INVALID_CONFIG_MASK)
- dev_warn(dev, "machine LCCR0 setting contains illegal bits: %08x\n",
+ dev_warn(&dev->dev, "machine LCCR0 setting contains illegal bits: %08x\n",
inf->lccr0 & LCCR0_INVALID_CONFIG_MASK);
if (inf->lccr3 & LCCR3_INVALID_CONFIG_MASK)
- dev_warn(dev, "machine LCCR3 setting contains illegal bits: %08x\n",
+ dev_warn(&dev->dev, "machine LCCR3 setting contains illegal bits: %08x\n",
inf->lccr3 & LCCR3_INVALID_CONFIG_MASK);
if (inf->lccr0 & LCCR0_DPD &&
((inf->lccr0 & LCCR0_PAS) != LCCR0_Pas ||
(inf->lccr0 & LCCR0_SDS) != LCCR0_Sngl ||
(inf->lccr0 & LCCR0_CMS) != LCCR0_Mono))
- dev_warn(dev, "Double Pixel Data (DPD) mode is only valid in passive mono"
+ dev_warn(&dev->dev, "Double Pixel Data (DPD) mode is only valid in passive mono"
" single panel mode\n");
if ((inf->lccr0 & LCCR0_PAS) == LCCR0_Act &&
(inf->lccr0 & LCCR0_SDS) == LCCR0_Dual)
- dev_warn(dev, "Dual panel only valid in passive mode\n");
+ dev_warn(&dev->dev, "Dual panel only valid in passive mode\n");
if ((inf->lccr0 & LCCR0_PAS) == LCCR0_Pas &&
(inf->upper_margin || inf->lower_margin))
- dev_warn(dev, "Upper and lower margins must be 0 in passive mode\n");
+ dev_warn(&dev->dev, "Upper and lower margins must be 0 in passive mode\n");
#endif

- dev_dbg(dev, "got a %dx%dx%d LCD\n",inf->xres, inf->yres, inf->bpp);
+ dev_dbg(&dev->dev, "got a %dx%dx%d LCD\n",inf->xres, inf->yres, inf->bpp);
if (inf->xres == 0 || inf->yres == 0 || inf->bpp == 0) {
- dev_err(dev, "Invalid resolution or bit depth\n");
+ dev_err(&dev->dev, "Invalid resolution or bit depth\n");
ret = -EINVAL;
goto failed;
}
@@ -1321,9 +1321,9 @@
}
pxafb_backlight_power = inf->pxafb_backlight_power;
pxafb_lcd_power = inf->pxafb_lcd_power;
- fbi = pxafb_init_fbinfo(dev);
+ fbi = pxafb_init_fbinfo(&dev->dev);
if (!fbi) {
- dev_err(dev, "Failed to initialize framebuffer device\n");
+ dev_err(&dev->dev, "Failed to initialize framebuffer device\n");
ret = -ENOMEM; // only reason for pxafb_init_fbinfo to fail is kmalloc
goto failed;
}
@@ -1331,14 +1331,14 @@
/* Initialize video memory */
ret = pxafb_map_video_memory(fbi);
if (ret) {
- dev_err(dev, "Failed to allocate video RAM: %d\n", ret);
+ dev_err(&dev->dev, "Failed to allocate video RAM: %d\n", ret);
ret = -ENOMEM;
goto failed;
}

ret = request_irq(IRQ_LCD, pxafb_handle_irq, SA_INTERRUPT, "LCD", fbi);
if (ret) {
- dev_err(dev, "request_irq failed: %d\n", ret);
+ dev_err(&dev->dev, "request_irq failed: %d\n", ret);
ret = -EBUSY;
goto failed;
}
@@ -1350,11 +1350,11 @@
pxafb_check_var(&fbi->fb.var, &fbi->fb);
pxafb_set_par(&fbi->fb);

- dev_set_drvdata(dev, fbi);
+ platform_set_drvdata(dev, fbi);

ret = register_framebuffer(&fbi->fb);
if (ret < 0) {
- dev_err(dev, "Failed to register framebuffer device: %d\n", ret);
+ dev_err(&dev->dev, "Failed to register framebuffer device: %d\n", ret);
goto failed;
}

@@ -1377,19 +1377,20 @@
return 0;

failed:
- dev_set_drvdata(dev, NULL);
+ platform_set_drvdata(dev, NULL);
kfree(fbi);
return ret;
}

-static struct device_driver pxafb_driver = {
- .name = "pxa2xx-fb",
- .bus = &platform_bus_type,
+static struct platform_driver pxafb_driver = {
.probe = pxafb_probe,
#ifdef CONFIG_PM
.suspend = pxafb_suspend,
.resume = pxafb_resume,
#endif
+ .driver = {
+ .name = "pxa2xx-fb",
+ },
};

#ifndef MODULE
@@ -1416,7 +1417,7 @@
return -ENODEV;
pxafb_setup(option);
#endif
- return driver_register(&pxafb_driver);
+ return platform_driver_register(&pxafb_driver);
}

module_init(pxafb_init);
diff -u b/sound/arm/pxa2xx-ac97.c b/sound/arm/pxa2xx-ac97.c
--- b/sound/arm/pxa2xx-ac97.c
+++ b/sound/arm/pxa2xx-ac97.c
@@ -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);


--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:16:35

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert ARM OMAP drivers

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c
--- a/drivers/i2c/chips/isp1301_omap.c
+++ b/drivers/i2c/chips/isp1301_omap.c
@@ -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;
}

diff -u b/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
--- b/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2707,18 +2707,17 @@
return 0;
}

-static int __init omap_udc_probe(struct device *dev)
+static int __init omap_udc_probe(struct platform_device *pdev)
{
- struct platform_device *odev = to_platform_device(dev);
int status = -ENODEV;
int hmc;
struct otg_transceiver *xceiv = NULL;
const char *type = NULL;
- struct omap_usb_config *config = dev->platform_data;
+ struct omap_usb_config *config = pdev->dev.platform_data;

/* NOTE: "knows" the order of the resources! */
- if (!request_mem_region(odev->resource[0].start,
- odev->resource[0].end - odev->resource[0].start + 1,
+ if (!request_mem_region(pdev->resource[0].start,
+ pdev->resource[0].end - pdev->resource[0].start + 1,
driver_name)) {
DBG("request_mem_region failed\n");
return -EBUSY;
@@ -2803,7 +2802,7 @@
INFO("hmc mode %d, %s transceiver\n", hmc, type);

/* a "gadget" abstracts/virtualizes the controller */
- status = omap_udc_setup(odev, xceiv);
+ status = omap_udc_setup(pdev, xceiv);
if (status) {
goto cleanup0;
}
@@ -2821,28 +2820,28 @@
udc->clr_halt = UDC_RESET_EP;

/* USB general purpose IRQ: ep0, state changes, dma, etc */
- status = request_irq(odev->resource[1].start, omap_udc_irq,
+ status = request_irq(pdev->resource[1].start, omap_udc_irq,
SA_SAMPLE_RANDOM, driver_name, udc);
if (status != 0) {
ERR( "can't get irq %ld, err %d\n",
- odev->resource[1].start, status);
+ pdev->resource[1].start, status);
goto cleanup1;
}

/* USB "non-iso" IRQ (PIO for all but ep0) */
- status = request_irq(odev->resource[2].start, omap_udc_pio_irq,
+ status = request_irq(pdev->resource[2].start, omap_udc_pio_irq,
SA_SAMPLE_RANDOM, "omap_udc pio", udc);
if (status != 0) {
ERR( "can't get irq %ld, err %d\n",
- odev->resource[2].start, status);
+ pdev->resource[2].start, status);
goto cleanup2;
}
#ifdef USE_ISO
- status = request_irq(odev->resource[3].start, omap_udc_iso_irq,
+ status = request_irq(pdev->resource[3].start, omap_udc_iso_irq,
SA_INTERRUPT, "omap_udc iso", udc);
if (status != 0) {
ERR("can't get irq %ld, err %d\n",
- odev->resource[3].start, status);
+ pdev->resource[3].start, status);
goto cleanup3;
}
#endif
@@ -2853,11 +2852,11 @@

#ifdef USE_ISO
cleanup3:
- free_irq(odev->resource[2].start, udc);
+ free_irq(pdev->resource[2].start, udc);
#endif

cleanup2:
- free_irq(odev->resource[1].start, udc);
+ free_irq(pdev->resource[1].start, udc);

cleanup1:
kfree (udc);
@@ -2866,14 +2865,13 @@
cleanup0:
if (xceiv)
put_device(xceiv->dev);
- release_mem_region(odev->resource[0].start,
- odev->resource[0].end - odev->resource[0].start + 1);
+ release_mem_region(pdev->resource[0].start,
+ pdev->resource[0].end - pdev->resource[0].start + 1);
return status;
}

-static int __exit omap_udc_remove(struct device *dev)
+static int __exit omap_udc_remove(struct platform_device *pdev)
{
- struct platform_device *odev = to_platform_device(dev);
DECLARE_COMPLETION(done);

if (!udc)
@@ -2891,13 +2889,13 @@
remove_proc_file();

#ifdef USE_ISO
- free_irq(odev->resource[3].start, udc);
+ free_irq(pdev->resource[3].start, udc);
#endif
- free_irq(odev->resource[2].start, udc);
- free_irq(odev->resource[1].start, udc);
+ free_irq(pdev->resource[2].start, udc);
+ free_irq(pdev->resource[1].start, udc);

- release_mem_region(odev->resource[0].start,
- odev->resource[0].end - odev->resource[0].start + 1);
+ release_mem_region(pdev->resource[0].start,
+ pdev->resource[0].end - pdev->resource[0].start + 1);

device_unregister(&udc->gadget.dev);
wait_for_completion(&done);
@@ -2915,7 +2913,7 @@
* may involve talking to an external transceiver (e.g. isp1301).
*/

-static int omap_udc_suspend(struct device *dev, pm_message_t message)
+static int omap_udc_suspend(struct platform_device *dev, pm_message_t message)
{
u32 devstat;

@@ -2935,7 +2933,7 @@
return 0;
}

-static int omap_udc_resume(struct device *dev)
+static int omap_udc_resume(struct platform_device *dev)
{
DBG("resume + wakeup/SRP\n");
omap_pullup(&udc->gadget, 1);
@@ -2947,14 +2945,15 @@

/*-------------------------------------------------------------------------*/

-static struct device_driver udc_driver = {
- .name = (char *) driver_name,
- .owner = THIS_MODULE,
- .bus = &platform_bus_type,
+static struct platform_driver udc_driver = {
.probe = omap_udc_probe,
.remove = __exit_p(omap_udc_remove),
.suspend = omap_udc_suspend,
.resume = omap_udc_resume,
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = (char *) driver_name,
+ },
};

static int __init udc_init(void)
@@ -2965,13 +2964,13 @@
#endif
"%s\n", driver_desc,
use_dma ? " (dma)" : "");
- return driver_register(&udc_driver);
+ return platform_driver_register(&udc_driver);
}
module_init(udc_init);

static void __exit udc_exit(void)
{
- driver_unregister(&udc_driver);
+ platform_driver_unregister(&udc_driver);
}
module_exit(udc_exit);

diff -u b/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
--- b/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -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);


--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:16:07

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert ARM IMX drivers

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff -u b/drivers/serial/imx.c b/drivers/serial/imx.c
--- b/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -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);

diff -u b/drivers/video/imxfb.c b/drivers/video/imxfb.c
--- b/drivers/video/imxfb.c
+++ b/drivers/video/imxfb.c
@@ -424,18 +424,18 @@
* Power management hooks. Note that we won't be called from IRQ context,
* unlike the blank functions above, so we may sleep.
*/
-static int imxfb_suspend(struct device *dev, pm_message_t state)
+static int imxfb_suspend(struct platform_device *dev, pm_message_t state)
{
- struct imxfb_info *fbi = dev_get_drvdata(dev);
+ struct imxfb_info *fbi = platform_get_drvdata(dev);
pr_debug("%s\n",__FUNCTION__);

imxfb_disable_controller(fbi);
return 0;
}

-static int imxfb_resume(struct device *dev)
+static int imxfb_resume(struct platform_device *dev)
{
- struct imxfb_info *fbi = dev_get_drvdata(dev);
+ struct imxfb_info *fbi = platform_get_drvdata(dev);
pr_debug("%s\n",__FUNCTION__);

imxfb_enable_controller(fbi);
@@ -539,9 +539,8 @@
return fbi->map_cpu ? 0 : -ENOMEM;
}

-static int __init imxfb_probe(struct device *dev)
+static int __init imxfb_probe(struct platform_device *pdev)
{
- struct platform_device *pdev = to_platform_device(dev);
struct imxfb_info *fbi;
struct fb_info *info;
struct imxfb_mach_info *inf;
@@ -554,21 +553,21 @@
if(!res)
return -ENODEV;

- inf = dev->platform_data;
+ inf = pdev->dev.platform_data;
if(!inf) {
dev_err(dev,"No platform_data available\n");
return -ENOMEM;
}

- info = framebuffer_alloc(sizeof(struct imxfb_info), dev);
+ info = framebuffer_alloc(sizeof(struct imxfb_info), &pdev->dev);
if(!info)
return -ENOMEM;

fbi = info->par;

- dev_set_drvdata(dev, info);
+ platform_set_drvdata(pdev, info);

- ret = imxfb_init_fbinfo(dev);
+ ret = imxfb_init_fbinfo(&pdev->dev);
if( ret < 0 )
goto failed_init;

@@ -622,22 +621,21 @@
fb_dealloc_cmap(&info->cmap);
failed_cmap:
if (!inf->fixed_screen_cpu)
- dma_free_writecombine(dev,fbi->map_size,fbi->map_cpu,
+ dma_free_writecombine(&pdev->dev,fbi->map_size,fbi->map_cpu,
fbi->map_dma);
failed_map:
kfree(info->pseudo_palette);
failed_regs:
release_mem_region(res->start, res->end - res->start);
failed_init:
- dev_set_drvdata(dev, NULL);
+ platform_set_drvdata(pdev, NULL);
framebuffer_release(info);
return ret;
}

-static int imxfb_remove(struct device *dev)
+static int imxfb_remove(struct platform_device *pdev)
{
- struct platform_device *pdev = to_platform_device(dev);
- struct fb_info *info = dev_get_drvdata(dev);
+ struct fb_info *info = platform_get_drvdata(pdev);
struct imxfb_info *fbi = info->par;
struct resource *res;

@@ -652,14 +650,14 @@
framebuffer_release(info);

release_mem_region(res->start, res->end - res->start + 1);
- dev_set_drvdata(dev, NULL);
+ platform_set_drvdata(pdev, NULL);

return 0;
}

-void imxfb_shutdown(struct device * dev)
+void imxfb_shutdown(struct platform_device * dev)
{
- struct fb_info *info = dev_get_drvdata(dev);
+ struct fb_info *info = platform_get_drvdata(dev);
struct imxfb_info *fbi = info->par;
imxfb_disable_controller(fbi);
}
@@ -664,24 +662,25 @@
imxfb_disable_controller(fbi);
}

-static struct device_driver imxfb_driver = {
- .name = "imx-fb",
- .bus = &platform_bus_type,
+static struct platform_driver imxfb_driver = {
.probe = imxfb_probe,
.suspend = imxfb_suspend,
.resume = imxfb_resume,
.remove = imxfb_remove,
.shutdown = imxfb_shutdown,
+ .driver = {
+ .name = "imx-fb",
+ },
};

int __init imxfb_init(void)
{
- return driver_register(&imxfb_driver);
+ return platform_driver_register(&imxfb_driver);
}

static void __exit imxfb_cleanup(void)
{
- driver_unregister(&imxfb_driver);
+ platform_driver_unregister(&imxfb_driver);
}

module_init(imxfb_init);

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:17:10

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert MMC drivers

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff -u b/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c
--- b/drivers/mmc/wbsd.c
+++ b/drivers/mmc/wbsd.c
@@ -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 *de

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");


--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:17:31

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert MTD drivers

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff -u b/drivers/mtd/maps/bast-flash.c b/drivers/mtd/maps/bast-flash.c
--- b/drivers/mtd/maps/bast-flash.c
+++ b/drivers/mtd/maps/bast-flash.c
@@ -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);
diff -u b/drivers/mtd/maps/integrator-flash.c b/drivers/mtd/maps/integrator-flash.c
--- b/drivers/mtd/maps/integrator-flash.c
+++ b/drivers/mtd/maps/integrator-flash.c
@@ -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 device
return 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);
diff -u b/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c
--- b/drivers/mtd/maps/ixp2000.c
+++ b/drivers/mtd/maps/ixp2000.c
@@ -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);
diff -u b/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
--- b/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -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);
}


diff -u b/drivers/mtd/maps/omap_nor.c b/drivers/mtd/maps/omap_nor.c
--- b/drivers/mtd/maps/omap_nor.c
+++ b/drivers/mtd/maps/omap_nor.c
@@ -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(st
return 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);
diff -u b/drivers/mtd/maps/plat-ram.c b/drivers/mtd/maps/plat-ram.c
--- b/drivers/mtd/maps/plat-ram.c
+++ b/drivers/mtd/maps/plat-ram.c
@@ -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_driv
static 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);

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:16:56

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert ARM Zaurus drivers

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff -u b/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c
--- b/drivers/input/keyboard/corgikbd.c
+++ b/drivers/input/keyboard/corgikbd.c
@@ -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);
diff -u b/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
--- b/drivers/input/keyboard/spitzkbd.c
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -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);
diff -u b/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
--- b/drivers/input/touchscreen/corgi_ts.c
+++ b/drivers/input/touchscreen/corgi_ts.c
@@ -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);
diff -u b/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c
--- b/drivers/video/backlight/corgi_bl.c
+++ b/drivers/video/backlight/corgi_bl.c
@@ -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);


--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:18:47

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert network drivers

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff -u b/drivers/net/depca.c b/drivers/net/depca.c
--- b/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -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) {
diff -u b/drivers/net/dm9000.c b/drivers/net/dm9000.c
--- b/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -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 __exit
dm9000_cleanup(void)
{
- driver_unregister(&dm9000_driver);
+ platform_driver_unregister(&dm9000_driver);
}

module_init(dm9000_init);
diff -u b/drivers/net/gianfar.c b/drivers/net/gianfar.c
--- b/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -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();
}

diff -u b/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c
--- b/drivers/net/irda/smsc-ircc2.c
+++ b/drivers/net/irda/smsc-ircc2.c
@@ -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);
}

/*
diff -u b/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c
--- b/drivers/net/jazzsonic.c
+++ b/drivers/net/jazzsonic.c
@@ -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_r
return 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);
diff -u b/drivers/net/macsonic.c b/drivers/net/macsonic.c
--- b/drivers/net/macsonic.c
+++ b/drivers/net/macsonic.c
@@ -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_re
return 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);
diff -u b/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
--- b/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -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(str
return 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);
diff -u b/drivers/net/smc91x.c b/drivers/net/smc91x.c
--- b/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -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);
diff -u b/drivers/net/tokenring/proteon.c b/drivers/net/tokenring/proteon.c
--- b/drivers/net/tokenring/proteon.c
+++ b/drivers/net/tokenring/proteon.c
@@ -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);
diff -u b/drivers/net/tokenring/skisa.c b/drivers/net/tokenring/skisa.c
--- b/drivers/net/tokenring/skisa.c
+++ b/drivers/net/tokenring/skisa.c
@@ -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);

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:18:01

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert serial drivers

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff -u b/drivers/serial/8250.c b/drivers/serial/8250.c
--- b/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -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);
diff -u b/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
--- b/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -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 __exit
mpc52xx_uart_exit(void)
{
- driver_unregister(&mpc52xx_uart_platform_driver);
+ platform_driver_unregister(&mpc52xx_uart_platform_driver);
uart_unregister_driver(&mpc52xx_uart_driver);
}

diff -u b/drivers/serial/mpsc.c b/drivers/serial/mpsc.c
--- b/drivers/serial/mpsc.c
+++ b/drivers/serial/mpsc.c
@@ -1551,15 +1551,14 @@
}

static int
-mpsc_shared_drv_probe(struct device *dev)
+mpsc_shared_drv_probe(struct platform_device *dev)
{
- struct platform_device *pd = to_platform_device(dev);
struct mpsc_shared_pdata *pdata;
int rc = -ENODEV;

- if (pd->id == 0) {
- if (!(rc = mpsc_shared_map_regs(pd))) {
- pdata = (struct mpsc_shared_pdata *)dev->platform_data;
+ if (dev->id == 0) {
+ if (!(rc = mpsc_shared_map_regs(dev))) {
+ pdata = (struct mpsc_shared_pdata *)dev->dev.platform_data;

mpsc_shared_regs.MPSC_MRR_m = pdata->mrr_val;
mpsc_shared_regs.MPSC_RCRR_m= pdata->rcrr_val;
@@ -1577,12 +1576,11 @@
}

static int
-mpsc_shared_drv_remove(struct device *dev)
+mpsc_shared_drv_remove(struct platform_device *dev)
{
- struct platform_device *pd = to_platform_device(dev);
int rc = -ENODEV;

- if (pd->id == 0) {
+ if (dev->id == 0) {
mpsc_shared_unmap_regs();
mpsc_shared_regs.MPSC_MRR_m = 0;
mpsc_shared_regs.MPSC_RCRR_m = 0;
@@ -1595,11 +1593,12 @@ mpsc_shared_drv_remove(struct device *de
return rc;
}

-static struct device_driver mpsc_shared_driver = {
- .name = MPSC_SHARED_NAME,
- .bus = &platform_bus_type,
+static struct platform_driver mpsc_shared_driver = {
.probe = mpsc_shared_drv_probe,
.remove = mpsc_shared_drv_remove,
+ .driver = {
+ .name = MPSC_SHARED_NAME,
+ },
};

/*
@@ -1732,19 +1731,18 @@
}

static int
-mpsc_drv_probe(struct device *dev)
+mpsc_drv_probe(struct platform_device *dev)
{
- struct platform_device *pd = to_platform_device(dev);
struct mpsc_port_info *pi;
int rc = -ENODEV;

- pr_debug("mpsc_drv_probe: Adding MPSC %d\n", pd->id);
+ pr_debug("mpsc_drv_probe: Adding MPSC %d\n", dev->id);

- if (pd->id < MPSC_NUM_CTLRS) {
- pi = &mpsc_ports[pd->id];
+ if (dev->id < MPSC_NUM_CTLRS) {
+ pi = &mpsc_ports[dev->id];

- if (!(rc = mpsc_drv_map_regs(pi, pd))) {
- mpsc_drv_get_platform_data(pi, pd, pd->id);
+ if (!(rc = mpsc_drv_map_regs(pi, dev))) {
+ mpsc_drv_get_platform_data(pi, dev, dev->id);

if (!(rc = mpsc_make_ready(pi)))
if (!(rc = uart_add_one_port(&mpsc_reg,
@@ -1764,16 +1762,14 @@
}

static int
-mpsc_drv_remove(struct device *dev)
+mpsc_drv_remove(struct platform_device *dev)
{
- struct platform_device *pd = to_platform_device(dev);
+ pr_debug("mpsc_drv_exit: Removing MPSC %d\n", dev->id);

- pr_debug("mpsc_drv_exit: Removing MPSC %d\n", pd->id);
-
- if (pd->id < MPSC_NUM_CTLRS) {
- uart_remove_one_port(&mpsc_reg, &mpsc_ports[pd->id].port);
- mpsc_release_port((struct uart_port *)&mpsc_ports[pd->id].port);
- mpsc_drv_unmap_regs(&mpsc_ports[pd->id]);
+ if (dev->id < MPSC_NUM_CTLRS) {
+ uart_remove_one_port(&mpsc_reg, &mpsc_ports[dev->id].port);
+ mpsc_release_port((struct uart_port *)&mpsc_ports[dev->id].port);
+ mpsc_drv_unmap_regs(&mpsc_ports[dev->id]);
return 0;
}
else
@@ -1780,11 +1776,12 @@ mpsc_drv_remove(struct device *dev)
return -ENODEV;
}

-static struct device_driver mpsc_driver = {
- .name = MPSC_CTLR_NAME,
- .bus = &platform_bus_type,
+static struct platform_driver mpsc_driver = {
.probe = mpsc_drv_probe,
.remove = mpsc_drv_remove,
+ .driver = {
+ .name = MPSC_CTLR_NAME,
+ },
};

static int __init
@@ -1798,9 +1795,9 @@ mpsc_drv_init(void)
memset(&mpsc_shared_regs, 0, sizeof(mpsc_shared_regs));

if (!(rc = uart_register_driver(&mpsc_reg))) {
- if (!(rc = driver_register(&mpsc_shared_driver))) {
- if ((rc = driver_register(&mpsc_driver))) {
- driver_unregister(&mpsc_shared_driver);
+ if (!(rc = platform_driver_register(&mpsc_shared_driver))) {
+ if ((rc = platform_driver_register(&mpsc_driver))) {
+ platform_driver_unregister(&mpsc_shared_driver);
uart_unregister_driver(&mpsc_reg);
}
}
@@ -1815,8 +1812,8 @@ mpsc_drv_init(void)
static void __exit
mpsc_drv_exit(void)
{
- driver_unregister(&mpsc_driver);
- driver_unregister(&mpsc_shared_driver);
+ platform_driver_unregister(&mpsc_driver);
+ platform_driver_unregister(&mpsc_shared_driver);
uart_unregister_driver(&mpsc_reg);
memset(mpsc_ports, 0, sizeof(mpsc_ports));
memset(&mpsc_shared_regs, 0, sizeof(mpsc_shared_regs));
diff -u b/drivers/serial/pxa.c b/drivers/serial/pxa.c
--- b/drivers/serial/pxa.c
+++ b/drivers/serial/pxa.c
@@ -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);
}

diff -u b/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c
--- b/drivers/serial/vr41xx_siu.c
+++ b/drivers/serial/vr41xx_siu.c
@@ -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);
}


--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:18:08

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert i2c drivers

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff -u b/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c
--- b/drivers/hwmon/hdaps.c
+++ b/drivers/hwmon/hdaps.c
@@ -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");
diff -u b/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c
--- b/drivers/i2c/busses/i2c-iop3xx.c
+++ b/drivers/i2c/busses/i2c-iop3xx.c
@@ -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 __exit
i2c_iop3xx_exit (void)
{
- driver_unregister(&iop3xx_i2c_driver);
+ platform_driver_unregister(&iop3xx_i2c_driver);
return;
}

diff -u b/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c
--- b/drivers/i2c/busses/i2c-ixp2000.c
+++ b/drivers/i2c/busses/i2c-ixp2000.c
@@ -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 devi
return 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);
diff -u b/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c
--- b/drivers/i2c/busses/i2c-ixp4xx.c
+++ b/drivers/i2c/busses/i2c-ixp4xx.c
@@ -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 devic
return 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);
diff -u b/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
--- b/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -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);
diff -u b/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
--- b/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -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 __exit
mv64xxx_i2c_exit(void)
{
- driver_unregister(&mv64xxx_i2c_driver);
+ platform_driver_unregister(&mv64xxx_i2c_driver);
}

module_init(mv64xxx_i2c_init);
diff -u b/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
--- b/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -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 device
return 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);


--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:19:08

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert USB drivers

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff -u b/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
--- b/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -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);
diff -u b/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
--- b/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -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);
diff -u b/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
--- b/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -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:
--- b/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -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);
diff -u b/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
--- b/drivers/usb/host/ohci-au1xxx.c
+++ b/drivers/usb/host/ohci-au1xxx.c
@@ -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);
diff -u b/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c
--- b/drivers/usb/host/ohci-lh7a404.c
+++ b/drivers/usb/host/ohci-lh7a404.c
@@ -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);
diff -u b/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c
--- b/drivers/usb/host/ohci-ppc-soc.c
+++ b/drivers/usb/host/ohci-ppc-soc.c
@@ -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);


--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:19:07

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert input drivers

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff -u b/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
--- b/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -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();

diff -u b/drivers/input/serio/rpckbd.c b/drivers/input/serio/rpckbd.c
--- b/drivers/input/serio/rpckbd.c
+++ b/drivers/input/serio/rpckbd.c
@@ -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);


--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:20:56

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert drivers/misc/hdpuftrs

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff -u b/drivers/misc/hdpuftrs/hdpu_cpustate.c b/drivers/misc/hdpuftrs/hdpu_cpustate.c
--- b/drivers/misc/hdpuftrs/hdpu_cpustate.c
+++ b/drivers/misc/hdpuftrs/hdpu_cpustate.c
@@ -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);
diff -u b/drivers/misc/hdpuftrs/hdpu_nexus.c b/drivers/misc/hdpuftrs/hdpu_nexus.c
--- b/drivers/misc/hdpuftrs/hdpu_nexus.c
+++ b/drivers/misc/hdpuftrs/hdpu_nexus.c
@@ -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);


--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:20:00

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert miscellaneous char drivers

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff -u b/drivers/char/sonypi.c b/drivers/char/sonypi.c
--- b/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -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();
}

diff -u b/drivers/char/tb0219.c b/drivers/char/tb0219.c
--- b/drivers/char/tb0219.c
+++ b/drivers/char/tb0219.c
@@ -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);
}
diff -u b/drivers/char/vr41xx_giu.c b/drivers/char/vr41xx_giu.c
--- b/drivers/char/vr41xx_giu.c
+++ b/drivers/char/vr41xx_giu.c
@@ -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 *dev

static 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(voi
if (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);
}
diff -u b/drivers/char/vr41xx_rtc.c b/drivers/char/vr41xx_rtc.c
--- b/drivers/char/vr41xx_rtc.c
+++ b/drivers/char/vr41xx_rtc.c
@@ -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 *dev

static 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(voi
if (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);
}
diff -u b/drivers/char/watchdog/mv64x60_wdt.c b/drivers/char/watchdog/mv64x60_wdt.c
--- b/drivers/char/watchdog/mv64x60_wdt.c
+++ b/drivers/char/watchdog/mv64x60_wdt.c
@@ -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);
}

diff -u b/drivers/char/watchdog/mpcore_wdt.c b/drivers/char/watchdog/mpcore_wdt.c
--- b/drivers/char/watchdog/mpcore_wdt.c
+++ b/drivers/char/watchdog/mpcore_wdt.c
@@ -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(s
return 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);

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:19:58

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert video drivers

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

diff -u b/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
--- b/drivers/video/s1d13xxxfb.c
+++ b/drivers/video/s1d13xxxfb.c
@@ -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 __exit
s1d13xxxfb_exit(void)
{
- driver_unregister(&s1d13xxxfb_driver);
+ platform_driver_unregister(&s1d13xxxfb_driver);
}

module_init(s1d13xxxfb_init);
diff -u b/drivers/video/w100fb.c b/drivers/video/w100fb.c
--- b/drivers/video/w100fb.c
+++ b/drivers/video/w100fb.c
@@ -438,9 +438,9 @@
}
}

-static int w100fb_suspend(struct device *dev, pm_message_t state)
+static int w100fb_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 w100fb_par *par=info->par;
struct w100_tg_info *tg = par->mach->tg;

@@ -453,9 +453,9 @@
return 0;
}

-static int w100fb_resume(struct device *dev)
+static int w100fb_resume(struct platform_device *dev)
{
- struct fb_info *info = dev_get_drvdata(dev);
+ struct fb_info *info = platform_get_drvdata(dev);
struct w100fb_par *par=info->par;
struct w100_tg_info *tg = par->mach->tg;

@@ -474,13 +474,12 @@
#endif


-int __init w100fb_probe(struct device *dev)
+int __init w100fb_probe(struct platform_device *pdev)
{
int err = -EIO;
struct w100fb_mach_info *inf;
struct fb_info *info = NULL;
struct w100fb_par *par;
- struct platform_device *pdev = to_platform_device(dev);
struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
unsigned int chip_id;

@@ -523,9 +522,9 @@
}

par = info->par;
- dev_set_drvdata(dev, info);
+ platform_set_drvdata(pdev, info);

- inf = dev->platform_data;
+ inf = pdev->dev.platform_data;
par->chip_id = chip_id;
par->mach = inf;
par->fastpll_mode = 0;
@@ -601,10 +600,10 @@
goto out;
}

- device_create_file(dev, &dev_attr_fastpllclk);
- device_create_file(dev, &dev_attr_reg_read);
- device_create_file(dev, &dev_attr_reg_write);
- device_create_file(dev, &dev_attr_flip);
+ device_create_file(&pdev->dev, &dev_attr_fastpllclk);
+ device_create_file(&pdev->dev, &dev_attr_reg_read);
+ device_create_file(&pdev->dev, &dev_attr_reg_write);
+ device_create_file(&pdev->dev, &dev_attr_flip);

printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, info->fix.id);
return 0;
@@ -623,15 +622,15 @@
}


-static int w100fb_remove(struct device *dev)
+static int w100fb_remove(struct platform_device *pdev)
{
- struct fb_info *info = dev_get_drvdata(dev);
+ struct fb_info *info = platform_get_drvdata(pdev);
struct w100fb_par *par=info->par;

- device_remove_file(dev, &dev_attr_fastpllclk);
- device_remove_file(dev, &dev_attr_reg_read);
- device_remove_file(dev, &dev_attr_reg_write);
- device_remove_file(dev, &dev_attr_flip);
+ device_remove_file(&pdev->dev, &dev_attr_fastpllclk);
+ device_remove_file(&pdev->dev, &dev_attr_reg_read);
+ device_remove_file(&pdev->dev, &dev_attr_reg_write);
+ device_remove_file(&pdev->dev, &dev_attr_flip);

unregister_framebuffer(info);

@@ -1449,23 +1448,24 @@
writel(0x00000002, remapped_regs + mmGEN_INT_STATUS);
}

-static struct device_driver w100fb_driver = {
- .name = "w100fb",
- .bus = &platform_bus_type,
+static struct platform_driver w100fb_driver = {
.probe = w100fb_probe,
.remove = w100fb_remove,
.suspend = w100fb_suspend,
.resume = w100fb_resume,
+ .driver = {
+ .name = "w100fb",
+ },
};

int __devinit w100fb_init(void)
{
- return driver_register(&w100fb_driver);
+ return platform_driver_register(&w100fb_driver);
}

void __exit w100fb_cleanup(void)
{
- driver_unregister(&w100fb_driver);
+ platform_driver_unregister(&w100fb_driver);
}

module_init(w100fb_init);
diff -u b/drivers/video/acornfb.c b/drivers/video/acornfb.c
--- b/drivers/video/acornfb.c
+++ b/drivers/video/acornfb.c
@@ -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);
diff -u b/drivers/video/arcfb.c b/drivers/video/arcfb.c
--- b/drivers/video/arcfb.c
+++ b/drivers/video/arcfb.c
@@ -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);
diff -u b/drivers/video/dnfb.c b/drivers/video/dnfb.c
--- b/drivers/video/dnfb.c
+++ b/drivers/video/dnfb.c
@@ -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;
}
diff -u b/drivers/video/epson1355fb.c b/drivers/video/epson1355fb.c
--- b/drivers/video/epson1355fb.c
+++ b/drivers/video/epson1355fb.c
@@ -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);
}

/* ------------------------------------------------------------------------- */
diff -u b/drivers/video/gbefb.c b/drivers/video/gbefb.c
--- b/drivers/video/gbefb.c
+++ b/drivers/video/gbefb.c
@@ -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);
diff -u b/drivers/video/q40fb.c b/drivers/video/q40fb.c
--- b/drivers/video/q40fb.c
+++ b/drivers/video/q40fb.c
@@ -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;
}
diff -u b/drivers/video/sgivwfb.c b/drivers/video/sgivwfb.c
--- b/drivers/video/sgivwfb.c
+++ b/drivers/video/sgivwfb.c
@@ -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);
diff -u b/drivers/video/vesafb.c b/drivers/video/vesafb.c
--- b/drivers/video/vesafb.c
+++ b/drivers/video/vesafb.c
@@ -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;
}
diff -u b/drivers/video/vfb.c b/drivers/video/vfb.c
--- b/drivers/video/vfb.c
+++ b/drivers/video/vfb.c
@@ -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);


--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-05 18:21:04

by Russell King

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Convert ALSA

Convert platform drivers to use struct platform_driver

Signed-off-by: Russell King <[email protected]>

unchanged:
--- b/sound/core/init.c
+++ b/sound/core/init.c
@@ -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:
--- b/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -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();


--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core

2005-11-06 20:41:13

by Greg KH

[permalink] [raw]
Subject: Re: [DRIVER MODEL] Add platform_driver

On Sat, Nov 05, 2005 at 06:12:17PM +0000, Russell King wrote:
> 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.
>
> Signed-off-by: Russell King <[email protected]>

Acked-by: Greg Kroah-Hartman <[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