From patchwork Sat Jun 17 10:58:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9794047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A51DD600F6 for ; Sat, 17 Jun 2017 10:58:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95EF9284D2 for ; Sat, 17 Jun 2017 10:58:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A60B284DC; Sat, 17 Jun 2017 10:58:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26FE4284D2 for ; Sat, 17 Jun 2017 10:58:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752751AbdFQK6j (ORCPT ); Sat, 17 Jun 2017 06:58:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42890 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752720AbdFQK6i (ORCPT ); Sat, 17 Jun 2017 06:58:38 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2F25081222; Sat, 17 Jun 2017 10:58:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2F25081222 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=hdegoede@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2F25081222 Received: from shalem.localdomain.com (ovpn-116-82.ams2.redhat.com [10.36.116.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id 548247EA38; Sat, 17 Jun 2017 10:58:35 +0000 (UTC) From: Hans de Goede To: Dmitry Torokhov Cc: Hans de Goede , Jiri Kosina , Benjamin Tissoires , linux-input@vger.kernel.org Subject: [PATCH 1/4] Input: icn8318 - Move of specific probe code to a helper function Date: Sat, 17 Jun 2017 12:58:31 +0200 Message-Id: <20170617105834.16255-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sat, 17 Jun 2017 10:58:38 +0000 (UTC) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Hans de Goede --- 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, };