From nobody Mon Apr 13 10:34:42 2026 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 10867C00140 for ; Fri, 12 Aug 2022 10:09:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237700AbiHLKJb (ORCPT ); Fri, 12 Aug 2022 06:09:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236734AbiHLKJ3 (ORCPT ); Fri, 12 Aug 2022 06:09:29 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BBD7A8CEB; Fri, 12 Aug 2022 03:09:28 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id z25so721460lfr.2; Fri, 12 Aug 2022 03:09:28 -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=yuAKn5slzZuEhtPm1LsezhtP3pivs5CCHH3xY7WDuVQ=; b=bY3a2ss7fDRzPC2k43zDwqSVkA56ODbouc/Mh4zivAGhRzzZE0J3tJIe4H888Enb+s xmSBomn3yZpqHIyyC9R+EPw4jJo7oslGkIosXdGkptn4Bt3U3NkYXbKLWJFSA4AT4z2W Xzf/RNoxKtJYgKfOFXAZ8GJ+cRyJWev8k4O+EAd8KpRgtZSoT0xuE/LALlxK81Ozsowv uDIlkI9/MmrzBmW0dnsWKiixPMXEdGjuIntvRpM9lIFAM+8IHitt0pVq1lSnmC0yCgvV 11ZrCffi2v6AibbzxHR5URpXRBWu+uCY2ZaHyFAWgUhTJGEDQlWMh85QCOXX8Zz4MeDY /gbA== 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=yuAKn5slzZuEhtPm1LsezhtP3pivs5CCHH3xY7WDuVQ=; b=pg6nk4f3T+1pfKCEgn/TCffJUfwExpqCBK03GVxZn29VuKiQbpjVL6ED1ec1h4VrCP Me4ZTDgNVi6MMjy+186f+LYIgCICwONpUNOxpsf9Kpj6Z1p91SvdRQUxm6RA2r+4+nO4 nSiX0e36IzOO65HwDT8teJ628wX42pdSZH0O09nXAvIKaBflp+WKeMtnyIYaXWwzQoxU Ualp/ii9xiY8MNmvIdzEVBEMGkT1p1tgiBIQNrc3b+1qSJmsfRY1C/xDjaEqoRPu2QgW QFE3H3T050/cR1UFhqJNNIdLEtdgCRNSbc5H734IqU38kPLXIKfZvwbJoNf6/hC79btb 0QiA== X-Gm-Message-State: ACgBeo2ym966XURmOzQ8Je4U22Hz6Kzabcrlfm+twTfKfr5VdDcC5m8W hnrgUe/9Ip4FhkWrLINaDqM= X-Google-Smtp-Source: AA6agR615W7kd9vT2AUcBZx3elPnt+50MwFv4xr43ufV0vRP94aIGxI1HACvs/SH5Oh+6FhoIDBMtQ== X-Received: by 2002:a05:6512:139d:b0:48d:3e4:6802 with SMTP id p29-20020a056512139d00b0048d03e46802mr983209lfa.424.1660298966644; Fri, 12 Aug 2022 03:09:26 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id u10-20020a05651220ca00b0048b0bf9f4bfsm160695lfr.140.2022.08.12.03.09.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 03:09:25 -0700 (PDT) Date: Fri, 12 Aug 2022 13:09:03 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Corbet , Liam Girdwood , Mark Brown , Matti Vaittinen , Johan Hovold , Alexandru Ardelean , Peter Rosin , Aswath Govindraju , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/7] docs: devres: regulator: Add missing devm_* functions to devres.rst Message-ID: <5efc0c90342b0a0ef3322b8fc1472b84cfc0eb45.1660292316.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="wQt+00N+A/DYJkCw" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --wQt+00N+A/DYJkCw Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" A few managed regulator functions were missing from the API list. Add missing functions. Signed-off-by: Matti Vaittinen --- RFCv1 =3D> v2: - No changes This one is actually a documentation fix which adds existing APIs to the list. I guess this patch is good for being merged independently from the rest of the series. --- Documentation/driver-api/driver-model/devres.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentati= on/driver-api/driver-model/devres.rst index 2d39967bafcc..271d1eb2234b 100644 --- a/Documentation/driver-api/driver-model/devres.rst +++ b/Documentation/driver-api/driver-model/devres.rst @@ -406,10 +406,17 @@ PWM devm_fwnode_pwm_get() =20 REGULATOR + devm_regulator_bulk_register_supply_alias() devm_regulator_bulk_get() devm_regulator_get() + devm_regulator_get_exclusive() + devm_regulator_get_optional() + devm_regulator_irq_helper() devm_regulator_put() devm_regulator_register() + devm_regulator_register_notifier() + devm_regulator_register_supply_alias() + devm_regulator_unregister_notifier() =20 RESET devm_reset_control_get() --=20 2.37.1 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --wQt+00N+A/DYJkCw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmL2Jr8ACgkQeFA3/03a ocXdkggAhZ5XSYLhVfVt8rPclxoH54IJ1sSVH8uiR1UkwWAR3bfg6ql8HfNaSuR0 frdTUki174UogGNj7mnoA+XGwRq4o+a8TQuzRGCkf/x6dQFPK6ElvxkEBTLFfXPT UXw1SPfNuq1I5CxaugCDZdnBlI5DampIh5uNwl6bai1VNrArwI0KqUTTWMECXIRS GDmAYNIgM90IyXnVvlDpk79tBbqCn/ZLow+bVGUX6hI2f4Nloh0Z97WJFwoI2X6/ 8tXRb5Rp6T4upFI0G1PgdoToGPkNZej9o/EOlpm1KbS/DKcyxEgU5Uo95GnTwW1P 4w51sAt7IkDjNFC9tBw7h8dVxZiFYw== =Y1jp -----END PGP SIGNATURE----- --wQt+00N+A/DYJkCw-- From nobody Mon Apr 13 10:34:42 2026 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 7106EC00140 for ; Fri, 12 Aug 2022 10:11:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237358AbiHLKLE (ORCPT ); Fri, 12 Aug 2022 06:11:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237622AbiHLKKp (ORCPT ); Fri, 12 Aug 2022 06:10:45 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23A516069B for ; Fri, 12 Aug 2022 03:10:44 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id u6so481775ljk.8 for ; Fri, 12 Aug 2022 03:10:44 -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=rME1hlHehvkpkCjZbKN0/GWU+K0a+iodQIRupA8e4s0=; b=AvdrbNIBlnKEhzBY3cpesIFWSAr+dg3Q+Hlq6H8NiUfezwUxYU8CtwkuBH4uQESU02 yxLwwoS5Y7NhLjbRpYAmFJ2SiUNUxQ4bPjsUn/KmFTpf6s1YO09ZAX0ewfbiOvrJTTJd G4UcKtXpONssng1DeTxDyGWvuiD5sjLbAOHKkmx0ld07d+0eUl14fv2+zTYdu0F3wp31 6rF5orfE655x2fYataU1Jo1iBmnTYPTb1VH+CbI0rW8mg+niwIxPFbcxYeeSeTrgKbQr A1iGw9Z8FhVrrdH9TAbPMubIciLtk3KEqs8rEX4sjD+GJeC/J7HMZHAYKCTCT6wPa56v pBww== 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=rME1hlHehvkpkCjZbKN0/GWU+K0a+iodQIRupA8e4s0=; b=wn+kfUNUWJc7BciXkkUkZKflNIu0L7EEPh/MPqrPt0PNPOTGZATtkLxacNY3jAUQIS GDyoWQqwMN+h3a45lnF3y42mJoZhqRaSzvk4qkAd7vxdQstUfrP/zlWiZsiE/TOJEvIa qUQaWNQJF+QScldAZKUmJQjA+UQYSfCYwG+ZFoVt5a0kvY4DV0w27OcRm+RW5FaZ/NgJ ozHxZSV9sEvCBWKTaD6ss854Ykub+LO60x2lI9FxfeqQqBQQFNyc/xeh4JKWFB3D4qpZ 3us6zVV5C36LpsQ6amZx7338dJhZogm5jPMP/Lj8QRziKTci4t6zVvrpa82As+eM41TP B2cg== X-Gm-Message-State: ACgBeo0Vxd8k1aCZe2qezbqUtHVoI+VOfe1PWP39vBmw8NDx80fOWk5u Jks5dT/bIjKgRjzLbb/KMc4= X-Google-Smtp-Source: AA6agR6s+5lWKjSbrhXM6b9DKEDihrll2YNJSr2ExETwbG9w/z2oEpnvOHQucT0hE6rwqZMCzyYFpQ== X-Received: by 2002:a05:651c:a12:b0:25e:bd44:b74b with SMTP id k18-20020a05651c0a1200b0025ebd44b74bmr871154ljq.381.1660299042350; Fri, 12 Aug 2022 03:10:42 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id w19-20020ac254b3000000b0048b37d29256sm164928lfk.63.2022.08.12.03.10.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 03:10:41 -0700 (PDT) Date: Fri, 12 Aug 2022 13:10:37 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/7] regulator: Add devm helpers for get and enable Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="VZj9oCS0OEeVyhn7" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --VZj9oCS0OEeVyhn7 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" A few regulator consumer drivers seem to be just getting a regulator, enabling it and registering a devm-action to disable the regulator at the driver detach and then forget about it. We can simplify this a bit by adding a devm-helper for this pattern. Add devm_regulator_get_enable() and devm_regulator_get_enable_optional() Signed-off-by: Matti Vaittinen --- RFCv1 =3D> v2 - Add devm_regulator_bulk_put() and devm_regulator_bulk_get_enable() --- drivers/regulator/devres.c | 164 +++++++++++++++++++++++++++++ include/linux/regulator/consumer.h | 27 +++++ 2 files changed, 191 insertions(+) diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c index 9113233f41cd..ca3d702b0634 100644 --- a/drivers/regulator/devres.c +++ b/drivers/regulator/devres.c @@ -70,6 +70,65 @@ struct regulator *devm_regulator_get_exclusive(struct de= vice *dev, } EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive); =20 +static void regulator_action_disable(void *d) +{ + struct regulator *r =3D (struct regulator *)d; + + regulator_disable(r); +} + +static int _devm_regulator_get_enable(struct device *dev, const char *id, + int get_type) +{ + struct regulator *r; + int ret; + + r =3D _devm_regulator_get(dev, id, get_type); + if (IS_ERR(r)) + return PTR_ERR(r); + + ret =3D regulator_enable(r); + if (!ret) + ret =3D devm_add_action_or_reset(dev, ®ulator_action_disable, r); + + if (ret) + devm_regulator_put(r); + + return ret; +} + +/** + * devm_regulator_get_enable_optional - Resource managed regulator get and= enable + * @dev: device to supply + * @id: supply name or regulator ID. + * + * Get and enable regulator for duration of the device life-time. + * regulator_disable() and regulator_put() are automatically called on dri= ver + * detach. See regulator_get_optional() and regulator_enable() for more + * information. + */ +int devm_regulator_get_enable_optional(struct device *dev, const char *id) +{ + return _devm_regulator_get_enable(dev, id, OPTIONAL_GET); +} +EXPORT_SYMBOL_GPL(devm_regulator_get_enable_optional); + +/** + * devm_regulator_get_enable - Resource managed regulator get and enable + * @dev: device to supply + * @id: supply name or regulator ID. + * + * Get and enable regulator for duration of the device life-time. + * regulator_disable() and regulator_put() are automatically called on dri= ver + * detach. See regulator_get() and regulator_enable() for more + * information. + */ +int devm_regulator_get_enable(struct device *dev, const char *id) +{ + return _devm_regulator_get_enable(dev, id, NORMAL_GET); +} +EXPORT_SYMBOL_GPL(devm_regulator_get_enable); + /** * devm_regulator_get_optional - Resource managed regulator_get_optional() * @dev: device to supply @@ -166,6 +225,111 @@ int devm_regulator_bulk_get(struct device *dev, int n= um_consumers, } EXPORT_SYMBOL_GPL(devm_regulator_bulk_get); =20 +static int devm_regulator_bulk_match(struct device *dev, void *res, + void *data) +{ + struct regulator_bulk_devres *match =3D res; + struct regulator_bulk_data *target =3D data; + + /* + * We check the put uses same consumer list as the get did. + * We _could_ scan all entries in consumer array and check the + * regulators match but ATM I don't see the need. We can change this + * later if needed. + */ + return match->consumers =3D=3D target; +} + +/** + * devm_regulator_bulk_put - Resource managed regulator_bulk_put() + * @consumers: consumers to free + * + * Deallocate regulators allocated with devm_regulator_bulk_get(). Normally + * this function will not need to be called and the resource management + * code will ensure that the resource is freed. + */ +void devm_regulator_bulk_put(struct regulator_bulk_data *consumers) +{ + int rc; + struct regulator *regulator =3D consumers[0].consumer; + + rc =3D devres_release(regulator->dev, devm_regulator_bulk_release, + devm_regulator_bulk_match, consumers); + if (rc !=3D 0) + WARN_ON(rc); +} +EXPORT_SYMBOL_GPL(devm_regulator_bulk_put); + +static void devm_regulator_bulk_disable(void *res) +{ + struct regulator_bulk_devres *devres =3D res; + int i; + + for (i =3D 0; i < devres->num_consumers; i++) + regulator_disable(devres->consumers[i].consumer); +} + +/** + * devm_regulator_bulk_get_enable - managed get'n enable multiple regulato= rs + * + * @dev: device to supply + * @num_consumers: number of consumers to register + * @id: list of supply names or regulator IDs + * + * @return 0 on success, an errno on failure. + * + * This helper function allows drivers to get several regulator + * consumers in one operation with management, the regulators will + * automatically be freed when the device is unbound. If any of the + * regulators cannot be acquired then any regulators that were + * allocated will be freed before returning to the caller. + */ +int devm_regulator_bulk_get_enable(struct device *dev, int num_consumers, + const char * const *id) +{ + struct regulator_bulk_devres *devres; + struct regulator_bulk_data *consumers; + int i, ret; + + devres =3D devm_kmalloc(dev, sizeof(*devres), GFP_KERNEL); + if (!devres) + return -ENOMEM; + + devres->consumers =3D devm_kcalloc(dev, num_consumers, sizeof(*consumers), + GFP_KERNEL); + consumers =3D devres->consumers; + if (!consumers) + return -ENOMEM; + + devres->num_consumers =3D num_consumers; + + for (i =3D 0; i < num_consumers; i++) + consumers[i].supply =3D id[i]; + + ret =3D devm_regulator_bulk_get(dev, num_consumers, consumers); + if (ret) + return ret; + + for (i =3D 0; i < num_consumers; i++) { + ret =3D regulator_enable(consumers[i].consumer); + if (ret) + goto unwind; + } + + ret =3D devm_add_action(dev, devm_regulator_bulk_disable, devres); + if (!ret) + return 0; + +unwind: + while (--i >=3D 0) + regulator_disable(consumers[i].consumer); + + devm_regulator_bulk_put(consumers); + + return ret; +} +EXPORT_SYMBOL_GPL(devm_regulator_bulk_get_enable); + static void devm_rdev_release(struct device *dev, void *res) { regulator_unregister(*(struct regulator_dev **)res); diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/c= onsumer.h index bbf6590a6dec..24cf5f099eef 100644 --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -203,6 +203,8 @@ struct regulator *__must_check regulator_get_optional(s= truct device *dev, const char *id); struct regulator *__must_check devm_regulator_get_optional(struct device *= dev, const char *id); +int devm_regulator_get_enable(struct device *dev, const char *id); +int devm_regulator_get_enable_optional(struct device *dev, const char *id); void regulator_put(struct regulator *regulator); void devm_regulator_put(struct regulator *regulator); =20 @@ -240,8 +242,11 @@ int __must_check regulator_bulk_get(struct device *dev= , int num_consumers, struct regulator_bulk_data *consumers); int __must_check devm_regulator_bulk_get(struct device *dev, int num_consu= mers, struct regulator_bulk_data *consumers); +void devm_regulator_bulk_put(struct regulator_bulk_data *consumers); int __must_check regulator_bulk_enable(int num_consumers, struct regulator_bulk_data *consumers); +int devm_regulator_bulk_get_enable(struct device *dev, int num_consumers, + const char * const *id); int regulator_bulk_disable(int num_consumers, struct regulator_bulk_data *consumers); int regulator_bulk_force_disable(int num_consumers, @@ -346,6 +351,17 @@ devm_regulator_get_exclusive(struct device *dev, const= char *id) return ERR_PTR(-ENODEV); } =20 +static inline int devm_regulator_get_enable(struct device *dev, const char= *id) +{ + return -ENODEV; +} + +static inline int devm_regulator_get_enable_optional(struct device *dev, + const char *id) +{ + return -ENODEV; +} + static inline struct regulator *__must_check regulator_get_optional(struct device *dev, const char *id) { @@ -367,6 +383,10 @@ static inline void devm_regulator_put(struct regulator= *regulator) { } =20 +static inline void devm_regulator_bulk_put(struct regulator_bulk_data *con= sumers) +{ +} + static inline int regulator_register_supply_alias(struct device *dev, const char *id, struct device *alias_dev, @@ -457,6 +477,13 @@ static inline int regulator_bulk_enable(int num_consum= ers, return 0; } =20 +static inline int devm_regulator_bulk_get_enable(struct device *dev, + int num_consumers, + const char * const *id) +{ + return 0; +} + static inline int regulator_bulk_disable(int num_consumers, struct regulator_bulk_data *consumers) { --=20 2.37.1 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --VZj9oCS0OEeVyhn7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmL2Jx0ACgkQeFA3/03a ocXmSAgApigTF0T1Hfye+lj960dlL1DA+2O2o8rHxGcxc0INZ/kcJ9o2JDxx9yb+ 0/TcNrvy5OFS4orNn9MLm+U8B7fd8581pwGx+zDcp4ki6W7152omYoxBtRKrLy3R 0D6/VLrz8akParG8tW3cKT2zMNTy/EvI8OsiJSfC+IDl32hWRIFHJm68t7YYX/Uf PuyFhCUp/I8XNkWyqeyv6nmWoH5xt+ayxBcH7KEJmFoJWTOCORWEnhUIBA+FTnXB +beVBnWxbPI5slZWyH9BMxp/Th1Bt4YvwwLSJCHpgmz1CBEUmYBRwajyaEYRFXBY Evx/ZaaO3aYlSVV5Y2BpyR0eXvIKlw== =un37 -----END PGP SIGNATURE----- --VZj9oCS0OEeVyhn7-- From nobody Mon Apr 13 10:34:42 2026 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 41B51C00140 for ; Fri, 12 Aug 2022 10:11:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236996AbiHLKLY (ORCPT ); Fri, 12 Aug 2022 06:11:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237656AbiHLKLI (ORCPT ); Fri, 12 Aug 2022 06:11:08 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C64E9E2FD; Fri, 12 Aug 2022 03:11:05 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id v10so473992ljh.9; Fri, 12 Aug 2022 03:11:05 -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=YBESrMui2lJGUDH8gauYExAGcJloTmJ6fo0JKbMJrZE=; b=KG66GScxKTWnb2YliYi2xu0dDLLOpEKNiyaeJ3KMwg0eVANR31JFg+AVhTEWoe+RX6 G77KToWSiXQCBVzf6fhe/qlaY/MpFuT0spXs7ao/4d3R7aI5FAk1F9SlAbCUYJ2EtH8+ PhYb7F2++TQ4whJ4y82sYJO3aI8bem66o1JARjAOUizdjJObdqBBHiiW5W01ooVWmSNZ jAofvWJsV8Pp74xuk94130J80OEQq3LUG4IqP5V/KlAh3VNE/32P/s1oAIfBgnPtwWCM V3YOE3X14tBqA1tuZC2WcjVsMLBiodw/hFhVOgB2RjKob9TBLBIZ1mEwsVGK4ESlTVE9 22pg== 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=YBESrMui2lJGUDH8gauYExAGcJloTmJ6fo0JKbMJrZE=; b=i89s+e8Q72Zm3XaoDzlqBJvTw/ZRXS3XiiJWt4r4y+yAwST36rAM3grdjiayyb7EnJ uF3CljQT0l44xOfMYC7RCr1vT+h9WQlUrcT7XxwR2oWSaKV1g+F1I2HDr9+A8Jt2HRjQ y8YLK6Jh0olhkwpPfsnjCLZhZP+qlC3xSyE+BHGiI3DDx0IRr3ilsa61gObXMwOSJupL 8wwSyLWspbZufjKvIQLVZ7T3EVAVmm2o5kvVuWMQ2QreutpVubzx73e8g/8uDzPkAJKE pYo+lzQK0AicGcj/dArGVAJR5wxd6uxkPtsaUakvX7x8F8AcOsQYhYkuPUvqgFcZqPyq 2Z0w== X-Gm-Message-State: ACgBeo3ASImcHmmAKn+Oa8XkXTzSCFnGh8iATQ/YUCbI7s8zTq1uzfTZ y1IRxAXa9GjNnNNakE2U+aY= X-Google-Smtp-Source: AA6agR4s+4Zw2E9mA/PvLeRL3I+oRWCY4/wi3HIj6UEgSySlWtPngzYCuCHLkvJZFpx4cdHYb2gTmA== X-Received: by 2002:a2e:9555:0:b0:260:3dc:12fb with SMTP id t21-20020a2e9555000000b0026003dc12fbmr977569ljh.125.1660299063444; Fri, 12 Aug 2022 03:11:03 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id n16-20020a05651203f000b0048b29b24761sm163629lfq.91.2022.08.12.03.11.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 03:11:02 -0700 (PDT) Date: Fri, 12 Aug 2022 13:10:57 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jonathan Corbet , Matti Vaittinen , Peter Rosin , Aswath Govindraju , Johan Hovold , Greg Kroah-Hartman , Alexandru Ardelean , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/7] docs: devres: regulator: Add new get_enable functions to devres.rst Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="aS0Vg+fv2MO10oy3" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --aS0Vg+fv2MO10oy3 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add the new devm_regulator_get_enable() and devm_regulator_get_enable_optional() to devres.rst Signed-off-by: Matti Vaittinen --- RFCv1 =3D> v2: - Add devm_regulator_bulk_put() and devm_regulator_bulk_get_enable() --- Documentation/driver-api/driver-model/devres.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentati= on/driver-api/driver-model/devres.rst index 271d1eb2234b..89f87ae613f0 100644 --- a/Documentation/driver-api/driver-model/devres.rst +++ b/Documentation/driver-api/driver-model/devres.rst @@ -408,7 +408,11 @@ PWM REGULATOR devm_regulator_bulk_register_supply_alias() devm_regulator_bulk_get() + devm_regulator_bulk_get_enable() + devm_regulator_bulk_put() devm_regulator_get() + devm_regulator_get_enable() + devm_regulator_get_enable_optional() devm_regulator_get_exclusive() devm_regulator_get_optional() devm_regulator_irq_helper() --=20 2.37.1 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --aS0Vg+fv2MO10oy3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmL2JzEACgkQeFA3/03a ocV78ggAporlbjPuasQq+tnOPaUEpGa6VzAkxMkmplUJuAgr7D8qW7cyXVlAS9aa qg1lvRD72jyNddYE/1VYWbQJ7EhToj7uZh5ontYxrLSdol4PUk0nESmz0QVVwktM 9oIXHnz78UrhLyfmD8k1HzOkwyzQcBpOC/LTdu2mQ/Uk5jdZW2dI9T+YIUcMqSLp V/U7lmLq7T7SLdEKpebXt1RJselxNCJbdEh8isnTK5WY3OWvgSbFDmk6J5XQlRlN ki6DaC/geB6oGpr4Xa71t8XaMMwhhqVRDFX8mO6KWXr1OWUYw2FHf7ZUEGlI3V+l qwk9xGsNwdFKaaAw8HI15RQncJy/SA== =rIMz -----END PGP SIGNATURE----- --aS0Vg+fv2MO10oy3-- From nobody Mon Apr 13 10:34:42 2026 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 B16CAC00140 for ; Fri, 12 Aug 2022 10:11:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237191AbiHLKLz (ORCPT ); Fri, 12 Aug 2022 06:11:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238009AbiHLKLW (ORCPT ); Fri, 12 Aug 2022 06:11:22 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A08BAB1AD; Fri, 12 Aug 2022 03:11:21 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id u3so701251lfk.8; Fri, 12 Aug 2022 03:11:21 -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=aLFMMy8sY7JakSoVwJi7F7tkYJbV0p0vrNiVSXwI33Q=; b=g3fQSUdZRhNr/Lh1HQZu8MtvXU5V43uZ3QtsGL/7TNjEpRexPInHyQ/FTUVcyYirYK PjZspZUtTwlNNIeoRZzMQry0I4PcRmA4YSqtL5zWHuAejyExLQiBSGJ0ddkoOOKlT8wQ 1x0Q/8cEiH6ZgrLMaE2A9Ne/Zn82Kj+a2UHJoxHLCvVzCSlHHSoPtMbGbw/S+bB1Di+R M3XqxOWErbXyqfzUQ8YaqzAMzM+Ku6dgrnMcHKN9BvWBmbY2wN1LjoRglG3nWers6eMs qYoy24HbrClTD2pX2ni9qbfSV9TfbGYaHDJX+YkqWufG5u/3TA2W2f2RgnMJle4wxPCJ 6i/w== 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=aLFMMy8sY7JakSoVwJi7F7tkYJbV0p0vrNiVSXwI33Q=; b=wsuUwTpYBsfV3+KdwLN4oSI7DRxFrUqj7iqijZJeJhMBDpKgJKlD3L9VeOjyosX9a4 c/B6USBGcDFQJoGLKJvl4pDZ61QxD8ILPNzrGYFM5Dsb6c7lqSFzHFG6UNCk6qBBcsv5 sVQ+/YpwVO+UjQV8dWSayJX36s67mbmEoyY0L6Yt/jwBITs3AgCHMufSSJaK/Hb8tR/W GUc8bqFqQtPyI+PZfCk+VE1gNox1jLAEHVfNS2FdwOBkBXqlNp3oZpVfLkOaa3EaPidb GEHr6tArjGf+p121ub3Esum9ukA6ELNZKgU1aaIN/bKJRZPsXliq0mJYUkmbYDbEs5KW 3sVA== X-Gm-Message-State: ACgBeo1Um2tW1O7fVdIw33kNYUPx2PjIrdT611ad1cxoukHDtNiYhWFU Y/rrQrOrqKFHI1SeTfsaOvsXb7DM9imriA== X-Google-Smtp-Source: AA6agR7oahz66TXK+4xNXwJ7WBweepHiLx1X956pR6Ll0CKUFsU/T6iafnKR0xdF0fNekUNxKpZZ6A== X-Received: by 2002:a05:6512:12c5:b0:48c:df54:a41a with SMTP id p5-20020a05651212c500b0048cdf54a41amr987403lfg.464.1660299079802; Fri, 12 Aug 2022 03:11:19 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id v4-20020a05651203a400b0048b17ecee71sm154675lfp.302.2022.08.12.03.11.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 03:11:19 -0700 (PDT) Date: Fri, 12 Aug 2022 13:11:16 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/7] clk: cdce925: simplify using devm_regulator_get_enable() Message-ID: <18255e2d364e19d4a4ba6c6329892a7a77c92ecd.1660292316.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="7YgUNn3cJXMVqVHU" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --7YgUNn3cJXMVqVHU Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Simplify the driver using devm_regulator_get_enable() instead of open-coding the devm_add_action_or_reset(). A (minor?) functional change is that we don't print an error in case of a deferred probe. Now we also print the error no matter which of the involved calls caused the failure. Signed-off-by: Matti Vaittinen --- RFCv1 =3D> v2: - No changes --- drivers/clk/clk-cdce925.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/clk/clk-cdce925.c b/drivers/clk/clk-cdce925.c index ef9a2d44e40c..6350682f7e6d 100644 --- a/drivers/clk/clk-cdce925.c +++ b/drivers/clk/clk-cdce925.c @@ -603,28 +603,15 @@ of_clk_cdce925_get(struct of_phandle_args *clkspec, v= oid *_data) return &data->clk[idx].hw; } =20 -static void cdce925_regulator_disable(void *regulator) -{ - regulator_disable(regulator); -} - static int cdce925_regulator_enable(struct device *dev, const char *name) { - struct regulator *regulator; int err; =20 - regulator =3D devm_regulator_get(dev, name); - if (IS_ERR(regulator)) - return PTR_ERR(regulator); - - err =3D regulator_enable(regulator); - if (err) { - dev_err(dev, "Failed to enable %s: %d\n", name, err); - return err; - } + err =3D devm_regulator_get_enable(dev, name); + if (err) + dev_err_probe(dev, err, "Failed to enable %s:\n", name); =20 - return devm_add_action_or_reset(dev, cdce925_regulator_disable, - regulator); + return err; } =20 /* The CDCE925 uses a funky way to read/write registers. Bulk mode is --=20 2.37.1 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --7YgUNn3cJXMVqVHU Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmL2J0MACgkQeFA3/03a ocVv2QgAo/YlNOW1HA2mG+CxYq7xFKcBzQbPKj/51C44Hv7PuOZ9qYKQl2y0ALO2 W9nyE1+wXsUrxSpRSh3RR84zgGGTiTVoZcSwjvgWhsd/DFQRRM+tYwdVCvCxuHK9 eAAEN+/nNjDmsBlWtCP/6+3ET6F5AyOvkqw9MFQK1qS9UxErBIT9PESsvFNcPv9z fmvywKBtskYFk1KKsVEJcg1Fjj01MsV7IjagPW9O25cXGLtWAoi54Zr7TpnWrMw/ 335TVbgmXr0NKguxFMGICeYv8lIsO2fEycNIEazSjI//t4UebsJUK1Ah/RFOwFBA OZUe74M3LJAT+rE9WV/YV2RYnAYhBA== =ZUnt -----END PGP SIGNATURE----- --7YgUNn3cJXMVqVHU-- From nobody Mon Apr 13 10:34:42 2026 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 420F8C00140 for ; Fri, 12 Aug 2022 10:12:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238167AbiHLKMH (ORCPT ); Fri, 12 Aug 2022 06:12:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238109AbiHLKLi (ORCPT ); Fri, 12 Aug 2022 06:11:38 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A59E1AB1A9 for ; Fri, 12 Aug 2022 03:11:34 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id u3so702076lfk.8 for ; Fri, 12 Aug 2022 03:11:34 -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=6aDzddAdi44gYxrtGzveI8akk+ZLwKh2Jsp1l+35n5M=; b=Q+3sLXPMIeE2lr8ycY3m5xLmWKjUKdY+/y2OWnnTBfTY4EuhUxMHlTfjcNOi1HTbkt 3dBmfvGNeHbZ0HbmM4st2HjDTDHYu26MMAOXD6OJEcfS/HQvuSBlinhjrPCQc1mAqJzd POaxkLRQGk9/fw/H6a1YB80KUrRYJvylB2tJhxXxE15r5GZhc+HhE9QVhGE8b4MG503F JAEG67em8oUa4w0Vutxw67ugsmfW8GyNxbRDSL37q+XW1toBFfJoB+n00OG64sHSXULS 4x0NYx2TlidOqAM+vExwUDYG85Yi5K6zRZhN8Ac0nuQFwxwhHWesDxw1H5+MFcsiKa6c iFQA== 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=6aDzddAdi44gYxrtGzveI8akk+ZLwKh2Jsp1l+35n5M=; b=i4qL2VHXiKLDQvmt9UBrB4hSmfSIpa5QQFAo7e+A2xo3ZXcWb+0St2YNpz7SZ8PrD1 o7IyzaLF96O1ZDX754yCaxF6DMuLIRz7/efLf/P9847F5+1xA/Dklk3Vp0zbdILJJMUe UNp2zPy4o67ibdLJHu3JXDIkEGhhbsgQkOQbgdY9J+ZYom7YMSyPGq1pzLbgjtRKODI7 eVM1E6/yn/dMvwZgyawOaRcVhHu8LNizhsHxBmmdzGHfpeVGp9+q2p4hf1QjHzaEqUBG NDayflays4S2TgZ/o9L1n9GJUKCs4cse+AyONyuK9ACu2B7mqbN7LDUiPtxcHAxKAHSu eiZw== X-Gm-Message-State: ACgBeo05U8CsrfyeT+NnPvPkx7yAG17lyO3Fp5Mu9vM4/4ZccveePTts CJzXpmz4eY6OpDtUqIRTSrs= X-Google-Smtp-Source: AA6agR5pNSqr97WKqmglCzCsOwtkCD5QhIzi4+k+Y/zOxRe9qNoFU4jVUA/TOBFEMWXyD+dQOb+w0Q== X-Received: by 2002:a05:6512:3403:b0:48c:9727:50b0 with SMTP id i3-20020a056512340300b0048c972750b0mr972034lfr.309.1660299094169; Fri, 12 Aug 2022 03:11:34 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id t13-20020a056512068d00b0048b052a7980sm160143lfe.168.2022.08.12.03.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 03:11:33 -0700 (PDT) Date: Fri, 12 Aug 2022 13:11:29 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Liam Girdwood , Mark Brown , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 5/7] gpu: drm: simplify drivers using devm_regulator_*get_enable*() Message-ID: <986ab4650ee4fb6fa9ec1a813152ac36da6119ce.1660292316.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ZglrX0HKdtncVIEd" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --ZglrX0HKdtncVIEd Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Simplify drivers using managed "regulator get and enable". meson: Use the devm_regulator_get_enable_optional(). Also drop the seemingly unused struct member 'hdmi_supply'. sii902x: Simplify using devm_regulator_bulk_get_enable() Signed-off-by: Matti Vaittinen --- RFCv1 =3D> v2: - Change also sii902x to use devm_regulator_bulk_get_enable() Please note - this is only compile-tested due to the lack of HW. Careful review and testing is _highly_ appreciated. --- drivers/gpu/drm/bridge/sii902x.c | 22 +++------------------- drivers/gpu/drm/meson/meson_dw_hdmi.c | 23 +++-------------------- 2 files changed, 6 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii9= 02x.c index 65549fbfdc87..4bf572b7ca77 100644 --- a/drivers/gpu/drm/bridge/sii902x.c +++ b/drivers/gpu/drm/bridge/sii902x.c @@ -170,7 +170,6 @@ struct sii902x { struct drm_connector connector; struct gpio_desc *reset_gpio; struct i2c_mux_core *i2cmux; - struct regulator_bulk_data supplies[2]; bool sink_is_hdmi; /* * Mutex protects audio and video functions from interfering @@ -1070,6 +1069,7 @@ static int sii902x_probe(struct i2c_client *client, struct device *dev =3D &client->dev; struct device_node *endpoint; struct sii902x *sii902x; + static const char * const supplies[] =3D {"iovcc", "cvcc12"}; int ret; =20 ret =3D i2c_check_functionality(client->adapter, @@ -1120,27 +1120,13 @@ static int sii902x_probe(struct i2c_client *client, =20 mutex_init(&sii902x->mutex); =20 - sii902x->supplies[0].supply =3D "iovcc"; - sii902x->supplies[1].supply =3D "cvcc12"; - ret =3D devm_regulator_bulk_get(dev, ARRAY_SIZE(sii902x->supplies), - sii902x->supplies); - if (ret < 0) - return ret; - - ret =3D regulator_bulk_enable(ARRAY_SIZE(sii902x->supplies), - sii902x->supplies); + ret =3D devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(supplies), supplie= s); if (ret < 0) { dev_err_probe(dev, ret, "Failed to enable supplies"); return ret; } =20 - ret =3D sii902x_init(sii902x); - if (ret < 0) { - regulator_bulk_disable(ARRAY_SIZE(sii902x->supplies), - sii902x->supplies); - } - - return ret; + return sii902x_init(sii902x); } =20 static int sii902x_remove(struct i2c_client *client) @@ -1150,8 +1136,6 @@ static int sii902x_remove(struct i2c_client *client) =20 i2c_mux_del_adapters(sii902x->i2cmux); drm_bridge_remove(&sii902x->bridge); - regulator_bulk_disable(ARRAY_SIZE(sii902x->supplies), - sii902x->supplies); =20 return 0; } diff --git a/drivers/gpu/drm/meson/meson_dw_hdmi.c b/drivers/gpu/drm/meson/= meson_dw_hdmi.c index 5cd2b2ebbbd3..7642f740272b 100644 --- a/drivers/gpu/drm/meson/meson_dw_hdmi.c +++ b/drivers/gpu/drm/meson/meson_dw_hdmi.c @@ -140,7 +140,6 @@ struct meson_dw_hdmi { struct reset_control *hdmitx_apb; struct reset_control *hdmitx_ctrl; struct reset_control *hdmitx_phy; - struct regulator *hdmi_supply; u32 irq_stat; struct dw_hdmi *hdmi; struct drm_bridge *bridge; @@ -665,11 +664,6 @@ static void meson_dw_hdmi_init(struct meson_dw_hdmi *m= eson_dw_hdmi) =20 } =20 -static void meson_disable_regulator(void *data) -{ - regulator_disable(data); -} - static void meson_disable_clk(void *data) { clk_disable_unprepare(data); @@ -723,20 +717,9 @@ static int meson_dw_hdmi_bind(struct device *dev, stru= ct device *master, meson_dw_hdmi->data =3D match; dw_plat_data =3D &meson_dw_hdmi->dw_plat_data; =20 - meson_dw_hdmi->hdmi_supply =3D devm_regulator_get_optional(dev, "hdmi"); - if (IS_ERR(meson_dw_hdmi->hdmi_supply)) { - if (PTR_ERR(meson_dw_hdmi->hdmi_supply) =3D=3D -EPROBE_DEFER) - return -EPROBE_DEFER; - meson_dw_hdmi->hdmi_supply =3D NULL; - } else { - ret =3D regulator_enable(meson_dw_hdmi->hdmi_supply); - if (ret) - return ret; - ret =3D devm_add_action_or_reset(dev, meson_disable_regulator, - meson_dw_hdmi->hdmi_supply); - if (ret) - return ret; - } + ret =3D devm_regulator_get_enable_optional(dev, "hdmi"); + if (ret !=3D -ENODEV) + return ret; =20 meson_dw_hdmi->hdmitx_apb =3D devm_reset_control_get_exclusive(dev, "hdmitx_apb"); --=20 2.37.1 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --ZglrX0HKdtncVIEd Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmL2J1AACgkQeFA3/03a ocXSqAf/VegCKp8gEwmyftaqdq9aTM7DX2Kktp0s+iK2JcKZ7zLzga4D3RRXlXs/ CsdpQ2uBx/lHbDi4leEwpCHSabV6AGBHxzGHbuyMckWRak46bOwuybhU/6AZqwNW QH9sNCqUDjVRqXQ9kpoejELJXJOIts6bDQ12WQHHAv5r5nIyz5Qv4hfIJMUF4AhF /RLkgLwj+hEpC+Kk0M8m+q/Gu+vdZO7HuZZYIXO8CxnOSYVsySL1COkHDj1+tkPh NR6XoM8p8LxFzX1HvZM14sonIc6Fok0qIbUDUwELlin8YKMtsWNivVRjv7xiHQva skZaRpV8t4qzAvHQOAt9hHy027E3Cg== =TFoX -----END PGP SIGNATURE----- --ZglrX0HKdtncVIEd-- From nobody Mon Apr 13 10:34:42 2026 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 045C5C25B0F for ; Fri, 12 Aug 2022 10:12:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232010AbiHLKMZ (ORCPT ); Fri, 12 Aug 2022 06:12:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238164AbiHLKLz (ORCPT ); Fri, 12 Aug 2022 06:11:55 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DC517E817; Fri, 12 Aug 2022 03:11:53 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id d14so679220lfl.13; Fri, 12 Aug 2022 03:11: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=dwxBURFo8GfnRI0NoBKurAx1Epv/InunwJ0Fniey2+M=; b=isxZWuJD6JPjv4gSweEK+c6jx0jXPontIi3rfRMQZeZLaKnP8Wpj3sQq7uY3+GxipH Hh4ereoCyP/uGczAlUx3QBGDFSxPFBgHXTxjCvGylL3jYcJnRzkZ6aAH+PDH5CS+F/Bq mgTS84oc373yZtxsn8AKXTWtdS2lHt3X6AWU8E46DdgSYYHvwmVKXtDNAgyyZBJg/9/s 2HGEmfZlYeToj1K84q1q9CjsEO1WHpWFHYWuRFUbXPwvBB3dWS/noTL/Ik8YW5LxBvfa oLMX9s3Fe9EFc5jJYPLphQ8DfjGf5woinm7MBoX7uT6i4lYU2vAgKKsTbXgN2Ka/kufT maMQ== 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=dwxBURFo8GfnRI0NoBKurAx1Epv/InunwJ0Fniey2+M=; b=s5AbwTALOFdIBuSB9RRgNUyfbmlq1vqbk5I/NWZSsW8Sm1wt3+HEnAe2kMd5/Q71wY Cq5CN7qxymOBOvFYwxeVfgmx62rnSbAhS4ZZOW34ERzAZ2Fvp6Z5oAAYDGYE2M0KVNWL k2hmuNjE5menSJB4KalULU2Mx7LAg6ZlkAaOoMfWQDXAX7TpPMknZkUU/o9dVukwdoTV ZJ4jMT+u0MJH6FZmnpzglqvbnCNsuOiXVPCuDRWFORZWnN3LppIpGucCAc/xDcuxuiOD WSRT7QpdF6Jvp+G2sJkSyj4qLYQtJdJ7N3bvoNdtZaqC8oQMFxkknniPY1QqvoTQ53Hv XxSQ== X-Gm-Message-State: ACgBeo1Icrjh7unT3lKn8FsWSVB+8AdyBO9Q7RcJc7HNGJ71QaAaJ5i2 i5cCS+mjG15NdzYEIFbfLe8= X-Google-Smtp-Source: AA6agR4eoBbZjCh+vk3G97u9WdjS4o7HVHcVMu3O5LRnkhbK2DM8Ty4q8UTMBXM32zG5rbvfQD3REw== X-Received: by 2002:ac2:418a:0:b0:48b:aa2:1d9f with SMTP id z10-20020ac2418a000000b0048b0aa21d9fmr1147227lfh.195.1660299111725; Fri, 12 Aug 2022 03:11:51 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id b14-20020ac25e8e000000b0048b365176d9sm155517lfq.286.2022.08.12.03.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 03:11:49 -0700 (PDT) Date: Fri, 12 Aug 2022 13:11:46 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 6/7] hwmon: lm90: simplify using devm_regulator_get_enable() Message-ID: <8959965542d71bb5ea5a928b539ff804eaa58f42.1660292316.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="MQq/gT6q2s4rf3c5" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --MQq/gT6q2s4rf3c5 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Drop open-coded pattern: 'devm_regulator_get(), regulator_enable(), add_action_or_reset(regulator_disable)' and use the devm_regulator_get_enable(). Signed-off-by: Matti Vaittinen Acked-by: Guenter Roeck --- RFCv1 =3D> v2: - No changes --- drivers/hwmon/lm90.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 3820f0e61510..2ab561ec367c 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c @@ -1848,12 +1848,6 @@ static void lm90_remove_pec(void *dev) device_remove_file(dev, &dev_attr_pec); } =20 -static void lm90_regulator_disable(void *regulator) -{ - regulator_disable(regulator); -} - - static const struct hwmon_ops lm90_ops =3D { .is_visible =3D lm90_is_visible, .read =3D lm90_read, @@ -1865,24 +1859,13 @@ static int lm90_probe(struct i2c_client *client) struct device *dev =3D &client->dev; struct i2c_adapter *adapter =3D client->adapter; struct hwmon_channel_info *info; - struct regulator *regulator; struct device *hwmon_dev; struct lm90_data *data; int err; =20 - regulator =3D devm_regulator_get(dev, "vcc"); - if (IS_ERR(regulator)) - return PTR_ERR(regulator); - - err =3D regulator_enable(regulator); - if (err < 0) { - dev_err(dev, "Failed to enable regulator: %d\n", err); - return err; - } - - err =3D devm_add_action_or_reset(dev, lm90_regulator_disable, regulator); + err =3D devm_regulator_get_enable(dev, "vcc"); if (err) - return err; + return dev_err_probe(dev, err, "Failed to enable regulator\n"); =20 data =3D devm_kzalloc(dev, sizeof(struct lm90_data), GFP_KERNEL); if (!data) --=20 2.37.1 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --MQq/gT6q2s4rf3c5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmL2J2EACgkQeFA3/03a ocXWzwgAx00ve0BRtfmRxnMqjlBzkRl0AnPA9SRGeZzAogR0YXxGUzT4Fp/r4E1S DEnAg886PdzUfTHk5bdQ2FeWzCxLLEFAr8kIVq+AC38dPDGCKQnZO1fx4Sgfqkuz hE3qxt+hwtMuVFm1kT9yjXdvI6FLzknJe6bRqePqi5cRkJZnsn2bHAJGdmlrC1Vk FvIdYfkfcAqe1dbJkvGphq+veDqZuYTg/Wim7bLKPcCheGjf59XEMOyL1haYAJwx odKFuxOemlwTxyP/PruF+uSauWP86JQMyDWuBCCPcwVXH5TmZmnzdwkpTUdc7Cu7 X57ydTmuqsNnMSeO2T4zvyFfHzW9TQ== =JoAl -----END PGP SIGNATURE----- --MQq/gT6q2s4rf3c5-- From nobody Mon Apr 13 10:34:42 2026 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 0917BC00140 for ; Fri, 12 Aug 2022 10:12:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238199AbiHLKMu (ORCPT ); Fri, 12 Aug 2022 06:12:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238186AbiHLKMP (ORCPT ); Fri, 12 Aug 2022 06:12:15 -0400 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52FC7AB43C; Fri, 12 Aug 2022 03:12:10 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id u1so721174lfq.4; Fri, 12 Aug 2022 03:12:09 -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=DeD431ghxLD17wCgiWSV6MzDX9uBGSE2qzGxwjVq9ao=; b=FVLMV6OrkixVc9xqZyTFxZ6fDC4wdgglZqQWmPC0gadPUxdsibc8yAymFp/f9fZ6qo MA9WYi0FCl4LVSjs+akVCpLHqNirqxOnQyyrA8WdaJKt0AJPDOSBzL3uNrv5y5IRIDEg QdA/skH1xWk/JYe924m+6Id0qZwQCGcmH2y62OkGuLJhglzcIQ8VwVmJ3/xNqCyJ5HVI a7sPayaWEvmjpvPzgJySMbEV/OKPejNwCbT5X+aswGPfGZHuJXadw13LlIHAKC/3dnR4 kc6Nq3ruIInwKR4khTznbYKAwMqiTRzzPLhbQoityr3PiyIxEWuE6GRJ8nW4A2P3NYIz H/yw== 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=DeD431ghxLD17wCgiWSV6MzDX9uBGSE2qzGxwjVq9ao=; b=K5f2oh68l8mk8aY+FDKgbFWYbavoTZVcMhO1/4tiRWFw0SMwNluaNFDZ/TpxCq7Ran /FQ17Ho2OvtwuULmvHMoa2FSdBXXnV1rHyaoRqvPAf5G7CrR7wBBg5VNtL9LsvfZsmq0 ykywDmZX0xrs+LdjGbdyDIENwkV7K3JJSLZAbOY3cHDTpgujcAfrwTyu0+ACJS33EW4c FlHDuWFY4pHSFbc+UYEUQMALPOs1I1H7dEX/ax06SPAjvlfAedmhrqISQOvf/9p1IwKA 4RK8EEbVvqPt7zHgIPNvpCGy8C2+pe+se6sIOVDKmGXQB6UM6vIOBUkLgWVCIXncPSWt 3obQ== X-Gm-Message-State: ACgBeo0OuYr+pVeOEgLJ/T8DeRsDkW5gORJgaTkg8Zc7yfqHfJN/i/hI JH3sse+GBdzRkfo6kCOxYza1DhCuh+4+ew== X-Google-Smtp-Source: AA6agR7u7LbwWwJWt0KfxYKaZu/OiJn6LdLRjYedua1UfKa+8e1lE1IF9M/JPZzPYRHAmmjt7OQ4fA== X-Received: by 2002:a19:5e49:0:b0:48a:7697:ddb1 with SMTP id z9-20020a195e49000000b0048a7697ddb1mr1085776lfi.323.1660299128266; Fri, 12 Aug 2022 03:12:08 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id 10-20020ac2484a000000b0048af7e58c9dsm156345lfy.278.2022.08.12.03.12.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 03:12:06 -0700 (PDT) Date: Fri, 12 Aug 2022 13:12:02 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Alexandru Tachici , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Nuno =?iso-8859-1?Q?S=E1?= , Lorenzo Bianconi , Matti Vaittinen , Andy Shevchenko , Miaoqian Lin , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 7/7] iio: Simplify drivers using devm_regulator_*get_enable() Message-ID: <13bb483e1f3ee003ca3a6949e27eee7f505e047d.1660292316.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="SnNffchV/nAgRcji" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --SnNffchV/nAgRcji Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" adc/ad7192: Use devm_regulator_get_enable() instead of open coded get, enable, add-action-to-disable-at-detach - pattern. Also drop the seemingly unused struct member 'dvdd'. dac/ltc2688: gyro/bmg160_core: Use devm_regulator_bulk_get_enable() instead of open coded bulk-get, bulk-enable, add-action-to-disable-at-detach - pattern. imu/st_lsm6dsx: 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 --- RFCv1 =3D> v2: Squashed all IIO changes to one patch. Added use of devm_regulator_bulk_get_enable(). Please note - this is only compile-tested due to the lack of HW. Careful review and testing is _highly_ appreciated. --- drivers/iio/adc/ad7192.c | 15 ++-------- drivers/iio/dac/ltc2688.c | 23 ++------------- drivers/iio/gyro/bmg160_core.c | 24 ++-------------- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 2 -- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 30 ++++---------------- 5 files changed, 13 insertions(+), 81 deletions(-) diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c index d71977be7d22..8a52c0dec3f9 100644 --- a/drivers/iio/adc/ad7192.c +++ b/drivers/iio/adc/ad7192.c @@ -177,7 +177,6 @@ struct ad7192_chip_info { struct ad7192_state { const struct ad7192_chip_info *chip_info; struct regulator *avdd; - struct regulator *dvdd; struct clk *mclk; u16 int_vref_mv; u32 fclk; @@ -1015,19 +1014,9 @@ static int ad7192_probe(struct spi_device *spi) if (ret) return ret; =20 - st->dvdd =3D devm_regulator_get(&spi->dev, "dvdd"); - if (IS_ERR(st->dvdd)) - return PTR_ERR(st->dvdd); - - ret =3D regulator_enable(st->dvdd); - if (ret) { - dev_err(&spi->dev, "Failed to enable specified DVdd supply\n"); - return ret; - } - - ret =3D devm_add_action_or_reset(&spi->dev, ad7192_reg_disable, st->dvdd); + ret =3D devm_regulator_get_enable(&spi->dev, "dvdd"); if (ret) - return ret; + return dev_err_probe(&spi->dev, ret, "Failed to enable specified DVdd su= pply\n"); =20 ret =3D regulator_get_voltage(st->avdd); if (ret < 0) { diff --git a/drivers/iio/dac/ltc2688.c b/drivers/iio/dac/ltc2688.c index 937b0d25a11c..1abc88cd99f9 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, str= uct regulator *vref) LTC2688_CONFIG_EXT_REF); } =20 -static void ltc2688_disable_regulators(void *data) -{ - struct ltc2688_state *st =3D 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 =3D &spi->dev; int ret; + static const char * const regulators[] =3D {"vcc", "iovcc"}; =20 indio_dev =3D 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"); =20 - st->regulators[0].supply =3D "vcc"; - st->regulators[1].supply =3D "iovcc"; - ret =3D 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 =3D regulator_bulk_enable(ARRAY_SIZE(st->regulators), st->regulators); + ret =3D devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators), + regulators); if (ret) return dev_err_probe(dev, ret, "Failed to enable regulators\n"); =20 - ret =3D devm_add_action_or_reset(dev, ltc2688_disable_regulators, st); - if (ret) - return ret; - vref_reg =3D devm_regulator_get_optional(dev, "vref"); if (IS_ERR(vref_reg)) { if (PTR_ERR(vref_reg) !=3D -ENODEV) diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c index 81a6d09788bd..acfabac645b6 100644 --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c @@ -93,7 +93,6 @@ =20 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); } =20 -static void bmg160_disable_regulators(void *d) -{ - struct bmg160_data *data =3D 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[] =3D {"vdd", "vddio"}; =20 indio_dev =3D devm_iio_device_alloc(dev, sizeof(*data)); if (!indio_dev) @@ -1090,22 +1083,11 @@ int bmg160_core_probe(struct device *dev, struct re= gmap *regmap, int irq, data->irq =3D irq; data->regmap =3D regmap; =20 - data->regulators[0].supply =3D "vdd"; - data->regulators[1].supply =3D "vddio"; - ret =3D devm_regulator_bulk_get(dev, ARRAY_SIZE(data->regulators), - data->regulators); + ret =3D devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators), + regulators); if (ret) return dev_err_probe(dev, ret, "Failed to get regulators\n"); =20 - ret =3D regulator_bulk_enable(ARRAY_SIZE(data->regulators), - data->regulators); - if (ret) - return ret; - - ret =3D devm_add_action_or_reset(dev, bmg160_disable_regulators, data); - if (ret) - return ret; - ret =3D iio_read_mount_matrix(dev, &data->orientation); if (ret) return ret; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_l= sm6dsx/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; =20 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 910397716833..7b40f6b58834 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_h= w *hw) =20 static int st_lsm6dsx_init_regulators(struct device *dev) { - struct st_lsm6dsx_hw *hw =3D dev_get_drvdata(dev); int err; - /* vdd-vddio power regulators */ - hw->regulators[0].supply =3D "vdd"; - hw->regulators[1].supply =3D "vddio"; - err =3D 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[] =3D {"vdd", "vddio"}; =20 - err =3D regulator_bulk_enable(ARRAY_SIZE(hw->regulators), - hw->regulators); - if (err) { - dev_err(dev, "failed to enable regulators: %d\n", err); - return err; - } + err =3D devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators), + regulators); + if (err) + return dev_err_probe(dev, err, "failed to enable regulators\n"); =20 msleep(50); =20 return 0; } =20 -static void st_lsm6dsx_chip_uninit(void *data) -{ - struct st_lsm6dsx_hw *hw =3D 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, in= t hw_id, if (err) return err; =20 - err =3D devm_add_action_or_reset(dev, st_lsm6dsx_chip_uninit, hw); - if (err) - return err; - hw->buff =3D devm_kzalloc(dev, ST_LSM6DSX_BUFF_SIZE, GFP_KERNEL); if (!hw->buff) return -ENOMEM; --=20 2.37.1 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --SnNffchV/nAgRcji Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmL2J3IACgkQeFA3/03a ocW2Ugf9GtyiWREszLlcfd7XlOiqb0aI8GXb9PRuL4pev4jWGaTsClRml6uKBlVw RQKfdrZrBrjfWhO6Ack3P5avUozowABn6AIyxR3iWldnFH7jF4/UAr6Q6LaRurMM N9WkwgAFi86+ZGxbdM7r24liigHd2ltZnt8OQ0FEQSyFyvu/9Co7UrJ3eWdOYNmm QKS+EJZTMC2TpSI0dLgVH6F9p3M53RN55hTwq4dNN/RKyLlmcq3xUHP+mfjDsoRa 4y7k6xHFU5ZTDWOq/PLjHTLjUCEGPv69ry0ezJ+JunAXwlq8q9B9w3Z+T9v5scBk C2H0r3mup7RobLyOxbv7Q4rDeYG25w== =xFzp -----END PGP SIGNATURE----- --SnNffchV/nAgRcji--