From: Guenter Roeck <linux@roeck-us.net>
To: Patrick Uiterwijk <patrick@puiterwijk.org>
Cc: davem@davemloft.net, linux@arm.linux.org.uk,
vivien.didelot@savoirfairelinux.com, andrew@lunn.ch,
netdev@vger.kernel.org, Dennis Gilmore <dennis@ausil.us>,
Peter Robinson <pbrobinson@gmail.com>
Subject: Re: [PATCH 1/2] net: dsa: mv88e6xxx: Introduce _mv88e6xxx_phy_page_{read,write}
Date: Fri, 25 Mar 2016 19:42:35 -0700 [thread overview]
Message-ID: <56F5F71B.3090703@roeck-us.net> (raw)
In-Reply-To: <CAJweMdYoiA5mwHW3kSQOY0y46=GuLhnBor7mS3kXo9K3FGqW4g@mail.gmail.com>
On 03/25/2016 06:58 PM, Patrick Uiterwijk wrote:
> On Sat, Mar 26, 2016 at 2:45 AM, Guenter Roeck <linux@roeck-us.net> wrote:
>> On 03/25/2016 05:10 PM, Patrick Uiterwijk wrote:
>>>
>>> Add versions of the phy_page_read and _write functions to
>>> be used in a context where the SMI mutex is held.
>>>
>>> Signed-off-by: Patrick Uiterwijk <patrick@puiterwijk.org>
>>> ---
>>> drivers/net/dsa/mv88e6xxx.c | 42
>>> ++++++++++++++++++++++++++++++++----------
>>> 1 file changed, 32 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/net/dsa/mv88e6xxx.c b/drivers/net/dsa/mv88e6xxx.c
>>> index fa086e0..13db5d8 100644
>>> --- a/drivers/net/dsa/mv88e6xxx.c
>>> +++ b/drivers/net/dsa/mv88e6xxx.c
>>> @@ -2708,37 +2708,59 @@ int mv88e6xxx_switch_reset(struct dsa_switch *ds,
>>> bool ppu_active)
>>> return 0;
>>> }
>>>
>>> -int mv88e6xxx_phy_page_read(struct dsa_switch *ds, int port, int page,
>>> int reg)
>>> +static int _mv88e6xxx_phy_page_read(struct dsa_switch *ds, int port, int
>>> page,
>>> + int reg)
>>> {
>>> - struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
>>> int ret;
>>>
>>> - mutex_lock(&ps->smi_mutex);
>>> ret = _mv88e6xxx_phy_write_indirect(ds, port, 0x16, page);
>>> if (ret < 0)
>>> - goto error;
>>> + goto clear;
>>> ret = _mv88e6xxx_phy_read_indirect(ds, port, reg);
>>> -error:
>>> +clear:
>>
>>
>> Is there some good reason for changing the name of those labels ?
>
> Vivien suggested to rename this since it makes more clear that this write is
> meant to return to page 0 to make sure that phylib doesn't get confused
> about the currently active page.
>
And "clear:" accomplishes that ? I would not have guessed.
Wonder if anyone else does. I would have used a comment.
/* Try to return to page 0 even after an error */
or something like that.
Guenter
> Patrick
>
>>
>> Guenter
>>
>>
>>> _mv88e6xxx_phy_write_indirect(ds, port, 0x16, 0x0);
>>> - mutex_unlock(&ps->smi_mutex);
>>> +
>>> return ret;
>>> }
>>>
>>> -int mv88e6xxx_phy_page_write(struct dsa_switch *ds, int port, int page,
>>> - int reg, int val)
>>> +int mv88e6xxx_phy_page_read(struct dsa_switch *ds, int port, int page,
>>> int reg)
>>> {
>>> struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
>>> int ret;
>>>
>>> mutex_lock(&ps->smi_mutex);
>>> + ret = _mv88e6xxx_phy_page_read(ds, port, page, reg);
>>> + mutex_unlock(&ps->smi_mutex);
>>> +
>>> + return ret;
>>> +}
>>> +
>>> +static int _mv88e6xxx_phy_page_write(struct dsa_switch *ds, int port, int
>>> page,
>>> + int reg, int val)
>>> +{
>>> + int ret;
>>> +
>>> ret = _mv88e6xxx_phy_write_indirect(ds, port, 0x16, page);
>>> if (ret < 0)
>>> - goto error;
>>> + goto clear;
>>>
>>> ret = _mv88e6xxx_phy_write_indirect(ds, port, reg, val);
>>> -error:
>>> +clear:
>>> _mv88e6xxx_phy_write_indirect(ds, port, 0x16, 0x0);
>>> +
>>> + return ret;
>>> +}
>>> +
>>> +int mv88e6xxx_phy_page_write(struct dsa_switch *ds, int port, int page,
>>> + int reg, int val)
>>> +{
>>> + struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
>>> + int ret;
>>> +
>>> + mutex_lock(&ps->smi_mutex);
>>> + ret = _mv88e6xxx_phy_page_write(ds, port, page, reg, val);
>>> mutex_unlock(&ps->smi_mutex);
>>> +
>>> return ret;
>>> }
>>>
>>>
>>
>
next prev parent reply other threads:[~2016-03-26 2:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-26 0:10 [PATCH 1/2] net: dsa: mv88e6xxx: Introduce _mv88e6xxx_phy_page_{read,write} Patrick Uiterwijk
2016-03-26 0:10 ` [PATCH 2/2] net: dsa: mv88e6xxx: Clear the PDOWN bit on setup Patrick Uiterwijk
2016-03-26 18:36 ` Vivien Didelot
2016-03-26 1:45 ` [PATCH 1/2] net: dsa: mv88e6xxx: Introduce _mv88e6xxx_phy_page_{read,write} Guenter Roeck
2016-03-26 1:58 ` Patrick Uiterwijk
2016-03-26 2:42 ` Guenter Roeck [this message]
2016-03-26 18:32 ` Vivien Didelot
2016-03-26 19:18 ` Andrew Lunn
2016-03-26 19:37 ` Vivien Didelot
2016-03-26 19:46 ` Andrew Lunn
2016-03-26 20:15 ` Vivien Didelot
2016-03-26 20:57 ` Guenter Roeck
2016-03-26 22:58 ` Vivien Didelot
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=56F5F71B.3090703@roeck-us.net \
--to=linux@roeck-us.net \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=dennis@ausil.us \
--cc=linux@arm.linux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=patrick@puiterwijk.org \
--cc=pbrobinson@gmail.com \
--cc=vivien.didelot@savoirfairelinux.com \
/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 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).