From patchwork Sat Feb 11 00:06:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 9567649 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 7FC5060573 for ; Sat, 11 Feb 2017 00:07:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67B91285CF for ; Sat, 11 Feb 2017 00:07:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58E5F285F1; Sat, 11 Feb 2017 00:07:30 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 0EAF7285CF for ; Sat, 11 Feb 2017 00:07:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753296AbdBKAGa (ORCPT ); Fri, 10 Feb 2017 19:06:30 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:34263 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751812AbdBKAG1 (ORCPT ); Fri, 10 Feb 2017 19:06:27 -0500 Received: by mail-pg0-f67.google.com with SMTP id v184so4139650pgv.1; Fri, 10 Feb 2017 16:06:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hPq3pLQLnZbyz0p0Xa4WD1wsezk9/5DDHNXa3rJ740w=; b=ZFaFArHGZtnAcbie1MCfqocD8FapFMLvnwgNA2ghIdT+ehCiuBxFT+uJwmrVjtVXLV Y4n0Lz0tP03Apg1O0yVHequhM4SQ9Rmp7uF4ouum7zkV+WfBgjk+MQtk2zjzMre2h7Ml QGlb+4oa5QhV25AQmvDOZIQf0oBatUvsgwDr/mcYjYfThGZJDBUDK5DGVILFPIti4McV Zf/2QooC8MKh+WdNi2lJWcGcuA+cWooj9KXMgc/f/wZ1lnlifjVKt2bJw9fhgfLE2h4q 14WHR1ZhmmPsWJDG4KOKkY8WSJHhP2ufX2/aiZOyYnNo/VnMDzcAcnGbOCFomhe/lnNz Qu+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hPq3pLQLnZbyz0p0Xa4WD1wsezk9/5DDHNXa3rJ740w=; b=VrQU3ABcnNE04BjLAwevlTLgGrKJEo3uUXTd72+w/bB1Nqh2kMkFaso3OPYXSB5zSl +mkd1cCNt4NcmbTNnbn3FHqil9lz65eu4vpZ1QL/AjeE27ufrpYkFPpiWz1RSNTCziwK xrmsQCXgwLVsCsCHsPmOwSASRSIU8Dkof2MJViFaUWeEs4ZbqySIgmjIU0aq3XgfT0iL bKL13KQ9i+nGLrq45lGhtBSKUthRMPx2tTvi1aKnNsBYb2wJnLXL49CMmu6JB05gW4n7 OyeOT5i57toYTHV8c0y04QztHC+G4YWiwrECZyvom7LozFODVarnpSHXKRl4o+bg/5PC uWag== X-Gm-Message-State: AMke39lTslEsojVK51QGh4znUPPd4DuUrqFGSZRjMbtjoP+NES9xVv+R9LTu1NBcBIlAQw== X-Received: by 10.98.16.14 with SMTP id y14mr13266390pfi.63.1486771586928; Fri, 10 Feb 2017 16:06:26 -0800 (PST) Received: from dtor-ws.mtv.corp.google.com ([172.22.152.34]) by smtp.gmail.com with ESMTPSA id 88sm7618592pfr.41.2017.02.10.16.06.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 10 Feb 2017 16:06:26 -0800 (PST) From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Sebastian Reichel , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Michael Welling , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] Input: tsc2004/5 - fix regulator handling Date: Fri, 10 Feb 2017 16:06:22 -0800 Message-Id: <20170211000623.33663-2-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.11.0.483.g087da7b7c-goog In-Reply-To: <20170211000623.33663-1-dmitry.torokhov@gmail.com> References: <20170211000623.33663-1-dmitry.torokhov@gmail.com> 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 In case of an optional regulator missing regulator core will return ERR_PTR(-ENOENT) and not NULL, so the check for missing regulator is incorrect. Also, the regulator is not optional, it may simply be missing from platform decsription, so let's use devm_regulator_get() and rely on regulator core to give us dummy supply when real one is not available. Fixes: d257f2980feb ("Input: tsc2005 - convert to gpiod") Signed-off-by: Dmitry Torokhov Acked-By: Sebastian Reichel --- Sebastian, I am wondering, what regulator this is. If it is IO VDD, then I think we activate it too late (i.e. we are truing to shut off the controller before we turn the regulator on. If it is sensor VDD, then we probably need to mention it, and also add IO VVD supply as well. drivers/input/touchscreen/tsc200x-core.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/input/touchscreen/tsc200x-core.c b/drivers/input/touchscreen/tsc200x-core.c index b7059ed8872e..1c14a38e3748 100644 --- a/drivers/input/touchscreen/tsc200x-core.c +++ b/drivers/input/touchscreen/tsc200x-core.c @@ -527,10 +527,10 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, return error; } - ts->vio = devm_regulator_get_optional(dev, "vio"); + ts->vio = devm_regulator_get(dev, "vio"); if (IS_ERR(ts->vio)) { error = PTR_ERR(ts->vio); - dev_err(dev, "vio regulator missing (%d)", error); + dev_err(dev, "error acquiring vio regulator: %d", error); return error; } @@ -587,12 +587,9 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, return error; } - /* enable regulator for DT */ - if (ts->vio) { - error = regulator_enable(ts->vio); - if (error) - return error; - } + error = regulator_enable(ts->vio); + if (error) + return error; dev_set_drvdata(dev, ts); error = sysfs_create_group(&dev->kobj, &tsc200x_attr_group); @@ -615,8 +612,7 @@ int tsc200x_probe(struct device *dev, int irq, const struct input_id *tsc_id, err_remove_sysfs: sysfs_remove_group(&dev->kobj, &tsc200x_attr_group); disable_regulator: - if (ts->vio) - regulator_disable(ts->vio); + regulator_disable(ts->vio); return error; } EXPORT_SYMBOL_GPL(tsc200x_probe); @@ -627,8 +623,7 @@ int tsc200x_remove(struct device *dev) sysfs_remove_group(&dev->kobj, &tsc200x_attr_group); - if (ts->vio) - regulator_disable(ts->vio); + regulator_disable(ts->vio); return 0; }