All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Hutchings <bhutchings@solarflare.com>
To: Steve.Glendinning@smsc.com
Cc: Bahadir Balban <Bahadir.Balban@arm.com>,
	Bill Gatliff <bgat@billgatliff.com>,
	catalin.marinas@arm.com, Dustin Mcintire <dustin@sensoria.com>,
	Enrik.Berkhan@ge.com, hennerich@blackfin.uclinux.org,
	ian.saturley@smsc.com, Michael.Hennerich@analog.com,
	netdev@vger.kernel.org, uclinux-dist-devel@blackfin.uclinux.org
Subject: Re: [PATCH] SMSC LAN911x and LAN921x vendor driver
Date: Mon, 2 Jun 2008 20:03:30 +0100	[thread overview]
Message-ID: <20080602190329.GC6192@solarflare.com> (raw)
In-Reply-To: <OF3A2B75A8.48ADA40F-ON8025745C.00633ABA-8025745C.0065B74E@smsc.com>

Steve.Glendinning@smsc.com wrote:
> Hi Ben,
> 
> Thanks for the feedback.  I've implemented most of your suggestions, but 
> have a few questions:
> 
> > [...]
> > > +/* Set a mac register, phy_lock must be acquired before calling */
> > > +static void smsc911x_mac_write(struct smsc911x_data *pdata,
> > > +                unsigned int offset, u32 val)
> > > +{
> > > +   unsigned int temp;
> > > +
> > > +#ifdef CONFIG_DEBUG_SPINLOCK
> > > +   if (!spin_is_locked(&pdata->phy_lock))
> > > +      SMSC_WARNING("phy_lock not held");
> > > +#endif            /* CONFIG_DEBUG_SPINLOCK */
> > > +
> > > +   temp = smsc911x_reg_read(pdata, MAC_CSR_CMD);
> > > +   if (unlikely(temp & MAC_CSR_CMD_CSR_BUSY_)) {
> > > +      SMSC_WARNING("smsc911x_mac_write failed, MAC busy at entry");
> > > +      return;
> > > +   }
> > 
> > Shouldn't this return an error code?
> > 
> > [...]
> > > +/* Sets a phy register, phy_lock must be acquired before calling */
> > > +static void smsc911x_phy_write(struct smsc911x_data *pdata,
> > > +                unsigned int index, u16 val)
> > > +{
> > > +   unsigned int addr;
> > > +   int i;
> > > +
> > > +#ifdef CONFIG_DEBUG_SPINLOCK
> > > +   if (!spin_is_locked(&pdata->phy_lock))
> > > +      SMSC_WARNING("phy_lock not held");
> > > +#endif            /* CONFIG_DEBUG_SPINLOCK */
> > > +
> > > +   /* Confirm MII not busy */
> > > +   if (unlikely(smsc911x_mac_read(pdata, MII_ACC) & 
> MII_ACC_MII_BUSY_)) {
> > > +      SMSC_WARNING("MII is busy in smsc911x_write_phy???");
> > > +      return;
> > > +   }
> > 
> > Similarly for this function.
> 
> I could return an error code from these write functions, but the 
> equivalent read functions currently return their register value.  Would 
> you change the read functions to take a result pointer?

If you can't reserve some range of values for errors (e.g. 32-bit reads
which may yield any 32-bit value) then I suppose so.  For 16-bit reads you
can return an int with negative values reserved for errors.

> I should mention this "MAC busy at entry" check is an assert to catch 
> driver locking problems during development (as is the spinlock check 
> above).  If the driver is "correct" it should only be seen in the case of 
> hardware failure.

Hardware failure does happen though, and once you've detected it it seems
like a bad idea to hide it.

> > [...]
> > > +static int smsc911x_soft_reset(struct smsc911x_data *pdata)
> > > +{
> > > +   unsigned int timeout;
> > > +   unsigned int temp;
> > > +
> > > +   /* Reset the LAN911x */
> > > +   smsc911x_reg_write(HW_CFG_SRST_, pdata, HW_CFG);
> > > +   timeout = 10;
> > > +   do {
> > > +      udelay(10);
> > > +      temp = smsc911x_reg_read(pdata, HW_CFG);
> > > +   } while ((--timeout) && (temp & HW_CFG_SRST_));
> > > +
> > > +   if (unlikely(temp & HW_CFG_SRST_)) {
> > > +      SMSC_WARNING("Failed to complete reset");
> > > +      return -ENODEV;
> > 
> > I think this should be -EIO unless this is only called during probe.
> 
> This reset function is called from both probe and open, although its 
> return code is only checked for nonzero by both.  Should probe return 
> -ENODEV, and open return -EIO if this device reset fails?

Personally I think -EIO is a perfectly reasonable error code for I/O
errors after the device has been positively identified, even during
probe.  You could have the probe function squash other errors into
-ENODEV if you want.

Ben.

-- 
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.

  reply	other threads:[~2008-06-02 19:04 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080515170728.GA3176@PTXN0038.genpitfi01.og.ge.com>
2008-05-19 12:34 ` [PATCH] SMSC LAN911x and LAN921x vendor driver Steve Glendinning
2008-05-19 15:27   ` [Uclinux-dist-devel] " Mike Frysinger
2008-05-19 15:45     ` Catalin Marinas
2008-05-19 15:50       ` Mike Frysinger
2008-05-19 15:55         ` Catalin Marinas
2008-05-19 16:24   ` Catalin Marinas
2008-05-19 19:06     ` Steve.Glendinning
2008-06-02 10:45   ` Steve Glendinning
2008-06-02 15:54     ` Ben Hutchings
2008-06-02 16:09       ` Bill Gatliff
2008-06-02 18:32         ` Peter Korsgaard
2008-06-02 18:30       ` Steve.Glendinning
2008-06-02 19:03         ` Ben Hutchings [this message]
2008-06-04 16:34       ` Steve.Glendinning
2008-06-02 18:47   ` Peter Korsgaard
2008-10-21 13:00 Steve Glendinning
  -- strict thread matches above, loose matches on Subject: below --
2007-07-16 18:54 Steve Glendinning
2007-07-18 22:38 ` Jeff Garzik
2007-07-20 16:22   ` Steve.Glendinning
2007-07-29 20:53 ` Peter Korsgaard
2007-07-30 18:31   ` Steve.Glendinning
2007-08-01 22:27     ` Peter Korsgaard
2007-08-07 23:09       ` Peter Korsgaard
2006-12-30 16:34 Steve Glendinning
2007-01-04 14:42 ` Pierre TARDY
2006-12-04 22:31 Steve Glendinning
2006-07-28 21:38 Francois Romieu
2006-08-01 15:12 ` [PATCH] " Steve Glendinning
2006-08-01 15:33   ` John W. Linville
2006-08-02 19:23     ` Steve.Glendinning
2006-08-02 19:51       ` John W. Linville
2006-08-01 18:28   ` Scott Murray
2006-08-01 19:27     ` Steve.Glendinning
2006-08-01 23:51       ` Scott Murray
2006-08-03 15:26         ` Steve.Glendinning
2006-08-03 21:07           ` Scott Murray
2006-08-01 21:40   ` Francois Romieu
2006-08-02 19:39     ` Steve.Glendinning
2006-08-02 21:07       ` Francois Romieu
2006-08-04 11:29         ` Steve Glendinning

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=20080602190329.GC6192@solarflare.com \
    --to=bhutchings@solarflare.com \
    --cc=Bahadir.Balban@arm.com \
    --cc=Enrik.Berkhan@ge.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=Steve.Glendinning@smsc.com \
    --cc=bgat@billgatliff.com \
    --cc=catalin.marinas@arm.com \
    --cc=dustin@sensoria.com \
    --cc=hennerich@blackfin.uclinux.org \
    --cc=ian.saturley@smsc.com \
    --cc=netdev@vger.kernel.org \
    --cc=uclinux-dist-devel@blackfin.uclinux.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.