From patchwork Mon Jul 6 23:25:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 6728371 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id DB5C59F2F0 for ; Mon, 6 Jul 2015 23:26:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C90C5206D6 for ; Mon, 6 Jul 2015 23:26:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A098520552 for ; Mon, 6 Jul 2015 23:25:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756212AbbGFXZ5 (ORCPT ); Mon, 6 Jul 2015 19:25:57 -0400 Received: from mail-ig0-f179.google.com ([209.85.213.179]:33205 "EHLO mail-ig0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756136AbbGFXZ4 (ORCPT ); Mon, 6 Jul 2015 19:25:56 -0400 Received: by igh16 with SMTP id 16so38361484igh.0 for ; Mon, 06 Jul 2015 16:25:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=ATEfH9M0IVMKcKm1nWuPHIfzyLjzYY7kJMzeJ6HjySQ=; b=OxCi0jE/5Dfzh1HU3KV48wIU+FM+l/abmrsNUyfNUp3hTjebj+2s1BgqepGI+3xkKT Ms7mPRpZh3ZeAqgO8qHc0dbQDu4d5C0phcpbRvzSw2rzmIX7pkbHe28dce8egZO02VlR pPlc+cfeRh4vT5pZ9eLSH+aUelcn6Dnb+MeiX2vQtXWwRY9gnzYPk08ndKPcsY2PqAht sKkQysgfmVMpMiAO3LEZLfgrkVjyqqpR628ph5sHyvAnUMlm74ivVhNC9f5YdKt/uGDz OIVxapTyBBONZugk3G3I1FMC1MrV3q3eSfAHRxhK1IzG2BrA/T3R7qRSWWylxutJ5i/L e8Xg== X-Received: by 10.42.207.129 with SMTP id fy1mr38929323icb.34.1436225156353; Mon, 06 Jul 2015 16:25:56 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1301:7cf5:28c5:1e3:78a6]) by mx.google.com with ESMTPSA id e69sm13435452ioe.11.2015.07.06.16.25.54 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 06 Jul 2015 16:25:54 -0700 (PDT) Date: Mon, 6 Jul 2015 16:25:51 -0700 From: Dmitry Torokhov To: Dirk Behme Cc: linux-input@vger.kernel.org Subject: Re: [PATCH 2/2] Input: zforce - convert to use the gpiod interface Message-ID: <20150706232551.GD32140@dtor-ws> References: <1435914469-8955-1-git-send-email-dirk.behme@de.bosch.com> <1435914469-8955-3-git-send-email-dirk.behme@de.bosch.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1435914469-8955-3-git-send-email-dirk.behme@de.bosch.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Dirk, On Fri, Jul 03, 2015 at 11:07:49AM +0200, Dirk Behme wrote: > diff --git a/include/linux/platform_data/zforce_ts.h b/include/linux/platform_data/zforce_ts.h > index 44cd90f..1794268 100644 > --- a/include/linux/platform_data/zforce_ts.h > +++ b/include/linux/platform_data/zforce_ts.h > @@ -15,12 +15,9 @@ > #ifndef _LINUX_INPUT_ZFORCE_TS_H > #define _LINUX_INPUT_ZFORCE_TS_H > > -#include > - > struct zforce_ts_platdata { > - int gpio_int; > - int gpio_rst; > - enum of_gpio_flags reset_active_low; > + struct gpio_desc *gpio_int; > + struct gpio_desc *gpio_rst; > > unsigned int x_max; > unsigned int y_max; I do not think we should be plumbing GPIO descriptors directly into platform data. If board doe snot want to use DT/ACPI they will simply have to attach GPIO lookup table to the device (via gpiod_add_lookup_table). So I intend to apply the version below... Thanks. diff --git a/drivers/input/touchscreen/zforce_ts.c b/drivers/input/touchscreen/zforce_ts.c index f58a196..c4cffcf 100644 --- a/drivers/input/touchscreen/zforce_ts.c +++ b/drivers/input/touchscreen/zforce_ts.c @@ -24,14 +24,13 @@ #include #include #include -#include +#include #include #include #include #include #include #include -#include #define WAIT_TIMEOUT msecs_to_jiffies(1000) @@ -120,6 +119,9 @@ struct zforce_ts { struct regulator *reg_vdd; + struct gpio_desc *gpio_int; + struct gpio_desc *gpio_rst; + bool suspending; bool suspended; bool boot_complete; @@ -161,6 +163,16 @@ static int zforce_command(struct zforce_ts *ts, u8 cmd) return 0; } +static void zforce_reset_assert(struct zforce_ts *ts) +{ + gpiod_set_value_cansleep(ts->gpio_rst, 1); +} + +static void zforce_reset_deassert(struct zforce_ts *ts) +{ + gpiod_set_value_cansleep(ts->gpio_rst, 0); +} + static int zforce_send_wait(struct zforce_ts *ts, const char *buf, int len) { struct i2c_client *client = ts->client; @@ -479,7 +491,6 @@ static irqreturn_t zforce_irq_thread(int irq, void *dev_id) { struct zforce_ts *ts = dev_id; struct i2c_client *client = ts->client; - const struct zforce_ts_platdata *pdata = ts->pdata; int ret; u8 payload_buffer[FRAME_MAXSIZE]; u8 *payload; @@ -499,7 +510,7 @@ static irqreturn_t zforce_irq_thread(int irq, void *dev_id) if (!ts->suspending && device_may_wakeup(&client->dev)) pm_stay_awake(&client->dev); - while (!gpio_get_value(pdata->gpio_int)) { + while (!gpiod_get_value_cansleep(ts->gpio_int)) { ret = zforce_read_packet(ts, payload_buffer); if (ret < 0) { dev_err(&client->dev, @@ -690,7 +701,7 @@ static void zforce_reset(void *data) { struct zforce_ts *ts = data; - gpio_set_value(ts->pdata->gpio_rst, 0); + zforce_reset_assert(ts); udelay(10); @@ -712,18 +723,6 @@ static struct zforce_ts_platdata *zforce_parse_dt(struct device *dev) return ERR_PTR(-ENOMEM); } - pdata->gpio_int = of_get_gpio(np, 0); - if (!gpio_is_valid(pdata->gpio_int)) { - dev_err(dev, "failed to get interrupt gpio\n"); - return ERR_PTR(-EINVAL); - } - - pdata->gpio_rst = of_get_gpio(np, 1); - if (!gpio_is_valid(pdata->gpio_rst)) { - dev_err(dev, "failed to get reset gpio\n"); - return ERR_PTR(-EINVAL); - } - if (of_property_read_u32(np, "x-size", &pdata->x_max)) { dev_err(dev, "failed to get x-size property\n"); return ERR_PTR(-EINVAL); @@ -755,19 +754,22 @@ static int zforce_probe(struct i2c_client *client, if (!ts) return -ENOMEM; - ret = devm_gpio_request_one(&client->dev, pdata->gpio_int, GPIOF_IN, - "zforce_ts_int"); - if (ret) { - dev_err(&client->dev, "request of gpio %d failed, %d\n", - pdata->gpio_int, ret); + /* INT GPIO */ + ts->gpio_int = devm_gpiod_get_index(&client->dev, NULL, 0, GPIOD_IN); + if (IS_ERR(ts->gpio_int)) { + ret = PTR_ERR(ts->gpio_int); + dev_err(&client->dev, + "failed to request interrupt GPIO: %d\n", ret); return ret; } - ret = devm_gpio_request_one(&client->dev, pdata->gpio_rst, - GPIOF_OUT_INIT_LOW, "zforce_ts_rst"); - if (ret) { - dev_err(&client->dev, "request of gpio %d failed, %d\n", - pdata->gpio_rst, ret); + /* RST GPIO */ + ts->gpio_rst = devm_gpiod_get_index(&client->dev, NULL, 1, + GPIOD_OUT_HIGH); + if (IS_ERR(ts->gpio_rst)) { + ret = PTR_ERR(ts->gpio_rst); + dev_err(&client->dev, + "failed to request reset GPIO: %d\n", ret); return ret; } @@ -863,7 +865,7 @@ static int zforce_probe(struct i2c_client *client, i2c_set_clientdata(client, ts); /* let the controller boot */ - gpio_set_value(pdata->gpio_rst, 1); + zforce_reset_deassert(ts); ts->command_waiting = NOTIFICATION_BOOTCOMPLETE; if (wait_for_completion_timeout(&ts->command_done, WAIT_TIMEOUT) == 0) diff --git a/include/linux/platform_data/zforce_ts.h b/include/linux/platform_data/zforce_ts.h index 0472ab2..7bdece8 100644 --- a/include/linux/platform_data/zforce_ts.h +++ b/include/linux/platform_data/zforce_ts.h @@ -16,9 +16,6 @@ #define _LINUX_INPUT_ZFORCE_TS_H struct zforce_ts_platdata { - int gpio_int; - int gpio_rst; - unsigned int x_max; unsigned int y_max; };