summaryrefslogtreecommitdiffstats
path: root/drivers/spi
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 /drivers/spi
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 'drivers/spi')
-rw-r--r--drivers/spi/imx_spi.c8
-rw-r--r--drivers/spi/mvebu_spi.c6
-rw-r--r--drivers/spi/omap3_spi.c6
3 files changed, 10 insertions, 10 deletions
diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c
index a1f19eba8b..95924f68da 100644
--- a/drivers/spi/imx_spi.c
+++ b/drivers/spi/imx_spi.c
@@ -521,7 +521,7 @@ static int imx_spi_probe(struct device_d *dev)
struct spi_imx_devtype_data *devdata = NULL;
int ret;
- ret = dev_get_drvdata(dev, (unsigned long *)&devdata);
+ ret = dev_get_drvdata(dev, (const void **)&devdata);
if (ret)
return -ENODEV;
@@ -569,19 +569,19 @@ static __maybe_unused struct of_device_id imx_spi_dt_ids[] = {
#if IS_ENABLED(CONFIG_DRIVER_SPI_IMX_0_0)
{
.compatible = "fsl,imx27-cspi",
- .data = (unsigned long)&spi_imx_devtype_data_0_0,
+ .data = &spi_imx_devtype_data_0_0,
},
#endif
#if IS_ENABLED(CONFIG_DRIVER_SPI_IMX_0_7)
{
.compatible = "fsl,imx35-cspi",
- .data = (unsigned long)&spi_imx_devtype_data_0_7,
+ .data = &spi_imx_devtype_data_0_7,
},
#endif
#if IS_ENABLED(CONFIG_DRIVER_SPI_IMX_2_3)
{
.compatible = "fsl,imx51-ecspi",
- .data = (unsigned long)&spi_imx_devtype_data_2_3,
+ .data = &spi_imx_devtype_data_2_3,
},
#endif
{
diff --git a/drivers/spi/mvebu_spi.c b/drivers/spi/mvebu_spi.c
index c2a2e5094d..bc0655f6a0 100644
--- a/drivers/spi/mvebu_spi.c
+++ b/drivers/spi/mvebu_spi.c
@@ -318,14 +318,14 @@ static int mvebu_spi_transfer(struct spi_device *spi, struct spi_message *msg)
static struct of_device_id mvebu_spi_dt_ids[] = {
{ .compatible = "marvell,orion-spi",
- .data = (unsigned long)&mvebu_spi_set_baudrate },
+ .data = &mvebu_spi_set_baudrate },
#if defined(CONFIG_ARCH_ARMADA_370) || defined(CONFIG_ARCH_ARMADA_XP)
{ .compatible = "marvell,armada-370-xp-spi",
- .data = (unsigned long)&armada_370_xp_spi_set_baudrate },
+ .data = &armada_370_xp_spi_set_baudrate },
#endif
#if defined(CONFIG_ARCH_DOVE)
{ .compatible = "marvell,dove-spi",
- .data = (unsigned long)&dove_spi_set_baudrate },
+ .data = &dove_spi_set_baudrate },
#endif
{ }
};
diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
index 761083ae03..8e29fde0bb 100644
--- a/drivers/spi/omap3_spi.c
+++ b/drivers/spi/omap3_spi.c
@@ -363,7 +363,7 @@ static int omap3_spi_probe(struct device_d *dev)
struct omap_spi_drvdata *devtype;
int ret;
- ret = dev_get_drvdata(dev, (unsigned long *)&devtype);
+ ret = dev_get_drvdata(dev, (const void **)&devtype);
if (ret)
return ret;
@@ -422,10 +422,10 @@ static struct omap_spi_drvdata omap4_data = {
static __maybe_unused struct of_device_id omap_spi_dt_ids[] = {
{
.compatible = "ti,omap2-mcspi",
- .data = (unsigned long)&omap3_data,
+ .data = &omap3_data,
}, {
.compatible = "ti,omap4-mcspi",
- .data = (unsigned long)&omap4_data,
+ .data = &omap4_data,
}, {
/* sentinel */
}