All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@cam.ac.uk>
To: Grant Grundler <grundler@google.com>
Cc: Dan Carpenter <error27@gmail.com>,
	linux-iio@vger.kernel.org, devel@driverdev.osuosl.org
Subject: Re: STAGING:iio:light: fix ISL29018 init to handle brownout
Date: Tue, 30 Aug 2011 11:05:01 +0100	[thread overview]
Message-ID: <4E5CB5CD.5060301@cam.ac.uk> (raw)
In-Reply-To: <CANEJEGtys_kBMMPstRahrYq956g22ZgowySxvOCqUpHww6x29w@mail.gmail.com>

On 08/26/11 22:58, Grant Grundler wrote:
> On Thu, Aug 25, 2011 at 6:15 PM, Dan Carpenter <error27@gmail.com> wrote:
> ...
>> In isl29018_write_data() it uses reg (ISL29018_REG_TEST) as the
>> offset into the ->reg_cache[] array:
>>        chip->reg_cache[reg] = regval;
>>
>> But ->reg_cache[] only has 3 elements, so we're past the end of the
>> array.
> 
> Dan,
> I've attached a preliminary patch to fix this that applies on top of
> 176f9f29cec9 "STAGING:iio:light:
> fix ISL29018 init to handle brownout".  This patch applies cleanly to
> the 2.6.38-based chromium.org tree.
> 
> In a nutshell, the attached patch implements what I was thinking of
> last night: don't cache REG_TEST.
> 
> I did change one basic behavior that I think was also broken: cache
> the value regardless of if the transaction completed successfully or
> not. 
Don't do that.  That means userspace will get an invalid value if it reads
in the meantime. If you have an error on a hardware bus - tell userspace about
it and don't 'guess' what is in the register.

Otherwise patch looks fine to me.
>For registers where we are frobbing bits, the later write to the
> same register  might succeed and things will work anyway despite the
> transient failure. If I'm wrong, please comment and I'll repost with
> original behavior.
> 
> I also noticed the original code had an "off-by-one" error in the
> allocation of reg_cache[] (allocated 3 but indexed up to offset +3).
> 
> I'll submit a cleaned up version that should cleanly apply to gregkh's
> staging-2.6 tree.
> 
> thanks again!
> grant


  parent reply	other threads:[~2011-08-30  9:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-26  1:15 STAGING:iio:light: fix ISL29018 init to handle brownout Dan Carpenter
2011-08-26  5:27 ` Grant Grundler
2011-08-26 21:58 ` Grant Grundler
2011-08-26 22:18   ` Dan Carpenter
2011-08-26 22:42     ` Grant Grundler
2011-08-30 10:05   ` Jonathan Cameron [this message]
2011-08-30 16:14     ` Grant Grundler
2011-08-30 16:31       ` Jonathan Cameron
2011-08-30 16:45         ` Grant Grundler

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=4E5CB5CD.5060301@cam.ac.uk \
    --to=jic23@cam.ac.uk \
    --cc=devel@driverdev.osuosl.org \
    --cc=error27@gmail.com \
    --cc=grundler@google.com \
    --cc=linux-iio@vger.kernel.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.