[DRIVER MODEL] Convert platform drivers to use struct platform_driver
This allows us to eliminate the casts in the drivers, and eventually remove the use of the device_driver function pointer methods for platform device drivers. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
@@ -86,12 +86,11 @@ struct ixp2000_i2c_data {
|
||||
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 @@ static int ixp2000_i2c_remove(struct device *dev)
|
||||
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,27 +137,28 @@ static int ixp2000_i2c_probe(struct device *dev)
|
||||
return err;
|
||||
}
|
||||
|
||||
dev_set_drvdata(&plat_dev->dev, drv_data);
|
||||
platform_set_drvdata(plat_dev, drv_data);
|
||||
|
||||
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);
|
||||
|
Reference in New Issue
Block a user