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;