Linux ARM-MSM sub-architecture
 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:28 ` [PATCH 04/12] PCI: qcom: " Julia Lawall
  0 siblings, 1 reply; 6+ 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] 6+ messages in thread

* [PATCH 04/12] PCI: qcom: 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-03 12:22   ` Lorenzo Pieralisi
  0 siblings, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2018-01-02 13:28 UTC (permalink / raw)
  To: Stanimir Varbanov
  Cc: kernel-janitors, Lorenzo Pieralisi, Bjorn Helgaas, linux-pci,
	linux-arm-msm, linux-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/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))

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

* Re: [PATCH 04/12] PCI: qcom: account for const type of of_device_id.data
  2018-01-02 13:28 ` [PATCH 04/12] PCI: qcom: " Julia Lawall
@ 2018-01-03 12:22   ` Lorenzo Pieralisi
  2018-01-03 12:38     ` Stanimir Varbanov
  2018-01-03 12:38     ` Julia Lawall
  0 siblings, 2 replies; 6+ messages in thread
From: Lorenzo Pieralisi @ 2018-01-03 12:22 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Stanimir Varbanov, kernel-janitors, Bjorn Helgaas, linux-pci,
	linux-arm-msm, linux-kernel

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

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

* Re: [PATCH 04/12] PCI: qcom: account for const type of of_device_id.data
  2018-01-03 12:22   ` Lorenzo Pieralisi
@ 2018-01-03 12:38     ` Stanimir Varbanov
  2018-01-03 12:38     ` Julia Lawall
  1 sibling, 0 replies; 6+ messages in thread
From: Stanimir Varbanov @ 2018-01-03 12:38 UTC (permalink / raw)
  To: Lorenzo Pieralisi, Julia Lawall
  Cc: kernel-janitors, Bjorn Helgaas, linux-pci, linux-arm-msm,
	linux-kernel

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 <Julia.Lawall@lip6.fr>
>>
>> ---
>>  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 <svarbanov@mm-sol.com>

-- 
regards,
Stan

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

* Re: [PATCH 04/12] PCI: qcom: account for const type of of_device_id.data
  2018-01-03 12:22   ` Lorenzo Pieralisi
  2018-01-03 12:38     ` Stanimir Varbanov
@ 2018-01-03 12:38     ` Julia Lawall
  2018-01-03 18:23       ` Lorenzo Pieralisi
  1 sibling, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2018-01-03 12:38 UTC (permalink / raw)
  To: Lorenzo Pieralisi
  Cc: Stanimir Varbanov, kernel-janitors, Bjorn Helgaas, linux-pci,
	linux-arm-msm, linux-kernel



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 <Julia.Lawall@lip6.fr>
> >
> > ---
> >  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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: [PATCH 04/12] PCI: qcom: account for const type of of_device_id.data
  2018-01-03 12:38     ` Julia Lawall
@ 2018-01-03 18:23       ` Lorenzo Pieralisi
  0 siblings, 0 replies; 6+ messages in thread
From: Lorenzo Pieralisi @ 2018-01-03 18:23 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Stanimir Varbanov, kernel-janitors, Bjorn Helgaas, linux-pci,
	linux-arm-msm, linux-kernel

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 <Julia.Lawall@lip6.fr>
> > >
> > > ---
> > >  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 majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >

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

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

Thread overview: 6+ 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 04/12] PCI: qcom: " Julia Lawall
2018-01-03 12:22   ` Lorenzo Pieralisi
2018-01-03 12:38     ` Stanimir Varbanov
2018-01-03 12:38     ` Julia Lawall
2018-01-03 18:23       ` Lorenzo Pieralisi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox