From: Jonathan Cameron <jic23@kernel.org>
To: Matt Ranostay <matt.ranostay@konsulko.com>
Cc: Mohan Kumar <mohankumar718@gmail.com>,
Andreas Klinger <ak@it-klinger.de>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers: iio: proximity: This patch fix the following checkpatch warning.
Date: Mon, 22 Apr 2019 11:48:21 +0100 [thread overview]
Message-ID: <20190422114821.5955d4fa@archlinux> (raw)
In-Reply-To: <CAJCx=gmi6=uXbydpE2gY2x-XijtAd=bfufoJ+gbO1KU1n++g3Q@mail.gmail.com>
On Thu, 18 Apr 2019 16:23:51 -0700
Matt Ranostay <matt.ranostay@konsulko.com> wrote:
> See comments inline
>
> On Wed, Apr 17, 2019 at 11:15 AM Mohan Kumar <mohankumar718@gmail.com> wrote:
> >
> > As per Documentation/timers/timers-howto.txt Msleep < 20ms can sleep for
> > up to 20ms. so use usleep_range.
> >
> > Signed-off-by: Mohan Kumar <mohankumar718@gmail.com>
> > ---
> > drivers/iio/proximity/mb1232.c | 2 +-
> > drivers/iio/proximity/srf08.c | 4 ++--
> > 2 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/iio/proximity/mb1232.c b/drivers/iio/proximity/mb1232.c
> > index 166b3e6..74f7eae 100644
> > --- a/drivers/iio/proximity/mb1232.c
> > +++ b/drivers/iio/proximity/mb1232.c
> > @@ -81,7 +81,7 @@ static s16 mb1232_read_distance(struct mb1232_data *data)
> > }
> > } else {
> > /* use simple sleep if announce irq is not connected */
> > - msleep(15);
> > + usleep_range(15000, 20000);
>
> This is actually less than ideal.. because usleep_range uses the
> hrtimers which forces an interrupt.
>
> Unless you actually need to read between 15ms and 20ms it is best just
> to leave the msleep() as it is, and let it take a bit longer
> if required.
Good response. Perhaps Mohan could follow up with a patch to add
a comment to this effect to save anyone else trying to 'fix' this
issue in future?
Thanks,
Jonathan
>
> - Matt
>
> > }
> >
> > ret = i2c_master_recv(client, (char *)&buf, sizeof(buf));
> > diff --git a/drivers/iio/proximity/srf08.c b/drivers/iio/proximity/srf08.c
> > index f2bf783..605a582 100644
> > --- a/drivers/iio/proximity/srf08.c
> > +++ b/drivers/iio/proximity/srf08.c
> > @@ -150,7 +150,7 @@ static int srf08_read_ranging(struct srf08_data *data)
> > * polling for not more than 20 ms should be enough
> > */
> > waittime = 1 + data->range_mm / 172;
> > - msleep(waittime);
> > + usleep_range(waittime * 1000, (waittime * 1000) + 2000);
> > for (i = 0; i < 4; i++) {
> > ret = i2c_smbus_read_byte_data(data->client,
> > SRF08_READ_SW_REVISION);
> > @@ -158,7 +158,7 @@ static int srf08_read_ranging(struct srf08_data *data)
> > /* check if a valid version number is read */
> > if (ret < 255 && ret > 0)
> > break;
> > - msleep(5);
> > + usleep_range(5000, 15000);
> > }
> >
> > if (ret >= 255 || ret <= 0) {
> > --
> > 2.7.4
> >
next prev parent reply other threads:[~2019-04-22 10:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-17 18:15 [PATCH] drivers: iio: proximity: This patch fix the following checkpatch warning Mohan Kumar
2019-04-18 23:23 ` Matt Ranostay
2019-04-22 10:48 ` Jonathan Cameron [this message]
2019-04-24 9:23 ` Matt Ranostay
2019-04-24 12:16 ` Jonathan Cameron
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=20190422114821.5955d4fa@archlinux \
--to=jic23@kernel.org \
--cc=ak@it-klinger.de \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.ranostay@konsulko.com \
--cc=mohankumar718@gmail.com \
--cc=pmeerw@pmeerw.net \
/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