From patchwork Wed Aug 8 13:23:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 1295751 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id DC7133FCFC for ; Wed, 8 Aug 2012 13:26:49 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Sz6ER-0004FE-B3; Wed, 08 Aug 2012 13:23:27 +0000 Received: from mail-bk0-f49.google.com ([209.85.214.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Sz6EN-0004DW-1v for linux-arm-kernel@lists.infradead.org; Wed, 08 Aug 2012 13:23:24 +0000 Received: by bkcji2 with SMTP id ji2so321245bkc.36 for ; Wed, 08 Aug 2012 06:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type; bh=Flw1LsHDIJBOa2w/cPxCpriWdPihFtp166CsbWwQkjQ=; b=Kqjf8xbMRsOLwJN128Uvn2dFwlIZ/kVbL0omhKPWVdBIdaMmT2as9gTKcbAkJlhQ8Y FeA6/a5U6PE9Qb5orHgEk9NH4hoeAMdx42RZd1KRXH23DFP+ywTZf+V+x73o/rYcHpmo WDZFLp5gH2va+GMFMauMsXzbSfbCyEKQDjUp2EBhBbqNXLaP2OuFHrEiZ9+chBBkc5ZS gaR4/f3HRHQRVK8fKk+jkmbxyq0LlWmAkTX0Ni2XfOJwXiVxLsCkY2A4w9m0H96+Ak/P mSwFVk5dmvfSbbrmQurhOHoxAm2mGpWK//kIExrSXOnvgOwqg66TDy7bfzC9HfDheNzY vWcA== Received: by 10.204.130.156 with SMTP id t28mr7625153bks.33.1344432199470; Wed, 08 Aug 2012 06:23:19 -0700 (PDT) Received: from [192.168.0.118] (91-64-199-89-dynip.superkabel.de. [91.64.199.89]) by mx.google.com with ESMTPS id m9sm10324216bkm.10.2012.08.08.06.23.16 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 08 Aug 2012 06:23:18 -0700 (PDT) Message-ID: <50226843.4080508@gmail.com> Date: Wed, 08 Aug 2012 15:23:15 +0200 From: Daniel Mack User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0 MIME-Version: 1.0 To: Arnd Bergmann Subject: Re: [PATCH 2/6] ARM: pxa remove irq_to_gpio from eeti_ts driver References: <1344430493-5304-1-git-send-email-arnd@arndb.de> <1344430493-5304-3-git-send-email-arnd@arndb.de> In-Reply-To: <1344430493-5304-3-git-send-email-arnd@arndb.de> X-Enigmail-Version: 1.4.3 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (zonque[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.49 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Haojian Zhuang , "v3.2+" , arm@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org On 08.08.2012 14:54, Arnd Bergmann wrote: > The irq_to_gpio function was removed from the pxa platform > in linux-3.2, and this driver has been broken since. > > Without this patch, building raumfeld_defconfig results in: > > drivers/input/touchscreen/eeti_ts.c: In function 'eeti_ts_irq_active': > drivers/input/touchscreen/eeti_ts.c:65:2: error: implicit declaration of function 'irq_to_gpio' [-Werror=implicit-function-declaration] I've sent out a slightly different version of such a patch just yesterday. It deferres mainly in the fact that it uses gpio_to_irq() and ignores the i2c_client's irq line. That way, there can't be any inconsitency. I've appended the patch again - I haven't heard back from Dmitry yet. Thanks, Daniel > Signed-off-by: Arnd Bergmann > Cc: stable@vger.kernel.org (v3.2+) > Cc: Daniel Mack > Cc: Haojian Zhuang > --- > arch/arm/mach-pxa/raumfeld.c | 1 + > drivers/input/touchscreen/eeti_ts.c | 8 +++++--- > include/linux/input/eeti_ts.h | 1 + > 3 files changed, 7 insertions(+), 3 deletions(-) > > diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c > index 5905ed1..9e1c4ea 100644 > --- a/arch/arm/mach-pxa/raumfeld.c > +++ b/arch/arm/mach-pxa/raumfeld.c > @@ -953,6 +953,7 @@ static struct i2c_board_info raumfeld_connector_i2c_board_info __initdata = { > > static struct eeti_ts_platform_data eeti_ts_pdata = { > .irq_active_high = 1, > + .gpio = GPIO_TOUCH_IRQ, > }; > > static struct i2c_board_info raumfeld_controller_i2c_board_info __initdata = { > diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c > index 503c709..45dab18 100644 > --- a/drivers/input/touchscreen/eeti_ts.c > +++ b/drivers/input/touchscreen/eeti_ts.c > @@ -48,7 +48,7 @@ struct eeti_ts_priv { > struct input_dev *input; > struct work_struct work; > struct mutex mutex; > - int irq, irq_active_high; > + int irq, gpio, irq_active_high; > }; > > #define EETI_TS_BITDEPTH (11) > @@ -62,7 +62,7 @@ struct eeti_ts_priv { > > static inline int eeti_ts_irq_active(struct eeti_ts_priv *priv) > { > - return gpio_get_value(irq_to_gpio(priv->irq)) == priv->irq_active_high; > + return gpio_get_value(priv->gpio) == priv->irq_active_high; > } > > static void eeti_ts_read(struct work_struct *work) > @@ -203,8 +203,10 @@ static int __devinit eeti_ts_probe(struct i2c_client *client, > > pdata = client->dev.platform_data; > > - if (pdata) > + if (pdata) { > + priv->gpio = pdata->gpio; > priv->irq_active_high = pdata->irq_active_high; > + } > > irq_flags = priv->irq_active_high ? > IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING; > diff --git a/include/linux/input/eeti_ts.h b/include/linux/input/eeti_ts.h > index f875b31..3404504 100644 > --- a/include/linux/input/eeti_ts.h > +++ b/include/linux/input/eeti_ts.h > @@ -3,6 +3,7 @@ > > struct eeti_ts_platform_data { > unsigned int irq_active_high; > + unsigned int gpio; > }; > > #endif /* LINUX_INPUT_EETI_TS_H */ > From bfb14c1a0417435ebcf5bdebbb94ae6812cb4aee Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Tue, 7 Aug 2012 17:02:59 +0200 Subject: [PATCH] Input: eeti_ts: pass gpio value instead of IRQ The EETI touchscreen asserts its IRQ line as soon as it has data in its internal buffers. The line is automatically deasserted once all data has been read via I2C. Hence, the driver has to monitor the GPIO line and cannot simply rely on the interrupt handler reception. In the current implementation of the driver, irq_to_gpio() is used to determine the GPIO number from the i2c_client's IRQ value. As irq_to_gpio() is not available on all platforms, this patch changes this and makes the driver ignore the passed in IRQ. Instead, a GPIO is added to the platform_data struct and gpio_to_irq is used to derive the IRQ from that GPIO. If this fails, bail out. The driver is only able to work in environments where the touchscreen GPIO can be mapped to an IRQ. Signed-off-by: Daniel Mack --- drivers/input/touchscreen/eeti_ts.c | 21 +++++++++++++-------- include/linux/input/eeti_ts.h | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c index 503c709..908407e 100644 --- a/drivers/input/touchscreen/eeti_ts.c +++ b/drivers/input/touchscreen/eeti_ts.c @@ -48,7 +48,7 @@ struct eeti_ts_priv { struct input_dev *input; struct work_struct work; struct mutex mutex; - int irq, irq_active_high; + int irq_gpio, irq, irq_active_high; }; #define EETI_TS_BITDEPTH (11) @@ -62,7 +62,7 @@ struct eeti_ts_priv { static inline int eeti_ts_irq_active(struct eeti_ts_priv *priv) { - return gpio_get_value(irq_to_gpio(priv->irq)) == priv->irq_active_high; + return gpio_get_value(priv->irq_gpio) == priv->irq_active_high; } static void eeti_ts_read(struct work_struct *work) @@ -157,7 +157,7 @@ static void eeti_ts_close(struct input_dev *dev) static int __devinit eeti_ts_probe(struct i2c_client *client, const struct i2c_device_id *idp) { - struct eeti_ts_platform_data *pdata; + struct eeti_ts_platform_data *pdata = client->dev.platform_data; struct eeti_ts_priv *priv; struct input_dev *input; unsigned int irq_flags; @@ -199,9 +199,12 @@ static int __devinit eeti_ts_probe(struct i2c_client *client, priv->client = client; priv->input = input; - priv->irq = client->irq; + priv->irq_gpio = pdata->irq_gpio; + priv->irq = gpio_to_irq(pdata->irq_gpio); - pdata = client->dev.platform_data; + err = gpio_request_one(pdata->irq_gpio, GPIOF_IN, client->name); + if (err < 0) + goto err1; if (pdata) priv->irq_active_high = pdata->irq_active_high; @@ -215,13 +218,13 @@ static int __devinit eeti_ts_probe(struct i2c_client *client, err = input_register_device(input); if (err) - goto err1; + goto err2; err = request_irq(priv->irq, eeti_ts_isr, irq_flags, client->name, priv); if (err) { dev_err(&client->dev, "Unable to request touchscreen IRQ.\n"); - goto err2; + goto err3; } /* @@ -233,9 +236,11 @@ static int __devinit eeti_ts_probe(struct i2c_client *client, device_init_wakeup(&client->dev, 0); return 0; -err2: +err3: input_unregister_device(input); input = NULL; /* so we dont try to free it below */ +err2: + gpio_free(pdata->irq_gpio); err1: input_free_device(input); kfree(priv); diff --git a/include/linux/input/eeti_ts.h b/include/linux/input/eeti_ts.h index f875b31..16625d7 100644 --- a/include/linux/input/eeti_ts.h +++ b/include/linux/input/eeti_ts.h @@ -2,6 +2,7 @@ #define LINUX_INPUT_EETI_TS_H struct eeti_ts_platform_data { + int irq_gpio; unsigned int irq_active_high; }; -- 1.7.11.2