linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/12] account for const type of of_device_id.data
@ 2018-01-02 13:27 Julia Lawall
  2018-01-02 13:27 ` [PATCH 01/12] PM / AVS: rockchip-io: " Julia Lawall
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Julia Lawall @ 2018-01-02 13:27 UTC (permalink / raw)
  To: linux-arm-kernel

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(-)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 01/12] PM / AVS: rockchip-io: account for const type of of_device_id.data
  2018-01-02 13:27 [PATCH 00/12] account for const type of of_device_id.data Julia Lawall
@ 2018-01-02 13:27 ` Julia Lawall
  2018-01-02 13:27 ` [PATCH 02/12] pinctrl: at91-pio4: " Julia Lawall
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Julia Lawall @ 2018-01-02 13:27 UTC (permalink / raw)
  To: linux-arm-kernel

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 <Julia.Lawall@lip6.fr>

---
 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) {

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 02/12] pinctrl: at91-pio4: account for const type of of_device_id.data
  2018-01-02 13:27 [PATCH 00/12] account for const type of of_device_id.data Julia Lawall
  2018-01-02 13:27 ` [PATCH 01/12] PM / AVS: rockchip-io: " Julia Lawall
@ 2018-01-02 13:27 ` Julia Lawall
  2018-01-03  7:58   ` Linus Walleij
  2018-01-02 13:27 ` [PATCH 03/12] spi: sirf: " Julia Lawall
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Julia Lawall @ 2018-01-02 13:27 UTC (permalink / raw)
  To: linux-arm-kernel

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 <Julia.Lawall@lip6.fr>

---
 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;
 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 03/12] spi: sirf: account for const type of of_device_id.data
  2018-01-02 13:27 [PATCH 00/12] account for const type of of_device_id.data Julia Lawall
  2018-01-02 13:27 ` [PATCH 01/12] PM / AVS: rockchip-io: " Julia Lawall
  2018-01-02 13:27 ` [PATCH 02/12] pinctrl: at91-pio4: " Julia Lawall
@ 2018-01-02 13:27 ` Julia Lawall
  2018-01-03 12:15   ` Applied "spi: sirf: account for const type of of_device_id.data" to the spi tree Mark Brown
  2018-01-03 12:22   ` Mark Brown
  2018-01-02 13:28 ` [PATCH 05/12] pinctrl: armada-37xx: account for const type of of_device_id.data Julia Lawall
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 17+ messages in thread
From: Julia Lawall @ 2018-01-02 13:27 UTC (permalink / raw)
  To: linux-arm-kernel

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 <Julia.Lawall@lip6.fr>

---
 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;

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 05/12] pinctrl: armada-37xx: account for const type of of_device_id.data
  2018-01-02 13:27 [PATCH 00/12] account for const type of of_device_id.data Julia Lawall
                   ` (2 preceding siblings ...)
  2018-01-02 13:27 ` [PATCH 03/12] spi: sirf: " Julia Lawall
@ 2018-01-02 13:28 ` Julia Lawall
  2018-01-02 15:36   ` Gregory CLEMENT
  2018-01-03  8:03   ` Linus Walleij
  2018-01-02 13:28 ` [PATCH 07/12] i2c: rk3x: " Julia Lawall
  2018-01-02 13:28 ` [PATCH 12/12] power: reset: " Julia Lawall
  5 siblings, 2 replies; 17+ messages in thread
From: Julia Lawall @ 2018-01-02 13:28 UTC (permalink / raw)
  To: linux-arm-kernel

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 <Julia.Lawall@lip6.fr>

---
 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,
 	},
 	{ },
 };

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 07/12] i2c: rk3x: account for const type of of_device_id.data
  2018-01-02 13:27 [PATCH 00/12] account for const type of of_device_id.data Julia Lawall
                   ` (3 preceding siblings ...)
  2018-01-02 13:28 ` [PATCH 05/12] pinctrl: armada-37xx: account for const type of of_device_id.data Julia Lawall
@ 2018-01-02 13:28 ` Julia Lawall
  2018-01-15 18:24   ` Wolfram Sang
  2018-01-17 23:12   ` Wolfram Sang
  2018-01-02 13:28 ` [PATCH 12/12] power: reset: " Julia Lawall
  5 siblings, 2 replies; 17+ messages in thread
From: Julia Lawall @ 2018-01-02 13:28 UTC (permalink / raw)
  To: linux-arm-kernel

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 <Julia.Lawall@lip6.fr>

---
 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);

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 12/12] power: reset: account for const type of of_device_id.data
  2018-01-02 13:27 [PATCH 00/12] account for const type of of_device_id.data Julia Lawall
                   ` (4 preceding siblings ...)
  2018-01-02 13:28 ` [PATCH 07/12] i2c: rk3x: " Julia Lawall
@ 2018-01-02 13:28 ` Julia Lawall
  2018-01-05 13:24   ` Alexandre Belloni
  2018-01-09 16:22   ` Sebastian Reichel
  5 siblings, 2 replies; 17+ messages in thread
From: Julia Lawall @ 2018-01-02 13:28 UTC (permalink / raw)
  To: linux-arm-kernel

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 <Julia.Lawall@lip6.fr>

---
 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))

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 05/12] pinctrl: armada-37xx: account for const type of of_device_id.data
  2018-01-02 13:28 ` [PATCH 05/12] pinctrl: armada-37xx: account for const type of of_device_id.data Julia Lawall
@ 2018-01-02 15:36   ` Gregory CLEMENT
  2018-01-03  8:03   ` Linus Walleij
  1 sibling, 0 replies; 17+ messages in thread
From: Gregory CLEMENT @ 2018-01-02 15:36 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Julia,
 
 On mar., janv. 02 2018, Julia Lawall <Julia.Lawall@lip6.fr> 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 <Julia.Lawall@lip6.fr>


Acked-by: Gregory CLEMENT <gregory.clement@free-electrons.com>

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
> linux-arm-kernel at lists.infradead.org
> 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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 02/12] pinctrl: at91-pio4: account for const type of of_device_id.data
  2018-01-02 13:27 ` [PATCH 02/12] pinctrl: at91-pio4: " Julia Lawall
@ 2018-01-03  7:58   ` Linus Walleij
  0 siblings, 0 replies; 17+ messages in thread
From: Linus Walleij @ 2018-01-03  7:58 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 2, 2018 at 2:27 PM, Julia Lawall <Julia.Lawall@lip6.fr> 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 <Julia.Lawall@lip6.fr>

Patch applied.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 05/12] pinctrl: armada-37xx: account for const type of of_device_id.data
  2018-01-02 13:28 ` [PATCH 05/12] pinctrl: armada-37xx: account for const type of of_device_id.data Julia Lawall
  2018-01-02 15:36   ` Gregory CLEMENT
@ 2018-01-03  8:03   ` Linus Walleij
  1 sibling, 0 replies; 17+ messages in thread
From: Linus Walleij @ 2018-01-03  8:03 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jan 2, 2018 at 2:28 PM, Julia Lawall <Julia.Lawall@lip6.fr> 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 <Julia.Lawall@lip6.fr>

Patch applied with Gregory's ACK.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Applied "spi: sirf: account for const type of of_device_id.data" to the spi tree
  2018-01-02 13:27 ` [PATCH 03/12] spi: sirf: " Julia Lawall
@ 2018-01-03 12:15   ` Mark Brown
  2018-01-03 12:22   ` Mark Brown
  1 sibling, 0 replies; 17+ messages in thread
From: Mark Brown @ 2018-01-03 12:15 UTC (permalink / raw)
  To: linux-arm-kernel

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 <Julia.Lawall@lip6.fr>
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 <Julia.Lawall@lip6.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 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

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Applied "spi: sirf: account for const type of of_device_id.data" to the spi tree
  2018-01-02 13:27 ` [PATCH 03/12] spi: sirf: " Julia Lawall
  2018-01-03 12:15   ` Applied "spi: sirf: account for const type of of_device_id.data" to the spi tree Mark Brown
@ 2018-01-03 12:22   ` Mark Brown
  1 sibling, 0 replies; 17+ messages in thread
From: Mark Brown @ 2018-01-03 12:22 UTC (permalink / raw)
  To: linux-arm-kernel

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 <Julia.Lawall@lip6.fr>
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 <Julia.Lawall@lip6.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 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

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 12/12] power: reset: account for const type of of_device_id.data
  2018-01-02 13:28 ` [PATCH 12/12] power: reset: " Julia Lawall
@ 2018-01-05 13:24   ` Alexandre Belloni
  2018-01-09 16:22   ` Sebastian Reichel
  1 sibling, 0 replies; 17+ messages in thread
From: Alexandre Belloni @ 2018-01-05 13:24 UTC (permalink / raw)
  To: linux-arm-kernel

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 <Julia.Lawall@lip6.fr>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>


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

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 12/12] power: reset: account for const type of of_device_id.data
  2018-01-02 13:28 ` [PATCH 12/12] power: reset: " Julia Lawall
  2018-01-05 13:24   ` Alexandre Belloni
@ 2018-01-09 16:22   ` Sebastian Reichel
  1 sibling, 0 replies; 17+ messages in thread
From: Sebastian Reichel @ 2018-01-09 16:22 UTC (permalink / raw)
  To: linux-arm-kernel

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 <Julia.Lawall@lip6.fr>
> 
> ---

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))
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180109/4c51cf66/attachment.sig>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 07/12] i2c: rk3x: account for const type of of_device_id.data
  2018-01-02 13:28 ` [PATCH 07/12] i2c: rk3x: " Julia Lawall
@ 2018-01-15 18:24   ` Wolfram Sang
  2018-01-17 11:00     ` Heiko Stuebner
  2018-01-17 23:12   ` Wolfram Sang
  1 sibling, 1 reply; 17+ messages in thread
From: Wolfram Sang @ 2018-01-15 18:24 UTC (permalink / raw)
  To: linux-arm-kernel

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 <Julia.Lawall@lip6.fr>

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);
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180115/5c0ecea0/attachment.sig>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 07/12] i2c: rk3x: account for const type of of_device_id.data
  2018-01-15 18:24   ` Wolfram Sang
@ 2018-01-17 11:00     ` Heiko Stuebner
  0 siblings, 0 replies; 17+ messages in thread
From: Heiko Stuebner @ 2018-01-17 11:00 UTC (permalink / raw)
  To: linux-arm-kernel

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 <Julia.Lawall@lip6.fr>
> 
> 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 <heiko@sntech.de>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 07/12] i2c: rk3x: account for const type of of_device_id.data
  2018-01-02 13:28 ` [PATCH 07/12] i2c: rk3x: " Julia Lawall
  2018-01-15 18:24   ` Wolfram Sang
@ 2018-01-17 23:12   ` Wolfram Sang
  1 sibling, 0 replies; 17+ messages in thread
From: Wolfram Sang @ 2018-01-17 23:12 UTC (permalink / raw)
  To: linux-arm-kernel

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 <Julia.Lawall@lip6.fr>
> 

Applied to for-next, thanks!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180118/4b380b13/attachment.sig>

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2018-01-17 23:12 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-02 13:27 [PATCH 00/12] account for const type of of_device_id.data Julia Lawall
2018-01-02 13:27 ` [PATCH 01/12] PM / AVS: rockchip-io: " Julia Lawall
2018-01-02 13:27 ` [PATCH 02/12] pinctrl: at91-pio4: " Julia Lawall
2018-01-03  7:58   ` Linus Walleij
2018-01-02 13:27 ` [PATCH 03/12] spi: sirf: " Julia Lawall
2018-01-03 12:15   ` Applied "spi: sirf: account for const type of of_device_id.data" to the spi tree Mark Brown
2018-01-03 12:22   ` Mark Brown
2018-01-02 13:28 ` [PATCH 05/12] pinctrl: armada-37xx: account for const type of of_device_id.data Julia Lawall
2018-01-02 15:36   ` Gregory CLEMENT
2018-01-03  8:03   ` Linus Walleij
2018-01-02 13:28 ` [PATCH 07/12] i2c: rk3x: " Julia Lawall
2018-01-15 18:24   ` Wolfram Sang
2018-01-17 11:00     ` Heiko Stuebner
2018-01-17 23:12   ` Wolfram Sang
2018-01-02 13:28 ` [PATCH 12/12] power: reset: " Julia Lawall
2018-01-05 13:24   ` Alexandre Belloni
2018-01-09 16:22   ` Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).