summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAntony Pavlov <antonynpavlov@gmail.com>2015-04-29 11:56:58 +0300
committerSascha Hauer <s.hauer@pengutronix.de>2015-04-30 08:12:57 +0200
commit377d261708d3057200c7ad9647fddb15169fea78 (patch)
tree9334590c4a63ec0b4ea01b91a7adc627a1ceb699 /include
parent92207cde490261c52cc804588561d8f3117cdf87 (diff)
downloadbarebox-377d261708d3057200c7ad9647fddb15169fea78.tar.gz
barebox-377d261708d3057200c7ad9647fddb15169fea78.tar.xz
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>
Diffstat (limited to 'include')
-rw-r--r--include/driver.h2
-rw-r--r--include/linux/clk.h2
-rw-r--r--include/of.h2
3 files changed, 3 insertions, 3 deletions
diff --git a/include/driver.h b/include/driver.h
index 0ee3b4554f..b8a94e487c 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -512,7 +512,7 @@ int devfs_create_partitions(const char *devname,
#define DRV_OF_COMPAT(compat) \
IS_ENABLED(CONFIG_OFDEVICE) ? (compat) : NULL
-int dev_get_drvdata(struct device_d *dev, unsigned long *data);
+int dev_get_drvdata(struct device_d *dev, const void **data);
int device_match_of_modalias(struct device_d *dev, struct driver_d *drv);
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 56890a0d5e..4aeec63a84 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -322,7 +322,7 @@ struct of_phandle_args;
#define CLK_OF_DECLARE(name, compat, fn) \
const struct of_device_id __clk_of_table_##name \
__attribute__ ((unused,section (".__clk_of_table_" __stringify(name)))) \
- = { .compatible = compat, .data = (u32)fn }
+ = { .compatible = compat, .data = fn }
#if defined(CONFIG_OFTREE) && defined(CONFIG_COMMON_CLK_OF_PROVIDER)
int of_clk_add_provider(struct device_node *np,
diff --git a/include/of.h b/include/of.h
index 764a2e5939..c1dd4d51ec 100644
--- a/include/of.h
+++ b/include/of.h
@@ -35,7 +35,7 @@ struct device_node {
struct of_device_id {
char *compatible;
- unsigned long data;
+ const void *data;
};
#define MAX_PHANDLE_ARGS 8