* [PATCH v2 0/3] of_mdio: use IS_ERR_OR_NULL() and PTR_ERR_OR_ZERO() @ 2016-03-12 21:32 Sergei Shtylyov 2016-03-12 21:33 ` [PATCH v2 1/3] of_mdio: mdio_device_create() never returns NULL Sergei Shtylyov ` (3 more replies) 0 siblings, 4 replies; 7+ messages in thread From: Sergei Shtylyov @ 2016-03-12 21:32 UTC (permalink / raw) To: grant.likely, robh+dt, devicetree, f.fainelli, netdev, frowand.list Hello. Here's the set of 3 patches against DaveM's 'net-next.git' repo. They deal with some error checks in the device tree MDIO code... [1/3] of_mdio: mdio_device_create() never returns NULL [2/3] of_mdio: use IS_ERR_OR_NULL() [3/3] of_mdio: use PTR_ERR_OR_ZERO() MBR, Sergei ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/3] of_mdio: mdio_device_create() never returns NULL 2016-03-12 21:32 [PATCH v2 0/3] of_mdio: use IS_ERR_OR_NULL() and PTR_ERR_OR_ZERO() Sergei Shtylyov @ 2016-03-12 21:33 ` Sergei Shtylyov 2016-03-12 21:34 ` [PATCH v2 2/3] of_mdio: use IS_ERR_OR_NULL() Sergei Shtylyov ` (2 subsequent siblings) 3 siblings, 0 replies; 7+ messages in thread From: Sergei Shtylyov @ 2016-03-12 21:33 UTC (permalink / raw) To: grant.likely, robh+dt, devicetree, f.fainelli, netdev, frowand.list mdio_device_create() never returns NULL, thus checking for it in of_mdiobus_register_device() is pointless... Suggested-by: Vladimir Zapolskiy <vz@mleia.com> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> --- Changes in version 2: - new patch. drivers/of/of_mdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: net-next/drivers/of/of_mdio.c =================================================================== --- net-next.orig/drivers/of/of_mdio.c +++ net-next/drivers/of/of_mdio.c @@ -98,7 +98,7 @@ static int of_mdiobus_register_device(st int rc; mdiodev = mdio_device_create(mdio, addr); - if (!mdiodev || IS_ERR(mdiodev)) + if (IS_ERR(mdiodev)) return 1; /* Associate the OF node with the device structure so it ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 2/3] of_mdio: use IS_ERR_OR_NULL() 2016-03-12 21:32 [PATCH v2 0/3] of_mdio: use IS_ERR_OR_NULL() and PTR_ERR_OR_ZERO() Sergei Shtylyov 2016-03-12 21:33 ` [PATCH v2 1/3] of_mdio: mdio_device_create() never returns NULL Sergei Shtylyov @ 2016-03-12 21:34 ` Sergei Shtylyov [not found] ` <2638820.ej0i0xi4Er-gHKXc3Y1Z8zGSmamagVegGFoWSdPRAKMAL8bYrjMMd8@public.gmane.org> 2016-03-12 21:34 ` [PATCH v2 3/3] of_mdio: use PTR_ERR_OR_ZERO() Sergei Shtylyov 2016-03-14 19:32 ` [PATCH v2 0/3] of_mdio: use IS_ERR_OR_NULL() and PTR_ERR_OR_ZERO() David Miller 3 siblings, 1 reply; 7+ messages in thread From: Sergei Shtylyov @ 2016-03-12 21:34 UTC (permalink / raw) To: grant.likely, robh+dt, devicetree, f.fainelli, netdev, frowand.list IS_ERR_OR_NULL() is open coded in of_mdiobus_register_phy(), so just call it directly... Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> --- Changes in version 2: - removed the of_mdiobus_register_device() hunk; - added the "Reviewed-by:" tag. drivers/of/of_mdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: net-next/drivers/of/of_mdio.c =================================================================== --- net-next.orig/drivers/of/of_mdio.c +++ net-next/drivers/of/of_mdio.c @@ -56,7 +56,7 @@ static int of_mdiobus_register_phy(struc phy = phy_device_create(mdio, addr, phy_id, 0, NULL); else phy = get_phy_device(mdio, addr, is_c45); - if (!phy || IS_ERR(phy)) + if (IS_ERR_OR_NULL(phy)) return 1; rc = irq_of_parse_and_map(child, 0); ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <2638820.ej0i0xi4Er-gHKXc3Y1Z8zGSmamagVegGFoWSdPRAKMAL8bYrjMMd8@public.gmane.org>]
* Re: [PATCH v2 2/3] of_mdio: use IS_ERR_OR_NULL() [not found] ` <2638820.ej0i0xi4Er-gHKXc3Y1Z8zGSmamagVegGFoWSdPRAKMAL8bYrjMMd8@public.gmane.org> @ 2016-03-13 22:22 ` Arnd Bergmann 2016-03-14 18:52 ` Sergei Shtylyov 0 siblings, 1 reply; 7+ messages in thread From: Arnd Bergmann @ 2016-03-13 22:22 UTC (permalink / raw) To: Sergei Shtylyov Cc: grant.likely-QSEj5FYQhm4dnm+yROfE0A, robh+dt-DgEjT+Ai2ygdnm+yROfE0A, devicetree-u79uwXL29TY76Z2rM5mHXA, f.fainelli-Re5JQEeQqe8AvxtiuMwx3w, netdev-u79uwXL29TY76Z2rM5mHXA, frowand.list-Re5JQEeQqe8AvxtiuMwx3w On Sunday 13 March 2016 00:34:02 Sergei Shtylyov wrote: > IS_ERR_OR_NULL() is open coded in of_mdiobus_register_phy(), so just call > it directly... > > Signed-off-by: Sergei Shtylyov <sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org> > Reviewed-by: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > --- > Changes in version 2: > - removed the of_mdiobus_register_device() hunk; > - added the "Reviewed-by:" tag. > > drivers/of/of_mdio.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > Index: net-next/drivers/of/of_mdio.c > =================================================================== > --- net-next.orig/drivers/of/of_mdio.c > +++ net-next/drivers/of/of_mdio.c > @@ -56,7 +56,7 @@ static int of_mdiobus_register_phy(struc > phy = phy_device_create(mdio, addr, phy_id, 0, NULL); > else > phy = get_phy_device(mdio, addr, is_c45); > - if (!phy || IS_ERR(phy)) > + if (IS_ERR_OR_NULL(phy)) > return 1; > > rc = irq_of_parse_and_map(child, 0); > > IS_ERR_OR_NULL() usually indicates that the code is wrong, or that an API has been misdesigned. Can you clarify in the changelog which one it is, or (better) change it so that 'phy' in this function is either NULL or IS_ERR() in case of an error but not both? I think moving the 'if (problem) return 1' into the two if/else is a correct transformation that also makes it very clear what is going on here. Arnd -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 2/3] of_mdio: use IS_ERR_OR_NULL() 2016-03-13 22:22 ` Arnd Bergmann @ 2016-03-14 18:52 ` Sergei Shtylyov 0 siblings, 0 replies; 7+ messages in thread From: Sergei Shtylyov @ 2016-03-14 18:52 UTC (permalink / raw) To: Arnd Bergmann Cc: grant.likely, robh+dt, devicetree, f.fainelli, netdev, frowand.list On 03/14/2016 01:22 AM, Arnd Bergmann wrote: >> IS_ERR_OR_NULL() is open coded in of_mdiobus_register_phy(), so just call >> it directly... >> >> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> >> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> >> >> --- >> Changes in version 2: >> - removed the of_mdiobus_register_device() hunk; >> - added the "Reviewed-by:" tag. >> >> drivers/of/of_mdio.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> Index: net-next/drivers/of/of_mdio.c >> =================================================================== >> --- net-next.orig/drivers/of/of_mdio.c >> +++ net-next/drivers/of/of_mdio.c >> @@ -56,7 +56,7 @@ static int of_mdiobus_register_phy(struc >> phy = phy_device_create(mdio, addr, phy_id, 0, NULL); >> else >> phy = get_phy_device(mdio, addr, is_c45); >> - if (!phy || IS_ERR(phy)) >> + if (IS_ERR_OR_NULL(phy)) >> return 1; >> >> rc = irq_of_parse_and_map(child, 0); >> >> > > IS_ERR_OR_NULL() usually indicates that the code is wrong, or that > an API has been misdesigned. > > Can you clarify in the changelog which one it is, The second. :-) > or (better) change > it so that 'phy' in this function is either NULL or IS_ERR() in case > of an error but not both? I guess you meant to change get_phy_device() to not return NULL (and so only return the error codes, not both), am I correct? > I think moving the 'if (problem) return 1' into the two if/else > is a correct transformation that also makes it very clear what > is going on here. Can be done too... it's not that I have much time for that many respins though. It all started with 1 little patch (this one). :-) > Arnd MBR, Sergei ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 3/3] of_mdio: use PTR_ERR_OR_ZERO() 2016-03-12 21:32 [PATCH v2 0/3] of_mdio: use IS_ERR_OR_NULL() and PTR_ERR_OR_ZERO() Sergei Shtylyov 2016-03-12 21:33 ` [PATCH v2 1/3] of_mdio: mdio_device_create() never returns NULL Sergei Shtylyov 2016-03-12 21:34 ` [PATCH v2 2/3] of_mdio: use IS_ERR_OR_NULL() Sergei Shtylyov @ 2016-03-12 21:34 ` Sergei Shtylyov 2016-03-14 19:32 ` [PATCH v2 0/3] of_mdio: use IS_ERR_OR_NULL() and PTR_ERR_OR_ZERO() David Miller 3 siblings, 0 replies; 7+ messages in thread From: Sergei Shtylyov @ 2016-03-12 21:34 UTC (permalink / raw) To: grant.likely, robh+dt, devicetree, f.fainelli, netdev, frowand.list PTR_ERR_OR_ZERO() is open coded in of_phy_register_fixed_link(), so just call it directly... Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Vladimir Zapolskiy <vz@mleia.com> --- Changes in version 2: - added the "Reviewed-by:" tags. drivers/of/of_mdio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) Index: net-next/drivers/of/of_mdio.c =================================================================== --- net-next.orig/drivers/of/of_mdio.c +++ net-next/drivers/of/of_mdio.c @@ -412,7 +412,7 @@ int of_phy_register_fixed_link(struct de if (strcmp(managed, "in-band-status") == 0) { /* status is zeroed, namely its .link member */ phy = fixed_phy_register(PHY_POLL, &status, -1, np); - return IS_ERR(phy) ? PTR_ERR(phy) : 0; + return PTR_ERR_OR_ZERO(phy); } } @@ -434,7 +434,7 @@ int of_phy_register_fixed_link(struct de return -EPROBE_DEFER; phy = fixed_phy_register(PHY_POLL, &status, link_gpio, np); - return IS_ERR(phy) ? PTR_ERR(phy) : 0; + return PTR_ERR_OR_ZERO(phy); } /* Old binding */ @@ -446,7 +446,7 @@ int of_phy_register_fixed_link(struct de status.pause = be32_to_cpu(fixed_link_prop[3]); status.asym_pause = be32_to_cpu(fixed_link_prop[4]); phy = fixed_phy_register(PHY_POLL, &status, -1, np); - return IS_ERR(phy) ? PTR_ERR(phy) : 0; + return PTR_ERR_OR_ZERO(phy); } return -ENODEV; ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/3] of_mdio: use IS_ERR_OR_NULL() and PTR_ERR_OR_ZERO() 2016-03-12 21:32 [PATCH v2 0/3] of_mdio: use IS_ERR_OR_NULL() and PTR_ERR_OR_ZERO() Sergei Shtylyov ` (2 preceding siblings ...) 2016-03-12 21:34 ` [PATCH v2 3/3] of_mdio: use PTR_ERR_OR_ZERO() Sergei Shtylyov @ 2016-03-14 19:32 ` David Miller 3 siblings, 0 replies; 7+ messages in thread From: David Miller @ 2016-03-14 19:32 UTC (permalink / raw) To: sergei.shtylyov Cc: grant.likely, robh+dt, devicetree, f.fainelli, netdev, frowand.list From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Date: Sun, 13 Mar 2016 00:32:13 +0300 > Here's the set of 3 patches against DaveM's 'net-next.git' > repo. They deal with some error checks in the device tree MDIO > code... Series applied, thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-03-14 19:32 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-03-12 21:32 [PATCH v2 0/3] of_mdio: use IS_ERR_OR_NULL() and PTR_ERR_OR_ZERO() Sergei Shtylyov 2016-03-12 21:33 ` [PATCH v2 1/3] of_mdio: mdio_device_create() never returns NULL Sergei Shtylyov 2016-03-12 21:34 ` [PATCH v2 2/3] of_mdio: use IS_ERR_OR_NULL() Sergei Shtylyov [not found] ` <2638820.ej0i0xi4Er-gHKXc3Y1Z8zGSmamagVegGFoWSdPRAKMAL8bYrjMMd8@public.gmane.org> 2016-03-13 22:22 ` Arnd Bergmann 2016-03-14 18:52 ` Sergei Shtylyov 2016-03-12 21:34 ` [PATCH v2 3/3] of_mdio: use PTR_ERR_OR_ZERO() Sergei Shtylyov 2016-03-14 19:32 ` [PATCH v2 0/3] of_mdio: use IS_ERR_OR_NULL() and PTR_ERR_OR_ZERO() David Miller
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).