public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Daniel Mack <daniel@caiaq.de>
Cc: linux-kernel@vger.kernel.org, syrjala@sci.fi,
	johnpol@2ka.mipt.ru, david-b@pacbell.net
Subject: Re: [PATCH] drivers/w1/masters/w1-gpio.c: fix read_bit()
Date: Tue, 10 Mar 2009 18:17:13 -0700	[thread overview]
Message-ID: <20090310181713.4420d488.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090311001048.GA21160@buzzloop.caiaq.de>

On Wed, 11 Mar 2009 01:10:48 +0100 Daniel Mack <daniel@caiaq.de> wrote:

> On Tue, Mar 10, 2009 at 03:00:59PM -0700, Andrew Morton wrote:
> > > > We recently merged a patch (I forget where) which fixed one
> > > > gpio_get_value() implementation so that it always returns 0 or 1.
> > > > 
> > > > From which I deduce that the correct fix for <whatever problem you're
> > > > seeing> is to fix <whichever driver that is>?
> > > 
> > > I agree those functions should return 0 and 1 only, but my patch fixes
> > > the w1-gpio driver for all platforms at once, so people can use it.
> > > 
> > > On the other hand, I will submit a patch which modifies PXA's
> > > gpio_get_value() and see what the maintainers say, but I can't go thru
> > > all the implemenations of all architectures to do this.
> > > 
> > > So for the time being, the above patch helps many users of that driver.
> > > 
> > 
> > Problem is, the patch will just conceal bugs.
> 
> There is a small discussion about that on the arm-linux mailing list and
> what people pointed out there is that gpio_get_value() is _not_ supposed
> to return 0 or 1 only, also according to Documentation/gpio.txt:
> 
> 	Use these calls to access such GPIOs:
> 
>         /* GPIO INPUT:  return zero or nonzero */
> 	int gpio_get_value(unsigned gpio);
> 
> Hence, any implementation of gpio_get_value() which returns 0 and 1 only
> is conform to the docs, but PXA's (which doesn't follow that rule) is as
> well. And that means that any driver using that function has to deal
> with values > 1 being returned by it, right?
> 
> Correct me if I missed the point, but I don't see how my patch will
> conceal any bug?
> 

Actually, I misremembered the discussion: http://lkml.org/lkml/2009/2/15/114

This "optimisation" has caused two bugs so far.  And it's forcing
callers of the "optimised" function to perform a test-n-branch for
something which the low-level function could have done with a shift.

Sigh, what a crock.  I'll go dig out your original fix.

  reply	other threads:[~2009-03-11  1:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-09 16:02 [PATCH] drivers/w1/masters/w1-gpio.c: fix read_bit() Daniel Mack
2009-03-10  2:14 ` Andrew Morton
2009-03-10  9:18   ` Daniel Mack
2009-03-10 22:00     ` Andrew Morton
2009-03-10 23:59       ` Ville Syrjälä
2009-03-11  0:10       ` Daniel Mack
2009-03-11  1:17         ` Andrew Morton [this message]
2009-03-10 14:13   ` Ville Syrjälä

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=20090310181713.4420d488.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=daniel@caiaq.de \
    --cc=david-b@pacbell.net \
    --cc=johnpol@2ka.mipt.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syrjala@sci.fi \
    /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