* [PATCH 00/11] use of_property_read_bool
@ 2016-08-05 8:56 Julia Lawall
2016-08-05 8:56 ` [PATCH 03/11] pinctrl: nomadik: " Julia Lawall
2016-08-05 8:56 ` [PATCH 10/11] soc: ti: knav_qmss_queue: " Julia Lawall
0 siblings, 2 replies; 7+ messages in thread
From: Julia Lawall @ 2016-08-05 8:56 UTC (permalink / raw)
To: linux-arm-kernel
Use of_property_read_bool to check for the existence of a property.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression e1,e2;
statement S2,S1;
@@
- if (of_get_property(e1,e2,NULL))
+ if (of_property_read_bool(e1,e2))
S1 else S2
// </smpl>
---
arch/powerpc/sysdev/mpic.c | 2 +-
drivers/i2c/busses/i2c-mpc.c | 2 +-
drivers/mmc/host/sdhci-of-esdhc.c | 2 +-
drivers/net/ethernet/freescale/xgmac_mdio.c | 3 +--
drivers/phy/phy-qcom-ufs.c | 2 +-
drivers/pinctrl/nomadik/pinctrl-nomadik.c | 2 +-
drivers/soc/fsl/qe/qe_tdm.c | 2 +-
drivers/soc/ti/knav_qmss_queue.c | 2 +-
drivers/tty/serial/atmel_serial.c | 8 ++++----
drivers/usb/host/fsl-mph-dr-of.c | 6 +++---
sound/soc/codecs/ab8500-codec.c | 10 +++++-----
sound/soc/sh/rcar/ssi.c | 2 +-
sound/soc/soc-core.c | 2 +-
13 files changed, 22 insertions(+), 23 deletions(-)
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 03/11] pinctrl: nomadik: use of_property_read_bool
2016-08-05 8:56 [PATCH 00/11] use of_property_read_bool Julia Lawall
@ 2016-08-05 8:56 ` Julia Lawall
2016-08-05 11:26 ` [PATCH 03/11 v2] " Julia Lawall
2016-08-11 11:52 ` [PATCH 03/11] " Linus Walleij
2016-08-05 8:56 ` [PATCH 10/11] soc: ti: knav_qmss_queue: " Julia Lawall
1 sibling, 2 replies; 7+ messages in thread
From: Julia Lawall @ 2016-08-05 8:56 UTC (permalink / raw)
To: linux-arm-kernel
Use of_property_read_bool to check for the existence of a property.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression e1,e2;
statement S2,S1;
@@
- if (of_get_property(e1,e2,NULL))
+ if (of_property_read_bool(e1,e2))
S1 else S2
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/pinctrl/nomadik/pinctrl-nomadik.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
index 35f6218..d8dc3fe 100644
--- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c
+++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
@@ -1110,7 +1110,7 @@ static int nmk_gpio_probe(struct platform_device *dev)
return PTR_ERR(nmk_chip);
}
- if (of_get_property(np, "st,supports-sleepmode", NULL))
+ if (of_property_read_bool(np, "st,supports-sleepmode"))
supports_sleepmode = true;
else
supports_sleepmode = false;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 10/11] soc: ti: knav_qmss_queue: use of_property_read_bool
2016-08-05 8:56 [PATCH 00/11] use of_property_read_bool Julia Lawall
2016-08-05 8:56 ` [PATCH 03/11] pinctrl: nomadik: " Julia Lawall
@ 2016-08-05 8:56 ` Julia Lawall
2016-08-05 12:47 ` Robin Murphy
1 sibling, 1 reply; 7+ messages in thread
From: Julia Lawall @ 2016-08-05 8:56 UTC (permalink / raw)
To: linux-arm-kernel
Use of_property_read_bool to check for the existence of a property.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression e1,e2;
statement S2,S1;
@@
- if (of_get_property(e1,e2,NULL))
+ if (of_property_read_bool(e1,e2))
S1 else S2
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/soc/ti/knav_qmss_queue.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
index b73e353..56b5d7c 100644
--- a/drivers/soc/ti/knav_qmss_queue.c
+++ b/drivers/soc/ti/knav_qmss_queue.c
@@ -1240,7 +1240,7 @@ static int knav_setup_queue_range(struct knav_device *kdev,
if (of_get_property(node, "qalloc-by-id", NULL))
range->flags |= RANGE_RESERVED;
- if (of_get_property(node, "accumulator", NULL)) {
+ if (of_property_read_bool(node, "accumulator")) {
ret = knav_init_acc_range(kdev, node, range);
if (ret < 0) {
devm_kfree(dev, range);
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 03/11 v2] pinctrl: nomadik: use of_property_read_bool
2016-08-05 8:56 ` [PATCH 03/11] pinctrl: nomadik: " Julia Lawall
@ 2016-08-05 11:26 ` Julia Lawall
2016-08-11 11:52 ` [PATCH 03/11] " Linus Walleij
1 sibling, 0 replies; 7+ messages in thread
From: Julia Lawall @ 2016-08-05 11:26 UTC (permalink / raw)
To: linux-arm-kernel
Use of_property_read_bool to check for the existence of a property.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression e1,e2,x;
@@
- if (of_get_property(e1,e2,NULL))
- x = true;
- else
- x = false;
+ x = of_property_read_bool(e1,e2);
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
v2: special case for propagating true and false
drivers/pinctrl/nomadik/pinctrl-nomadik.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
index 35f6218..6f2e1da 100644
--- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c
+++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
@@ -1110,10 +1110,8 @@ static int nmk_gpio_probe(struct platform_device *dev)
return PTR_ERR(nmk_chip);
}
- if (of_get_property(np, "st,supports-sleepmode", NULL))
- supports_sleepmode = true;
- else
- supports_sleepmode = false;
+ supports_sleepmode =
+ of_property_read_bool(np, "st,supports-sleepmode");
/* Correct platform device ID */
dev->id = nmk_chip->bank;
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 10/11] soc: ti: knav_qmss_queue: use of_property_read_bool
2016-08-05 8:56 ` [PATCH 10/11] soc: ti: knav_qmss_queue: " Julia Lawall
@ 2016-08-05 12:47 ` Robin Murphy
2016-08-05 12:59 ` Julia Lawall
0 siblings, 1 reply; 7+ messages in thread
From: Robin Murphy @ 2016-08-05 12:47 UTC (permalink / raw)
To: linux-arm-kernel
Hi Julia,
On 05/08/16 09:56, Julia Lawall wrote:
> Use of_property_read_bool to check for the existence of a property.
This caught my eye since Rob told me off for doing the same recently[1].
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression e1,e2;
> statement S2,S1;
> @@
> - if (of_get_property(e1,e2,NULL))
> + if (of_property_read_bool(e1,e2))
> S1 else S2
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
>
> ---
> drivers/soc/ti/knav_qmss_queue.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
> index b73e353..56b5d7c 100644
> --- a/drivers/soc/ti/knav_qmss_queue.c
> +++ b/drivers/soc/ti/knav_qmss_queue.c
> @@ -1240,7 +1240,7 @@ static int knav_setup_queue_range(struct knav_device *kdev,
> if (of_get_property(node, "qalloc-by-id", NULL))
According to the binding, "qalloc-by-id" _is_ a boolean property, so
this one really does deserve to be of_property_read_bool()...
> range->flags |= RANGE_RESERVED;
>
> - if (of_get_property(node, "accumulator", NULL)) {
> + if (of_property_read_bool(node, "accumulator")) {
...whereas "accumulator" must have a value, so this isn't technically
appropriate. In general, most of these "if the property exists, read the
property and do stuff" checks are probably a sign of code that could be
simplified by refactoring the "do stuff" step to just specifically
handle the "read the property" step returning -EINVAL when it's not present.
Robin.
[1]:https://www.mail-archive.com/iommu at lists.linux-foundation.org/msg13375.html
> ret = knav_init_acc_range(kdev, node, range);
> if (ret < 0) {
> devm_kfree(dev, range);
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 10/11] soc: ti: knav_qmss_queue: use of_property_read_bool
2016-08-05 12:47 ` Robin Murphy
@ 2016-08-05 12:59 ` Julia Lawall
0 siblings, 0 replies; 7+ messages in thread
From: Julia Lawall @ 2016-08-05 12:59 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, 5 Aug 2016, Robin Murphy wrote:
> Hi Julia,
>
> On 05/08/16 09:56, Julia Lawall wrote:
> > Use of_property_read_bool to check for the existence of a property.
>
> This caught my eye since Rob told me off for doing the same recently[1].
>
> > The semantic patch that makes this change is as follows:
> > (http://coccinelle.lip6.fr/)
> >
> > // <smpl>
> > @@
> > expression e1,e2;
> > statement S2,S1;
> > @@
> > - if (of_get_property(e1,e2,NULL))
> > + if (of_property_read_bool(e1,e2))
> > S1 else S2
> > // </smpl>
> >
> > Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> >
> > ---
> > drivers/soc/ti/knav_qmss_queue.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c
> > index b73e353..56b5d7c 100644
> > --- a/drivers/soc/ti/knav_qmss_queue.c
> > +++ b/drivers/soc/ti/knav_qmss_queue.c
> > @@ -1240,7 +1240,7 @@ static int knav_setup_queue_range(struct knav_device *kdev,
> > if (of_get_property(node, "qalloc-by-id", NULL))
>
> According to the binding, "qalloc-by-id" _is_ a boolean property, so
> this one really does deserve to be of_property_read_bool()...
>
> > range->flags |= RANGE_RESERVED;
> >
> > - if (of_get_property(node, "accumulator", NULL)) {
> > + if (of_property_read_bool(node, "accumulator")) {
>
> ...whereas "accumulator" must have a value, so this isn't technically
> appropriate. In general, most of these "if the property exists, read the
> property and do stuff" checks are probably a sign of code that could be
> simplified by refactoring the "do stuff" step to just specifically
> handle the "read the property" step returning -EINVAL when it's not present.
Thanks for the very helpful feedback. I will rethink the patch set in
light of this information.
julia
> Robin.
>
> [1]:https://www.mail-archive.com/iommu at lists.linux-foundation.org/msg13375.html
>
> > ret = knav_init_acc_range(kdev, node, range);
> > if (ret < 0) {
> > devm_kfree(dev, range);
> >
> >
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel at lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> >
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 03/11] pinctrl: nomadik: use of_property_read_bool
2016-08-05 8:56 ` [PATCH 03/11] pinctrl: nomadik: " Julia Lawall
2016-08-05 11:26 ` [PATCH 03/11 v2] " Julia Lawall
@ 2016-08-11 11:52 ` Linus Walleij
1 sibling, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2016-08-11 11:52 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Aug 5, 2016 at 10:56 AM, Julia Lawall <Julia.Lawall@lip6.fr> wrote:
> Use of_property_read_bool to check for the existence of a property.
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression e1,e2;
> statement S2,S1;
> @@
> - if (of_get_property(e1,e2,NULL))
> + if (of_property_read_bool(e1,e2))
> S1 else S2
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-08-11 11:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-05 8:56 [PATCH 00/11] use of_property_read_bool Julia Lawall
2016-08-05 8:56 ` [PATCH 03/11] pinctrl: nomadik: " Julia Lawall
2016-08-05 11:26 ` [PATCH 03/11 v2] " Julia Lawall
2016-08-11 11:52 ` [PATCH 03/11] " Linus Walleij
2016-08-05 8:56 ` [PATCH 10/11] soc: ti: knav_qmss_queue: " Julia Lawall
2016-08-05 12:47 ` Robin Murphy
2016-08-05 12:59 ` Julia Lawall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox