From patchwork Sun Oct 16 16:33:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 13007891 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 E1337C4332F for ; Sun, 16 Oct 2022 16:34:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229806AbiJPQeN (ORCPT ); Sun, 16 Oct 2022 12:34:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229790AbiJPQeM (ORCPT ); Sun, 16 Oct 2022 12:34:12 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4995032051 for ; Sun, 16 Oct 2022 09:34:11 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F21DEB80D08 for ; Sun, 16 Oct 2022 16:34:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB29FC433C1; Sun, 16 Oct 2022 16:34:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665938048; bh=arxZhQJ7U+QAgYN2rLi/aduvff2rpMRCnpW6s51ODRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pHrL192Gp+yTruiTh8MSPPeLlzUvUDlnLn5FSymVF8caFIpwiuN2OHAXmf6NZU2gB Bq9LN+tSrvKBrbkqpZ1fAxRqp+sSpl7pnDjsy2yyAk+dFTxuG2ptz0uUVRArkajmwj 4v2QTJwdcuyJMpeDE20TyYLMTeoG1Gp7Z941vZ5Ws6vb/AFA/ZjgLbiYYuK9glUucc b+8bI8hdmm0ZzKvs0Tnbn30Fn+A0GMut1NuhlnW0cQpF+4nh3S4GAoPtzhkj9GNvFw 2j5M4sky5vDISWivTPImafq6XXPtOeOD7ZkyNats6Or6MPQnmAUJcqPCqZK7GZyowN 3FfewYVeKJptg== From: Jonathan Cameron To: linux-iio@vger.kernel.org Cc: Matti Vaittinen , Matti Vaittinen , Cosmin Tanislav , Jagath Jog J , Sean Nyekjaer , Dmitry Rokosov , Linus Walleij , Andy Shevchenko , Michael Hennerich , Lorenzo Bianconi , Martyn Welch , Gwendal Grignou , Stephen Boyd , Tomasz Duszynski , Jonathan Cameron Subject: [PATCH 04/14] iio: accel: kxcjk-1013: Use devm_regulator_bulk_get_enable() Date: Sun, 16 Oct 2022 17:33:59 +0100 Message-Id: <20221016163409.320197-5-jic23@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221016163409.320197-1-jic23@kernel.org> References: <20221016163409.320197-1-jic23@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org From: Jonathan Cameron This driver only turns the power on at probe and off via a custom devm_add_action_or_reset() callback. The new devm_regulator_bulk_get_enable() replaces this boilerplate code. Signed-off-by: Jonathan Cameron Reviewed-by: Matti Vaittinen --- drivers/iio/accel/kxcjk-1013.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index adc66b3615c0..e626b6fa8a36 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -241,7 +241,6 @@ enum kxcjk1013_axis { }; struct kxcjk1013_data { - struct regulator_bulk_data regulators[2]; struct i2c_client *client; struct iio_trigger *dready_trig; struct iio_trigger *motion_trig; @@ -1425,16 +1424,10 @@ static const char *kxcjk1013_match_acpi_device(struct device *dev, return dev_name(dev); } -static void kxcjk1013_disable_regulators(void *d) -{ - struct kxcjk1013_data *data = d; - - regulator_bulk_disable(ARRAY_SIZE(data->regulators), data->regulators); -} - static int kxcjk1013_probe(struct i2c_client *client, const struct i2c_device_id *id) { + static const char * const regulator_names[] = { "vdd", "vddio" }; struct kxcjk1013_data *data; struct iio_dev *indio_dev; struct kxcjk_1013_platform_data *pdata; @@ -1461,22 +1454,12 @@ static int kxcjk1013_probe(struct i2c_client *client, return ret; } - data->regulators[0].supply = "vdd"; - data->regulators[1].supply = "vddio"; - ret = devm_regulator_bulk_get(&client->dev, ARRAY_SIZE(data->regulators), - data->regulators); + ret = devm_regulator_bulk_get_enable(&client->dev, + ARRAY_SIZE(regulator_names), + regulator_names); if (ret) return dev_err_probe(&client->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(&client->dev, kxcjk1013_disable_regulators, data); - if (ret) - return ret; - /* * A typical delay of 10ms is required for powering up * according to the data sheets of supported chips.