Linux IIO development
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: Otavio Salvador <otavio@ossystems.com.br>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	linux-iio@vger.kernel.org, Jonathan Cameron <jic23@kernel.org>,
	Fabio Estevam <fabio.estevam@freescale.com>
Subject: Re: [PATCH] iio: mxs-lradc: Remove useless check in read_raw
Date: Tue, 2 Jul 2013 19:55:45 +0200	[thread overview]
Message-ID: <201307021955.45799.marex@denx.de> (raw)
In-Reply-To: <CAP9ODKrDnw5ATc1gdfzAMcks5HN8D9v=twcZ2n9KwjehdJfWuQ@mail.gmail.com>

Dear Otavio Salvador,

> On Tue, Jul 2, 2013 at 2:36 PM, Marek Vasut <marex@denx.de> wrote:
> > Dear Otavio Salvador,
> > 
> >> On Tue, Jul 2, 2013 at 1:13 PM, Marek Vasut <marex@denx.de> wrote:
> >> > Dear Alexandre Belloni,
> >> > 
> >> >> On 02/07/2013 14:03, Marek Vasut wrote:
> >> >> > Dear Alexandre Belloni,
> >> >> > 
> >> >> >> Dear Marek,
> >> >> >> 
> >> >> >> I don't seem to be hitting that issue. I'm using 3.10rc7. Do you
> >> >> >> know how to reproduce it ?
> >> >> > 
> >> >> > The check is just redundant, it's not a bug.
> >> >> 
> >> >> Ok, that's what I understood first but then got confused by reports
> >> >> of it solving a bug.
> >> > 
> >> > It cannot solve a thing. If it does, then we have a problem.
> >> > 
> >> > What kind of bug do you see ? How can I replicate it ? Can you send me
> >> > a testcase?
> >> 
> >> As I said this code sometimes work. If you put a printf before this
> >> call it sometimes work. So I think we have a race somewhere.
> >> 
> >> When I were debugging this I found that when it works we have 10
> >> active channels, it seems.
> > 
> > Uh, the read_raw() should exit with -EBUSY, since the mutex_tryload()
> > will fail iff buffered operation is in progress. Or what do you mean by
> > having "10 active channels"?
> 
> The read_raw returned invalid. The onehot always returns false and I
> have 10 as mask comparing return.

Looking at the code.

the bitmap_set() will set (1 << chan->channel) into "mask" var.

The iio_validate_scan_mask_onehot is implemented like this:

688 bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev,
689         const unsigned long *mask)
690 {
691         return bitmap_weight(mask, indio_dev->masklength) == 1;
692 }

So if mask _always_ has exactly one bit set, the iio_validate_scan_mask_onehot 
will always return 1. Aaaand ... now I see why it fixes a bug for you.

if (ret)
 return -EINVAL;

This stuff above will always be if (1) so will always return -EINVAL. Dang!

Best regards,
Marek Vasut

  reply	other threads:[~2013-07-02 17:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-02  0:08 [PATCH] iio: mxs-lradc: Remove useless check in read_raw Marek Vasut
2013-07-02  3:38 ` Otavio Salvador
2013-07-02 17:58   ` Marek Vasut
2013-07-02  9:19 ` Hector Palacios
2013-07-02 11:43 ` Alexandre Belloni
2013-07-02 11:53   ` Otavio Salvador
2013-07-02 12:03   ` Marek Vasut
2013-07-02 12:49     ` Alexandre Belloni
2013-07-02 16:13       ` Marek Vasut
2013-07-02 16:37         ` Otavio Salvador
2013-07-02 17:36           ` Marek Vasut
2013-07-02 17:42             ` Otavio Salvador
2013-07-02 17:55               ` Marek Vasut [this message]
2013-07-03  9:25                 ` Hector Palacios
2013-07-03 11:38                   ` Marek Vasut
2013-07-03 13:58                     ` Hector Palacios
2013-07-03 19:26                       ` Jonathan Cameron
2013-07-02 17:19         ` Alexandre Belloni

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=201307021955.45799.marex@denx.de \
    --to=marex@denx.de \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=fabio.estevam@freescale.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=otavio@ossystems.com.br \
    /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