9
0
Fork 0
barebox/drivers/mfd
Antony Pavlov 377d261708 of: use 'const void *' for struct of_device_id.data
Since 2011 barebox' of_device_id struct uses unsigned long type for data field:

    struct of_device_id {
            char *compatible;
            unsigned long data;
    };

Almost always struct of_device_id.data field are used as pointer
and need 'unsigned long' casting.

E.g. see 'git grep -A 4 of_device_id drivers/' output:

    drivers/ata/sata-imx.c:static __maybe_unused struct of_device_id imx_sata_dt_ids[] = {
    drivers/ata/sata-imx.c- {
    drivers/ata/sata-imx.c-         .compatible = "fsl,imx6q-ahci",
    drivers/ata/sata-imx.c-         .data = (unsigned long)&data_imx6,
    drivers/ata/sata-imx.c- }, {

Here is of_device_id struct in linux kernel v4.0:

    struct of_device_id {
            char name[32];
            char type[32];
            char compatible[128];
            const void *data;
    };

Changing of_device_id.data type to 'const void *data' will increase
barebox' linux kernel compatibility and decrease number of 'unsigned
long' casts.

Part of the patch was done using the 'coccinelle' tool with the
following semantic patch:

    @rule1@
    identifier dev;
    identifier type;
    identifier func;
    @@
    func(...) {
    <...
    - dev_get_drvdata(dev, (unsigned long *)&type)
    + dev_get_drvdata(dev, (const void **)&type)
    ...>
    }
    @rule2@
    identifier dev;
    identifier type;
    identifier func;
    identifier data;
    @@
    func(...) {
    <...
    - dev_get_drvdata(dev, (unsigned long *)&type->data)
    + dev_get_drvdata(dev, (const void **)&type->data)
    ...>
    }

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-04-30 08:12:57 +02:00
..
Kconfig mfd: add act8846 driver 2014-04-29 08:12:32 +02:00
Makefile mfd: add act8846 driver 2014-04-29 08:12:32 +02:00
act8846.c mfd: add act8846 driver 2014-04-29 08:12:32 +02:00
lp3972.c I2C: Rename i2c_register_driver() for using with register_driver_macro() 2013-03-14 07:15:44 +01:00
mc9sdz60.c I2C: Rename i2c_register_driver() for using with register_driver_macro() 2013-03-14 07:15:44 +01:00
mc13xxx.c of: use 'const void *' for struct of_device_id.data 2015-04-30 08:12:57 +02:00
mc34704.c mfd: mc34704: Add DT support 2014-07-29 08:22:05 +02:00
stmpe-i2c.c treewide: Add missing includes 2013-11-08 15:42:04 +01:00
syscon.c resource: Let dev_get_resource return an error pointer 2014-09-16 08:32:09 +02:00
twl-core.c use loff_t for file offsets 2012-06-30 16:53:24 +02:00
twl4030.c I2C: Rename i2c_register_driver() for using with register_driver_macro() 2013-03-14 07:15:44 +01:00
twl6030.c I2C: Rename i2c_register_driver() for using with register_driver_macro() 2013-03-14 07:15:44 +01:00