From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>,
Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andrea Merello <andrea.merello@gmail.com>,
Magnus Damm <magnus.damm@gmail.com>,
linux-iio@vger.kernel.org, linux-staging@lists.linux.dev,
Jacopo Mondi <jacopo@jmondi.org>
Subject: Re: [PATCH 2/2] staging: iio: imu: Add CEVA BNO08x driver
Date: Mon, 20 Jun 2022 12:14:03 +0300 [thread overview]
Message-ID: <20220620091403.GH16517@kadam> (raw)
In-Reply-To: <20220617184941.00001fcb@Huawei.com>
On Fri, Jun 17, 2022 at 06:49:41PM +0100, Jonathan Cameron wrote:
> > +static irqreturn_t bno08x_trigger_handler(int irq, void *p)
> > +{
> > + struct iio_poll_func *pf = p;
> > + struct iio_dev *iio_dev = pf->indio_dev;
> > + struct bno08x_dev *bno08x = iio_priv(iio_dev);
> > + u8 cargo[BNO08x_CARGO_BUFFER_SIZE];
> > + int ret;
> > +
> > + ret = bno08x_wait_for_cargo_timeout(bno08x, cargo, BNO08x_CARGO_BUFFER_SIZE);
> > + if (ret < 0)
> > + goto done;
> > +
> I'm lazy - if it's less than 0 it's definitely less than 24 so no need for separate
> paths unless you add some dev_dbg/err or similar which might make sense here.
>
Also 24 is a magic number. But you have to be a bit careful with
combining conditions. The two common bugs are forgot to set the error
code and type promotion to unsigned long:
if (ret < sizeof(buf))
goto done;
Negative ret values are > sizeof(buf) and for 0 to sizeof - 1 then the
error code isn't set so this made up example would be totally broken.
None of that applies here, of course, but I like breaking the conditions
apart just as a habit.
> > + if (ret < 24)
> > + goto done;
> > +
regards,
dan carpenter
prev parent reply other threads:[~2022-06-20 9:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-16 10:00 [PATCH 0/2] staging: iio: imu: Add CEVA BNO08x through the staging tree Jacopo Mondi
2022-06-16 10:00 ` [PATCH 1/2] dt-bindings: staging: iio: imu: Document CEVA BNO08x Jacopo Mondi
2022-06-27 22:25 ` Rob Herring
2022-06-16 10:00 ` [PATCH 2/2] staging: iio: imu: Add CEVA BNO08x driver Jacopo Mondi
2022-06-16 10:26 ` Greg Kroah-Hartman
2022-06-16 10:36 ` Jacopo Mondi
2022-06-16 10:57 ` Greg Kroah-Hartman
2022-06-16 12:30 ` Jacopo Mondi
2022-06-17 17:20 ` Jonathan Cameron
2022-06-16 11:12 ` Dan Carpenter
2022-06-17 17:49 ` Jonathan Cameron
2022-06-20 9:14 ` Dan Carpenter [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=20220620091403.GH16517@kadam \
--to=dan.carpenter@oracle.com \
--cc=Jonathan.Cameron@Huawei.com \
--cc=andrea.merello@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jacopo+renesas@jmondi.org \
--cc=jacopo@jmondi.org \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=magnus.damm@gmail.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