All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomasz Figa <tfiga@chromium.org>
To: "Yeh, Andy" <andy.yeh@intel.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	devicetree@vger.kernel.org, jacopo@jmondi.org,
	Alan Chiang <alanx.chiang@intel.com>
Subject: Re: [RESEND PATCH v7 2/2] media: dw9807: Add dw9807 vcm driver
Date: Wed, 11 Apr 2018 04:42:21 +0000	[thread overview]
Message-ID: <CAAFQd5DmQaNOpYiyg9WR+LVAWiMQ3o8e6V3ShVwhknUg51U61A@mail.gmail.com> (raw)
In-Reply-To: <CAAFQd5ApQdHCFAmA1PjUOcDGa6VMbc=JJA1mLa8WH2PJJGD17g@mail.gmail.com>

On Wed, Apr 11, 2018 at 1:38 PM Tomasz Figa <tfiga@chromium.org> wrote:
[snip]
> > +static int dw9807_set_dac(struct i2c_client *client, u16 data)
> > +{
> > +       const char tx_data[3] = {
> > +               DW9807_MSB_ADDR, ((data >> 8) & 0x03), (data & 0xff)
> > +       };
> > +       int ret, retry = 0;
> > +
> > +       /*
> > +        * According to the datasheet, need to check the bus status
> before we
> > +        * write VCM position. This ensure that we really write the
value
> > +        * into the register
> > +        */
> > +       while ((ret = dw9807_i2c_check(client)) != 0) {
> > +               if (ret < 0)
> > +                       return ret;
> > +
> > +               if (MAX_RETRY == ++retry) {
> > +                       dev_err(&client->dev,
> > +                               "Cannot do the write operation because
> VCM is busy\n");
> > +                       return -EIO;
> > +               }
> > +               usleep_range(DW9807_CTRL_DELAY_US, DW9807_CTRL_DELAY_US
+
> 10);
> > +       }

> One could use readx_poll_timeout() here:

> int val;

> ret = readx_poll_timeout(dw9807_i2c_check, client, val, !val,

Actually, to handle errors, it should be

ret = readx_poll_timeout(dw9807_i2c_check, client, val, val <= 0,

>                            DW9807_CTRL_DELAY_US,
>                            MAX_RETRY * DW9807_CTRL_DELAY_US);

> if (ret) {

if (ret || val < 0) {

>           dev_err(&client->dev,
>                   "Cannot do the write operation because VCM is busy\n");
>           return -EIO;

return ret ? ret : val;

Sorry for not spotting this earlier.

Best regards,
Tomasz

  reply	other threads:[~2018-04-11  4:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-10 15:48 [RESEND PATCH v7 0/2] DW9807 DT binding and driver patches Andy Yeh
2018-04-10 15:48 ` [RESEND PATCH v7 1/2] media: dt-bindings: Add bindings for Dongwoon DW9807 voice coil Andy Yeh
2018-04-13 15:10   ` Rob Herring
2018-04-25  2:31     ` Yeh, Andy
2018-04-10 15:48 ` [RESEND PATCH v7 2/2] media: dw9807: Add dw9807 vcm driver Andy Yeh
2018-04-11  4:38   ` Tomasz Figa
2018-04-11  4:42     ` Tomasz Figa [this message]
2018-04-12  8:57   ` jacopo mondi
2018-04-12  9:57     ` Sakari Ailus
2018-04-16  4:30       ` Tomasz Figa
2018-04-16  9:49         ` Sakari Ailus
2018-04-25  2:28     ` Yeh, Andy

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=CAAFQd5DmQaNOpYiyg9WR+LVAWiMQ3o8e6V3ShVwhknUg51U61A@mail.gmail.com \
    --to=tfiga@chromium.org \
    --cc=alanx.chiang@intel.com \
    --cc=andy.yeh@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jacopo@jmondi.org \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.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 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.