From patchwork Thu Feb 4 13:39:18 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grazvydas Ignotas X-Patchwork-Id: 76982 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o14DdYk8027546 for ; Thu, 4 Feb 2010 13:39:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758226Ab0BDNjd (ORCPT ); Thu, 4 Feb 2010 08:39:33 -0500 Received: from ey-out-2122.google.com ([74.125.78.27]:10440 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758074Ab0BDNjc (ORCPT ); Thu, 4 Feb 2010 08:39:32 -0500 Received: by ey-out-2122.google.com with SMTP id d26so582519eyd.19 for ; Thu, 04 Feb 2010 05:39:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=mqxNsKpNvEuSFSN6so4yI88djHpLmJTSf8Hdm7Pvj8c=; b=iEa/5XCvybNV1fGmfjFNASL99Qz4DAWe3HUD+oLYWOlpFNfhAEIir6LLct9LtK3nDU 67dl5GFybYEcF1CENNlsFKnQOOPO5NpaheGoDHBrpDAR+Y95cCi7lE9+Thp+Zp21mCzv yHL9ZjbfwXPbfp4xxxCBtkLiexqqoGrSSxR+Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=RGd02D5QoJf2+DaeDoHQgc+9jphmnjtM2LSUcTzzzZR6E7lw9Dvw1ZaZBKdDmMbcDZ swwdouStWleykpeR7WQPIDL8N6/1v81HSJ7kPyHf53mT+tUu+WdqXdMksgmvIT2VqeNT sbwKusFtxr7jcDYF9sUYD6XjnT5a/jF9/ITSk= Received: by 10.213.109.217 with SMTP id k25mr969462ebp.88.1265290770936; Thu, 04 Feb 2010 05:39:30 -0800 (PST) Received: from localhost.localdomain (ip-88-119-226-136.static.b4net.lt [88.119.226.136]) by mx.google.com with ESMTPS id 14sm90350ewy.3.2010.02.04.05.39.29 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 04 Feb 2010 05:39:29 -0800 (PST) From: Grazvydas Ignotas To: linux-input@vger.kernel.org Cc: Dmitry Torokhov , linux-omap@vger.kernel.org, Grazvydas Ignotas Subject: [PATCH] Input: ads7846: add regulator support Date: Thu, 4 Feb 2010 15:39:18 +0200 Message-Id: <1265290758-2035-1-git-send-email-notasas@gmail.com> X-Mailer: git-send-email 1.6.3.3 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 04 Feb 2010 13:39:34 +0000 (UTC) diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 52d2ca1..5da902a 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c @@ -27,6 +27,7 @@ #include #include #include +#include #include /* @@ -85,6 +86,7 @@ struct ads7846 { char name[32]; struct spi_device *spi; + struct regulator *reg; #if defined(CONFIG_HWMON) || defined(CONFIG_HWMON_MODULE) struct attribute_group *attr_group; @@ -788,6 +790,9 @@ static void ads7846_disable(struct ads7846 *ts) } } + if (!IS_ERR(ts->reg)) + regulator_disable(ts->reg); + /* we know the chip's in lowpower mode since we always * leave it that way after every request */ @@ -799,6 +804,9 @@ static void ads7846_enable(struct ads7846 *ts) if (!ts->disabled) return; + if (!IS_ERR(ts->reg)) + regulator_enable(ts->reg); + ts->disabled = 0; ts->irq_disabled = 0; enable_irq(ts->spi->irq); @@ -1139,6 +1147,13 @@ static int __devinit ads7846_probe(struct spi_device *spi) ts->last_msg = m; + ts->reg = regulator_get(&spi->dev, "vcc"); + if (!IS_ERR(ts->reg)) { + err = regulator_enable(ts->reg); + if (err) + goto err_put_regulator; + } + if (request_irq(spi->irq, ads7846_irq, IRQF_TRIGGER_FALLING, spi->dev.driver->name, ts)) { dev_info(&spi->dev, @@ -1148,7 +1163,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) spi->dev.driver->name, ts); if (err) { dev_dbg(&spi->dev, "irq %d busy?\n", spi->irq); - goto err_free_gpio; + goto err_disable_regulator; } } @@ -1180,7 +1195,12 @@ static int __devinit ads7846_probe(struct spi_device *spi) ads784x_hwmon_unregister(spi, ts); err_free_irq: free_irq(spi->irq, ts); - err_free_gpio: + err_disable_regulator: + if (!IS_ERR(ts->reg)) + regulator_disable(ts->reg); + err_put_regulator: + if (!IS_ERR(ts->reg)) + regulator_put(ts->reg); if (ts->gpio_pendown != -1) gpio_free(ts->gpio_pendown); err_cleanup_filter: @@ -1208,6 +1228,11 @@ static int __devexit ads7846_remove(struct spi_device *spi) /* suspend left the IRQ disabled */ enable_irq(ts->spi->irq); + if (!IS_ERR(ts->reg)) { + regulator_disable(ts->reg); + regulator_put(ts->reg); + } + if (ts->gpio_pendown != -1) gpio_free(ts->gpio_pendown);