linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Linux Input <linux-input@vger.kernel.org>,
	Henrik Rydberg <rydberg@bitmath.org>
Subject: Re: [PATCH 2/2 v5] Input: cy8ctma140 - add driver
Date: Wed, 6 May 2020 14:32:29 +0200	[thread overview]
Message-ID: <CACRpkdZVsTeNQWcsu3S4qL8YrGwrefozeTsc2W4eiPM11wgD9w@mail.gmail.com> (raw)
In-Reply-To: <20200423020530.GH125362@dtor-ws>

Hi Dmitry!

First: THANKS for fixing my driver.
Second: sorry for slow answer :(

On Thu, Apr 23, 2020 at 4:05 AM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:

> > +config TOUCHSCREEN_CY8CTMA140
> > +     tristate "cy8ctma140 touchscreen"
> > +     depends on I2C
> > +     depends on GPIOLIB || COMPILE_TEST
>
> Why do we need gpiolib here?

Not really. Dropped it.

> > +     ret = __i2c_transfer(ts->client->adapter, msg, ARRAY_SIZE(msg));
>
> Why do we use "unlocked" __i2c_transfer()? Can't we use normal
> i2c_transfer()? For __i2c_transfer() someone has to lock the segment...

Good point. Your patch works fine here.

> Hmm, I think if we do use loop the code is actually _much_ simpler,
> please see the patch below.

Indeed. Works like a charm after some fixes.

> > +     addr[0] = CY8CTMA140_GET_FW_INFO;
> > +     ret = i2c_master_send(ts->client, addr, 1);
> > +     if (ret < 0) {
> > +             dev_err(ts->dev, "error sending FW info message\n");
> > +             return ret;
> > +     }
> > +     ret = i2c_master_recv(ts->client, buf, 5);
> > +     if (ret < 0) {
> > +             dev_err(ts->dev, "error recieveing FW info message\n");
> > +             return ret;
> > +     }
>
> Does it have to be 2 separate transactions? Can we use write/read
> i2c_transfer() here?

I think it is necessary for the FW info test, this is not a standard
I2C transaction, notice that addr[0] does not contain the I2C
address of the device.

I tried to do it some other way but this was the
only way I could get it to work and detect the device properly.

> Can you please try the patch below on top of yours?

Folded it in and will resend with my changes as v6.

> @@ -187,26 +144,28 @@ static int cy8ctma140_init(struct cy8ctma140 *ts)
>  {
>         u8 addr[1];
>         u8 buf[5];
> +       int error;
>         int ret;
>
>         addr[0] = CY8CTMA140_GET_FW_INFO;
> -       ret = i2c_master_send(ts->client, addr, 1);
> -       if (ret < 0) {
> +       error = i2c_master_send(ts->client, addr, 1);
> +       if (error) {

This didn't work as i2c_master_send() returns the number of
bytes sent. I reverted this function back to using ret.

After that everything started to work!

Yours,
Linus Walleij

      reply	other threads:[~2020-05-06 12:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21  8:06 [PATCH 1/2 v5] dt-bindings: touchscreen: Add CY8CTMA140 bindings Linus Walleij
2020-04-21  8:06 ` [PATCH 2/2 v5] Input: cy8ctma140 - add driver Linus Walleij
2020-04-23  2:05   ` Dmitry Torokhov
2020-05-06 12:32     ` Linus Walleij [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=CACRpkdZVsTeNQWcsu3S4qL8YrGwrefozeTsc2W4eiPM11wgD9w@mail.gmail.com \
    --to=linus.walleij@linaro.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=rydberg@bitmath.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).