* [PATCH 00/12] account for const type of of_device_id.data
@ 2018-01-02 13:27 Julia Lawall
2018-01-02 13:28 ` [PATCH 07/12] i2c: rk3x: " Julia Lawall
0 siblings, 1 reply; 5+ messages in thread
From: Julia Lawall @ 2018-01-02 13:27 UTC (permalink / raw)
To: linux-iio
Cc: kernel-janitors, Peter Meerwald-Stadler, Lars-Peter Clausen,
Hartmut Knaack, linux-mtd, linux-i2c, linux-spi, linux-rockchip,
linux-arm-kernel, linux-pm, linux-kernel, linux-gpio, linux-pci,
linux-arm-msm
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] 5+ 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 @ 2018-01-02 13:28 ` Julia Lawall 2018-01-15 18:24 ` Wolfram Sang 2018-01-17 23:12 ` Wolfram Sang 0 siblings, 2 replies; 5+ messages in thread From: Julia Lawall @ 2018-01-02 13:28 UTC (permalink / raw) To: Heiko Stuebner Cc: kernel-janitors, Wolfram Sang, linux-arm-kernel, linux-rockchip, linux-i2c, linux-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] 5+ messages in thread
* Re: [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; 5+ messages in thread From: Wolfram Sang @ 2018-01-15 18:24 UTC (permalink / raw) To: Julia Lawall Cc: Heiko Stuebner, kernel-janitors, linux-arm-kernel, linux-rockchip, linux-i2c, linux-kernel [-- Attachment #1: Type: text/plain, Size: 2604 bytes --] 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); > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [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; 5+ messages in thread From: Heiko Stuebner @ 2018-01-17 11:00 UTC (permalink / raw) To: Wolfram Sang Cc: Julia Lawall, kernel-janitors, linux-arm-kernel, linux-rockchip, linux-i2c, linux-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] 5+ messages in thread
* Re: [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; 5+ messages in thread From: Wolfram Sang @ 2018-01-17 23:12 UTC (permalink / raw) To: Julia Lawall Cc: Heiko Stuebner, kernel-janitors, linux-arm-kernel, linux-rockchip, linux-i2c, linux-kernel [-- Attachment #1: Type: text/plain, Size: 778 bytes --] 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! [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-01-17 23:12 UTC | newest] Thread overview: 5+ 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: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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox