From patchwork Fri Aug 19 19:19:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 12949117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DB69C32773 for ; Fri, 19 Aug 2022 19:19:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350882AbiHSTT5 (ORCPT ); Fri, 19 Aug 2022 15:19:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351371AbiHSTTU (ORCPT ); Fri, 19 Aug 2022 15:19:20 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED1BFF4F; Fri, 19 Aug 2022 12:19:08 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id l1so6776390lfk.8; Fri, 19 Aug 2022 12:19:08 -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=AANLxeJ0LpA7gGpSl1Si3QPJ6JAdv159yU2e2glG7p8=; b=DsvV8zNJOqwTBy5DNUpgWBkMYnMY5LZZwKR79UqkxspV1lqtqz3+WHbLFY9l/tQIGn 2C0XuxGAZ9AtM08pWBu2/uMDCtkNlICuR2SSN2gzsh5vAljxtJBI/m79Qi757gsTj6dA 82E9gFLnqgPB0pLzcLYCb+D6SFDYQSjeJGWyZYij3dMxtO1m0YFp4z82uIrFLCYgSMOj sJb/I6jjHGvWq1qKKDOx4+ckdtDQZUW38H4kO+UYdOQmEyqii8i1IqnleyP11OKveFww LB8rNoJnCMq3VfZbF3SpN9399ul+MVM+xMUmsNXQDCShjl4YGB4iIHwnCE0bXxEECfLR VZbQ== 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=AANLxeJ0LpA7gGpSl1Si3QPJ6JAdv159yU2e2glG7p8=; b=o9sQBA12lb0EpYS2u1h8WpDLebWcmZmaDollXpsyoXKOLoE9vOraYDfPqFi8BKyLer qopRvqqaKPKYecbZpxCPAHAW17NBA5eZ7BTSclXH1SdMcAnAtqDhZqly9MVrSEb5jAm3 PsITmTYMJusnj+mnJYX7z8bSWwnEv2IjH6qH4Gt+NbklySvZxbtB/Tad9Jh8iG625Kkq qfIIQVRJU55vjKlyQkeeEMA0hjSH32ZP+VmhDTt2cQbQQ7uytzS2dA+S8niaAkDmMwET qrYmw+Od523X8roS9KPydDaQgkWraAYFj2+p1CaPWDwPuISDmDQ+wuWTPSGhahEdqDQN Mntw== X-Gm-Message-State: ACgBeo2MIQQUIWyu2J1010bOCdTBahsNdEdRD86l/OvL50ujYd9IypJ7 enOxPR0qsgESdROG4rzhlHw= X-Google-Smtp-Source: AA6agR51+Y9+XrHdyIIEGtNp4Q/w/K7E3YqgGy2J+KZPVECydq1v4p4Cw5CW4w4QIEU3eTwkM5wpDA== X-Received: by 2002:ac2:4da2:0:b0:492:c6a9:f430 with SMTP id h2-20020ac24da2000000b00492c6a9f430mr1683375lfe.96.1660936747173; Fri, 19 Aug 2022 12:19:07 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::1]) by smtp.gmail.com with ESMTPSA id a16-20020a056512391000b0048aa9d67483sm736249lfu.160.2022.08.19.12.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 12:19:06 -0700 (PDT) Date: Fri, 19 Aug 2022 22:19:01 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Alexandru Tachici , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 06/14] iio: ad7192: Simplify using devm_regulator_get_enable() Message-ID: <9719c445c095d3d308e2fc9f4f93294f5806c41c.1660934107.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Use devm_regulator_get_enable() instead of open coded get, enable, add-action-to-disable-at-detach - pattern. Also drop the seemingly unused struct member 'dvdd'. Signed-off-by: Matti Vaittinen --- v2 => v3 Split to own patch. --- drivers/iio/adc/ad7192.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c index d71977be7d22..8a52c0dec3f9 100644 --- a/drivers/iio/adc/ad7192.c +++ b/drivers/iio/adc/ad7192.c @@ -177,7 +177,6 @@ struct ad7192_chip_info { struct ad7192_state { const struct ad7192_chip_info *chip_info; struct regulator *avdd; - struct regulator *dvdd; struct clk *mclk; u16 int_vref_mv; u32 fclk; @@ -1015,19 +1014,9 @@ static int ad7192_probe(struct spi_device *spi) if (ret) return ret; - st->dvdd = devm_regulator_get(&spi->dev, "dvdd"); - if (IS_ERR(st->dvdd)) - return PTR_ERR(st->dvdd); - - ret = regulator_enable(st->dvdd); - if (ret) { - dev_err(&spi->dev, "Failed to enable specified DVdd supply\n"); - return ret; - } - - ret = devm_add_action_or_reset(&spi->dev, ad7192_reg_disable, st->dvdd); + ret = devm_regulator_get_enable(&spi->dev, "dvdd"); if (ret) - return ret; + return dev_err_probe(&spi->dev, ret, "Failed to enable specified DVdd supply\n"); ret = regulator_get_voltage(st->avdd); if (ret < 0) { From patchwork Fri Aug 19 19:19:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 12949118 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E230DC32771 for ; Fri, 19 Aug 2022 19:20:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350232AbiHSTUD (ORCPT ); Fri, 19 Aug 2022 15:20:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351290AbiHSTTZ (ORCPT ); Fri, 19 Aug 2022 15:19:25 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA3D524F13; Fri, 19 Aug 2022 12:19:23 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id u9so7267387lfg.11; Fri, 19 Aug 2022 12:19:23 -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=ExwQj6OxxYffzIEbicVKMuJlzABDjdqO2Cx3MfYHzWI=; b=hnjXCBFPtyC8FZIu5Ggbdvmh2xLpIzJqiWuiVbNQ1BNEUdAzr6gw65fWLIvuC/UO05 YqAOiKwtq6ZY/GiVsFyuePNQ78cV+8hre8dm1k8jF2RIpgL8RRQAf/4k+c2P4c7YDZT6 Mem+5mt0mkOTM5B9pz1PQRdhMbEmWfH19T/iJoCgjIDd15H3nBZ3v5OkXIcBpMSv35ds ihooGBLZ5Dq0ObWe0nyWpcl8v7DeDoVh4m78hL9tsPrnNzlPFCG8OsExRb+yuEddgY9F eWwJ8fptlEFy/ZkG7I5AFkYfGjPHW6EWrol7dbj2dRDW7MiJM5lufy779HvzgY2amJW/ v6fQ== 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=ExwQj6OxxYffzIEbicVKMuJlzABDjdqO2Cx3MfYHzWI=; b=5mo4dqw2gXF8cQ/D4KEgPWa2oO+yPuEBqBB6cXRTpmp8n4TquvC9JGX2o0CsSg2W/g 4IpB3M6xizCKN9TL2O92J6KthSv1990SdR36c4wwrL7y0g8Lcgm07o0FX/snBITIlrP8 BGcH2Q0/yR3bGjiW4cjPGVGIyOlx1IWg/FXYvhP0nXSHo4ghKTjinzJmPf3QC0mPV/R0 id8yI8YDR1ASpF0mWSVIuxar4JwOeiG+2RRatXl8WUusSSbOdnV9yNush2Ur0z/gToMY F43O8BeZpsJ0abcHSaidVcKXMPPYDh1iZn6TExclTJuGIost9gRnvNXizXhj14iEQzHV aPXQ== X-Gm-Message-State: ACgBeo00VYQNHEL4/+ZbCwFlz2XTn23rxr3hZvs67BTpgMpAlh39JCMM 3leDPdS3RcTR/hKtrDeuZ/s= X-Google-Smtp-Source: AA6agR6IDvsDzM94+byJN3IeqXk5VH6LQuv8Iy1GJYSDqHomnQQoHPryRAw6enrzyx1YiAM0Dw0Pdw== X-Received: by 2002:a05:6512:2316:b0:48a:f2e3:be97 with SMTP id o22-20020a056512231600b0048af2e3be97mr2721404lfu.383.1660936762055; Fri, 19 Aug 2022 12:19:22 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::1]) by smtp.gmail.com with ESMTPSA id c3-20020ac25f63000000b00492bf0eaedfsm712558lfc.187.2022.08.19.12.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 12:19:21 -0700 (PDT) Date: Fri, 19 Aug 2022 22:19:17 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Nuno =?iso-8859-1?q?S=E1?= , Jonathan Cameron , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 07/14] iio: ltc2688: Simplify using devm_regulator_*get_enable() Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Use devm_regulator_bulk_get_enable() instead of open coded bulk-get, bulk-enable, add-action-to-disable-at-detach - pattern. Signed-off-by: Matti Vaittinen Reviewed-by: Nuno Sá --- v2 => v3 Split to own patch. --- drivers/iio/dac/ltc2688.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/iio/dac/ltc2688.c b/drivers/iio/dac/ltc2688.c index 28bdde2d3088..fcad3efe62ea 100644 --- a/drivers/iio/dac/ltc2688.c +++ b/drivers/iio/dac/ltc2688.c @@ -84,7 +84,6 @@ struct ltc2688_chan { struct ltc2688_state { struct spi_device *spi; struct regmap *regmap; - struct regulator_bulk_data regulators[2]; struct ltc2688_chan channels[LTC2688_DAC_CHANNELS]; struct iio_chan_spec *iio_chan; /* lock to protect against multiple access to the device and shared data */ @@ -902,13 +901,6 @@ static int ltc2688_setup(struct ltc2688_state *st, struct regulator *vref) LTC2688_CONFIG_EXT_REF); } -static void ltc2688_disable_regulators(void *data) -{ - struct ltc2688_state *st = data; - - regulator_bulk_disable(ARRAY_SIZE(st->regulators), st->regulators); -} - static void ltc2688_disable_regulator(void *regulator) { regulator_disable(regulator); @@ -970,6 +962,7 @@ static int ltc2688_probe(struct spi_device *spi) struct regulator *vref_reg; struct device *dev = &spi->dev; int ret; + static const char * const regulators[] = {"vcc", "iovcc"}; indio_dev = devm_iio_device_alloc(dev, sizeof(*st)); if (!indio_dev) @@ -988,21 +981,11 @@ static int ltc2688_probe(struct spi_device *spi) return dev_err_probe(dev, PTR_ERR(st->regmap), "Failed to init regmap"); - st->regulators[0].supply = "vcc"; - st->regulators[1].supply = "iovcc"; - ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(st->regulators), - st->regulators); - if (ret) - return dev_err_probe(dev, ret, "Failed to get regulators\n"); - - ret = regulator_bulk_enable(ARRAY_SIZE(st->regulators), st->regulators); + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators), + regulators); if (ret) return dev_err_probe(dev, ret, "Failed to enable regulators\n"); - ret = devm_add_action_or_reset(dev, ltc2688_disable_regulators, st); - if (ret) - return ret; - vref_reg = devm_regulator_get_optional(dev, "vref"); if (IS_ERR(vref_reg)) { if (PTR_ERR(vref_reg) != -ENODEV) From patchwork Fri Aug 19 19:19:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 12949119 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B842C32772 for ; Fri, 19 Aug 2022 19:20:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351377AbiHSTUR (ORCPT ); Fri, 19 Aug 2022 15:20:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350916AbiHSTTu (ORCPT ); Fri, 19 Aug 2022 15:19:50 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 008ED114A4E; Fri, 19 Aug 2022 12:19:39 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id l19so2216974ljg.8; Fri, 19 Aug 2022 12:19:39 -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=+shOGg3Tz+kG6HTarECyFtwcGQNn5JtMbQQqiFqaNwI=; b=bjm9EA/l2/yd4W4EVgILA9jpnKLjihtFbs1lqazlL+jJkmUuZK6UqnGtsrdTUlL2Ei wetnUavAiz/04AbwDVtTPcw4sqjeQSwwKuEzjORCdWy7Rd8+z59MhYyaZyoZjZQVk4mj XNsQ8d0C/dGrEqCjcHkKLYflnhcJ/YSGgmDASQvlw7qPGq4jPUw4XZzXGrkq+qMArzpC Miz7BBxLct/rSOeO00NrYFz+SfNyiCUowJqBaIyxPdlQBrPSiBlJB7DVzbUM8MB/dHwb EmVq7414CXDDdYb/KMlShNFI5g/H9NcmI4tagTYwmk83uEKRLcOCA/Ptd9sNHjgoO2q3 yQdw== 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=+shOGg3Tz+kG6HTarECyFtwcGQNn5JtMbQQqiFqaNwI=; b=jClgFsejBZSx/8BB82JP06TV4Ib5jo00tU5TqDTh3uzi0FGC7pGv7FWyz9ntdnSnbV bvfa7HlQBzFdCysZIJXnP8nu9fjAKLy3GKdCw8Wg/rzPMWCFS8fT3vehExvsLZ9Opkkw Sj0K/YOx8WaCQRxm0PAwKWt5Xy500Gzh8lO5vWJD9Pc8HRav63WJpY/xuQ13u1NT85un vSYR5o88J5ghUh0nrgtMOj2T6oDko+TH7Ux/xTZZSPF/lQ9RlVv8pfL9c5ewg33ueIiH NbLsGtRC/umTBVi8jR42Ovwpn7ivWUAhNz03H6neKSQeNdQlkekEtfXA1VJ7f8/Ck8w9 0Z+Q== X-Gm-Message-State: ACgBeo3RZtWGV5wkfYNBSeslj7vPIoVotg/6eOYQ5KRzCMpypMH27iPe cMoSt1FYiK4rixH1OPEz95dht0Vnfbc= X-Google-Smtp-Source: AA6agR71sEnW/+gDMUEVRtuiTSKTMimhnGKZQe30ADzWZ4sCFdlHu9NpwU51np65ZeSqUCYIkwNkdw== X-Received: by 2002:a05:651c:222c:b0:25f:e654:36e3 with SMTP id y44-20020a05651c222c00b0025fe65436e3mr2500674ljq.20.1660936776934; Fri, 19 Aug 2022 12:19:36 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::1]) by smtp.gmail.com with ESMTPSA id a22-20020a2eb556000000b0025e428ba415sm724768ljn.38.2022.08.19.12.19.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 12:19:36 -0700 (PDT) Date: Fri, 19 Aug 2022 22:19:31 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Matti Vaittinen , Miaoqian Lin , Andy Shevchenko , Xiang wangx , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 08/14] iio: bmg160_core: Simplify using devm_regulator_*get_enable() Message-ID: <3fd11489356b1c73a3d7b4bd9dec7e12c9fe8788.1660934107.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Use devm_regulator_bulk_get_enable() instead of open coded bulk-get, bulk-enable, add-action-to-disable-at-detach - pattern. Signed-off-by: Matti Vaittinen --- v2 => v3 Split to own patch. --- drivers/iio/gyro/bmg160_core.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c index cedd9f02ea21..baa80980c99f 100644 --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c @@ -93,7 +93,6 @@ struct bmg160_data { struct regmap *regmap; - struct regulator_bulk_data regulators[2]; struct iio_trigger *dready_trig; struct iio_trigger *motion_trig; struct iio_mount_matrix orientation; @@ -1067,19 +1066,13 @@ static const char *bmg160_match_acpi_device(struct device *dev) return dev_name(dev); } -static void bmg160_disable_regulators(void *d) -{ - struct bmg160_data *data = d; - - regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators); -} - int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq, const char *name) { struct bmg160_data *data; struct iio_dev *indio_dev; int ret; + static const char * const regulators[] = {"vdd", "vddio"}; indio_dev = devm_iio_device_alloc(dev, sizeof(*data)); if (!indio_dev) @@ -1090,22 +1083,11 @@ int bmg160_core_probe(struct device *dev, struct regmap *regmap, int irq, data->irq = irq; data->regmap = regmap; - data->regulators[0].supply = "vdd"; - data->regulators[1].supply = "vddio"; - ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->regulators), - data->regulators); + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators), + regulators); if (ret) return dev_err_probe(dev, ret, "Failed to get regulators\n"); - ret = regulator_bulk_enable(ARRAY_SIZE(data->regulators), - data->regulators); - if (ret) - return ret; - - ret = devm_add_action_or_reset(dev, bmg160_disable_regulators, data); - if (ret) - return ret; - ret = iio_read_mount_matrix(dev, &data->orientation); if (ret) return ret; From patchwork Fri Aug 19 19:19:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 12949120 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E33DC32792 for ; Fri, 19 Aug 2022 19:20:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351468AbiHSTUc (ORCPT ); Fri, 19 Aug 2022 15:20:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350123AbiHSTTz (ORCPT ); Fri, 19 Aug 2022 15:19:55 -0400 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC2D658B64; Fri, 19 Aug 2022 12:19:53 -0700 (PDT) Received: by mail-lj1-x229.google.com with SMTP id l21so5379417ljj.2; Fri, 19 Aug 2022 12:19:53 -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=xA/ke3CMJXrkb/C6eCqgufQvUpSsHijYG7v6oeOUAc4=; b=dWowpJ0LCyqZDwtRe1d88trfFBCVsxCTFNduJjcPppJ5Lh+G+WKTyvzSxRXeTpwM7q +PJiEU3s1GzyiFmg2vGqEhFRXnF34ifXy16Im4iS+DY8cdip1vr8mC0upO1brBs8P5Ox iyijFpyU3MGy7y9uNXN+HFzQybNM2maTS+QzHkS+ARwPiUhZYtQV5Mpose1WbEpBWh7m jEuETxgdF9ZJsyBmA1Sx6cr892ESmFR0Zm92yVmuaHZkkPjXOzjX5yxpa9ZhtgNH3r1P BDFeJy+2uP4Q1dKDz9U08nyPbA6OtjsHI40+/SX94BucHZmOSFXSmXBILfY7Z2yDbA/l X4SQ== 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=xA/ke3CMJXrkb/C6eCqgufQvUpSsHijYG7v6oeOUAc4=; b=i3jFypHUpgjGPCXuF88ouCjthJEYQksIN54iDCvqNIkL7z5YKlM+Ka15lwf29mpBVz hBNFVLolNJdPHpsaH+RDlF7etJv6ut7e86IC1qNWhRXgOmXlg+WqqhsU2Cp/rSP4Pabw 4uUaXxOvGgQm3SgzWufCOAJgacPlma3aTJJ3idiuM81DdnVITOhtlELrkn2x2uUJk/oL m7PT+m+YKXOzrXD5SRuSqKedobCg7aO93xy0glDcphXU/c7m69eGHsmc9bgDzn+yPrfI HDuBq/v/E+i1rncE3IooaoMWKFUko3x62N2J6UNsu8apANYyaWM6HItr8+wAG0Ay+r5+ fYzg== X-Gm-Message-State: ACgBeo3HWqdAnMlPcmMNWWmJ6HuiRUg0KNQC8UfeTGzXISHPVwX79WPy WUmWd0Rj4UsvSiLAb/ohVmI= X-Google-Smtp-Source: AA6agR6u2y6WF2xMTdFM70O9C5CrrEg40+35FhcdAC5vhKEcF3Ob0kFN+2ZM+IuaiEYci3u39ZC0Bw== X-Received: by 2002:a2e:a987:0:b0:25f:d70a:c63c with SMTP id x7-20020a2ea987000000b0025fd70ac63cmr2654996ljq.34.1660936792127; Fri, 19 Aug 2022 12:19:52 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::1]) by smtp.gmail.com with ESMTPSA id s14-20020a056512314e00b0048c55ff738asm735230lfi.246.2022.08.19.12.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 12:19:51 -0700 (PDT) Date: Fri, 19 Aug 2022 22:19:46 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Lorenzo Bianconi , Jonathan Cameron , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 09/14] iio: st_lsm6dsx: Simplify using devm_regulator_*get_enable() Message-ID: <876e58428cec056d51070e49eff559e2d7c23b12.1660934107.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org Use devm_regulator_bulk_get_enable() instead of open coded bulk-get, bulk-enable, add-action-to-disable-at-detach - pattern. A functional change (which seems like a bugfix) is that if regulator_bulk_get fails, the enable is not attempted. Signed-off-by: Matti Vaittinen --- v2 => v3 Split to own patch. --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 2 -- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 30 ++++---------------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index a86dd29a4738..03238c64c777 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -372,7 +372,6 @@ struct st_lsm6dsx_sensor { * struct st_lsm6dsx_hw - ST IMU MEMS hw instance * @dev: Pointer to instance of struct device (I2C or SPI). * @regmap: Register map of the device. - * @regulators: VDD/VDDIO voltage regulators. * @irq: Device interrupt line (I2C or SPI). * @fifo_lock: Mutex to prevent concurrent access to the hw FIFO. * @conf_lock: Mutex to prevent concurrent FIFO configuration update. @@ -395,7 +394,6 @@ struct st_lsm6dsx_sensor { struct st_lsm6dsx_hw { struct device *dev; struct regmap *regmap; - struct regulator_bulk_data regulators[2]; int irq; struct mutex fifo_lock; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index b5e4a4113652..c328d1a36d34 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -2172,36 +2172,20 @@ static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw) static int st_lsm6dsx_init_regulators(struct device *dev) { - struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev); int err; - /* vdd-vddio power regulators */ - hw->regulators[0].supply = "vdd"; - hw->regulators[1].supply = "vddio"; - err = devm_regulator_bulk_get(dev, ARRAY_SIZE(hw->regulators), - hw->regulators); - if (err) - return dev_err_probe(dev, err, "failed to get regulators\n"); + static const char * const regulators[] = {"vdd", "vddio"}; - err = regulator_bulk_enable(ARRAY_SIZE(hw->regulators), - hw->regulators); - if (err) { - dev_err(dev, "failed to enable regulators: %d\n", err); - return err; - } + err = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators), + regulators); + if (err) + return dev_err_probe(dev, err, "failed to enable regulators\n"); msleep(50); return 0; } -static void st_lsm6dsx_chip_uninit(void *data) -{ - struct st_lsm6dsx_hw *hw = data; - - regulator_bulk_disable(ARRAY_SIZE(hw->regulators), hw->regulators); -} - int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, struct regmap *regmap) { @@ -2225,10 +2209,6 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, if (err) return err; - err = devm_add_action_or_reset(dev, st_lsm6dsx_chip_uninit, hw); - if (err) - return err; - hw->buff = devm_kzalloc(dev, ST_LSM6DSX_BUFF_SIZE, GFP_KERNEL); if (!hw->buff) return -ENOMEM; From patchwork Fri Aug 19 19:20:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 12949121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB35AC32771 for ; Fri, 19 Aug 2022 19:20:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350276AbiHSTUd (ORCPT ); Fri, 19 Aug 2022 15:20:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351331AbiHSTUN (ORCPT ); Fri, 19 Aug 2022 15:20:13 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 067896D9E6; Fri, 19 Aug 2022 12:20:11 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id z6so7286193lfu.9; Fri, 19 Aug 2022 12:20:10 -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=Pb/vY0IBh75ZxywBj3v0sp843PBbdLtQyqNhmT3+yDY=; b=Lc6bZjFhO4FgG/ECahM5tfFzfVv7QznDYxYW+vyWZl5wUwNh+9D5my2vtz1wPmRHDi RdZEUfILboDCP2srh+Kr3JiH5wfUBTbQqETUemABjxBJWHaHZhDhQ6Jo0gI0cxkyx3Xd CrY/AyciFVtr+dUP67Iqu56O0hQTxAb0m9NlrrCNpdx0YbgdIL2yKOVaum3/tG3KPixR fnJarH/DYbmMnpaJxA6jDzjb4PT+0lXIWjTNDCOWD7xoxRagwXikcTQV7mBP8lowElRH ourck/o6z8bQJ589jOeT1O4gpJjC0992rXG19RsJB6Hqt99xzoSSLgYK18SrMnOWr1YA y47g== 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=Pb/vY0IBh75ZxywBj3v0sp843PBbdLtQyqNhmT3+yDY=; b=v+6BEClQVoTntpU9d56dWOjZB73JErVUkq1HRWefKKwLEDiiGpbtvFev6EkcoD1aU0 dBi7OljGqsTjsEt98+SWeem/LrLSZrTDKu7FgyDLvtaMvmg+Qleu8prs9y3I0ibAfxW5 ELeP9MDbFVSQoLTCG9wnRBp8xpcpL0bapLWvkt7Nz6H3MuG9/g+aenYn+uXh8gHekqVS X2uwAsdq5W4dWErIquW/fRadPbo0IaxchBQeo+/eXI6ETJGreOxckYdjdkMS3fZDLirT qnNzFFIku9WDjFuUgj/Aov4z5yUbJFoBRcISqW2Vwe6XqQ+J0dgJkfpmGeDL/TVNyJ9n KCpQ== X-Gm-Message-State: ACgBeo1bo0FfRQDlMH3B0JC7aZkkbv5XxBD0UqTRljI3MapxV1rDLqMB 0ObbwU7jGnyxcAGvhCkxjZA= X-Google-Smtp-Source: AA6agR6sSl5AeA+spE/uhfMLz4mNqOIZlUn5Ia6HGVZ+eGY6fNoTHtAREYsO/rTgc07wCXPidRCxzQ== X-Received: by 2002:a05:6512:3d20:b0:48b:9e72:fb42 with SMTP id d32-20020a0565123d2000b0048b9e72fb42mr3149772lfv.299.1660936809121; Fri, 19 Aug 2022 12:20:09 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::1]) by smtp.gmail.com with ESMTPSA id t22-20020ac25496000000b0048b0c8fb31asm734602lfk.159.2022.08.19.12.20.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 12:20:08 -0700 (PDT) Date: Fri, 19 Aug 2022 22:20:03 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 10/14] iio: ad7476: simplify using devm_regulator_get_enable() Message-ID: <33070d66b9b976acac1cee5570facef9278b6b61.1660934107.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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 Acked-by: Nuno Sá --- v2 => v3: New patch --- drivers/iio/adc/ad7476.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c index 94776f696290..80aebed47d1f 100644 --- a/drivers/iio/adc/ad7476.c +++ b/drivers/iio/adc/ad7476.c @@ -368,16 +368,7 @@ static int ad7476_probe(struct spi_device *spi) } if (st->chip_info->has_vdrive) { - reg = devm_regulator_get(&spi->dev, "vdrive"); - if (IS_ERR(reg)) - return PTR_ERR(reg); - - ret = regulator_enable(reg); - if (ret) - return ret; - - ret = devm_add_action_or_reset(&spi->dev, ad7476_reg_disable, - reg); + ret = devm_regulator_get_enable(&spi->dev, "vdrive"); if (ret) return ret; } From patchwork Fri Aug 19 19:20:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 12949122 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D618EC32773 for ; Fri, 19 Aug 2022 19:20:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351452AbiHSTUp (ORCPT ); Fri, 19 Aug 2022 15:20:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351429AbiHSTU1 (ORCPT ); Fri, 19 Aug 2022 15:20:27 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 880AA4CA39; Fri, 19 Aug 2022 12:20:25 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id d23so2943003lfl.13; Fri, 19 Aug 2022 12:20:25 -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=FdWk3y+T5Xz7F0ok6QUYuKZuWMUSNYttRlt11tcAS4o=; b=GZxVL7QRvxWWsB/hSG7pqSJMKuQnlrju1SMvDxiWaoMfVBtuJ3S4dmMCdAJQDsI6D7 aEo5jmgCPgWLU5qB17qMeZVJCVcvITK8Fi+PX60t1DCkiLaPkkTVj6cRdiValj58BsRn 1PBAd1QOPVJYxXf5YMO+vc33IAwpBhiNFBeBaiw1DEtgW66QJYzqNpGo9DUOYthYDLa6 MhdATPVcFV+lpi4KckDcKkdLB0vlntgXdbfKjvC7g87aIuW906+yYWuE2IbSjkV51gIx kMYoNcRnoRNKvpa7kvcyDLuhbkLOjzLqrtFgLHxeFDldhceMI0+d6g684fF738oVBJe1 jnfw== 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=FdWk3y+T5Xz7F0ok6QUYuKZuWMUSNYttRlt11tcAS4o=; b=JZRYiHc5toWRHrr744RR5AxXE/eNHTjzuBObp3VkYeDi+hb2OECbUWm8i+c/aq0AP1 y+7lge7xow4B9QGarj32wjL60tQJ09l7/5WRrzLUo3CK+HVm60JDeZBDWgKkT6RSVINJ mbyqgsoylzmZFDsYoMWipeGmOZzJpW0JNhmxqb23PzgC1m1kuLG67mUJRGQg3e+Eq47g uypl0ivOOAQKAJZ9mzFSjPtSwQQg+ed4GstcwNindtXQg2NTW3VrVIlkRyDDAhOQC9Q6 Laov8fzHr7U1MHOT4KDp+Cp187SWIKKiZ4BC2sqwX10DoL7QsN11Js41wm9MxK+5OsN2 6wcA== X-Gm-Message-State: ACgBeo0CqeNd+oc6d6nMyaP8clKb5XaX6boZ67Mjs+xgxLMHT+e6/MkO xx+SF55cNzm6qf79YDcgKa4= X-Google-Smtp-Source: AA6agR6Nm6+xYuT0Cdd/DZvMSYDopH8+KN7zKoa6NqMWE7jDy4ZBgO1w5bvayvM5+eeSUhM4+mjQdg== X-Received: by 2002:a05:6512:358d:b0:48b:37f:dce2 with SMTP id m13-20020a056512358d00b0048b037fdce2mr2608198lfr.267.1660936823571; Fri, 19 Aug 2022 12:20:23 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::1]) by smtp.gmail.com with ESMTPSA id w16-20020a19c510000000b00491aee1c4a5sm734450lfe.168.2022.08.19.12.20.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 12:20:22 -0700 (PDT) Date: Fri, 19 Aug 2022 22:20:18 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 11/14] iio: ad7606: simplify using devm_regulator_get_enable() Message-ID: <521c52f5a9bdc2db04d5775b36df4b233ae338da.1660934107.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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: Nuno Sá --- v2 => v3: New patch --- drivers/iio/adc/ad7606.c | 22 +++------------------- drivers/iio/adc/ad7606.h | 1 - 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index ba24f99523e0..dd6b603f65ea 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -557,13 +557,6 @@ static const struct iio_trigger_ops ad7606_trigger_ops = { .validate_device = iio_trigger_validate_own_device, }; -static void ad7606_regulator_disable(void *data) -{ - struct ad7606_state *st = data; - - regulator_disable(st->reg); -} - int ad7606_probe(struct device *dev, int irq, void __iomem *base_address, const char *name, unsigned int id, const struct ad7606_bus_ops *bops) @@ -589,19 +582,10 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address, st->scale_avail = ad7606_scale_avail; st->num_scales = ARRAY_SIZE(ad7606_scale_avail); - st->reg = devm_regulator_get(dev, "avcc"); - if (IS_ERR(st->reg)) - return PTR_ERR(st->reg); - - ret = regulator_enable(st->reg); - if (ret) { - dev_err(dev, "Failed to enable specified AVcc supply\n"); - return ret; - } - - ret = devm_add_action_or_reset(dev, ad7606_regulator_disable, st); + ret = devm_regulator_get_enable(dev, "avcc"); if (ret) - return ret; + return dev_err_probe(dev, ret, + "Failed to enable specified AVcc supply\n"); st->chip_info = &ad7606_chip_info_tbl[id]; diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h index 2dc4f599f9df..924a2d1a6d94 100644 --- a/drivers/iio/adc/ad7606.h +++ b/drivers/iio/adc/ad7606.h @@ -92,7 +92,6 @@ struct ad7606_chip_info { struct ad7606_state { struct device *dev; const struct ad7606_chip_info *chip_info; - struct regulator *reg; const struct ad7606_bus_ops *bops; unsigned int range[16]; unsigned int oversampling; From patchwork Fri Aug 19 19:20:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 12949123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EE14C32773 for ; Fri, 19 Aug 2022 19:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350677AbiHSTVE (ORCPT ); Fri, 19 Aug 2022 15:21:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351497AbiHSTUr (ORCPT ); Fri, 19 Aug 2022 15:20:47 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB36811521A; Fri, 19 Aug 2022 12:20:39 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id s1so4511584lfp.6; Fri, 19 Aug 2022 12:20:39 -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=xN5m22WfaWqHbczZVUXbDhaaAcllqpHvQCGoo7vtQ3Q=; b=oGku/UZ6JGk6V0C5bLYbPWu66MUuJjgYpY3NGBPivcZhtS7WFLDvjIC8N3BUUM+ojm XrqzbPZ7BrMhKgw6iqLfOiywA2/e+V1CI1Bv+ibOwljypZIiJAJvqWYl5GdTGvHtfSGD AjC8c/AA3lgjgppMd1cIaGUH2dRgdYoZWaD8x6OXrTYVzs/Sv572IV2k0tCdTTzuCx3t 2ikwrDFd4TfQyxs2LX1weme559lC2wREdRcP6Dc7/B3NufUGyFdifmPs2+vqf1zmp4X2 gc4AimqIJ4eobRPhboGYfD+oUL8eSDviG7Sv1YPnqbnnXUpkKhIJwyz8+6Ut4CAQV+ES OCMQ== 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=xN5m22WfaWqHbczZVUXbDhaaAcllqpHvQCGoo7vtQ3Q=; b=rb86DLwfnmcmt8EIlrK28WfImb5QpWQKawf0p0FzjDUmbuaaxrfvo4P7Uti9Uo9yZY VHl4Y2pNeV9GlOtcA1/2Jbb2SRUdHv+/ArKL2MNww2p9SqZ8lwNNpEDl0RmIGH7d6JV7 HKsA1u18rl0USXGpWTNTiYs38kWNEN3Lh1aPhIOu8h1w3V4xCqJjtLM9FKibeqM414Ua +Y09JcDEMuq1SzgAPAOFmwJcqD2Tu4DJg1iBSZ11WbzDxndX/LOrOjgEhucFVtXHtXWt zGIEyhc5KzKlpxRJE6abGL0fuOmdvgrO4xOa1uHtct88eV6IU+wn1hw9xEEeX6ZzwdMM 94XA== X-Gm-Message-State: ACgBeo2PvdqTdf+00OVr9Bzun5vsRHJshWivUKjMduLFxUR+F5J0nBlL sWvygERrGQfmD3bvUCB9TQ4= X-Google-Smtp-Source: AA6agR6BPAMdFFb/vkSsLm2HrUQWrAH7AmJz5zOLk+hoeikQiaWUiHe1ZL4CVAhLy51sQSCSL2zS7Q== X-Received: by 2002:a05:6512:3686:b0:492:bd6f:ad4 with SMTP id d6-20020a056512368600b00492bd6f0ad4mr2926283lfs.151.1660936837811; Fri, 19 Aug 2022 12:20:37 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::1]) by smtp.gmail.com with ESMTPSA id p4-20020a19f004000000b0048aeef1b2bcsm725453lfc.294.2022.08.19.12.20.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 12:20:37 -0700 (PDT) Date: Fri, 19 Aug 2022 22:20:32 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Matti Vaittinen , Nuno =?iso-8859-1?q?S=E1?= , Alexandru Lazar , Cai Huoqing , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 12/14] iio: max1241: simplify using devm_regulator_get_enable() Message-ID: <7c759bf6c06e72ae70bffeebc1939d9903427278.1660934107.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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: Alexandru Lazar --- v2 => v3: New patch --- drivers/iio/adc/max1241.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/drivers/iio/adc/max1241.c b/drivers/iio/adc/max1241.c index a815ad1f6913..500bb09ab19b 100644 --- a/drivers/iio/adc/max1241.c +++ b/drivers/iio/adc/max1241.c @@ -22,7 +22,6 @@ enum max1241_id { struct max1241 { struct spi_device *spi; struct mutex lock; - struct regulator *vdd; struct regulator *vref; struct gpio_desc *shutdown; @@ -110,17 +109,6 @@ static const struct iio_info max1241_info = { .read_raw = max1241_read_raw, }; -static void max1241_disable_vdd_action(void *data) -{ - struct max1241 *adc = data; - struct device *dev = &adc->spi->dev; - int err; - - err = regulator_disable(adc->vdd); - if (err) - dev_err(dev, "could not disable vdd regulator.\n"); -} - static void max1241_disable_vref_action(void *data) { struct max1241 *adc = data; @@ -147,20 +135,10 @@ static int max1241_probe(struct spi_device *spi) adc->spi = spi; mutex_init(&adc->lock); - adc->vdd = devm_regulator_get(dev, "vdd"); - if (IS_ERR(adc->vdd)) - return dev_err_probe(dev, PTR_ERR(adc->vdd), - "failed to get vdd regulator\n"); - - ret = regulator_enable(adc->vdd); + ret = devm_regulator_get_enable(dev, "vdd"); if (ret) - return ret; - - ret = devm_add_action_or_reset(dev, max1241_disable_vdd_action, adc); - if (ret) { - dev_err(dev, "could not set up vdd regulator cleanup action\n"); - return ret; - } + return dev_err_probe(dev, ret, + "failed to get/enable vdd regulator\n"); adc->vref = devm_regulator_get(dev, "vref"); if (IS_ERR(adc->vref)) From patchwork Fri Aug 19 19:20:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 12949124 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA7BEC32771 for ; Fri, 19 Aug 2022 19:21:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351569AbiHSTVr (ORCPT ); Fri, 19 Aug 2022 15:21:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350791AbiHSTVX (ORCPT ); Fri, 19 Aug 2022 15:21:23 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B69A115596; Fri, 19 Aug 2022 12:21:07 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id e2so474874ljj.1; Fri, 19 Aug 2022 12:21:07 -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=3f/bG1xCcH9GlVDTu4IzFUvz5kFlob5DxhGhmkJbqE8=; b=UCyMDvX/1FVk1yWhyHofjNsW9oECG44IwYhTOrlo2KlNMkFv95nrgnmiQPvF+TveQF l2MxXibmbK9uqtYV+IX807QQ2BanWvX3s754doGrYt5CaQ7SBz7J5RPkteMftGnTef50 4GsSk0CCeaDtXsRpnP9lWBHX4h4igKZqUAnePldKa7gl+vQr/8cT8cFFhBmpqz/V4avx CyeLa6HCUV2oa6ZJvL2LfsK+y8axCMWiy7qzdznZ0eXLyBGUeAb9evfkWqC0QjQ2hfpZ SY76pRX27eGh/P9I2HisCbOMmg/POwjECFzZgKGNdCbsMzQF63NuPGAI5BKomOeZ1/qK eL6g== 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=3f/bG1xCcH9GlVDTu4IzFUvz5kFlob5DxhGhmkJbqE8=; b=keGPt8X5ep5QXM8jJnD2sWdL721aL9VfDrbtBLtK4ZXx9zX0L+CO3Cbr0mW4aq23SH G9dbyyc3eu4W1MKii2pdgENNz8QAzKMFL6VjdUHcZs1g7ESWqE0GEUqTQIrRqTSnCoMK 76jlRQo40eMbqYDF+P3AFFj5OxaYhEuOUmkYaboBeZlKTqsRzZcnhVjLQaLtdREkUn8S vYeCX8SYB2h++Ny9/AJw/EzXjXmS3a0q1Ks2SDhdjErsrwzdLOnES41I9PjXBTlhiTkf 1qFUsaD8jRwa8LSRaJsfSXq51AyT4JGLfArwgWzx6ANvBgN1ItK/Rxb+8BOQEZn8sX2d Q5Iw== X-Gm-Message-State: ACgBeo11KIocwz5ZdxRb2XExWMGUDMyBicMfzRG6DlpttYFus9yTqNgS N3kmFBR776CLUiCUPNoDqHk= X-Google-Smtp-Source: AA6agR6uM1ayQwnZqYrF0fmvp6E2av0FzUwAAh/AwkDnw0AXgdhgSv039E65NyLc4bXqZ9P1zcVs5g== X-Received: by 2002:a05:651c:179c:b0:261:8fbe:b729 with SMTP id bn28-20020a05651c179c00b002618fbeb729mr2606226ljb.114.1660936852242; Fri, 19 Aug 2022 12:20:52 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::1]) by smtp.gmail.com with ESMTPSA id d11-20020ac25ecb000000b00492b494c4dbsm738480lfq.89.2022.08.19.12.20.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 12:20:51 -0700 (PDT) Date: Fri, 19 Aug 2022 22:20:47 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Cameron , Lars-Peter Clausen , Matti Vaittinen , Alexandru Ardelean , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 13/14] iio: max1363: simplify using devm_regulator_get_enable() Message-ID: <1286ea127d190e5708a0aaff271819b2d3f8802d.1660934107.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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: Nuno Sá --- v2 => v3: New patch --- drivers/iio/adc/max1363.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index eef55ed4814a..d900e29d6cb7 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -169,7 +169,6 @@ struct max1363_state { const struct max1363_chip_info *chip_info; const struct max1363_mode *current_mode; u32 requestedmask; - struct regulator *reg; struct mutex lock; /* Using monitor modes and buffer at the same time is @@ -1603,15 +1602,7 @@ static int max1363_probe(struct i2c_client *client, st = iio_priv(indio_dev); mutex_init(&st->lock); - st->reg = devm_regulator_get(&client->dev, "vcc"); - if (IS_ERR(st->reg)) - return PTR_ERR(st->reg); - - ret = regulator_enable(st->reg); - if (ret) - return ret; - - ret = devm_add_action_or_reset(&client->dev, max1363_reg_disable, st->reg); + ret = devm_regulator_get_enable(&client->dev, "vcc"); if (ret) return ret; From patchwork Fri Aug 19 19:21:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 12949125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E387AC32771 for ; Fri, 19 Aug 2022 19:21:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351429AbiHSTVv (ORCPT ); Fri, 19 Aug 2022 15:21:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351480AbiHSTV1 (ORCPT ); Fri, 19 Aug 2022 15:21:27 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46D7A1155B0; Fri, 19 Aug 2022 12:21:13 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id bx38so5352767ljb.10; Fri, 19 Aug 2022 12:21:13 -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=a+PnZAwbnyxlFPa4YTGTR9Nn3kx7SIjA9eZbEWP7QKo=; b=i6hF2TK47IL6OucnkuO0ZZDBdrZCY0I+aqauSm7cwbQFP/lMdEasMpn5cTmwY6/oHY 3p4h/c4nLLavxgmnBPIXrPWybBgsUw2WWlLeSVGcg2a3NMPpWDwH+74wWJ+PGUVBECJS tP2n22FsXCwrrf2B+qrOw0w8gTfTLXO3+BFbm+S7cfIIP8wEzpxOBcWsd9rXTZPN4slb qcxxhFnNbcsNMulPd2PcNwGw7VgtHHKI+jRrADrfoYwGvjr+bYrJxXthZO4A4X6zgsQi sGptDDE+M1btRF2FMVxoeIBy0IkYU1P4GmFEwAFwmwM9SOVb/8VFbu0hZNoQqO5x09uF UwrQ== 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=a+PnZAwbnyxlFPa4YTGTR9Nn3kx7SIjA9eZbEWP7QKo=; b=ZNbc344OVhkNnEhoBKDkSUj49clwmsRoDVm4tUlYpjUD0q2gPconEPqqBSoRkgLEVf GuNa6XFmoAIpcrIh59D0h+OSB1cxMh+2PAaK1sAdUFj51hifpTh+jaXFFnLtZtQqR7E0 cKhpw6AUjoYF9crqn7AES+4EBEDJuWRoDy5s91r8QLMyfALskqxUZi2hKJ6kphp3CkNC 3gbR5UgCpvMOCgI1txoUddJrpwiVAP5SDsImt4r9ArfeKdWfOM7igpCiDFimaTZ1CwJ8 Y7LHef/735MguwKcizKiys6bRrWE4ldT63NuIk57u93yD1WdKyGiduf0u68/nzduBnX+ oYZg== X-Gm-Message-State: ACgBeo1dxyqup1kCTsSTmXQjkHtJ1zz9Xo7u77O7B864/xjgmyyHjB8B WmSnSkjg6XzLmozYNHRA3EM= X-Google-Smtp-Source: AA6agR46yG7niNqKEUERouB3aXkhxNgAps0NbeAnMPogiKGrAyKrNvIAecpExpxeJb0itxekUn1sXA== X-Received: by 2002:a05:651c:1026:b0:25e:77f3:e0bd with SMTP id w6-20020a05651c102600b0025e77f3e0bdmr2449571ljm.383.1660936868038; Fri, 19 Aug 2022 12:21:08 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::1]) by smtp.gmail.com with ESMTPSA id i17-20020a2ea231000000b002618a31be1csm699147ljm.62.2022.08.19.12.21.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 12:21:07 -0700 (PDT) Date: Fri, 19 Aug 2022 22:21:02 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 14/14] iio: hmc425a: simplify using devm_regulator_get_enable() Message-ID: <8b1193fdefb231a6d721e2bded52c48e56039c20.1660934107.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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: Nuno Sá --- v2 => v3: New patch --- drivers/iio/amplifiers/hmc425a.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/iio/amplifiers/hmc425a.c b/drivers/iio/amplifiers/hmc425a.c index ce80e0c916f4..108f0f1685ef 100644 --- a/drivers/iio/amplifiers/hmc425a.c +++ b/drivers/iio/amplifiers/hmc425a.c @@ -34,7 +34,6 @@ struct hmc425a_chip_info { }; struct hmc425a_state { - struct regulator *reg; struct mutex lock; /* protect sensor state */ struct hmc425a_chip_info *chip_info; struct gpio_descs *gpios; @@ -162,13 +161,6 @@ static const struct of_device_id hmc425a_of_match[] = { }; MODULE_DEVICE_TABLE(of, hmc425a_of_match); -static void hmc425a_reg_disable(void *data) -{ - struct hmc425a_state *st = data; - - regulator_disable(st->reg); -} - static struct hmc425a_chip_info hmc425a_chip_info_tbl[] = { [ID_HMC425A] = { .name = "hmc425a", @@ -211,14 +203,7 @@ static int hmc425a_probe(struct platform_device *pdev) return -ENODEV; } - st->reg = devm_regulator_get(&pdev->dev, "vcc-supply"); - if (IS_ERR(st->reg)) - return PTR_ERR(st->reg); - - ret = regulator_enable(st->reg); - if (ret) - return ret; - ret = devm_add_action_or_reset(&pdev->dev, hmc425a_reg_disable, st); + ret = devm_regulator_get_enable(&pdev->dev, "vcc-supply"); if (ret) return ret;