2018-01-02 13:56:51

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 00/12] account for const type of of_device_id.data

Maintain const annotations when putting values into the data field of
an of_device_id structure, and afterwards when extracting them from
the data field of such a structure.

This was done using the following semantic patch:
(http://coccinelle.lip6.fr/)

// <smpl>
@r@
identifier i,j;
const struct j *m;
struct i *y;
type T;
expression x,e;
position p;
@@

(
y =@p (T)(of_device_get_match_data(...));
|
x = of_match_node(...);
... when != x = e
(
m = e;
|
y =@p (T)(x->data);
)
)

@s@
identifier r.i,j;
@@

const struct i j = { ... };

@t depends on s disable optional_qualifier@
expression e;
identifier r.i,x,j,n;
struct j *m;
struct i *e1;
position any r.p;
type T;
@@

(
+const
struct i *x;
<+...
(
x =@p
- (T)(e)
+ e
|
x =@p e
)
...+>
|
m->@e1 n =@p
- (T)(e)
+ e
|
m->@e1 n =@p e
)

@disable optional_qualifier@
identifier t.j,t.n,r.i;
@@

struct j {
...
+ const
struct i *n;
...
}

@@
identifier x,s.j;
type T;
@@

struct of_device_id x[] = { ...,
{ .data =
- (T)
&j, }, ...};

// </smpl>

---

drivers/i2c/busses/i2c-rk3x.c | 16 ++++++++--------
drivers/iio/common/ssp_sensors/ssp.h | 2 +-
drivers/iio/common/ssp_sensors/ssp_dev.c | 2 +-
drivers/mtd/spi-nor/fsl-quadspi.c | 8 ++++----
drivers/pci/dwc/pcie-qcom.c | 4 ++--
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 4 ++--
drivers/pinctrl/pinctrl-at91-pio4.c | 4 ++--
drivers/pinctrl/pinctrl-axp209.c | 2 +-
drivers/power/avs/rockchip-io-domain.c | 24 ++++++++++++------------
drivers/power/reset/at91-sama5d2_shdwc.c | 4 ++--
drivers/power/supply/axp20x_ac_power.c | 8 ++++----
drivers/spi/spi-fsl-dspi.c | 7 +++----
drivers/spi/spi-sirf.c | 4 ++--
13 files changed, 44 insertions(+), 44 deletions(-)


2018-01-02 13:56:57

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 04/12] PCI: qcom: account for const type of of_device_id.data

This driver creates various const structures that it stores in the
data field of an of_device_id array.

Adding const to the declaration of the location that receives the
const value from the data field ensures that the compiler will
continue to check that the value is not modified. Furthermore, the
const-discarding cast on the extraction from the data field is no
longer needed.

Done using Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/pci/dwc/pcie-qcom.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/drivers/pci/dwc/pcie-qcom.c b/drivers/pci/dwc/pcie-qcom.c
--- a/drivers/pci/dwc/pcie-qcom.c
+++ b/drivers/pci/dwc/pcie-qcom.c
@@ -171,7 +171,7 @@ struct qcom_pcie {
union qcom_pcie_resources res;
struct phy *phy;
struct gpio_desc *reset;
- struct qcom_pcie_ops *ops;
+ const struct qcom_pcie_ops *ops;
};

#define to_qcom_pcie(x) dev_get_drvdata((x)->dev)
@@ -1234,7 +1234,7 @@ static int qcom_pcie_probe(struct platfo

pcie->pci = pci;

- pcie->ops = (struct qcom_pcie_ops *)of_device_get_match_data(dev);
+ pcie->ops = of_device_get_match_data(dev);

pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_LOW);
if (IS_ERR(pcie->reset))

2018-01-02 13:56:55

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 05/12] pinctrl: armada-37xx: account for const type of of_device_id.data

The data field of an of_device_id structure has type const void *, so
there is no need for a const-discarding cast when putting const values
into such a structure.

Done using Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -1006,11 +1006,11 @@ static int armada_37xx_pinctrl_register(
static const struct of_device_id armada_37xx_pinctrl_of_match[] = {
{
.compatible = "marvell,armada3710-sb-pinctrl",
- .data = (void *)&armada_37xx_pin_sb,
+ .data = &armada_37xx_pin_sb,
},
{
.compatible = "marvell,armada3710-nb-pinctrl",
- .data = (void *)&armada_37xx_pin_nb,
+ .data = &armada_37xx_pin_nb,
},
{ },
};

2018-01-02 13:57:29

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 12/12] power: reset: account for const type of of_device_id.data

This driver creates a const structure that it stores in the data
field of an of_device_id array.

Add const to the declaration of the location that receives a value
from the data field to ensure that the compiler will continue to check
that the value is not modified and remove the const-dropping cast on
the access to the data field.

Done using Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/power/reset/at91-sama5d2_shdwc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c
--- a/drivers/power/reset/at91-sama5d2_shdwc.c
+++ b/drivers/power/reset/at91-sama5d2_shdwc.c
@@ -68,7 +68,7 @@ struct shdwc_config {
};

struct shdwc {
- struct shdwc_config *cfg;
+ const struct shdwc_config *cfg;
void __iomem *at91_shdwc_base;
};

@@ -260,7 +260,7 @@ static int __init at91_shdwc_probe(struc
}

match = of_match_node(at91_shdwc_of_match, pdev->dev.of_node);
- at91_shdwc->cfg = (struct shdwc_config *)(match->data);
+ at91_shdwc->cfg = match->data;

sclk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(sclk))

2018-01-02 13:57:58

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 09/12] mtd: fsl-quadspi: account for const type of of_device_id.data

This driver creates a number of const structures that it stores in the
data field of an of_device_id array.

The data field of an of_device_id structure has type const void *, so
there is no need for a const-discarding cast when putting const values
into such a structure.

Done using Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/mtd/spi-nor/fsl-quadspi.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff -u -p a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
--- a/drivers/mtd/spi-nor/fsl-quadspi.c
+++ b/drivers/mtd/spi-nor/fsl-quadspi.c
@@ -801,10 +801,10 @@ static int fsl_qspi_nor_setup_last(struc
}

static const struct of_device_id fsl_qspi_dt_ids[] = {
- { .compatible = "fsl,vf610-qspi", .data = (void *)&vybrid_data, },
- { .compatible = "fsl,imx6sx-qspi", .data = (void *)&imx6sx_data, },
- { .compatible = "fsl,imx7d-qspi", .data = (void *)&imx7d_data, },
- { .compatible = "fsl,imx6ul-qspi", .data = (void *)&imx6ul_data, },
+ { .compatible = "fsl,vf610-qspi", .data = &vybrid_data, },
+ { .compatible = "fsl,imx6sx-qspi", .data = &imx6sx_data, },
+ { .compatible = "fsl,imx7d-qspi", .data = &imx7d_data, },
+ { .compatible = "fsl,imx6ul-qspi", .data = &imx6ul_data, },
{ .compatible = "fsl,ls1021a-qspi", .data = (void *)&ls1021a_data, },
{ /* sentinel */ }
};

2018-01-02 13:57:57

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 11/12] iio: common: ssp_sensors: account for const type of of_device_id.data

This driver creates a number of const structures that it stores in the
data field of an of_device_id array.

Add const to the declaration of the location that receives a value
from the data field to ensure that the compiler will continue to check
that the value is not modified and remove the const-dropping cast on
the access to the data field.

Done using Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/iio/common/ssp_sensors/ssp.h | 2 +-
drivers/iio/common/ssp_sensors/ssp_dev.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/drivers/iio/common/ssp_sensors/ssp.h b/drivers/iio/common/ssp_sensors/ssp.h
--- a/drivers/iio/common/ssp_sensors/ssp.h
+++ b/drivers/iio/common/ssp_sensors/ssp.h
@@ -188,7 +188,7 @@ struct ssp_sensorhub_info {
*/
struct ssp_data {
struct spi_device *spi;
- struct ssp_sensorhub_info *sensorhub_info;
+ const struct ssp_sensorhub_info *sensorhub_info;
struct timer_list wdt_timer;
struct work_struct work_wdt;
struct delayed_work work_refresh;
diff -u -p a/drivers/iio/common/ssp_sensors/ssp_dev.c b/drivers/iio/common/ssp_sensors/ssp_dev.c
--- a/drivers/iio/common/ssp_sensors/ssp_dev.c
+++ b/drivers/iio/common/ssp_sensors/ssp_dev.c
@@ -486,7 +486,7 @@ static struct ssp_data *ssp_parse_dt(str
if (!match)
goto err_mcu_reset_gpio;

- data->sensorhub_info = (struct ssp_sensorhub_info *)match->data;
+ data->sensorhub_info = match->data;

dev_set_drvdata(dev, data);


2018-01-02 13:58:29

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 10/12] spi: spi-fsl-dspi: account for const type of of_device_id.data

This driver creates a number of const structures that it stores in the
data field of an of_device_id array.

The data field of an of_device_id structure has type const void *, so
there is no need for a const-discarding cast when putting const values
into such a structure.

Done using Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/spi/spi-fsl-dspi.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 02d3ed7..0630962 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -903,10 +903,9 @@ static irqreturn_t dspi_interrupt(int irq, void *dev_id)
}

static const struct of_device_id fsl_dspi_dt_ids[] = {
- { .compatible = "fsl,vf610-dspi", .data = (void *)&vf610_data, },
- { .compatible = "fsl,ls1021a-v1.0-dspi",
- .data = (void *)&ls1021a_v1_data, },
- { .compatible = "fsl,ls2085a-dspi", .data = (void *)&ls2085a_data, },
+ { .compatible = "fsl,vf610-dspi", .data = &vf610_data, },
+ { .compatible = "fsl,ls1021a-v1.0-dspi", .data = &ls1021a_v1_data, },
+ { .compatible = "fsl,ls2085a-dspi", .data = &ls2085a_data, },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, fsl_dspi_dt_ids);

2018-01-02 13:56:54

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 03/12] spi: sirf: account for const type of of_device_id.data

This driver creates various const structures that it stores in the
data field of an of_device_id array.

Adding const to the declaration of the location that receives the
const value from the data field ensures that the compiler will
continue to check that the value is not modified. Furthermore, the
const-discarding cast on the extraction from the data field is no
longer needed.

Done using Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/spi/spi-sirf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c
--- a/drivers/spi/spi-sirf.c
+++ b/drivers/spi/spi-sirf.c
@@ -1072,7 +1072,7 @@ static int spi_sirfsoc_probe(struct plat
struct sirfsoc_spi *sspi;
struct spi_master *master;
struct resource *mem_res;
- struct sirf_spi_comp_data *spi_comp_data;
+ const struct sirf_spi_comp_data *spi_comp_data;
int irq;
int ret;
const struct of_device_id *match;
@@ -1092,7 +1092,7 @@ static int spi_sirfsoc_probe(struct plat
platform_set_drvdata(pdev, master);
sspi = spi_master_get_devdata(master);
sspi->fifo_full_offset = ilog2(sspi->fifo_size);
- spi_comp_data = (struct sirf_spi_comp_data *)match->data;
+ spi_comp_data = match->data;
sspi->regs = spi_comp_data->regs;
sspi->type = spi_comp_data->type;
sspi->fifo_level_chk_mask = (sspi->fifo_size / 4) - 1;

2018-01-02 13:58:59

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 07/12] i2c: rk3x: account for const type of of_device_id.data

This driver creates a number of const structures that it stores in
the data field of an of_device_id array.

The data field of an of_device_id structure has type const void *, so
there is no need for a const-discarding cast when putting const values
into such a structure.

Furthermore, adding const to the declaration of the location that
receives a const value from such a field ensures that the compiler
will continue to check that the value is not modified. The
const-discarding cast on the extraction from the data field is thus
no longer needed.

Done using Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/i2c/busses/i2c-rk3x.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff -u -p a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c
--- a/drivers/i2c/busses/i2c-rk3x.c
+++ b/drivers/i2c/busses/i2c-rk3x.c
@@ -194,7 +194,7 @@ struct rk3x_i2c_soc_data {
struct rk3x_i2c {
struct i2c_adapter adap;
struct device *dev;
- struct rk3x_i2c_soc_data *soc_data;
+ const struct rk3x_i2c_soc_data *soc_data;

/* Hardware resources */
void __iomem *regs;
@@ -1164,27 +1164,27 @@ static const struct rk3x_i2c_soc_data rk
static const struct of_device_id rk3x_i2c_match[] = {
{
.compatible = "rockchip,rv1108-i2c",
- .data = (void *)&rv1108_soc_data
+ .data = &rv1108_soc_data
},
{
.compatible = "rockchip,rk3066-i2c",
- .data = (void *)&rk3066_soc_data
+ .data = &rk3066_soc_data
},
{
.compatible = "rockchip,rk3188-i2c",
- .data = (void *)&rk3188_soc_data
+ .data = &rk3188_soc_data
},
{
.compatible = "rockchip,rk3228-i2c",
- .data = (void *)&rk3228_soc_data
+ .data = &rk3228_soc_data
},
{
.compatible = "rockchip,rk3288-i2c",
- .data = (void *)&rk3288_soc_data
+ .data = &rk3288_soc_data
},
{
.compatible = "rockchip,rk3399-i2c",
- .data = (void *)&rk3399_soc_data
+ .data = &rk3399_soc_data
},
{},
};
@@ -1207,7 +1207,7 @@ static int rk3x_i2c_probe(struct platfor
return -ENOMEM;

match = of_match_node(rk3x_i2c_match, np);
- i2c->soc_data = (struct rk3x_i2c_soc_data *)match->data;
+ i2c->soc_data = match->data;

/* use common interface to get I2C timing properties */
i2c_parse_fw_timings(&pdev->dev, &i2c->t, true);

2018-01-02 13:58:58

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 08/12] pinctrl: axp209: account for const type of of_device_id.data

The return value of of_device_get_match_data has type const void *.
The desc field of the pctl structure also has a const type, so there
is no need for the const-discarding cast between them.

Done using Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/pinctrl/pinctrl-axp209.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff -u -p a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c
--- a/drivers/pinctrl/pinctrl-axp209.c
+++ b/drivers/pinctrl/pinctrl-axp209.c
@@ -414,7 +414,7 @@ static int axp20x_pctl_probe(struct plat
pctl->chip.direction_input = axp20x_gpio_input;
pctl->chip.direction_output = axp20x_gpio_output;

- pctl->desc = (struct axp20x_pctrl_desc *)of_device_get_match_data(dev);
+ pctl->desc = of_device_get_match_data(dev);

pctl->chip.ngpio = pctl->desc->npins;


2018-01-02 13:59:34

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 06/12] power: supply: account for const type of of_device_id.data

This driver creates two const structures that it stores in the data
field of an of_device_id array.

The data field of an of_device_id structure has type const void *, so
there is no need for a const-discarding cast when putting const values
into such a structure.

Furthermore, adding const to the declaration of the location that
receives a const value from such a field ensures that the compiler
will continue to check that the value is not modified. The
const-discarding cast on the extraction from the data field is thus
no longer needed.

Done using Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/power/supply/axp20x_ac_power.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff -u -p a/drivers/power/supply/axp20x_ac_power.c b/drivers/power/supply/axp20x_ac_power.c
--- a/drivers/power/supply/axp20x_ac_power.c
+++ b/drivers/power/supply/axp20x_ac_power.c
@@ -159,7 +159,7 @@ static int axp20x_ac_power_probe(struct
struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
struct power_supply_config psy_cfg = {};
struct axp20x_ac_power *power;
- struct axp_data *axp_data;
+ const struct axp_data *axp_data;
static const char * const irq_names[] = { "ACIN_PLUGIN", "ACIN_REMOVAL",
NULL };
int i, irq, ret;
@@ -176,7 +176,7 @@ static int axp20x_ac_power_probe(struct
if (!power)
return -ENOMEM;

- axp_data = (struct axp_data *)of_device_get_match_data(&pdev->dev);
+ axp_data = of_device_get_match_data(&pdev->dev);

if (axp_data->acin_adc) {
power->acin_v = devm_iio_channel_get(&pdev->dev, "acin_v");
@@ -230,10 +230,10 @@ static int axp20x_ac_power_probe(struct
static const struct of_device_id axp20x_ac_power_match[] = {
{
.compatible = "x-powers,axp202-ac-power-supply",
- .data = (void *)&axp20x_data,
+ .data = &axp20x_data,
}, {
.compatible = "x-powers,axp221-ac-power-supply",
- .data = (void *)&axp22x_data,
+ .data = &axp22x_data,
}, { /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, axp20x_ac_power_match);

2018-01-02 14:00:30

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 02/12] pinctrl: at91-pio4: account for const type of of_device_id.data

This driver creates a const structure that it stores in the data field
of an of_device_id array.

Adding const to the declaration of the location that receives the
const value from the data field ensures that the compiler will
continue to check that the value is not modified. Furthermore, the
const-discarding cast on the extraction from the data field is no
longer needed.

Done using Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/pinctrl/pinctrl-at91-pio4.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c
--- a/drivers/pinctrl/pinctrl-at91-pio4.c
+++ b/drivers/pinctrl/pinctrl-at91-pio4.c
@@ -910,7 +910,7 @@ static int atmel_pinctrl_probe(struct pl
int i, ret;
struct resource *res;
struct atmel_pioctrl *atmel_pioctrl;
- struct atmel_pioctrl_data *atmel_pioctrl_data;
+ const struct atmel_pioctrl_data *atmel_pioctrl_data;

atmel_pioctrl = devm_kzalloc(dev, sizeof(*atmel_pioctrl), GFP_KERNEL);
if (!atmel_pioctrl)
@@ -924,7 +924,7 @@ static int atmel_pinctrl_probe(struct pl
dev_err(dev, "unknown compatible string\n");
return -ENODEV;
}
- atmel_pioctrl_data = (struct atmel_pioctrl_data *)match->data;
+ atmel_pioctrl_data = match->data;
atmel_pioctrl->nbanks = atmel_pioctrl_data->nbanks;
atmel_pioctrl->npins = atmel_pioctrl->nbanks * ATMEL_PIO_NPINS_PER_BANK;


2018-01-02 14:00:47

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 01/12] PM / AVS: rockchip-io: account for const type of of_device_id.data

This driver creates a number of const structures that it stores in the
data field of an of_device_id array.

The data field of an of_device_id structure has type const void *, so
there is no need for a const-discarding cast when putting const values
into such a structure.

Furthermore, adding const to the declaration of the location that
receives a const value from such a field ensures that the compiler
will continue to check that the value is not modified. The
const-discarding cast on the extraction from the data field is
thus no longer needed.

Done using Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>

---
drivers/power/avs/rockchip-io-domain.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff -u -p a/drivers/power/avs/rockchip-io-domain.c b/drivers/power/avs/rockchip-io-domain.c
--- a/drivers/power/avs/rockchip-io-domain.c
+++ b/drivers/power/avs/rockchip-io-domain.c
@@ -76,7 +76,7 @@ struct rockchip_iodomain_supply {
struct rockchip_iodomain {
struct device *dev;
struct regmap *grf;
- struct rockchip_iodomain_soc_data *soc_data;
+ const struct rockchip_iodomain_soc_data *soc_data;
struct rockchip_iodomain_supply supplies[MAX_SUPPLIES];
};

@@ -382,43 +382,43 @@ static const struct rockchip_iodomain_so
static const struct of_device_id rockchip_iodomain_match[] = {
{
.compatible = "rockchip,rk3188-io-voltage-domain",
- .data = (void *)&soc_data_rk3188
+ .data = &soc_data_rk3188
},
{
.compatible = "rockchip,rk3228-io-voltage-domain",
- .data = (void *)&soc_data_rk3228
+ .data = &soc_data_rk3228
},
{
.compatible = "rockchip,rk3288-io-voltage-domain",
- .data = (void *)&soc_data_rk3288
+ .data = &soc_data_rk3288
},
{
.compatible = "rockchip,rk3328-io-voltage-domain",
- .data = (void *)&soc_data_rk3328
+ .data = &soc_data_rk3328
},
{
.compatible = "rockchip,rk3368-io-voltage-domain",
- .data = (void *)&soc_data_rk3368
+ .data = &soc_data_rk3368
},
{
.compatible = "rockchip,rk3368-pmu-io-voltage-domain",
- .data = (void *)&soc_data_rk3368_pmu
+ .data = &soc_data_rk3368_pmu
},
{
.compatible = "rockchip,rk3399-io-voltage-domain",
- .data = (void *)&soc_data_rk3399
+ .data = &soc_data_rk3399
},
{
.compatible = "rockchip,rk3399-pmu-io-voltage-domain",
- .data = (void *)&soc_data_rk3399_pmu
+ .data = &soc_data_rk3399_pmu
},
{
.compatible = "rockchip,rv1108-io-voltage-domain",
- .data = (void *)&soc_data_rv1108
+ .data = &soc_data_rv1108
},
{
.compatible = "rockchip,rv1108-pmu-io-voltage-domain",
- .data = (void *)&soc_data_rv1108_pmu
+ .data = &soc_data_rv1108_pmu
},
{ /* sentinel */ },
};
@@ -443,7 +443,7 @@ static int rockchip_iodomain_probe(struc
platform_set_drvdata(pdev, iod);

match = of_match_node(rockchip_iodomain_match, np);
- iod->soc_data = (struct rockchip_iodomain_soc_data *)match->data;
+ iod->soc_data = match->data;

parent = pdev->dev.parent;
if (parent && parent->of_node) {

2018-01-02 15:36:22

by Gregory CLEMENT

[permalink] [raw]
Subject: Re: [PATCH 05/12] pinctrl: armada-37xx: account for const type of of_device_id.data

Hi Julia,

On mar., janv. 02 2018, Julia Lawall <[email protected]> wrote:

> The data field of an of_device_id structure has type const void *, so
> there is no need for a const-discarding cast when putting const values
> into such a structure.
>
> Done using Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>


Acked-by: Gregory CLEMENT <[email protected]>

Thanks,

Gregory


PS: actually the intent was not to do a const-discarding cast it was
just a useless cast! :)


>
> ---
> drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff -u -p a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
> --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
> +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
> @@ -1006,11 +1006,11 @@ static int armada_37xx_pinctrl_register(
> static const struct of_device_id armada_37xx_pinctrl_of_match[] = {
> {
> .compatible = "marvell,armada3710-sb-pinctrl",
> - .data = (void *)&armada_37xx_pin_sb,
> + .data = &armada_37xx_pin_sb,
> },
> {
> .compatible = "marvell,armada3710-nb-pinctrl",
> - .data = (void *)&armada_37xx_pin_nb,
> + .data = &armada_37xx_pin_nb,
> },
> { },
> };
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

--
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

2018-01-03 07:58:27

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 02/12] pinctrl: at91-pio4: account for const type of of_device_id.data

On Tue, Jan 2, 2018 at 2:27 PM, Julia Lawall <[email protected]> wrote:

> This driver creates a const structure that it stores in the data field
> of an of_device_id array.
>
> Adding const to the declaration of the location that receives the
> const value from the data field ensures that the compiler will
> continue to check that the value is not modified. Furthermore, the
> const-discarding cast on the extraction from the data field is no
> longer needed.
>
> Done using Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>

Patch applied.

Yours,
Linus Walleij

2018-01-03 07:59:28

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 08/12] pinctrl: axp209: account for const type of of_device_id.data

On Tue, Jan 2, 2018 at 2:28 PM, Julia Lawall <[email protected]> wrote:

> The return value of of_device_get_match_data has type const void *.
> The desc field of the pctl structure also has a const type, so there
> is no need for the const-discarding cast between them.
>
> Done using Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>

Patch applied.

Yours,
Linus Walleij

2018-01-03 08:03:44

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 05/12] pinctrl: armada-37xx: account for const type of of_device_id.data

On Tue, Jan 2, 2018 at 2:28 PM, Julia Lawall <[email protected]> wrote:

> The data field of an of_device_id structure has type const void *, so
> there is no need for a const-discarding cast when putting const values
> into such a structure.
>
> Done using Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>

Patch applied with Gregory's ACK.

Yours,
Linus Walleij

2018-01-03 12:15:29

by Mark Brown

[permalink] [raw]
Subject: Applied "spi: sirf: account for const type of of_device_id.data" to the spi tree

The patch

spi: sirf: account for const type of of_device_id.data

has been applied to the spi tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 9e327ce71f3894e7e6b57f5c15a0dfa5be79f44e Mon Sep 17 00:00:00 2001
From: Julia Lawall <[email protected]>
Date: Tue, 2 Jan 2018 14:27:59 +0100
Subject: [PATCH] spi: sirf: account for const type of of_device_id.data

This driver creates various const structures that it stores in the
data field of an of_device_id array.

Adding const to the declaration of the location that receives the
const value from the data field ensures that the compiler will
continue to check that the value is not modified. Furthermore, the
const-discarding cast on the extraction from the data field is no
longer needed.

Done using Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
---
drivers/spi/spi-sirf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c
index bbb1a275f718..f009d76f96b1 100644
--- a/drivers/spi/spi-sirf.c
+++ b/drivers/spi/spi-sirf.c
@@ -1072,7 +1072,7 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
struct sirfsoc_spi *sspi;
struct spi_master *master;
struct resource *mem_res;
- struct sirf_spi_comp_data *spi_comp_data;
+ const struct sirf_spi_comp_data *spi_comp_data;
int irq;
int ret;
const struct of_device_id *match;
@@ -1092,7 +1092,7 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, master);
sspi = spi_master_get_devdata(master);
sspi->fifo_full_offset = ilog2(sspi->fifo_size);
- spi_comp_data = (struct sirf_spi_comp_data *)match->data;
+ spi_comp_data = match->data;
sspi->regs = spi_comp_data->regs;
sspi->type = spi_comp_data->type;
sspi->fifo_level_chk_mask = (sspi->fifo_size / 4) - 1;
--
2.15.1

2018-01-03 12:21:43

by Lorenzo Pieralisi

[permalink] [raw]
Subject: Re: [PATCH 04/12] PCI: qcom: account for const type of of_device_id.data

On Tue, Jan 02, 2018 at 02:28:00PM +0100, Julia Lawall wrote:
> This driver creates various const structures that it stores in the
> data field of an of_device_id array.
>
> Adding const to the declaration of the location that receives the
> const value from the data field ensures that the compiler will
> continue to check that the value is not modified. Furthermore, the
> const-discarding cast on the extraction from the data field is no
> longer needed.
>
> Done using Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>
>
> ---
> drivers/pci/dwc/pcie-qcom.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

Hi Julia,

I am happy to take this patch through the PCI tree unless you see a
problem with that, please let me know.

Thanks,
Lorenzo

> diff -u -p a/drivers/pci/dwc/pcie-qcom.c b/drivers/pci/dwc/pcie-qcom.c
> --- a/drivers/pci/dwc/pcie-qcom.c
> +++ b/drivers/pci/dwc/pcie-qcom.c
> @@ -171,7 +171,7 @@ struct qcom_pcie {
> union qcom_pcie_resources res;
> struct phy *phy;
> struct gpio_desc *reset;
> - struct qcom_pcie_ops *ops;
> + const struct qcom_pcie_ops *ops;
> };
>
> #define to_qcom_pcie(x) dev_get_drvdata((x)->dev)
> @@ -1234,7 +1234,7 @@ static int qcom_pcie_probe(struct platfo
>
> pcie->pci = pci;
>
> - pcie->ops = (struct qcom_pcie_ops *)of_device_get_match_data(dev);
> + pcie->ops = of_device_get_match_data(dev);
>
> pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_LOW);
> if (IS_ERR(pcie->reset))
>

2018-01-03 12:22:53

by Mark Brown

[permalink] [raw]
Subject: Applied "spi: spi-fsl-dspi: account for const type of of_device_id.data" to the spi tree

The patch

spi: spi-fsl-dspi: account for const type of of_device_id.data

has been applied to the spi tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 230c08b2acf65863ac5905ea1fa93106bdd20af3 Mon Sep 17 00:00:00 2001
From: Julia Lawall <[email protected]>
Date: Tue, 2 Jan 2018 14:28:06 +0100
Subject: [PATCH] spi: spi-fsl-dspi: account for const type of
of_device_id.data

This driver creates a number of const structures that it stores in the
data field of an of_device_id array.

The data field of an of_device_id structure has type const void *, so
there is no need for a const-discarding cast when putting const values
into such a structure.

Done using Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
---
drivers/spi/spi-fsl-dspi.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
index 02d3ed7f2558..0630962ce442 100644
--- a/drivers/spi/spi-fsl-dspi.c
+++ b/drivers/spi/spi-fsl-dspi.c
@@ -903,10 +903,9 @@ static irqreturn_t dspi_interrupt(int irq, void *dev_id)
}

static const struct of_device_id fsl_dspi_dt_ids[] = {
- { .compatible = "fsl,vf610-dspi", .data = (void *)&vf610_data, },
- { .compatible = "fsl,ls1021a-v1.0-dspi",
- .data = (void *)&ls1021a_v1_data, },
- { .compatible = "fsl,ls2085a-dspi", .data = (void *)&ls2085a_data, },
+ { .compatible = "fsl,vf610-dspi", .data = &vf610_data, },
+ { .compatible = "fsl,ls1021a-v1.0-dspi", .data = &ls1021a_v1_data, },
+ { .compatible = "fsl,ls2085a-dspi", .data = &ls2085a_data, },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, fsl_dspi_dt_ids);
--
2.15.1

2018-01-03 12:23:01

by Mark Brown

[permalink] [raw]
Subject: Applied "spi: sirf: account for const type of of_device_id.data" to the spi tree

The patch

spi: sirf: account for const type of of_device_id.data

has been applied to the spi tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 9e327ce71f3894e7e6b57f5c15a0dfa5be79f44e Mon Sep 17 00:00:00 2001
From: Julia Lawall <[email protected]>
Date: Tue, 2 Jan 2018 14:27:59 +0100
Subject: [PATCH] spi: sirf: account for const type of of_device_id.data

This driver creates various const structures that it stores in the
data field of an of_device_id array.

Adding const to the declaration of the location that receives the
const value from the data field ensures that the compiler will
continue to check that the value is not modified. Furthermore, the
const-discarding cast on the extraction from the data field is no
longer needed.

Done using Coccinelle.

Signed-off-by: Julia Lawall <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
---
drivers/spi/spi-sirf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c
index bbb1a275f718..f009d76f96b1 100644
--- a/drivers/spi/spi-sirf.c
+++ b/drivers/spi/spi-sirf.c
@@ -1072,7 +1072,7 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
struct sirfsoc_spi *sspi;
struct spi_master *master;
struct resource *mem_res;
- struct sirf_spi_comp_data *spi_comp_data;
+ const struct sirf_spi_comp_data *spi_comp_data;
int irq;
int ret;
const struct of_device_id *match;
@@ -1092,7 +1092,7 @@ static int spi_sirfsoc_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, master);
sspi = spi_master_get_devdata(master);
sspi->fifo_full_offset = ilog2(sspi->fifo_size);
- spi_comp_data = (struct sirf_spi_comp_data *)match->data;
+ spi_comp_data = match->data;
sspi->regs = spi_comp_data->regs;
sspi->type = spi_comp_data->type;
sspi->fifo_level_chk_mask = (sspi->fifo_size / 4) - 1;
--
2.15.1

2018-01-03 12:38:33

by Stanimir Varbanov

[permalink] [raw]
Subject: Re: [PATCH 04/12] PCI: qcom: account for const type of of_device_id.data

Hi Lorenzo,

On 01/03/2018 02:22 PM, Lorenzo Pieralisi wrote:
> On Tue, Jan 02, 2018 at 02:28:00PM +0100, Julia Lawall wrote:
>> This driver creates various const structures that it stores in the
>> data field of an of_device_id array.
>>
>> Adding const to the declaration of the location that receives the
>> const value from the data field ensures that the compiler will
>> continue to check that the value is not modified. Furthermore, the
>> const-discarding cast on the extraction from the data field is no
>> longer needed.
>>
>> Done using Coccinelle.
>>
>> Signed-off-by: Julia Lawall <[email protected]>
>>
>> ---
>> drivers/pci/dwc/pcie-qcom.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> Hi Julia,

Probably that is addressed to me :)

>
> I am happy to take this patch through the PCI tree unless you see a
> problem with that, please let me know.

The patch looks fine.

Acked-by: Stanimir Varbanov <[email protected]>

--
regards,
Stan

2018-01-03 12:38:36

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH 04/12] PCI: qcom: account for const type of of_device_id.data



On Wed, 3 Jan 2018, Lorenzo Pieralisi wrote:

> On Tue, Jan 02, 2018 at 02:28:00PM +0100, Julia Lawall wrote:
> > This driver creates various const structures that it stores in the
> > data field of an of_device_id array.
> >
> > Adding const to the declaration of the location that receives the
> > const value from the data field ensures that the compiler will
> > continue to check that the value is not modified. Furthermore, the
> > const-discarding cast on the extraction from the data field is no
> > longer needed.
> >
> > Done using Coccinelle.
> >
> > Signed-off-by: Julia Lawall <[email protected]>
> >
> > ---
> > drivers/pci/dwc/pcie-qcom.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
>
> Hi Julia,
>
> I am happy to take this patch through the PCI tree unless you see a
> problem with that, please let me know.

Please take it. Thanks.

julia

>
> Thanks,
> Lorenzo
>
> > diff -u -p a/drivers/pci/dwc/pcie-qcom.c b/drivers/pci/dwc/pcie-qcom.c
> > --- a/drivers/pci/dwc/pcie-qcom.c
> > +++ b/drivers/pci/dwc/pcie-qcom.c
> > @@ -171,7 +171,7 @@ struct qcom_pcie {
> > union qcom_pcie_resources res;
> > struct phy *phy;
> > struct gpio_desc *reset;
> > - struct qcom_pcie_ops *ops;
> > + const struct qcom_pcie_ops *ops;
> > };
> >
> > #define to_qcom_pcie(x) dev_get_drvdata((x)->dev)
> > @@ -1234,7 +1234,7 @@ static int qcom_pcie_probe(struct platfo
> >
> > pcie->pci = pci;
> >
> > - pcie->ops = (struct qcom_pcie_ops *)of_device_get_match_data(dev);
> > + pcie->ops = of_device_get_match_data(dev);
> >
> > pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_LOW);
> > if (IS_ERR(pcie->reset))
> >
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>

2018-01-03 18:23:34

by Lorenzo Pieralisi

[permalink] [raw]
Subject: Re: [PATCH 04/12] PCI: qcom: account for const type of of_device_id.data

On Wed, Jan 03, 2018 at 01:38:27PM +0100, Julia Lawall wrote:
>
>
> On Wed, 3 Jan 2018, Lorenzo Pieralisi wrote:
>
> > On Tue, Jan 02, 2018 at 02:28:00PM +0100, Julia Lawall wrote:
> > > This driver creates various const structures that it stores in the
> > > data field of an of_device_id array.
> > >
> > > Adding const to the declaration of the location that receives the
> > > const value from the data field ensures that the compiler will
> > > continue to check that the value is not modified. Furthermore, the
> > > const-discarding cast on the extraction from the data field is no
> > > longer needed.
> > >
> > > Done using Coccinelle.
> > >
> > > Signed-off-by: Julia Lawall <[email protected]>
> > >
> > > ---
> > > drivers/pci/dwc/pcie-qcom.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > Hi Julia,
> >
> > I am happy to take this patch through the PCI tree unless you see a
> > problem with that, please let me know.
>
> Please take it. Thanks.

Applied to pci/dwc for v4.16, thanks.

Lorenzo

> julia
>
> >
> > Thanks,
> > Lorenzo
> >
> > > diff -u -p a/drivers/pci/dwc/pcie-qcom.c b/drivers/pci/dwc/pcie-qcom.c
> > > --- a/drivers/pci/dwc/pcie-qcom.c
> > > +++ b/drivers/pci/dwc/pcie-qcom.c
> > > @@ -171,7 +171,7 @@ struct qcom_pcie {
> > > union qcom_pcie_resources res;
> > > struct phy *phy;
> > > struct gpio_desc *reset;
> > > - struct qcom_pcie_ops *ops;
> > > + const struct qcom_pcie_ops *ops;
> > > };
> > >
> > > #define to_qcom_pcie(x) dev_get_drvdata((x)->dev)
> > > @@ -1234,7 +1234,7 @@ static int qcom_pcie_probe(struct platfo
> > >
> > > pcie->pci = pci;
> > >
> > > - pcie->ops = (struct qcom_pcie_ops *)of_device_get_match_data(dev);
> > > + pcie->ops = of_device_get_match_data(dev);
> > >
> > > pcie->reset = devm_gpiod_get_optional(dev, "perst", GPIOD_OUT_LOW);
> > > if (IS_ERR(pcie->reset))
> > >
> > --
> > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> > the body of a message to [email protected]
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> >

2018-01-05 13:25:00

by Alexandre Belloni

[permalink] [raw]
Subject: Re: [PATCH 12/12] power: reset: account for const type of of_device_id.data

On 02/01/2018 at 14:28:08 +0100, Julia Lawall wrote:
> This driver creates a const structure that it stores in the data
> field of an of_device_id array.
>
> Add const to the declaration of the location that receives a value
> from the data field to ensure that the compiler will continue to check
> that the value is not modified and remove the const-dropping cast on
> the access to the data field.
>
> Done using Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>
Acked-by: Alexandre Belloni <[email protected]>


--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

2018-01-06 12:23:13

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH 11/12] iio: common: ssp_sensors: account for const type of of_device_id.data

On Tue, 2 Jan 2018 14:28:07 +0100
Julia Lawall <[email protected]> wrote:

> This driver creates a number of const structures that it stores in the
> data field of an of_device_id array.
>
> Add const to the declaration of the location that receives a value
> from the data field to ensure that the compiler will continue to check
> that the value is not modified and remove the const-dropping cast on
> the access to the data field.
>
> Done using Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>

Thanks. Applied to the togreg branch of iio.git and pushed out
as testing for the autobuilders to play with it.

Jonathan

>
> ---
> drivers/iio/common/ssp_sensors/ssp.h | 2 +-
> drivers/iio/common/ssp_sensors/ssp_dev.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff -u -p a/drivers/iio/common/ssp_sensors/ssp.h b/drivers/iio/common/ssp_sensors/ssp.h
> --- a/drivers/iio/common/ssp_sensors/ssp.h
> +++ b/drivers/iio/common/ssp_sensors/ssp.h
> @@ -188,7 +188,7 @@ struct ssp_sensorhub_info {
> */
> struct ssp_data {
> struct spi_device *spi;
> - struct ssp_sensorhub_info *sensorhub_info;
> + const struct ssp_sensorhub_info *sensorhub_info;
> struct timer_list wdt_timer;
> struct work_struct work_wdt;
> struct delayed_work work_refresh;
> diff -u -p a/drivers/iio/common/ssp_sensors/ssp_dev.c b/drivers/iio/common/ssp_sensors/ssp_dev.c
> --- a/drivers/iio/common/ssp_sensors/ssp_dev.c
> +++ b/drivers/iio/common/ssp_sensors/ssp_dev.c
> @@ -486,7 +486,7 @@ static struct ssp_data *ssp_parse_dt(str
> if (!match)
> goto err_mcu_reset_gpio;
>
> - data->sensorhub_info = (struct ssp_sensorhub_info *)match->data;
> + data->sensorhub_info = match->data;
>
> dev_set_drvdata(dev, data);
>
>

2018-01-07 18:08:23

by Cyrille Pitchen

[permalink] [raw]
Subject: Re: [PATCH 09/12] mtd: fsl-quadspi: account for const type of of_device_id.data

Le 02/01/2018 à 14:28, Julia Lawall a écrit :
> This driver creates a number of const structures that it stores in the
> data field of an of_device_id array.
>
> The data field of an of_device_id structure has type const void *, so
> there is no need for a const-discarding cast when putting const values
> into such a structure.
>
> Done using Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>
>

Applied to the spi-nor/next branch of linux-mtd

Thanks!

> ---
> drivers/mtd/spi-nor/fsl-quadspi.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff -u -p a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
> --- a/drivers/mtd/spi-nor/fsl-quadspi.c
> +++ b/drivers/mtd/spi-nor/fsl-quadspi.c
> @@ -801,10 +801,10 @@ static int fsl_qspi_nor_setup_last(struc
> }
>
> static const struct of_device_id fsl_qspi_dt_ids[] = {
> - { .compatible = "fsl,vf610-qspi", .data = (void *)&vybrid_data, },
> - { .compatible = "fsl,imx6sx-qspi", .data = (void *)&imx6sx_data, },
> - { .compatible = "fsl,imx7d-qspi", .data = (void *)&imx7d_data, },
> - { .compatible = "fsl,imx6ul-qspi", .data = (void *)&imx6ul_data, },
> + { .compatible = "fsl,vf610-qspi", .data = &vybrid_data, },
> + { .compatible = "fsl,imx6sx-qspi", .data = &imx6sx_data, },
> + { .compatible = "fsl,imx7d-qspi", .data = &imx7d_data, },
> + { .compatible = "fsl,imx6ul-qspi", .data = &imx6ul_data, },
> { .compatible = "fsl,ls1021a-qspi", .data = (void *)&ls1021a_data, },
> { /* sentinel */ }
> };
>
>

2018-01-09 16:22:30

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 06/12] power: supply: account for const type of of_device_id.data

Hi,

On Tue, Jan 02, 2018 at 02:28:02PM +0100, Julia Lawall wrote:
> This driver creates two const structures that it stores in the data
> field of an of_device_id array.
>
> The data field of an of_device_id structure has type const void *, so
> there is no need for a const-discarding cast when putting const values
> into such a structure.
>
> Furthermore, adding const to the declaration of the location that
> receives a const value from such a field ensures that the compiler
> will continue to check that the value is not modified. The
> const-discarding cast on the extraction from the data field is thus
> no longer needed.
>
> Done using Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>
>
> ---

Thanks, queued.

-- Sebastian

> drivers/power/supply/axp20x_ac_power.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff -u -p a/drivers/power/supply/axp20x_ac_power.c b/drivers/power/supply/axp20x_ac_power.c
> --- a/drivers/power/supply/axp20x_ac_power.c
> +++ b/drivers/power/supply/axp20x_ac_power.c
> @@ -159,7 +159,7 @@ static int axp20x_ac_power_probe(struct
> struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
> struct power_supply_config psy_cfg = {};
> struct axp20x_ac_power *power;
> - struct axp_data *axp_data;
> + const struct axp_data *axp_data;
> static const char * const irq_names[] = { "ACIN_PLUGIN", "ACIN_REMOVAL",
> NULL };
> int i, irq, ret;
> @@ -176,7 +176,7 @@ static int axp20x_ac_power_probe(struct
> if (!power)
> return -ENOMEM;
>
> - axp_data = (struct axp_data *)of_device_get_match_data(&pdev->dev);
> + axp_data = of_device_get_match_data(&pdev->dev);
>
> if (axp_data->acin_adc) {
> power->acin_v = devm_iio_channel_get(&pdev->dev, "acin_v");
> @@ -230,10 +230,10 @@ static int axp20x_ac_power_probe(struct
> static const struct of_device_id axp20x_ac_power_match[] = {
> {
> .compatible = "x-powers,axp202-ac-power-supply",
> - .data = (void *)&axp20x_data,
> + .data = &axp20x_data,
> }, {
> .compatible = "x-powers,axp221-ac-power-supply",
> - .data = (void *)&axp22x_data,
> + .data = &axp22x_data,
> }, { /* sentinel */ }
> };
> MODULE_DEVICE_TABLE(of, axp20x_ac_power_match);
>


Attachments:
(No filename) (2.19 kB)
signature.asc (833.00 B)
Download all attachments

2018-01-09 16:22:49

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCH 12/12] power: reset: account for const type of of_device_id.data

Hi,

On Tue, Jan 02, 2018 at 02:28:08PM +0100, Julia Lawall wrote:
> This driver creates a const structure that it stores in the data
> field of an of_device_id array.
>
> Add const to the declaration of the location that receives a value
> from the data field to ensure that the compiler will continue to check
> that the value is not modified and remove the const-dropping cast on
> the access to the data field.
>
> Done using Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>
>
> ---

Thanks, queued.

-- Sebastian

> drivers/power/reset/at91-sama5d2_shdwc.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff -u -p a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c
> --- a/drivers/power/reset/at91-sama5d2_shdwc.c
> +++ b/drivers/power/reset/at91-sama5d2_shdwc.c
> @@ -68,7 +68,7 @@ struct shdwc_config {
> };
>
> struct shdwc {
> - struct shdwc_config *cfg;
> + const struct shdwc_config *cfg;
> void __iomem *at91_shdwc_base;
> };
>
> @@ -260,7 +260,7 @@ static int __init at91_shdwc_probe(struc
> }
>
> match = of_match_node(at91_shdwc_of_match, pdev->dev.of_node);
> - at91_shdwc->cfg = (struct shdwc_config *)(match->data);
> + at91_shdwc->cfg = match->data;
>
> sclk = devm_clk_get(&pdev->dev, NULL);
> if (IS_ERR(sclk))
>


Attachments:
(No filename) (1.30 kB)
signature.asc (833.00 B)
Download all attachments

2018-01-15 18:25:00

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH 07/12] i2c: rk3x: account for const type of of_device_id.data

On Tue, Jan 02, 2018 at 02:28:03PM +0100, Julia Lawall wrote:
> This driver creates a number of const structures that it stores in
> the data field of an of_device_id array.
>
> The data field of an of_device_id structure has type const void *, so
> there is no need for a const-discarding cast when putting const values
> into such a structure.
>
> Furthermore, adding const to the declaration of the location that
> receives a const value from such a field ensures that the compiler
> will continue to check that the value is not modified. The
> const-discarding cast on the extraction from the data field is thus
> no longer needed.
>
> Done using Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>

Heiko, you okay with the patch?

>
> ---
> drivers/i2c/busses/i2c-rk3x.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff -u -p a/drivers/i2c/busses/i2c-rk3x.c b/drivers/i2c/busses/i2c-rk3x.c
> --- a/drivers/i2c/busses/i2c-rk3x.c
> +++ b/drivers/i2c/busses/i2c-rk3x.c
> @@ -194,7 +194,7 @@ struct rk3x_i2c_soc_data {
> struct rk3x_i2c {
> struct i2c_adapter adap;
> struct device *dev;
> - struct rk3x_i2c_soc_data *soc_data;
> + const struct rk3x_i2c_soc_data *soc_data;
>
> /* Hardware resources */
> void __iomem *regs;
> @@ -1164,27 +1164,27 @@ static const struct rk3x_i2c_soc_data rk
> static const struct of_device_id rk3x_i2c_match[] = {
> {
> .compatible = "rockchip,rv1108-i2c",
> - .data = (void *)&rv1108_soc_data
> + .data = &rv1108_soc_data
> },
> {
> .compatible = "rockchip,rk3066-i2c",
> - .data = (void *)&rk3066_soc_data
> + .data = &rk3066_soc_data
> },
> {
> .compatible = "rockchip,rk3188-i2c",
> - .data = (void *)&rk3188_soc_data
> + .data = &rk3188_soc_data
> },
> {
> .compatible = "rockchip,rk3228-i2c",
> - .data = (void *)&rk3228_soc_data
> + .data = &rk3228_soc_data
> },
> {
> .compatible = "rockchip,rk3288-i2c",
> - .data = (void *)&rk3288_soc_data
> + .data = &rk3288_soc_data
> },
> {
> .compatible = "rockchip,rk3399-i2c",
> - .data = (void *)&rk3399_soc_data
> + .data = &rk3399_soc_data
> },
> {},
> };
> @@ -1207,7 +1207,7 @@ static int rk3x_i2c_probe(struct platfor
> return -ENOMEM;
>
> match = of_match_node(rk3x_i2c_match, np);
> - i2c->soc_data = (struct rk3x_i2c_soc_data *)match->data;
> + i2c->soc_data = match->data;
>
> /* use common interface to get I2C timing properties */
> i2c_parse_fw_timings(&pdev->dev, &i2c->t, true);
>


Attachments:
(No filename) (2.46 kB)
signature.asc (833.00 B)
Download all attachments

2018-01-17 11:00:26

by Heiko Stuebner

[permalink] [raw]
Subject: Re: [PATCH 07/12] i2c: rk3x: account for const type of of_device_id.data

Am Montag, 15. Januar 2018, 19:24:56 CET schrieb Wolfram Sang:
> On Tue, Jan 02, 2018 at 02:28:03PM +0100, Julia Lawall wrote:
> > This driver creates a number of const structures that it stores in
> > the data field of an of_device_id array.
> >
> > The data field of an of_device_id structure has type const void *, so
> > there is no need for a const-discarding cast when putting const values
> > into such a structure.
> >
> > Furthermore, adding const to the declaration of the location that
> > receives a const value from such a field ensures that the compiler
> > will continue to check that the value is not modified. The
> > const-discarding cast on the extraction from the data field is thus
> > no longer needed.
> >
> > Done using Coccinelle.
> >
> > Signed-off-by: Julia Lawall <[email protected]>
>
> Heiko, you okay with the patch?

Looks good to me and does not seem to contain any changes related
to actual functionality, so
Reviewed-by: Heiko Stuebner <[email protected]>

2018-01-17 23:13:33

by Wolfram Sang

[permalink] [raw]
Subject: Re: [PATCH 07/12] i2c: rk3x: account for const type of of_device_id.data

On Tue, Jan 02, 2018 at 02:28:03PM +0100, Julia Lawall wrote:
> This driver creates a number of const structures that it stores in
> the data field of an of_device_id array.
>
> The data field of an of_device_id structure has type const void *, so
> there is no need for a const-discarding cast when putting const values
> into such a structure.
>
> Furthermore, adding const to the declaration of the location that
> receives a const value from such a field ensures that the compiler
> will continue to check that the value is not modified. The
> const-discarding cast on the extraction from the data field is thus
> no longer needed.
>
> Done using Coccinelle.
>
> Signed-off-by: Julia Lawall <[email protected]>
>

Applied to for-next, thanks!


Attachments:
(No filename) (778.00 B)
signature.asc (849.00 B)
Download all attachments