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)