Commit 25db8372 authored by Komal Shah's avatar Komal Shah Committed by Tony Lindgren

[PATCH] ARM: OMAP: I2C: Use struct platform_driver

Attached patch uses "struct platform_driver" and kmalloc->kzalloc.
Signed-off-by: default avatarKomal Shah <komal_shah802003@yahoo.com>
Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
parent 9bf91763
...@@ -571,9 +571,8 @@ static void omap_i2c_24xx_enable_clocks(struct omap_i2c_dev *omap_i2c_dev, ...@@ -571,9 +571,8 @@ static void omap_i2c_24xx_enable_clocks(struct omap_i2c_dev *omap_i2c_dev,
#endif #endif
static int static int
omap_i2c_probe(struct device *dev) omap_i2c_probe(struct platform_device *pdev)
{ {
struct platform_device *pdev = to_platform_device(dev);
struct omap_i2c_dev *omap_i2c_dev; struct omap_i2c_dev *omap_i2c_dev;
struct i2c_adapter *adap; struct i2c_adapter *adap;
struct resource *mem, *irq; struct resource *mem, *irq;
...@@ -606,17 +605,16 @@ omap_i2c_probe(struct device *dev) ...@@ -606,17 +605,16 @@ omap_i2c_probe(struct device *dev)
if (own < 1 || own > 0x7f) if (own < 1 || own > 0x7f)
own = DEFAULT_OWN; own = DEFAULT_OWN;
omap_i2c_dev = kmalloc(sizeof(struct omap_i2c_dev), GFP_KERNEL); omap_i2c_dev = kzalloc(sizeof(struct omap_i2c_dev), GFP_KERNEL);
if (!omap_i2c_dev) { if (!omap_i2c_dev) {
r = -ENOMEM; r = -ENOMEM;
goto do_release_region; goto do_release_region;
} }
memset(omap_i2c_dev, 0, sizeof(struct omap_i2c_dev));
omap_i2c_dev->dev = dev; omap_i2c_dev->dev = &pdev->dev;
omap_i2c_dev->irq = irq->start; omap_i2c_dev->irq = irq->start;
omap_i2c_dev->base = (void __iomem *)IO_ADDRESS(mem->start); omap_i2c_dev->base = (void __iomem *)IO_ADDRESS(mem->start);
dev_set_drvdata(omap_i2c_dev->dev, omap_i2c_dev); platform_set_drvdata(pdev, omap_i2c_dev);
init_waitqueue_head(&omap_i2c_dev->cmd_wait); init_waitqueue_head(&omap_i2c_dev->cmd_wait);
if ((r = omap_i2c_24xx_get_clocks(omap_i2c_dev, pdev->id)) != 0) if ((r = omap_i2c_24xx_get_clocks(omap_i2c_dev, pdev->id)) != 0)
...@@ -648,7 +646,7 @@ omap_i2c_probe(struct device *dev) ...@@ -648,7 +646,7 @@ omap_i2c_probe(struct device *dev)
adap->class = I2C_CLASS_HWMON; adap->class = I2C_CLASS_HWMON;
strncpy(adap->name, "OMAP I2C adapter", sizeof(adap->name)); strncpy(adap->name, "OMAP I2C adapter", sizeof(adap->name));
adap->algo = &omap_i2c_algo; adap->algo = &omap_i2c_algo;
adap->dev.parent = dev; adap->dev.parent = &pdev->dev;
/* i2c device drivers may be active on return from add_adapter() */ /* i2c device drivers may be active on return from add_adapter() */
r = i2c_add_adapter(adap); r = i2c_add_adapter(adap);
if (r) { if (r) {
...@@ -673,10 +671,9 @@ do_release_region: ...@@ -673,10 +671,9 @@ do_release_region:
} }
static int static int
omap_i2c_remove(struct device *dev) omap_i2c_remove(struct platform_device *pdev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct omap_i2c_dev *omap_i2c_dev = platform_get_drvdata(pdev);
struct omap_i2c_dev *omap_i2c_dev = dev_get_drvdata(dev);
struct resource *mem; struct resource *mem;
omap_i2c_write(omap_i2c_dev, 0, OMAP_I2C_CON); omap_i2c_write(omap_i2c_dev, 0, OMAP_I2C_CON);
...@@ -690,24 +687,25 @@ omap_i2c_remove(struct device *dev) ...@@ -690,24 +687,25 @@ omap_i2c_remove(struct device *dev)
return 0; return 0;
} }
static struct device_driver omap_i2c_driver = { static struct platform_driver omap_i2c_driver = {
.name = (char *)driver_name,
.bus = &platform_bus_type,
.probe = omap_i2c_probe, .probe = omap_i2c_probe,
.remove = omap_i2c_remove, .remove = omap_i2c_remove,
.driver = {
.name = (char *)driver_name,
},
}; };
/* i2c may be needed to bring up other drivers */ /* i2c may be needed to bring up other drivers */
static int __init static int __init
omap_i2c_init_driver(void) omap_i2c_init_driver(void)
{ {
return driver_register(&omap_i2c_driver); return platform_driver_register(&omap_i2c_driver);
} }
subsys_initcall(omap_i2c_init_driver); subsys_initcall(omap_i2c_init_driver);
static void __exit omap_i2c_exit_driver(void) static void __exit omap_i2c_exit_driver(void)
{ {
driver_unregister(&omap_i2c_driver); platform_driver_unregister(&omap_i2c_driver);
} }
module_exit(omap_i2c_exit_driver); module_exit(omap_i2c_exit_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment