From patchwork Thu Feb 3 17:19:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 530171 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p13HKLVH027434 for ; Thu, 3 Feb 2011 17:20:22 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756627Ab1BCRUK (ORCPT ); Thu, 3 Feb 2011 12:20:10 -0500 Received: from mail-px0-f174.google.com ([209.85.212.174]:34011 "EHLO mail-px0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756620Ab1BCRUG (ORCPT ); Thu, 3 Feb 2011 12:20:06 -0500 Received: by pxi15 with SMTP id 15so249187pxi.19 for ; Thu, 03 Feb 2011 09:20:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=tg6AMoBt83zS7/3iLHdG8ZAK5wgzl55UWUDNl4EtM8k=; b=r64Krz4Hyj0LXzVElr+Llp2zTutp1KWIqYnAxzGEwYCNo7xwSIYt7lt+l5ZU3nYen2 pRFXRUr4r6h7EmZW1shLJzIX9kqYLBGszvyMzLi1AfdcsR3XsHnbX5cx7a9iLctXZGKn xrTXxIrROcvCrPdOpjsblYr37UVcHjjs1jCK4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=xj7+Tr4vwlMe7S10kMwYEtfpFnA4JmeLmgCHPiZfuZ9tp0z+J2A0mw2Q9zak8PiqL4 BhuE3+qvb54p3ru66ecAbJoymxdnPMKtkQstPYIWPJUnVT4RCf3e4Rbk95W4vYOTcUM4 goT0SlMx7/48Tc6QHA/MSzEuLGQvi9OwIyYoQ= Received: by 10.143.8.2 with SMTP id l2mr10451362wfi.214.1296753605819; Thu, 03 Feb 2011 09:20:05 -0800 (PST) Received: from mailhub.coreip.homeip.net (c-98-234-113-65.hsd1.ca.comcast.net [98.234.113.65]) by mx.google.com with ESMTPS id e14sm1292956wfg.20.2011.02.03.09.20.02 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 03 Feb 2011 09:20:03 -0800 (PST) Date: Thu, 3 Feb 2011 09:19:53 -0800 From: Dmitry Torokhov To: Sourav Poddar Cc: LW@karo-electronics.de, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-input@vger.kernel.org, gadiyar@ti.com, charu@ti.com, grinberg@compulab.co.il, balbi@ti.com Subject: Re: [PATCH v3 2/2] Input: ads7846: use gpio_request_one to configure pendown_gpio Message-ID: <20110203171953.GA13997@core.coreip.homeip.net> References: <1296746506-12221-1-git-send-email-sourav.poddar@ti.com> <20110203165405.GB12802@core.coreip.homeip.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110203165405.GB12802@core.coreip.homeip.net> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 03 Feb 2011 17:20:33 +0000 (UTC) diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 0e9492d..b1217e1 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -946,30 +946,30 @@ static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads784 struct ads7846_platform_data *pdata = spi->dev.platform_data; int err; - /* REVISIT when the irq can be triggered active-low, or if for some + /* + * REVISIT when the irq can be triggered active-low, or if for some * reason the touchscreen isn't hooked up, we don't need to access * the pendown state. */ - if (!pdata->get_pendown_state && !gpio_is_valid(pdata->gpio_pendown)) { - dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n"); - return -EINVAL; - } if (pdata->get_pendown_state) { ts->get_pendown_state = pdata->get_pendown_state; - return 0; - } + } else if (gpio_is_valid(pdata->gpio_pendown)) { + + err = gpio_request_one(pdata->gpio_pendown, GPIOF_DIR_IN, + "ads7846_pendown"); + if (err) { + dev_err(&spi->dev, "failed to request pendown GPIO%d\n", + pdata->gpio_pendown); + return err; + } - err = gpio_request_one(pdata->gpio_pendown, GPIOF_DIR_IN, - "ads7846_pendown"); - if (err) { - dev_err(&spi->dev, "failed to request pendown GPIO%d\n", - pdata->gpio_pendown); - return err; + ts->gpio_pendown = pdata->gpio_pendown; + } else { + dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n"); + return -EINVAL; } - ts->gpio_pendown = pdata->gpio_pendown; - return 0; } @@ -1359,7 +1359,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) err_put_regulator: regulator_put(ts->reg); err_free_gpio: - if (ts->gpio_pendown != -1) + if (!ts->get_pendown_state) gpio_free(ts->gpio_pendown); err_cleanup_filter: if (ts->filter_cleanup) @@ -1389,8 +1389,13 @@ static int __devexit ads7846_remove(struct spi_device *spi) regulator_disable(ts->reg); regulator_put(ts->reg); - if (ts->gpio_pendown != -1) + if (!ts->get_pendown_state) { + /* + * If we are not using specialized pendown method we must + * have been relying on gpio we set up ourselves. + */ gpio_free(ts->gpio_pendown); + } if (ts->filter_cleanup) ts->filter_cleanup(ts->filter_data);