Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2675623rwi; Fri, 21 Oct 2022 06:44:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5WP0hYnylJ3X12HBd039t/LXgvnExcCy1H3ckZR1QVNKfJDbFnkOxo0KvvLHiQ4XEUu3on X-Received: by 2002:a05:6a00:b41:b0:52f:59dc:75 with SMTP id p1-20020a056a000b4100b0052f59dc0075mr19388479pfo.33.1666359861697; Fri, 21 Oct 2022 06:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666359861; cv=none; d=google.com; s=arc-20160816; b=FVKH4RLOjw1frOWi6PHag3dVtEc39RgzNHo8cjCYG8RcDhP7pNKadG6qK8EMoGZoiE 30AfFeC3ctQIH4b8STkCy+b5a+34XKJ0QCJE9jKOBlFAu8+cdtpSPU/kkJppp4t0gbTv 7eDbCmffBv1CQHFRye+lCBDxIg3O4baD6SGTr7tLeT8xsAJVK73cSdB8ipoy0acLhN0w +eEexO8eish6etUJl60amuEG+v+RGLt8kZGDpnsBihr1+FpJQWGbgOkVMphx42vHlIEW vdCOHiKilAsFayzf7D0qftjQlHq5y3Dwjfwn+Ds+7XWKvjADepHMeU+fyPTEowe0ojGf 6E9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kSylMpx0YFsO31Hjkjkcjn2msnx+oITUaLGfh+0vVIE=; b=Shh66aybUPQDwpccIjUILRcnZt8nneTH8RygaO4tZv33yzWzyYs0M6SuEAankRALdi 7mSUoRW92EdcF2Xxz2PXd+FjooM2K91qdWrbAPoywIAqz4mKsdlEZOgcBrFTJl3ZcGha cOHReaChF4Tgb3WU0zYKRwzcPU4WTTqKvUwFcpTVWyDPGZhqShq1DeaRxnCohAQ6TsPT oeMI8p0fijWANxju2ZfKC0yMGwQ0CY4vut3WG3cj3SUq5vahR2uUmyaacXMZ/k8g0u9K T3S2b0n9qKu70a4QzJra+7l7f3EjwHoBjWqrdvEtDCD48IxXaSaov9Spdqpud7PiIRdT Diew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pCPCyBdc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cm18-20020a056a00339200b005672abf1284si14960742pfb.161.2022.10.21.06.44.07; Fri, 21 Oct 2022 06:44:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=pCPCyBdc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230394AbiJUNT2 (ORCPT + 99 others); Fri, 21 Oct 2022 09:19:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231173AbiJUNTO (ORCPT ); Fri, 21 Oct 2022 09:19:14 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0A6C5C9C3; Fri, 21 Oct 2022 06:19:12 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id f37so5022230lfv.8; Fri, 21 Oct 2022 06:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=kSylMpx0YFsO31Hjkjkcjn2msnx+oITUaLGfh+0vVIE=; b=pCPCyBdcW1Dxce4rSpZGxMbdmm3k4A8+8OJ+rBpD3sbTSRkrm98zqrhlvRnQWFeiPg MvE5i8PbKLTNGMCyql6GsXQQQ4AR2ycbx55uOON8fjLAXKw1N1IBmzFeQxB0fFF0QTvZ sCGFD9eb/7U66Fpi96reXKRp56nrV4AmnyftOqBEv2yi3p1CsRspKkhJVvp6/3qJ1su6 pkHlAUz4/0AKk43eHoddYd1qtd+kWkhCaZublMPgaLlXzl7DWblkEvA7QSZTmVRiU630 2QBEo8/zjdrjSYeh4Rw9zactbfWk8r4o2nbgHhwqzAUkO1V/qtgpjOR8LbtCfaPN8YmA /Xtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=kSylMpx0YFsO31Hjkjkcjn2msnx+oITUaLGfh+0vVIE=; b=IcTlfFt/B9gO994TEG10yP1jztBiFsAYwCQCoGZPJiYM2IVnYh3Z1ff38NBySwdrRG UD5RYZ3BJJmnnBMauXjHG7Kl39YnLdh160j7fwOcl/NJGWyuDZ4p/J6TlzTcQ2KaUP4N 3qlVtOBZ+Dj0h3+Co0CypKphHyOTDPsVlUHjkJe/aumcgJnDKuNIQMm3RnExkyi5KH2V n6+ADhHBOKI/v3/dfumtc/ji+d93Y7fgD1mLdtdfhwuyG8OXvxqHrHLNrqnOV1bgnFOY 6Kj9jRsL9kDlbLjRqcJVJKU+6GqnXHXiAZ0gRZIgjY7hsrrte9wb6TxjBzrv/xENWlPV PCRQ== X-Gm-Message-State: ACrzQf01QhQOGzTPhRXkAy5NO/nQmPIK/KmR0ITwaORGEUtTPITNqFYf x/hn8cQrYxcAYx6bgAxVT4g= X-Received: by 2002:a05:6512:1681:b0:4a2:1925:e3ff with SMTP id bu1-20020a056512168100b004a21925e3ffmr7580907lfb.517.1666358350758; Fri, 21 Oct 2022 06:19:10 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyby-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::2]) by smtp.gmail.com with ESMTPSA id t28-20020a05651c205c00b0026e02eb613csm3398419ljo.18.2022.10.21.06.19.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 06:19:09 -0700 (PDT) Date: Fri, 21 Oct 2022 16:19:04 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Michael Hennerich , Jean Delvare , Guenter Roeck , Liam Girdwood , Mark Brown , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-hwmon@vger.kernel.org Subject: [PATCH v4 4/4] hwmon: adm1177: simplify using devm_regulator_get_enable() Message-ID: <7773541795f280db31dd981ffc21df8a630b794a.1666357434.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="LNJ8AAv0zmlHvO2X" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --LNJ8AAv0zmlHvO2X Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Drop open-coded pattern: 'devm_regulator_get(), regulator_enable(), add_action_or_reset(regulator_disable)' and use the devm_regulator_get_enable() and drop the pointer to the regulator. This simplifies code and makes it less tempting to add manual control for the regulator which is also controlled by devm. Signed-off-by: Matti Vaittinen Acked-by: Guenter Roeck --- v2 =3D> v3: New patch --- drivers/hwmon/adm1177.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/drivers/hwmon/adm1177.c b/drivers/hwmon/adm1177.c index 0c5dbc5e33b4..be17a26a84f1 100644 --- a/drivers/hwmon/adm1177.c +++ b/drivers/hwmon/adm1177.c @@ -26,14 +26,12 @@ /** * struct adm1177_state - driver instance specific data * @client: pointer to i2c client - * @reg: regulator info for the power supply of the device * @r_sense_uohm: current sense resistor value * @alert_threshold_ua: current limit for shutdown * @vrange_high: internal voltage divider */ struct adm1177_state { struct i2c_client *client; - struct regulator *reg; u32 r_sense_uohm; u32 alert_threshold_ua; bool vrange_high; @@ -189,13 +187,6 @@ static const struct hwmon_chip_info adm1177_chip_info = =3D { .info =3D adm1177_info, }; =20 -static void adm1177_remove(void *data) -{ - struct adm1177_state *st =3D data; - - regulator_disable(st->reg); -} - static int adm1177_probe(struct i2c_client *client) { struct device *dev =3D &client->dev; @@ -210,21 +201,9 @@ static int adm1177_probe(struct i2c_client *client) =20 st->client =3D client; =20 - st->reg =3D devm_regulator_get_optional(&client->dev, "vref"); - if (IS_ERR(st->reg)) { - if (PTR_ERR(st->reg) =3D=3D -EPROBE_DEFER) - return -EPROBE_DEFER; - - st->reg =3D NULL; - } else { - ret =3D regulator_enable(st->reg); - if (ret) - return ret; - ret =3D devm_add_action_or_reset(&client->dev, adm1177_remove, - st); - if (ret) - return ret; - } + ret =3D devm_regulator_get_enable_optional(&client->dev, "vref"); + if (ret =3D=3D -EPROBE_DEFER) + return -EPROBE_DEFER; =20 if (device_property_read_u32(dev, "shunt-resistor-micro-ohms", &st->r_sense_uohm)) --=20 2.37.3 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --LNJ8AAv0zmlHvO2X Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmNSnEgACgkQeFA3/03a ocXPvwgAun6eU41kkrvzy+dbHSs4Z56InICDSb5ZiwM1LMLovJ07qcF9l187tw70 FKRnuRPz02GuzMiZbxxv1vbZ9mQtvKrHgQikiuhopx4O8fdesdNGvf/5LGKGcr7n uuWSI+R+6obt7WyZOoO85KrCIXehRfRGMWEAqJtztlfF+SmQDbbPuwxePYNt5tyk 1/v3ZHiDBFWIP5SdVBkn/uEwGisVbodkhh8g6G9CF68ubMIpJEtO2YfGmbwOJGBs hWzuPnYcun0hdtOQs0iyvHzbGV229OqpDJoTbe7+ZmkQgNVG5wq4NREC9U8kg0BN 5WaVxylnzRD6aew57/PKqteO4AWbkA== =Tmnu -----END PGP SIGNATURE----- --LNJ8AAv0zmlHvO2X--