From: Grant Likely <grant.likely@secretlab.ca>
To: John Linn <John.Linn@xilinx.com>
Cc: John Williams <john.williams@petalogix.com>,
netdev@vger.kernel.org, linuxppc-dev@ozlabs.org,
jgarzik@pobox.com, jwboyer@linux.vnet.ibm.com,
Sadanand Mutyala <sadanan@xilinx.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 reg)
>> > +{
>> > + struct net_local *lp = bus->priv;
>> > + u32 ctrl_reg;
>> > + u32 rc;
>> > +
>> > + mutex_lock(&lp->mdio_mutex);
>> > +
>> > + if (xemaclite_mdio_wait(lp)) {
>> > + mutex_unlock(&lp->mdio_mutex);
>> > + return -ETIMEDOUT;
>> > + }
>>
>> [snip]
>>
>>
>> > + if (xemaclite_mdio_wait(lp)) {
>> > + mutex_unlock(&lp->mdio_mutex);
>> > + return -ETIMEDOUT;
>> > + }
>>
>> [snip]
>>
>>
>> > + dev_dbg(&lp->ndev->dev,
>> > + "xemaclite_mdio_read(phy_id=%i, reg=%x) == %x\n",
>> > + phy_id, reg, rc);
>> > +
>> > + return rc;
>>
>> Can this be better expressed like this:
>>
>> my_func() {
>> mutex_lock()
>> ..
>>
>> if(some error) {
>> rc=-ETIMEDOUT;
>> goto out_unlock;
>> }
>> ...
>>
>> /* success path */
>> rc=0;
>> ..
>> out_unlock:
>> mutex_unlock()
>> 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=jwboyer@linux.vnet.ibm.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;
as well as URLs for NNTP newsgroup(s).