From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Gireesh.Hiremath@in.bosch.com
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
dmitry.torokhov@gmail.com, Jonathan.Cameron@huawei.com,
lis8215@gmail.com, sjoerd.simons@collabora.co.uk,
VinayKumar.Shettar@in.bosch.com,
Govindaraji.Sivanantham@in.bosch.com,
anaclaudia.dias@de.bosch.com
Subject: Re: [PATCH] driver: input: matric-keypad: switch to gpiod API
Date: Fri, 13 Jan 2023 20:43:13 +0200 [thread overview]
Message-ID: <Y8GmQVgjmsUwsA/w@smile.fi.intel.com> (raw)
In-Reply-To: <20230113062538.1537-1-Gireesh.Hiremath@in.bosch.com>
On Fri, Jan 13, 2023 at 06:25:38AM +0000, Gireesh.Hiremath@in.bosch.com wrote:
> From: Gireesh Hiremath <Gireesh.Hiremath@in.bosch.com>
Thank you for the patch, my comments below.
> switch to new gpio descriptor based API
Please, respect English grammar and punctuation.
Also, you have a typo in the Subject besides the fact that the template for
Input subsystem is different. So prefix has to be changed as well.
...
> bool level_on = !pdata->active_low;
>
> if (on) {
> - gpio_direction_output(pdata->col_gpios[col], level_on);
> + gpiod_direction_output(pdata->col_gpios[col], level_on);
> } else {
> - gpio_set_value_cansleep(pdata->col_gpios[col], !level_on);
> + gpiod_set_value_cansleep(pdata->col_gpios[col], !level_on);
> }
I believe it's not so trivial. The GPIO descriptor already has encoded the
level information and above one as below are not clear now.
> - return gpio_get_value_cansleep(pdata->row_gpios[row]) ?
> + return gpiod_get_value_cansleep(pdata->row_gpios[row]) ?
> !pdata->active_low : pdata->active_low;
...
> - err = gpio_request(pdata->col_gpios[i], "matrix_kbd_col");
> + err = gpiod_direction_output(pdata->col_gpios[i], !pdata->active_low);
> while (--i >= 0)
> - gpio_free(pdata->row_gpios[i]);
> + gpiod_put(pdata->row_gpios[i]);
This looks like an incorrect change.
> while (--i >= 0)
> - gpio_free(pdata->col_gpios[i]);
> + gpiod_put(pdata->col_gpios[i]);
So does this.
Since you dropped gpio_request() you need to drop gpio_free() as well,
and not replace it.
...
> for (i = 0; i < nrow; i++) {
> - ret = of_get_named_gpio(np, "row-gpios", i);
> - if (ret < 0)
> - return ERR_PTR(ret);
(1)
> - gpios[i] = ret;
> + desc = gpiod_get_index(dev, "row", i, GPIOD_IN);
> + if (IS_ERR(desc))
> + return ERR_PTR(-EINVAL);
Why?! How will it handle deferred probe, for example?
> + gpios[i] = desc;
> }
...
> for (i = 0; i < ncol; i++) {
> - ret = of_get_named_gpio(np, "col-gpios", i);
> - if (ret < 0)
> - return ERR_PTR(ret);
> - gpios[nrow + i] = ret;
> + desc = gpiod_get_index(dev, "col", i, GPIOD_IN);
> + if (IS_ERR(desc))
> + return ERR_PTR(-EINVAL);
Ditto.
> + gpios[nrow + i] = desc;
> }
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-01-13 18:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-13 6:25 [PATCH] driver: input: matric-keypad: switch to gpiod API Gireesh.Hiremath
2023-01-13 18:43 ` Andy Shevchenko [this message]
2023-01-19 11:47 ` Gireesh.Hiremath
2023-01-19 14:19 ` Andy Shevchenko
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=Y8GmQVgjmsUwsA/w@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=Gireesh.Hiremath@in.bosch.com \
--cc=Govindaraji.Sivanantham@in.bosch.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=VinayKumar.Shettar@in.bosch.com \
--cc=anaclaudia.dias@de.bosch.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lis8215@gmail.com \
--cc=sjoerd.simons@collabora.co.uk \
/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