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;