Received: by 2002:a05:6359:322:b0:b3:69d0:12d8 with SMTP id ef34csp78406rwb; Wed, 10 Aug 2022 05:14:08 -0700 (PDT) X-Google-Smtp-Source: AA6agR62G1BmYyCrzcS41T7XcVEVbmNl3lTx67cCk1VhsU5Rs3VWIgRLo5RNd6EhZFmYKNFsPjJq X-Received: by 2002:a05:6402:4143:b0:43b:206d:c283 with SMTP id x3-20020a056402414300b0043b206dc283mr26089098eda.381.1660133648043; Wed, 10 Aug 2022 05:14:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660133648; cv=none; d=google.com; s=arc-20160816; b=EEl8xLK41ncdpavBGI1ThlusWxw8U9axxVS7Yyc6a6haDHdn0IDQ3AVhx4EWkJ1lkL rp6nuc4bJB4UoxfTx6OEmOxOj929NaxuHc4f+btZkwotOoCHQkxGz72tdGxYXFF77TT5 MVCfQOblYsv/EzDrehGJ73GYZg+rcz9k/ofwQ0B4HsTxuz7VEaeTNRg8qaN+IuGlbnwz 5/xVyr6OdFN/OjJ+LYDu6fPGynrgjB268NFLsRpgAcD156GMMNlZc6ZFZshFU+MzDQlg RtvwmePsq0QwbPNHG70eD2bJEpUUqQEbFmFNmLFTdfe0D+sPWRHSB9y8Er1zty7lgYXm pKug== 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=C7PP55XLKwk3Ov8DaaLsfjSN7+Fbj+g7x+jMv9Fy+O8=; b=SRo/Btj15+EGPPBm1xGhkpOh8RGEdlQ6pGDjJu1EH/qMQrlk1xyUzbn1x8HFTm9eWE VRjZauq1z3/nJrelB6ZPTHJMYx6a1/1Ml3QSXXYanDdzlisSON1XiLtNbsxa7QYFRtBf yRbNFdqYwXuiLuqgRw0m+0vRp1lVzwHY1Xm48NYFE2iTMFysAxhPdRD3JDkacY3keVV+ I3pjkQddLcQaiMXqCzHgAc62rmIuXq0pqv3Y9CVrlu49FwDyoh/Ivu4io2fbgjQ3oWxh RzP8dnKvc/zYdFyWS18B2Eo/9IXvpPnI2d7GH0M3GHl2KpsDtXY2cOmS0NzQfxPMhG4b BBzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=hv9hgdfk; 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 l7-20020a170906794700b00732fa7c5051si3774817ejo.166.2022.08.10.05.13.41; Wed, 10 Aug 2022 05:14:08 -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=hv9hgdfk; 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 S232093AbiHJLcu (ORCPT + 99 others); Wed, 10 Aug 2022 07:32:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231464AbiHJLcf (ORCPT ); Wed, 10 Aug 2022 07:32:35 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EBAE6DF96; Wed, 10 Aug 2022 04:32:34 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id f20so20776606lfc.10; Wed, 10 Aug 2022 04:32:34 -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; bh=C7PP55XLKwk3Ov8DaaLsfjSN7+Fbj+g7x+jMv9Fy+O8=; b=hv9hgdfkJ5AxzikQUS60rpuILK9NqDDXlWKzc8hO7hrZI4x6iJUFEpO2xyGRn99AtC fiuGhpGi821ulpOdkMIRb4bK0Ul5NciCSyBDYrMHYsx4Y6Veq+cU6q1Vsp29etpqCMW4 LwDz5hrMfgHk/1HHCu24hi4p7FRPSL5b/VXT2n8ccZVwqTCq9XU6TM083h0kGked0nad kGUrA3Ra2vOlRUIHbJmMm9UTmdzo4TWgQZa1kFh9IJo04cariKMZJb5ToJLbH17mE2+B 3fO/TWZOoeR4Vte3Ym4cdno3r0b9WB8oI1cFp/4WGFNWOZ2mwh8s31jqsR9iQYaWGPmM k+LA== 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; bh=C7PP55XLKwk3Ov8DaaLsfjSN7+Fbj+g7x+jMv9Fy+O8=; b=Ug6XDMU1dm3gHUBk6VhInqu+/+AEhIWv6ylanZ5AjnSYU1px7iV0oy5NIYGHUtYkhk 4YWaOKiLxBA5KuDVK+9c/O13AdHNYE1OZX1R9ksN/wMEFpymAAPbjjJzRel51WLzykk+ JGS5gG5VZdZljMBWoPV8PloZHEcOi/9SaJLF+1lWE5NAm133PqreHBzQ+JDrve5uBCHy 6jT2CbzTPiuqa0GvskjX3z0WnziHnCNoADnpXHErUwb5KDO7hquXA8zJ57VZDL9jaH38 8Fv4OojaqWqlJlkGgn/lHCLRq1m5gV5cUYbkwmDr8oPlqGFvCsBTuBUMaEU4gSzv8Ku7 t7cQ== X-Gm-Message-State: ACgBeo1wrt0BdjS8+dWUjbwE3tVHLfslx2WcDPtV1kG7FWmMfUOr3wdK GpN/rpzzXjYLGYJaC/icsAo= X-Received: by 2002:a05:6512:234f:b0:48d:b66:9b54 with SMTP id p15-20020a056512234f00b0048d0b669b54mr2866706lfu.118.1660131152866; Wed, 10 Aug 2022 04:32:32 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id p21-20020a2eb7d5000000b0025fde1697b0sm369392ljo.135.2022.08.10.04.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 04:32:32 -0700 (PDT) Date: Wed, 10 Aug 2022 14:32:18 +0300 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Cc: Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 6/7] hwmon: lm90: simplify using devm_regulator_get_enable() Message-ID: <4565950ddca2f78209dad49e169d4af7517db27e.1660127865.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="dUGNtiJXsye5By6f" 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,T_SCC_BODY_TEXT_LINE 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 --dUGNtiJXsye5By6f 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(). Signed-off-by: Matti Vaittinen --- drivers/hwmon/lm90.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 3820f0e61510..2ab561ec367c 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -1848,12 +1848,6 @@ static void lm90_remove_pec(void *dev) device_remove_file(dev, &dev_attr_pec); } =20 -static void lm90_regulator_disable(void *regulator) -{ - regulator_disable(regulator); -} - - static const struct hwmon_ops lm90_ops =3D { .is_visible =3D lm90_is_visible, .read =3D lm90_read, @@ -1865,24 +1859,13 @@ static int lm90_probe(struct i2c_client *client) struct device *dev =3D &client->dev; struct i2c_adapter *adapter =3D client->adapter; struct hwmon_channel_info *info; - struct regulator *regulator; struct device *hwmon_dev; struct lm90_data *data; int err; =20 - regulator =3D devm_regulator_get(dev, "vcc"); - if (IS_ERR(regulator)) - return PTR_ERR(regulator); - - err =3D regulator_enable(regulator); - if (err < 0) { - dev_err(dev, "Failed to enable regulator: %d\n", err); - return err; - } - - err =3D devm_add_action_or_reset(dev, lm90_regulator_disable, regulator); + err =3D devm_regulator_get_enable(dev, "vcc"); if (err) - return err; + return dev_err_probe(dev, err, "Failed to enable regulator\n"); =20 data =3D devm_kzalloc(dev, sizeof(struct lm90_data), GFP_KERNEL); if (!data) --=20 2.37.1 --=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 --dUGNtiJXsye5By6f Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmLzl0EACgkQeFA3/03a ocW8hAgAwkdNU8q2l23A0DVzeCBVBsc0QTY0W7HwHu18UT5Oj+j4xWyA2tP8Q28L NXNG8k+tWvZJFqZepKzi/qnCFE08xUTwED11WkPdOTFfAARqSw/kVDKsfcf5bQw4 rFZtNpF6Wl7i28l5wadqW1K/fWbkKzgxh0kpkSrKl/HoHVcS7UpJIu/TzwT4o1hH ReOkCwl6GMsS8emD29//+PM3WigB5a7gp+mnQiXGjdUTTkEZ40p7ujG5SWobB4Qu aqdE2LfFtp4fvtMLr+9g2hCwyFBOqivBEfDU2wO18z1H3/dqKKakaEzTOfJYr5Wt lMkj6Hvn7O1wCMcyEYoSoTlxM++yVg== =NVIF -----END PGP SIGNATURE----- --dUGNtiJXsye5By6f--