From: Grant Likely <grant.likely@secretlab.ca>
To: John Linn <John.Linn@xilinx.com>
Cc: linuxppc-dev@ozlabs.org, netdev@vger.kernel.org,
Sadanand Mutyala <sadanan@xilinx.com>,
jgarzik@pobox.com, John Williams <john.williams@petalogix.com>
Subject: Re: [PATCH] [V3] net: emaclite: adding MDIO and phy lib support
Date: Tue, 9 Feb 2010 18:53:01 -0700 [thread overview]
Message-ID: <fa686aa41002091753n36c59e3brd2b2174035e4933d@mail.gmail.com> (raw)
In-Reply-To: <ad1b9321-b7ad-47a6-93ca-ca260ff2a66d@SG2EHSMHS011.ehs.local>
On Tue, Feb 9, 2010 at 4:00 PM, John Linn <John.Linn@xilinx.com> wrote:
>> -----Original Message-----
>> From: John Williams [mailto:john.williams@petalogix.com]
>> Sent: Tuesday, February 09, 2010 3:30 PM
>> To: John Linn
>> Cc: netdev@vger.kernel.org; linuxppc-dev@ozlabs.org; jgarzik@pobox.com; =
grant.likely@secretlab.ca;
>> jwboyer@linux.vnet.ibm.com; Sadanand Mutyala
>> Subject: Re: [PATCH] [V3] net: emaclite: adding MDIO and phy lib support
>>
>> Hi John,
>>
>> Sorry If I'm painting bike-sheds here, just one tiny tweak might be in
>> order to standardise your mutex_unlock exit path:
>>
>> > +static int xemaclite_mdio_read(struct mii_bus *bus, int phy_id, int r=
eg)
>> > +{
>> > + =A0 =A0 =A0 struct net_local *lp =3D bus->priv;
>> > + =A0 =A0 =A0 u32 ctrl_reg;
>> > + =A0 =A0 =A0 u32 rc;
>> > +
>> > + =A0 =A0 =A0 mutex_lock(&lp->mdio_mutex);
>> > +
>> > + =A0 =A0 =A0 if (xemaclite_mdio_wait(lp)) {
>> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 mutex_unlock(&lp->mdio_mutex);
>> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ETIMEDOUT;
>> > + =A0 =A0 =A0 }
>>
>> [snip]
>>
>>
>> > + =A0 =A0 =A0 if (xemaclite_mdio_wait(lp)) {
>> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 mutex_unlock(&lp->mdio_mutex);
>> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -ETIMEDOUT;
>> > + =A0 =A0 =A0 }
>>
>> [snip]
>>
>>
>> > + =A0 =A0 =A0 dev_dbg(&lp->ndev->dev,
>> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 "xemaclite_mdio_read(phy_id=3D%i, reg=3D=
%x) =3D=3D %x\n",
>> > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 phy_id, reg, rc);
>> > +
>> > + =A0 =A0 =A0 return rc;
>>
>> Can this be better expressed like this:
>>
>> my_func() {
>> =A0 mutex_lock()
>> ..
>>
>> =A0 if(some error) {
>> =A0 =A0 rc=3D-ETIMEDOUT;
>> =A0 =A0 goto out_unlock;
>> =A0 }
>> =A0 ...
>>
>> =A0 /* success path */
>> =A0 rc=3D0;
>> ..
>> out_unlock:
>> =A0 mutex_unlock()
>> =A0 return rc;
>> }
>>
>>
>> Is this style still favoured in driver exit paths?
>
> It looks to me like the mutex is not needed in the driver mdio functions =
as there's a mutex in the mdiobus functions already.
Yes, you're correct, but you still need to protect against direct
calls to the read/write routines from within the driver. But you can
probably use the mdio_lock mutex for this.
g.
prev parent reply other threads:[~2010-02-10 1:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-09 20:31 [PATCH] [V3] net: emaclite: adding MDIO and phy lib support John Linn
2010-02-09 22:30 ` John Williams
2010-02-09 22:38 ` John Linn
2010-02-09 23:00 ` John Linn
2010-02-10 1:53 ` Grant Likely [this message]
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=fa686aa41002091753n36c59e3brd2b2174035e4933d@mail.gmail.com \
--to=grant.likely@secretlab.ca \
--cc=John.Linn@xilinx.com \
--cc=jgarzik@pobox.com \
--cc=john.williams@petalogix.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=netdev@vger.kernel.org \
--cc=sadanan@xilinx.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