Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1691631lqa; Mon, 29 Apr 2024 16:50:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUbm47OTnvYsFPF0geoU9grH16Ix+YdtOeFHOMMHmefrq8zdTww0Yr2K/bR4Do6gGjdtPU+/+AjniKzJFWr0tg26HaIZou0ACsV93RFcA== X-Google-Smtp-Source: AGHT+IGGw78kp6DrLVrW7DKQ9++VsMg3rIhbJW8doyH2zOHrEJZAa62aFv14edfcifCogcR3wpTy X-Received: by 2002:a17:90a:b391:b0:2b0:c678:a3 with SMTP id e17-20020a17090ab39100b002b0c67800a3mr6896083pjr.41.1714434655894; Mon, 29 Apr 2024 16:50:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714434655; cv=pass; d=google.com; s=arc-20160816; b=ZGPJWLCBu3n4Je9xh0zaTqoVDa9MXLj3wkbXzTM8+xk3Sw2Slde2JBrEbQl44tmaA6 rKSpeiTalkxMJrxmhdCSAeJxq7IWDAQdlX/mehos/O2njFxQaOnFsIhmC44sV475liie 32x9pYAA5fWcmw0LBuNv+7f0kzA9wu5iKQ63YCbCIXMjx36At1NT8KeO5+vxFWszbZ6g YQCHyqnksm17ZjgRDg7ZIU25iZ0jgZo/b0ygwoKTpSFQZ85mG+R6ToQ7Kz/6LdpeIp0V XBh1CgmTKyypqvGqetxaj22obXTMsebTmwg/zqzi9TRL3FKWlut8H/6G166r2GIAV4jQ OPRg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BJ+ZTMWPcJc+hIlvH7T2PbKtWet9tgeGz07/T80YEuU=; fh=Os7QNDMOQ0wtfiWdlc8oPbUxYVxBTKuDZgfaP5KVGbU=; b=lYc6n1YVdgk6ntd/LjR+8ZCeP+Hf3v6wdMwTsj6le7LeLCxrhvayXkSgMo9xqA4aql +KVDJpqlovcC8pLgHy+Z/XeY8vO+pn0wAG6uH+9E964SWJmUmXLVp0/VOIDDQnAC8KE6 4pAO51XGntpRPtMANhhuRzNsp8ghBdFAVW4uzJfE4adkdlYnqdYpAeCbmEjw7TXWul4c K8O6V+6BMoNtpVMMjIjnkiUQBVW99lEh38U1LrJv2bgwavLLtZqQtmHqOv3jhaQdU8EH D0NIpcr0LVNTEUYfjaAD0+hjhivxn6ndVnljWzaPatYjJq94rerfJfJE6cpzXcoZ658m zx+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=pbHWLuh1; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-163166-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163166-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h4-20020a17090adb8400b002a09c6ccdc6si22315198pjv.182.2024.04.29.16.50.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 16:50:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163166-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=pbHWLuh1; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-163166-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163166-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 9A099B23EA7 for ; Mon, 29 Apr 2024 23:42:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D4D951BED70; Mon, 29 Apr 2024 23:40:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="pbHWLuh1" Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6AADB199E8C for ; Mon, 29 Apr 2024 23:40:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714434044; cv=none; b=RiW5443BZSwA6juGxpWXs+OvqhMODPhJqTMdVfZncs5uJHbZfkxlESJ7/jR4lr3tbFHfP+swSSoFTIrEKkuczoNT78M/sbe2D/QhETKfXA17/bc+HN3meZ/LgT1cMTYWLsrymboIj8Tr9p4KWwf9XtKq/jWbRdp6RkzPnbH5+xQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714434044; c=relaxed/simple; bh=f4G2L1z1zSkKaPQHDBq/6+aryPTA/FbiB2tWbX2f5ms=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O8muAnIFRnOkhK0IDKYsISD5XT1UZOxJrft6HBsDUKrr2Wn+WUtprtQ8x5FPFIJvOFMxya1XxCI2aPauRzqfD7B970V8qJsMskX+iul8ow2WZOmDUQwe/X5jBnA/6lPtWXyOAdOQkqTlTVQDuC4ph2w3ASKVk1U8tPdlsDyw5jo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=pbHWLuh1; arc=none smtp.client-ip=209.85.160.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-23319017c4cso3290564fac.2 for ; Mon, 29 Apr 2024 16:40:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1714434041; x=1715038841; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BJ+ZTMWPcJc+hIlvH7T2PbKtWet9tgeGz07/T80YEuU=; b=pbHWLuh1Xtu6uL38XxK4B+0fCiYd7UAwdMdtMKEw/UnHF+S5JWR9mR8jvJ3OUqvOzN +XZS726FcasBZjgbGGkIgIKBUfRivinxaNyiqaIrikWJeI8r7gNxTlyZzuzuXox2+/FT 2AQjVJCSbxn2GGKD3hKBaOv7Ht925iNAwn62flLi3MhStzwJnVi2znE9gcVZyG2WPGAO YEr1UUDXrWCr3PhBrJg5FQuMcvfnvMhNLYeBrdaqvzMYX98mauFd7Ld/p8IUN//xEpFn FLz2S3oonXYn8tsBuPNLQuA28PQpkvrdFT/GnsmpriwdnuiApTQACfseTpOKCR5GIwDz hFpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714434041; x=1715038841; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BJ+ZTMWPcJc+hIlvH7T2PbKtWet9tgeGz07/T80YEuU=; b=R38+Toek++mbJNjjEKFParLG9xIZK1EowUoRNTTHOGBqD2aeVX0oFFFoFzT7y3zKRB n/jGvsCt8De/bXurV8+wImnEw+qt64HJ6Usaq5Oqg0IxXNeDwdXtyskIyXS38xlYmOjb iovK4MVIYKGzMGtXZgu9tCnkPhx4xRvklfe23wGGfmzHsYk9hS7+VFu+RvPzOhaCj/4g MCXxTvLmBXeI/DHZU0Gf9hm0ZNQPrpJwyEB0u8aLVNrGInU6GQ4/A9blvOBJ0JISrrL3 zgAF3Ts/XQ2zXcTbk5W4d+Anu6ECQSf+mSaQG/+5zlykt154BENg0cV1u5Hg+Y/1+78V DfJg== X-Forwarded-Encrypted: i=1; AJvYcCW/9bZ574ePLHzArb3ByegEzh1v9aybjCHzzrP+J3yCDTCVNKfXCPnVEf6MTz+/wplvFhwgsEmfOUtaaihlSS80vZiUB4mnVDhd/FpR X-Gm-Message-State: AOJu0YzjI5v17Jy8uKSncolHRnE04QagEK0T4wG9Gh0EiYo8T7IOWXIj mUBJMwYiF6VNmDVKW+qIGTJhDsma/kvQHe9doXj6YKgGp64JqccEEq8Ujdi3er4= X-Received: by 2002:a05:6870:618a:b0:23b:4854:820b with SMTP id a10-20020a056870618a00b0023b4854820bmr12720046oah.2.1714434041609; Mon, 29 Apr 2024 16:40:41 -0700 (PDT) Received: from freyr.lechnology.com (ip98-183-112-25.ok.ok.cox.net. [98.183.112.25]) by smtp.gmail.com with ESMTPSA id hp22-20020a0568709a9600b0023b58aa20afsm2144508oab.25.2024.04.29.16.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 16:40:41 -0700 (PDT) From: David Lechner To: Liam Girdwood , Mark Brown , Jean Delvare , Guenter Roeck , Jonathan Cameron , Dmitry Torokhov Cc: David Lechner , Jonathan Corbet , Support Opensource , Cosmin Tanislav , Lars-Peter Clausen , Michael Hennerich , Antoniu Miclaus , Greg Kroah-Hartman , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-iio@vger.kernel.org, linux-staging@lists.linux.dev, linux-input@vger.kernel.org, Jonathan Cameron Subject: [PATCH v2 7/7] Input: mpr121: Use devm_regulator_get_enable_read_voltage() Date: Mon, 29 Apr 2024 18:40:15 -0500 Message-ID: <20240429-regulator-get-enable-get-votlage-v2-7-b1f11ab766c1@baylibre.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240429-regulator-get-enable-get-votlage-v2-0-b1f11ab766c1@baylibre.com> References: <20240429-regulator-get-enable-get-votlage-v2-0-b1f11ab766c1@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.12.4 Content-Transfer-Encoding: 8bit We can reduce boilerplate code by using devm_regulator_get_enable_read_voltage(). Reviewed-by: Jonathan Cameron Signed-off-by: David Lechner --- v2 changes: * renamed to devm_regulator_get_enable_read_voltage() * restored error message --- drivers/input/keyboard/mpr121_touchkey.c | 45 +++----------------------------- 1 file changed, 3 insertions(+), 42 deletions(-) diff --git a/drivers/input/keyboard/mpr121_touchkey.c b/drivers/input/keyboard/mpr121_touchkey.c index d434753afab1..0ea3ab9b8bbb 100644 --- a/drivers/input/keyboard/mpr121_touchkey.c +++ b/drivers/input/keyboard/mpr121_touchkey.c @@ -82,42 +82,6 @@ static const struct mpr121_init_register init_reg_table[] = { { AUTO_CONFIG_CTRL_ADDR, 0x0b }, }; -static void mpr121_vdd_supply_disable(void *data) -{ - struct regulator *vdd_supply = data; - - regulator_disable(vdd_supply); -} - -static struct regulator *mpr121_vdd_supply_init(struct device *dev) -{ - struct regulator *vdd_supply; - int err; - - vdd_supply = devm_regulator_get(dev, "vdd"); - if (IS_ERR(vdd_supply)) { - dev_err(dev, "failed to get vdd regulator: %ld\n", - PTR_ERR(vdd_supply)); - return vdd_supply; - } - - err = regulator_enable(vdd_supply); - if (err) { - dev_err(dev, "failed to enable vdd regulator: %d\n", err); - return ERR_PTR(err); - } - - err = devm_add_action_or_reset(dev, mpr121_vdd_supply_disable, - vdd_supply); - if (err) { - dev_err(dev, "failed to add disable regulator action: %d\n", - err); - return ERR_PTR(err); - } - - return vdd_supply; -} - static void mpr_touchkey_report(struct input_dev *dev) { struct mpr121_touchkey *mpr121 = input_get_drvdata(dev); @@ -233,7 +197,6 @@ static int mpr121_phys_init(struct mpr121_touchkey *mpr121, static int mpr_touchkey_probe(struct i2c_client *client) { struct device *dev = &client->dev; - struct regulator *vdd_supply; int vdd_uv; struct mpr121_touchkey *mpr121; struct input_dev *input_dev; @@ -241,11 +204,9 @@ static int mpr_touchkey_probe(struct i2c_client *client) int error; int i; - vdd_supply = mpr121_vdd_supply_init(dev); - if (IS_ERR(vdd_supply)) - return PTR_ERR(vdd_supply); - - vdd_uv = regulator_get_voltage(vdd_supply); + vdd_uv = devm_regulator_get_enable_read_voltage(dev, "vdd"); + if (vdd_uv < 0) + return dev_err_probe(dev, vdd_uv, "failed to get vdd voltage\n"); mpr121 = devm_kzalloc(dev, sizeof(*mpr121), GFP_KERNEL); if (!mpr121) -- 2.43.2