From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
linux-input@vger.kernel.org
Subject: Re: [PATCH v2 1/4] Input: icn8318 - Move of specific probe code to a helper function
Date: Sun, 18 Jun 2017 14:55:06 -0700 [thread overview]
Message-ID: <20170618215506.GA40590@dtor-ws> (raw)
In-Reply-To: <20170618101829.18734-1-hdegoede@redhat.com>
Hi Hans,
On Sun, Jun 18, 2017 at 12:18:26PM +0200, Hans de Goede wrote:
> This is a preparation patch for adding support for ACPI enumerated
> Chipone touchscreens. On ACPI platforms the wake GPIO is unused, move
> the code to get the GPIO to a new icn8318_probe_of helper function.
It might be used later though. If we decide that wakeup gpio is optional
then let's switch to devm_gpiod_get_optional().
Thanks.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/input/touchscreen/chipone_icn8318.c | 50 ++++++++++++++++++++---------
> 1 file changed, 35 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/input/touchscreen/chipone_icn8318.c b/drivers/input/touchscreen/chipone_icn8318.c
> index 0bf14067c167..ddaae91f02fc 100644
> --- a/drivers/input/touchscreen/chipone_icn8318.c
> +++ b/drivers/input/touchscreen/chipone_icn8318.c
> @@ -137,7 +137,8 @@ static int icn8318_start(struct input_dev *dev)
> struct icn8318_data *data = input_get_drvdata(dev);
>
> enable_irq(data->client->irq);
> - gpiod_set_value_cansleep(data->wake_gpio, 1);
> + if (data->wake_gpio)
> + gpiod_set_value_cansleep(data->wake_gpio, 1);
>
> return 0;
> }
> @@ -149,7 +150,8 @@ static void icn8318_stop(struct input_dev *dev)
> disable_irq(data->client->irq);
> i2c_smbus_write_byte_data(data->client, ICN8318_REG_POWER,
> ICN8318_POWER_HIBERNATE);
> - gpiod_set_value_cansleep(data->wake_gpio, 0);
> + if (data->wake_gpio)
> + gpiod_set_value_cansleep(data->wake_gpio, 0);
> }
>
> #ifdef CONFIG_PM_SLEEP
> @@ -180,8 +182,29 @@ static int icn8318_resume(struct device *dev)
>
> static SIMPLE_DEV_PM_OPS(icn8318_pm_ops, icn8318_suspend, icn8318_resume);
>
> -static int icn8318_probe(struct i2c_client *client,
> - const struct i2c_device_id *id)
> +#ifdef CONFIG_OF
> +static int icn8318_probe_of(struct icn8318_data *data, struct device *dev)
> +{
> + int error;
> +
> + data->wake_gpio = devm_gpiod_get(dev, "wake", GPIOD_OUT_LOW);
> + if (IS_ERR(data->wake_gpio)) {
> + error = PTR_ERR(data->wake_gpio);
> + if (error != -EPROBE_DEFER)
> + dev_err(dev, "Error getting wake gpio: %d\n", error);
> + return error;
> + }
> +
> + return 0;
> +}
> +#else
> +static int icn8318_probe_of(struct icn8318_data *data, struct device *dev)
> +{
> + return -ENODEV;
> +}
> +#endif
> +
> +static int icn8318_probe(struct i2c_client *client)
> {
> struct device *dev = &client->dev;
> struct icn8318_data *data;
> @@ -197,18 +220,13 @@ static int icn8318_probe(struct i2c_client *client,
> if (!data)
> return -ENOMEM;
>
> - data->wake_gpio = devm_gpiod_get(dev, "wake", GPIOD_OUT_LOW);
> - if (IS_ERR(data->wake_gpio)) {
> - error = PTR_ERR(data->wake_gpio);
> - if (error != -EPROBE_DEFER)
> - dev_err(dev, "Error getting wake gpio: %d\n", error);
> - return error;
> - }
> -
> input = devm_input_allocate_device(dev);
> if (!input)
> return -ENOMEM;
>
> + data->client = client;
> + data->input = input;
> +
> input->name = client->name;
> input->id.bustype = BUS_I2C;
> input->open = icn8318_start;
> @@ -218,6 +236,10 @@ static int icn8318_probe(struct i2c_client *client,
> input_set_capability(input, EV_ABS, ABS_MT_POSITION_X);
> input_set_capability(input, EV_ABS, ABS_MT_POSITION_Y);
>
> + error = icn8318_probe_of(data, dev);
> + if (error)
> + return error;
> +
> touchscreen_parse_properties(input, true, &data->prop);
> if (!input_abs_get_max(input, ABS_MT_POSITION_X) ||
> !input_abs_get_max(input, ABS_MT_POSITION_Y)) {
> @@ -230,8 +252,6 @@ static int icn8318_probe(struct i2c_client *client,
> if (error)
> return error;
>
> - data->client = client;
> - data->input = input;
> input_set_drvdata(input, data);
>
> error = devm_request_threaded_irq(dev, client->irq, NULL, icn8318_irq,
> @@ -271,7 +291,7 @@ static struct i2c_driver icn8318_driver = {
> .pm = &icn8318_pm_ops,
> .of_match_table = icn8318_of_match,
> },
> - .probe = icn8318_probe,
> + .probe_new = icn8318_probe,
> .id_table = icn8318_i2c_id,
> };
>
> --
> 2.13.0
>
--
Dmitry
next prev parent reply other threads:[~2017-06-18 21:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-18 10:18 [PATCH v2 1/4] Input: icn8318 - Move of specific probe code to a helper function Hans de Goede
2017-06-18 10:18 ` [PATCH v2 2/4] Input: icn8318 - Add support for icn8505 Hans de Goede
2017-06-18 22:06 ` Dmitry Torokhov
2017-07-06 19:35 ` Hans de Goede
2017-06-18 10:18 ` [PATCH v2 3/4] Input: icn8318 - Add support for ACPI enumeration Hans de Goede
2017-06-18 21:58 ` Dmitry Torokhov
2017-07-06 19:38 ` Hans de Goede
2017-06-18 10:18 ` [PATCH v2 4/4] Input: icn8318 - Add support for capacative home button Hans de Goede
2017-06-18 21:55 ` Dmitry Torokhov [this message]
2017-07-06 19:34 ` [PATCH v2 1/4] Input: icn8318 - Move of specific probe code to a helper function Hans de Goede
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=20170618215506.GA40590@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=benjamin.tissoires@redhat.com \
--cc=hdegoede@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.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).