From: Ben Dooks <ben.dooks@codethink.co.uk>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: linux-kernel <linux-kernel@lists.codethink.co.uk>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH] phy: micrel: add of configuration for LED mode
Date: Thu, 27 Feb 2014 10:22:22 +0000 [thread overview]
Message-ID: <530F11DE.2000309@codethink.co.uk> (raw)
In-Reply-To: <CAGVrzcbUShzdYgEgHJiG8gL11+1DANiJpAk3PL5=jKASqXAyGg@mail.gmail.com>
On 26/02/14 22:20, Florian Fainelli wrote:
> Hi,
>
> 2014-02-26 3:48 GMT-08:00 Ben Dooks <ben.dooks@codethink.co.uk>:
>
> [snip]
>
>> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
>> index 5a8993b..0c9e434 100644
>> --- a/drivers/net/phy/micrel.c
>> +++ b/drivers/net/phy/micrel.c
>> @@ -148,15 +148,52 @@ static int ks8737_config_intr(struct phy_device *phydev)
>> return rc < 0 ? rc : 0;
>> }
>>
>> +static int kszphy_setup_led(struct phy_device *phydev,
>> + unsigned int reg, unsigned int shift)
>> +{
>> +
>> + struct device *dev = &phydev->dev;
>> + struct device_node *of_node = dev->of_node;
>> + int rc, temp;
>> + u32 val;
>> +
>> + if (!of_node && dev->parent->of_node)
>> + of_node = dev->parent->of_node;
>> +
>> + if (of_property_read_u32(of_node, "micrel,led-mode", &val))
>> + return 0;
>
> This breaks non-OF configuration because of_read_property_read_u32()
> will return -ENOSYS, so you skip the LED register configuration
> entirely, is that intended?
Yes, it is only here for OF case. I should however check if
of_node is available for the !OF case.
>> +
>> + temp = phy_read(phydev, reg);
>> + if (temp < 0)
>> + return temp;
>> +
>> + temp &= 3 << shift;
>
> The compiler cannot verify that we are not overflowing, you might want
> to make sure that shift <= 14 (just in case)
Ok, should I add a WARN_ON(shift > 14) ?
>> + temp |= val << shift;
>> + rc = phy_write(phydev, reg, temp);
>> +
>> + return rc < 0 ? rc : 0;
>
> You could have;
>
> return phy_write(phydev, reg, temp);
Thanks, will change to doing that.
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
next prev parent reply other threads:[~2014-02-27 10:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-26 11:48 [PATCH] phy: micrel: add of configuration for LED mode Ben Dooks
2014-02-26 22:00 ` David Miller
2014-02-26 22:20 ` Florian Fainelli
2014-02-27 10:22 ` Ben Dooks [this message]
2014-02-27 9:15 ` Mark Rutland
2014-02-27 10:30 ` Ben Dooks
[not found] ` <530F13DB.90009-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
2014-03-18 15:56 ` Laurent Pinchart
2014-03-18 16:11 ` Laurent Pinchart
2014-03-18 16:21 ` Ben Dooks
[not found] ` <53287270.1020908-4yDnlxn2s6sWdaTGBSpHTA@public.gmane.org>
2014-03-18 16:31 ` Laurent Pinchart
2014-03-18 19:39 ` Sergei Shtylyov
2014-03-18 20:39 ` Sergei Shtylyov
2014-03-18 22:15 ` Sergei Shtylyov
2014-03-18 23:15 ` Sergei Shtylyov
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=530F11DE.2000309@codethink.co.uk \
--to=ben.dooks@codethink.co.uk \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@lists.codethink.co.uk \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.