Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1241024 > unrolled thread
| Started by | fcooper@ti.com |
|---|---|
| First post | 2015-10-07 00:00 +0200 |
| Last post | 2015-10-07 00:50 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] Input: edt-ft5x06 - Only call desc_to_gpio for valid gpios fcooper@ti.com - 2015-10-07 00:00 +0200
Re: [PATCH] Input: edt-ft5x06 - Only call desc_to_gpio for valid gpios Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-10-07 00:50 +0200
| From | fcooper@ti.com |
|---|---|
| Date | 2015-10-07 00:00 +0200 |
| Subject | [PATCH] Input: edt-ft5x06 - Only call desc_to_gpio for valid gpios |
| Message-ID | <qgIr8-1WE-5@gated-at.bofh.it> |
From: Franklin S Cooper Jr <fcooper@ti.com>
Since reset and wake pin are optional the gpio structure for those
pins may be null. Therefore, they can't be blindly passed to
desc_to_gpio.
Only use desc_to_gpio for valid gpios.
This issue was detected by Smatch
http://permalink.gmane.org/gmane.linux.kernel.input/45927
Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
---
This patch is based on top of the following patchset which already
is already in linux-next:
https://patchwork.kernel.org/patch/7166931/
drivers/input/touchscreen/edt-ft5x06.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 7239c31..f877404 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -876,11 +876,13 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
struct edt_ft5x06_ts_data *tsdata;
struct input_dev *input;
unsigned long irq_flags;
- int error;
+ int error, reset_pin, wake_pin;
char fw_version[EDT_NAME_LEN];
dev_dbg(&client->dev, "probing for EDT FT5x06 I2C\n");
+ reset_pin = wake_pin = -1;
+
tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL);
if (!tsdata) {
dev_err(&client->dev, "failed to allocate driver data.\n");
@@ -908,12 +910,14 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
if (tsdata->wake_gpio) {
usleep_range(5000, 6000);
gpiod_set_value_cansleep(tsdata->wake_gpio, 1);
+ wake_pin = desc_to_gpio(tsdata->wake_gpio);
}
if (tsdata->reset_gpio) {
usleep_range(5000, 6000);
gpiod_set_value_cansleep(tsdata->reset_gpio, 0);
msleep(300);
+ reset_pin = desc_to_gpio(tsdata->reset_gpio);
}
input = devm_input_allocate_device(&client->dev);
@@ -987,8 +991,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
dev_dbg(&client->dev,
"EDT FT5x06 initialized: IRQ %d, WAKE pin %d, Reset pin %d.\n",
- client->irq, desc_to_gpio(tsdata->wake_gpio),
- desc_to_gpio(tsdata->reset_gpio));
+ client->irq, wake_pin, reset_pin);
return 0;
--
2.6.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Dmitry Torokhov <dmitry.torokhov@gmail.com> |
|---|---|
| Date | 2015-10-07 00:50 +0200 |
| Subject | Re: [PATCH] Input: edt-ft5x06 - Only call desc_to_gpio for valid gpios |
| Message-ID | <qgJdw-35V-9@gated-at.bofh.it> |
| In reply to | #1241024 |
Hi Franklin,
On Tue, Oct 06, 2015 at 04:49:47PM -0500, fcooper@ti.com wrote:
> From: Franklin S Cooper Jr <fcooper@ti.com>
>
> Since reset and wake pin are optional the gpio structure for those
> pins may be null. Therefore, they can't be blindly passed to
> desc_to_gpio.
>
> Only use desc_to_gpio for valid gpios.
>
> This issue was detected by Smatch
> http://permalink.gmane.org/gmane.linux.kernel.input/45927
>
> Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
> ---
> This patch is based on top of the following patchset which already
> is already in linux-next:
> https://patchwork.kernel.org/patch/7166931/
>
> drivers/input/touchscreen/edt-ft5x06.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
> index 7239c31..f877404 100644
> --- a/drivers/input/touchscreen/edt-ft5x06.c
> +++ b/drivers/input/touchscreen/edt-ft5x06.c
> @@ -876,11 +876,13 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
> struct edt_ft5x06_ts_data *tsdata;
> struct input_dev *input;
> unsigned long irq_flags;
> - int error;
> + int error, reset_pin, wake_pin;
> char fw_version[EDT_NAME_LEN];
>
> dev_dbg(&client->dev, "probing for EDT FT5x06 I2C\n");
>
> + reset_pin = wake_pin = -1;
> +
> tsdata = devm_kzalloc(&client->dev, sizeof(*tsdata), GFP_KERNEL);
> if (!tsdata) {
> dev_err(&client->dev, "failed to allocate driver data.\n");
> @@ -908,12 +910,14 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
> if (tsdata->wake_gpio) {
> usleep_range(5000, 6000);
> gpiod_set_value_cansleep(tsdata->wake_gpio, 1);
> + wake_pin = desc_to_gpio(tsdata->wake_gpio);
> }
>
> if (tsdata->reset_gpio) {
> usleep_range(5000, 6000);
> gpiod_set_value_cansleep(tsdata->reset_gpio, 0);
> msleep(300);
> + reset_pin = desc_to_gpio(tsdata->reset_gpio);
> }
>
> input = devm_input_allocate_device(&client->dev);
> @@ -987,8 +991,7 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
>
> dev_dbg(&client->dev,
> "EDT FT5x06 initialized: IRQ %d, WAKE pin %d, Reset pin %d.\n",
> - client->irq, desc_to_gpio(tsdata->wake_gpio),
> - desc_to_gpio(tsdata->reset_gpio));
> + client->irq, wake_pin, reset_pin);
I changed to use ternary operators in dev_dbg instead of temp variables
and applied.
Thanks.
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web