public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew-g2DYL2Zd6BY@public•gmane.org>
To: Raju Lakkaraju <Raju.Lakkaraju-dzo6w/eZyo2tG0bUXCXiUA@public•gmane.org>
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public•gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public•gmane.org,
	f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public•gmane.org,
	Allan.Nielsen-dzo6w/eZyo2tG0bUXCXiUA@public•gmane.org
Subject: Re: [PATCH v2 net-next] net: phy: Add LED mode driver for Microsemi PHYs.
Date: Tue, 7 Feb 2017 14:12:23 +0100	[thread overview]
Message-ID: <20170207131223.GE31560@lunn.ch> (raw)
In-Reply-To: <20170207091737.GA24582-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org>

> > > +- vsc8531,led-1-mode : LED mode. Specify how the LED[1] should behave.
> > > +                       Allowed values are define in
> > > +     int rc;
> > > +
> > > +     if (!of_node)
> > > +             return -ENODEV;
> > > +
> > > +     rc = of_property_read_u8(of_node, led, &led_mode);
> > > +     if ((rc == 0) &&
> > > +         ((led_mode > 15) || (led_mode == 7) || (led_mode == 11))) {
> > > +             phydev_err(phydev, "DT %s invalid\n", led);
> > > +             return -EINVAL;
> > > +     } else if (rc == -EINVAL) {
> > > +             return default_mode;
> > > +     }
> > 
> > I don't think you understood my comment about of_property_read_u8()
> > not modifying &led_mode on error. Please read the comment again, and
> > simplify this.
> > 
> 
> If i understand your comment correctly

Nope, you don't.

     rc = of_property_read_u8(of_node, led, &led_mode);

If rc indicates an error, led_mode is not touched. Read the
documentation for this function. So you can simplifiy the code:

	led_mode = default_mode;
	err = of_property_read_u8(of_node, led, &led_mode);
	if (!err && (led_mode > 15 || led_mode == 7) | (led_mode == 11) {
             phydev_err(phydev, "DT %s invalid\n", led);
             return -EINVAL;
	}
	return led_mode;

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

  parent reply	other threads:[~2017-02-07 13:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-01 12:53 [PATCH v2 net-next] net: phy: Add LED mode driver for Microsemi Raju Lakkaraju
2017-02-01 12:53 ` [PATCH v2 net-next] net: phy: Add LED mode driver for Microsemi PHYs Raju Lakkaraju
2017-02-01 13:55   ` Andrew Lunn
     [not found]     ` <20170201135555.GE4967-g2DYL2Zd6BY@public.gmane.org>
2017-02-07  9:17       ` Raju Lakkaraju
     [not found]         ` <20170207091737.GA24582-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org>
2017-02-07 13:12           ` Andrew Lunn [this message]
     [not found]   ` <1485953626-25780-2-git-send-email-Raju.Lakkaraju-dzo6w/eZyo2tG0bUXCXiUA@public.gmane.org>
2017-02-01 18:02     ` Rob Herring
2017-02-01 18:04 ` [PATCH v2 net-next] net: phy: Add LED mode driver for Microsemi Florian Fainelli
2017-02-07 13:39   ` Raju Lakkaraju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170207131223.GE31560@lunn.ch \
    --to=andrew-g2dyl2zd6by@public$(echo .)gmane.org \
    --cc=Allan.Nielsen-dzo6w/eZyo2tG0bUXCXiUA@public$(echo .)gmane.org \
    --cc=Raju.Lakkaraju-dzo6w/eZyo2tG0bUXCXiUA@public$(echo .)gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public$(echo .)gmane.org \
    --cc=f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public$(echo .)gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public$(echo .)gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox