From 377d261708d3057200c7ad9647fddb15169fea78 Mon Sep 17 00:00:00 2001 From: Antony Pavlov Date: Wed, 29 Apr 2015 11:56:58 +0300 Subject: 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 Signed-off-by: Sascha Hauer --- drivers/watchdog/imxwd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/watchdog') diff --git a/drivers/watchdog/imxwd.c b/drivers/watchdog/imxwd.c index 221ad93107..5ffbac7cdd 100644 --- a/drivers/watchdog/imxwd.c +++ b/drivers/watchdog/imxwd.c @@ -173,7 +173,7 @@ static int imx_wd_probe(struct device_d *dev) void *ops; int ret; - ret = dev_get_drvdata(dev, (unsigned long *)&ops); + ret = dev_get_drvdata(dev, (const void **)&ops); if (ret) return ret; @@ -240,10 +240,10 @@ static const struct imx_wd_ops imx1_wd_ops = { static __maybe_unused struct of_device_id imx_wdt_dt_ids[] = { { .compatible = "fsl,imx1-wdt", - .data = (unsigned long)&imx1_wd_ops, + .data = &imx1_wd_ops, }, { .compatible = "fsl,imx21-wdt", - .data = (unsigned long)&imx21_wd_ops, + .data = &imx21_wd_ops, }, { /* sentinel */ } -- cgit v1.2.3