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;