From nobody Mon Apr 13 10:20:06 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 CE1A1C00140 for ; Wed, 10 Aug 2022 11:29:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231991AbiHJL3q (ORCPT ); Wed, 10 Aug 2022 07:29:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232106AbiHJL3k (ORCPT ); Wed, 10 Aug 2022 07:29:40 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 765E96F546; Wed, 10 Aug 2022 04:29:39 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id d14so20764109lfl.13; Wed, 10 Aug 2022 04:29: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=zyQncW0FI88VXCnhEMRRxk76nEkFXEItNVzGssoDpEc=; b=pGCX3jZR6L4dwd5GUK5HlMvpSN9kZZFQqmCnJg6p+fjhVdpRx63Kkw27pANqW854YC k8+0anm8I6jlPwabkd2ACE+1WF78jotyaCmCnRvg+PxaD8ZttYR66oGMJhnky9DtasRk /XJIRgg4LWB54EolltMdv7NJiaJ/Ndabri3jAkOzUadwgCVcTuPnyZ5bfa9ElCAEstLd fL6fFNziP67gQagP9gJioSbpK6bc3/mBgANT28Br0A7pjGbNnUnC3TLtCXP0YbmNfdea hucNdep3dcVjaGYfmBQfk9LHFDBmrviTBW03/6S+CI1KOoXglzFHzPFHlEYSNMuoQ3Mm Q84Q== 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=zyQncW0FI88VXCnhEMRRxk76nEkFXEItNVzGssoDpEc=; b=l8uhfeX/EylbEY8TaypfIZv7iJQA3IzqnEmgg6ORQQpUAP3HHZIWy+cObslN9gNhHQ UczjLb3UWySehQFRhImvg/HzHZhqKk78TsH1BAJUdDNLtYQH/Ey+mNCDs4DiFYiH2N6P 8bDDlghfILKtLkrtN1HUZc/yxh0yZgfyD5K6lyC/aWFwBM3iGJxmNl1rAx10YTqYlk79 g7C+Yvufcn2SBnRoRe6yydpYcnUfUYLHuu0khnqv6aFATvHNOaQIbXC7sUS9gJXzuvyL 0kNWL6I5v5kqVCd6xyma4mnfyFuWl8tksNibe1AEKgRkdgkoPZsGnTY5Bj1/dJBeHsiD c2Wg== X-Gm-Message-State: ACgBeo3WMvtLzhlhguuPbkXi75qQ9jsbKi78mtx1zlgtVHd9ApWat+BK 2c2EHlny8ttOha1h40MyPmg= X-Google-Smtp-Source: AA6agR7nUCE9WDtimgmPGy6/vwoHYHIQrllNUBcKiuBtxVNqgo/Ek7dorqsX0BPq333hWX32VRfxTw== X-Received: by 2002:ac2:4e07:0:b0:48a:f6f2:8555 with SMTP id e7-20020ac24e07000000b0048af6f28555mr8913936lfr.200.1660130977716; Wed, 10 Aug 2022 04:29:37 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id c26-20020ac25f7a000000b0048d2547b3a5sm194525lfc.147.2022.08.10.04.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 04:29:36 -0700 (PDT) Date: Wed, 10 Aug 2022 14:29:15 +0300 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Cc: Jonathan Corbet , Liam Girdwood , Mark Brown , Matti Vaittinen , Peter Rosin , Jonathan Cameron , Alexandru Ardelean , Aswath Govindraju , Johan Hovold , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/7] docs: devres: regulator: Add missing devm_* functions to devres.rst Message-ID: <8f8d755d573080144a8b9369d05b71dda2165106.1660127865.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="K/Mcy/68muy1+BEu" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --K/Mcy/68muy1+BEu 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 --- 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 (which is just an RFC atm). 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 --K/Mcy/68muy1+BEu Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmLzlooACgkQeFA3/03a ocXb9Qf/cIT21tEv7nNH0U2HyoG3MYG+kcR9gXgRYDOgwac0KPZv4P8JtusxiRzR 19Pg4Yl1jFLkTPxtP1+ANFakSEd5LeOBDEUNG+LW6Es0KViqCUAG5DyDBmbhiF1C yrnS1Cellp4nHZ+5GugecKO1524VLPQMlsYOABxggMzG+6wtYb7FL7Le74K+Yx7k 3PcXj2T3unrkyJ+dIscs77KcZfkwKfPbRqgNQdANc4frpyUbMAVCnQio2b83rItE 0OOOInzEMyD7SEAUxr9vV4t+2/yr/wZzaI/byC/NKahfRYYuO9aU+xXnJjMvxlIj b4QCYUixBYJ9ere6Fu/yawizzZ7DUg== =Jefo -----END PGP SIGNATURE----- --K/Mcy/68muy1+BEu-- From nobody Mon Apr 13 10:20:06 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 CD71FC00140 for ; Wed, 10 Aug 2022 11:30:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232054AbiHJLaY (ORCPT ); Wed, 10 Aug 2022 07:30:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232038AbiHJLaU (ORCPT ); Wed, 10 Aug 2022 07:30:20 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E36FA12A95 for ; Wed, 10 Aug 2022 04:30:18 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id v2so12168788lfi.6 for ; Wed, 10 Aug 2022 04:30:18 -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=SFoCwOXNr0V39FyKhCLQaYvVdFKqeXujdHzvpYNfbIQ=; b=l3jmBboJ998Hwr8yFQDRZhKEuNZgIIS35r9X9X8IT4vtg60yZOLMJ8Q9RRkIeQLRSS /ZfP/Enp5O5LxEmlGQtm57Xc9U8IV5WXq4nDJz5IP8iwHhfLEgfS5lnaTaF1LxXr3p6u zo2SO+LUsfSj9LkwPzuCAfRla49YRRHvJ6qloGUKVzjvFYG77DtPDI/5QEBDmCPBAAS8 YEo1YTGl1cTI1dUCuo+HR2vc5X9fteC0UjIXL8VMS4JrwzBTjCdwVnkMVcerybpgWJ03 6LaRwpAqLoBmf87+2ZWOSl+kb+e8qYOaSHH7vl0aT2vf9VP9UvHoUKdUblmVsRfT+4qm 43Vg== 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=SFoCwOXNr0V39FyKhCLQaYvVdFKqeXujdHzvpYNfbIQ=; b=NPRpWhPwUxIoZHBCmq/Ix1lt/kF7eAgYmvnSXAtMh0pItMq8BDz20Buqyadr6YhNMq wI2IvU3dZrXoXBSkT/SJTOhqyQlJCyxdAKOoDlezBOqyl6ErkUnMpjqC8w3PxvwEbOtP i1DpHwUBAsRbBNEMSKSYjIdppgGfiox9Gm5XJWOzbPg6xnN/k8zhx1eJn6MfjiLjFeXu Ayi7qzJWVe/J5OIz6G4QfD+f3/ipiSUwUUEwNCbKR2IMOtIEjgBRNM6melvua6CFgMcW JAo+e9HcVyG3Cd64a2ifXXGgm5n+gP20iyu541eDg4B0l5UnE5qDa37r0nD5RUvh6PI+ yzqw== X-Gm-Message-State: ACgBeo0pnqoC71ABy/9UozLXePBHQvGhaEXLq3TGyP+3l6+qXWglGw+K wIzxozSnR5YdQVbviWVnTxV2Gh+wbgK79A== X-Google-Smtp-Source: AA6agR75eRwjMdqZZsyN3FnDGrXo30NXB3d4aY6I3Mikcgb59H+oJRBURNwGvg31kMw89PO59+Hejw== X-Received: by 2002:a05:6512:3406:b0:48c:2e06:6c72 with SMTP id i6-20020a056512340600b0048c2e066c72mr6043502lfr.324.1660131017164; Wed, 10 Aug 2022 04:30:17 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id h28-20020a19ca5c000000b0048af3e54b47sm311069lfj.95.2022.08.10.04.30.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 04:30:16 -0700 (PDT) Date: Wed, 10 Aug 2022 14:29:55 +0300 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Cc: Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org Subject: [RFC PATCH 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="o0HAkEsHRf+3t9c6" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --o0HAkEsHRf+3t9c6 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 --- drivers/regulator/devres.c | 59 ++++++++++++++++++++++++++++++ include/linux/regulator/consumer.h | 13 +++++++ 2 files changed, 72 insertions(+) diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c index 9113233f41cd..61b0facc975b 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 diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/c= onsumer.h index bbf6590a6dec..58e3dbcddb12 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 @@ -346,6 +348,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) { --=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 --o0HAkEsHRf+3t9c6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmLzlrMACgkQeFA3/03a ocXljgf/dQYLub1c+SOBZGohlwrTURR/rcB4ZN0V8Ayk/fjdzVgvj4DNcdwvAcjv 8X0U57U6nwMIbo//vQ/cOZEEFP3sQLyv6vNx5CjFeSc37t9WfVQTdrUh3kQlbuXb yiEve1DcMDd8k4hC2aIJwkjlMNzpJPSWRsnXKko7cBfyM+OtvleIhzunJ+LHgVP9 zhAAhmybWYhHQWqOmvXNrctIEbZ8KdDokAkdlucJ1vdUmqrkSCUrRT5GIPmAvakD G3s3W+f/jUmBkzlcoUYJLuxxnkHjLnSTBQBluVA3Dtl/zrGI/VtqrCfGJXRJp/Cc mUJBV9rN2R6oI9/Gw/ZIBmnJm5F5Iw== =l/IP -----END PGP SIGNATURE----- --o0HAkEsHRf+3t9c6-- From nobody Mon Apr 13 10:20:06 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 2202BC25B08 for ; Wed, 10 Aug 2022 11:31:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232066AbiHJLb2 (ORCPT ); Wed, 10 Aug 2022 07:31:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232069AbiHJLaz (ORCPT ); Wed, 10 Aug 2022 07:30:55 -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 2F4AF75FE5; Wed, 10 Aug 2022 04:30:54 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id t1so20814336lft.8; Wed, 10 Aug 2022 04:30:54 -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=eB7oLoCQF6payCuc5mHfMzJURoGI/V0Crtv4U4P2dAI=; b=jw+YMrEl/xDtcCkzbVNModdhkasctgvd4R8F/uvn33TCxkX+hwPGiENWLDDcWV7kAG cYkRt5HOJZdUkwEUjkNv6WJo5l171joS98ni5erRsormwBzF7FGYkRbxDuZ79NR8uxAi RuSd2LBFGE1qOW5SE65EpMVyY8jNTglYfR2hgI44ZVPBecA7V94u/Cky8Pk1zW5j4q7V 0z7qLiUDEdGjmmHZj8dn73AwZA0m42JrmNjefT/i26Zgk5VldmU8thpLAgYR4nFZmXvo JdO4lmGwnrd3jqpxwNledgLr8aVcafZ/5z46W2+UBYsL6hR/0s2hYSZxsuC4BCkkZxIK s5eg== 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=eB7oLoCQF6payCuc5mHfMzJURoGI/V0Crtv4U4P2dAI=; b=rj163t9H1qByHt1ZosoVRDT3vA9USIVV+LIyDSK9FXdK89vTg8m4i9DScMZ9++rJ9o TQKnyo2Y6nnbiY5fuCb8uA2NTsmt5gk3LnUS6K8i3vV0Yzf0Z9f7DacyhRxJjjboNKQq FBiAkX5xLZhqt/SNc/7kGtXAcOPAf4FEDI5kp0m4/jmB9hHq8RBSxdxkPI+DkgCOvN1m ZWWRvlNjQAzLRLFZX10rT79nHKQ5FoR7aPyEZ3uwJaWUezIQf+R+CU1E/Uufzv3kGNBZ TZHeQRJPPpp2thTLxJ23oLK3YvxWhvnKBXo/q2DevCPk/WVTfh359Tt/WLoR7CH+UkhA Zs9Q== X-Gm-Message-State: ACgBeo3uH+AQGge83gb58vyqCkfVi1i42m3C3UdQNC9rQUw2w4ZhzOrS 8mS1ZATritlg/bwSJOR28Ew= X-Google-Smtp-Source: AA6agR7b7RztjkrU1SD51bchus+hJlyMSsls6cXl5Pq+GNFYFU/CdxrG1O0ZZCdJRM+AX+zvDwB9dg== X-Received: by 2002:ac2:4c4c:0:b0:48b:9780:2b3 with SMTP id o12-20020ac24c4c000000b0048b978002b3mr6500559lfk.682.1660131052543; Wed, 10 Aug 2022 04:30:52 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id d23-20020a056512369700b00489c6c76385sm304917lfs.268.2022.08.10.04.30.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 04:30:51 -0700 (PDT) Date: Wed, 10 Aug 2022 14:30:36 +0300 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Cc: Jonathan Corbet , Liam Girdwood , Mark Brown , Matti Vaittinen , Peter Rosin , Jonathan Cameron , Alexandru Ardelean , Aswath Govindraju , Johan Hovold , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 3/7] docs: devres: regulator: Add new get_enable functions to devres.rst Message-ID: <1f935c9ef14fd95663646c1dfd22483ac4b71fe1.1660127865.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="b5brqWRO9x+JmUFp" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --b5brqWRO9x+JmUFp 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 --- Documentation/driver-api/driver-model/devres.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/driver-api/driver-model/devres.rst b/Documentati= on/driver-api/driver-model/devres.rst index 271d1eb2234b..6ee8e9ab2478 100644 --- a/Documentation/driver-api/driver-model/devres.rst +++ b/Documentation/driver-api/driver-model/devres.rst @@ -409,6 +409,8 @@ REGULATOR devm_regulator_bulk_register_supply_alias() devm_regulator_bulk_get() 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 --b5brqWRO9x+JmUFp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmLzltwACgkQeFA3/03a ocWthwf/TFG58eWrBlE6Yb6BqzMfdJ4vdfY2vsp69hWKvC4iqjeJHjYDdpBisdwR OB4kNTr1sTHZYV5ZB30kHHdFvrIfsd+6btFKzcBa1CjgLZ3h9AJ0rRsXuaxhaTDV B/mz2U0vKaFPzuzS4HizIOGl73dvA7aoiKhdNIZeqgg5j5lWJwjUbtvUwMgIO1VB 4qFNTpdD23pxN8t1E/YHdh42nAFDG55p+IocqmMKn08FkSMbLu0BhHF/HUxoyh7U gZuFwijAM25W0KmUgOBHIOQfx+zngVyT+kQf2IjGzRvqPBPHBjyFSvkeVbIel8n5 cODNmCZorwBXEhGlHyUAtl3wVQZxHw== =eIgl -----END PGP SIGNATURE----- --b5brqWRO9x+JmUFp-- From nobody Mon Apr 13 10:20:06 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 D168EC25B08 for ; Wed, 10 Aug 2022 11:32:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232070AbiHJLcB (ORCPT ); Wed, 10 Aug 2022 07:32:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232068AbiHJLbe (ORCPT ); Wed, 10 Aug 2022 07:31:34 -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 7439D6DF96; Wed, 10 Aug 2022 04:31:33 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id x19so12538260lfq.7; Wed, 10 Aug 2022 04:31:33 -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=orgHsxCL/eDSeRNUzdbN1mK+oxAKvucrAmf97xEKdZ4=; b=aQBbvfoxFa5ZcvxCLanORYq1fw6LPa6LJS0OX6FJ0JtBpG5jUfth69xuLBOg1Pb36N W/3oXgvSrJxxSowDotXK1W7QR/tQX+wOJ3vc4ZGNP50sdBTohycLImlEEdHbKEBuf6MC JDEqLFaQ55xdrfizREF5egPILUc0JxUeBxHGr1fIVbur0jVNRixK97P/J6FvCi3W0bl/ nVGWZFxHEAsOeqCKKqYc0OzbCU9uunyxjcDwiCxvsWOMqVzjq8xc69l946Q6IWAuQHF9 xtbIuMg/I1lCvB7wvfHTh1n7CSw6HjBr/3kT7LuX25ZQH0TEdPtlJG17wzbGaE0jSWen f/Cg== 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=orgHsxCL/eDSeRNUzdbN1mK+oxAKvucrAmf97xEKdZ4=; b=nAkYku9lWJOk0KuKTmL2DIeq/QAXf9AHLU4gLL83+FgVLHfD26OE6gL25kA1NpQULJ ilUQLhyAxvIh1j21BgXostRqF6YGw3IXf3PO/iCcJ7mn5BsSFLRwhLEI4dZakuNNBOfC Ymz/LQ21n8aEc5Mp0Wc8kcvNvchcw3utwbVcLcL5P6RebbP7yPtqCiDqKpd9vX43Esnv fTnIcIhCXjfTLxG9MM3EHA3FBvQLamTatdOCkIJgoN8VQq8EJUD8s7u3yURTpLVUAS11 NuD6WZyrCgYnqGB2+Etd1yw1MWgcXvoUQjcX7cJC0Unc2Jafxz55FYKu1hIFMLTmn9CR Yr6w== X-Gm-Message-State: ACgBeo0BEIcXALls2yF3ryx48fM0NFYB0A1EXprdx9iEw9q7MqZqj68h CMaBpfDJ+4r+VEzJ+dQOHLCh6M+8xzhwgQ== X-Google-Smtp-Source: AA6agR7JBR57kzyt+os6biJsAEIfgSQ8d2KfZwIU6MqbBsmV7bTr8/YkqnI+aQiMYBwj/s8+hOWD6g== X-Received: by 2002:a05:6512:32c5:b0:48b:969a:9c24 with SMTP id f5-20020a05651232c500b0048b969a9c24mr6704678lfg.300.1660131091804; Wed, 10 Aug 2022 04:31:31 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id f18-20020a19ae12000000b0048b998be041sm300359lfc.309.2022.08.10.04.31.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 04:31:30 -0700 (PDT) Date: Wed, 10 Aug 2022 14:31:16 +0300 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Cc: Michael Turquette , Stephen Boyd , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 4/7] clk: cdce925: simplify using devm_regulator_get_enable() Message-ID: <7daaf2e66cc72d646e88a93e8cca39e104ef6505.1660127865.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="pjh2KveCiReW/EIb" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --pjh2KveCiReW/EIb 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 --- 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 --pjh2KveCiReW/EIb Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmLzlwQACgkQeFA3/03a ocXROAgAmxCDpZZxZ93CGZ6jIwXn4OGmKyfR7a6PjxqD5qL2rGck9VBS1VZPenS7 +C7/Qu9ViKNCG+VU2ftVKQDh/PhHC83+6e7YPJQERS53clNvRZoth/Qntoaer1FA T3mWCTJyo/UDvWGixLOCtC4dMUXHys9vHKyTOiHXAGFU/rsvWHu0alSrv7ENm3Wr TzJWewPAYrUbHVGBG8/E3rYVTdQB7tAKYtC8h0ZqFwQwi6hrp4I8Vy1Y3TTdfX7K HDUFrIGbVEbISD+fLFTlTR8i2BNiUAVGfb+QAZSX6gkLUMGlaxylNKG73ovbvg3X Y3/dNRzZrKxRMPaGVYCbBKZUOnJ/qQ== =3blC -----END PGP SIGNATURE----- --pjh2KveCiReW/EIb-- From nobody Mon Apr 13 10:20:06 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 00C88C00140 for ; Wed, 10 Aug 2022 11:32:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232087AbiHJLcP (ORCPT ); Wed, 10 Aug 2022 07:32:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232100AbiHJLcF (ORCPT ); Wed, 10 Aug 2022 07:32:05 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC3FC73934 for ; Wed, 10 Aug 2022 04:32:02 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id bq11so20840454lfb.5 for ; Wed, 10 Aug 2022 04:32:02 -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=0n1Y/OzhfJeE+j8g4UzOYZL6N5O4tDg71xSPH024khI=; b=kA7ZPWE9auNagXtgXGfNtwEbiMHmU8S7bBqOGTC5NBs+JJVZUXFFFEKRBKXN0LiZTT 8P2baQgcumnHOmqX6NsVEjubxnpriOq+frTO+MO9OeJaYrKLoifhAi7spYfhjOGPpc3y /ymTjg8OFT7ro70OslfoDXPppb7eNMwKTJTDA30Gddtjtl4aCrS5bq2+0lwscyTjwPgZ 9XqVPHRM7dh7/p8X7XwoaajDzVBGXk1VM6g2+HW02gSiMnKvuyadkG18Jhgnln7nzXph qujTz7lr0LXTEintAq/wjENu1LQF89E4HU2Wm7mJglCYq5s9eQaZghukzoNwdYwEdEpF TaPw== 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=0n1Y/OzhfJeE+j8g4UzOYZL6N5O4tDg71xSPH024khI=; b=iP6ctlIWRl8jpt0vAznvWp8UZZQyn3/OCqR6dYb+KkF14K/3gquCCoX8lll++kXiEa HaJt4FVDlyjoAgFTbdUcGfZvYazWK2CoDp0RJ1nk1z9P78INKP543zqpwe4ZPhqLzUa/ fVIjvshC/NOYdT84o1XtA6BM5O7AtW8IurB9esOtomdg+33rrIzXrS/8qK+/3L9sMJf/ 4hfCOiaPIXIOZvCkzyRpxDdO28iae+Ns7DN0QGwSL8hcHE+Sr4YtgmnT5UQpjuQK5bqK jH+z5U95gTiKil0P97/4/GoKThj4Mfvag6eSQz9m6ew2ierC1XkeXjEyEUsrb69dwPYq Uo+Q== X-Gm-Message-State: ACgBeo38sS5m3pd8NwdwtTFocUYa+pKWNxLe/9NhmBo2ZF9kMYtEhhOW ohWcGUfJbDv7RRvMOzroIV8= X-Google-Smtp-Source: AA6agR4HJ7z9C6Qx/mQgUXeus0gaIaf5bRpOkkYd5YSpgaeaMscj9In5G4yyt6jyUcuHoI4k+C+cpw== X-Received: by 2002:a05:6512:13a4:b0:477:a28a:2280 with SMTP id p36-20020a05651213a400b00477a28a2280mr8901373lfa.689.1660131121036; Wed, 10 Aug 2022 04:32:01 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id v10-20020a2ea60a000000b0026008acb55asm134927ljp.113.2022.08.10.04.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 04:32:00 -0700 (PDT) Date: Wed, 10 Aug 2022 14:31:46 +0300 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Cc: Neil Armstrong , David Airlie , Daniel Vetter , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Liam Girdwood , Mark Brown , dri-devel@lists.freedesktop.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 5/7] gpu: drm: meson: simplify using devm_regulator_get_enable_optional() Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ON+BJfnFjobaZBs+" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --ON+BJfnFjobaZBs+ 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_optional(). Also drop the seemingly unused struct member 'hdmi_supply'. Signed-off-by: Matti Vaittinen --- drivers/gpu/drm/meson/meson_dw_hdmi.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) 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 --ON+BJfnFjobaZBs+ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmLzlyIACgkQeFA3/03a ocVZnwf+Lv1xHGjupIg4noibrWXhjS6WmrvGpZqs49VnTsvbxRbVPjEzn6JfF+8i SbHdoe+KSl5d/OfYx7CtXlQnJwJ5qLZHIaYcMewnJHMzQwSWQdeu+/W6DbAmuPPi rOZtSzW/jDUANoxUtDX5sfgimagrnUWh1VPSxOz4CYjq6r77TquMfF1hclrECSVD DrElf2B0R3Yw2OHJmoWsg80uk96ZURuXJB1/H5entU0CMKZZbpEeX2hhYDu7c6rl EXbfot5+kVmIc7PwYI0D8ysIXmylHqKzJUqy8kMiL9zHXNm+eXeBvpxry7ryt2S5 7wITQS0z6ReN4U0nhXrniyBKGJ8MIw== =4h4p -----END PGP SIGNATURE----- --ON+BJfnFjobaZBs+-- From nobody Mon Apr 13 10:20:06 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 2D471C25B0E for ; Wed, 10 Aug 2022 11:33:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232096AbiHJLcv (ORCPT ); Wed, 10 Aug 2022 07:32:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231464AbiHJLcf (ORCPT ); Wed, 10 Aug 2022 07:32:35 -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 7EBAE6DF96; Wed, 10 Aug 2022 04:32:34 -0700 (PDT) Received: by mail-lf1-x12b.google.com with SMTP id f20so20776606lfc.10; Wed, 10 Aug 2022 04:32: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=C7PP55XLKwk3Ov8DaaLsfjSN7+Fbj+g7x+jMv9Fy+O8=; b=hv9hgdfkJ5AxzikQUS60rpuILK9NqDDXlWKzc8hO7hrZI4x6iJUFEpO2xyGRn99AtC fiuGhpGi821ulpOdkMIRb4bK0Ul5NciCSyBDYrMHYsx4Y6Veq+cU6q1Vsp29etpqCMW4 LwDz5hrMfgHk/1HHCu24hi4p7FRPSL5b/VXT2n8ccZVwqTCq9XU6TM083h0kGked0nad kGUrA3Ra2vOlRUIHbJmMm9UTmdzo4TWgQZa1kFh9IJo04cariKMZJb5ToJLbH17mE2+B 3fO/TWZOoeR4Vte3Ym4cdno3r0b9WB8oI1cFp/4WGFNWOZ2mwh8s31jqsR9iQYaWGPmM k+LA== 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=C7PP55XLKwk3Ov8DaaLsfjSN7+Fbj+g7x+jMv9Fy+O8=; b=Ug6XDMU1dm3gHUBk6VhInqu+/+AEhIWv6ylanZ5AjnSYU1px7iV0oy5NIYGHUtYkhk 4YWaOKiLxBA5KuDVK+9c/O13AdHNYE1OZX1R9ksN/wMEFpymAAPbjjJzRel51WLzykk+ JGS5gG5VZdZljMBWoPV8PloZHEcOi/9SaJLF+1lWE5NAm133PqreHBzQ+JDrve5uBCHy 6jT2CbzTPiuqa0GvskjX3z0WnziHnCNoADnpXHErUwb5KDO7hquXA8zJ57VZDL9jaH38 8Fv4OojaqWqlJlkGgn/lHCLRq1m5gV5cUYbkwmDr8oPlqGFvCsBTuBUMaEU4gSzv8Ku7 t7cQ== X-Gm-Message-State: ACgBeo1wrt0BdjS8+dWUjbwE3tVHLfslx2WcDPtV1kG7FWmMfUOr3wdK GpN/rpzzXjYLGYJaC/icsAo= X-Google-Smtp-Source: AA6agR6Xq1QwE7A7NhkBgpQo3mWmrrFZhTsvzsp8tWf86CYVVLXEuMTCMlUC/jvaEufDdGjrCdaEXw== X-Received: by 2002:a05:6512:234f:b0:48d:b66:9b54 with SMTP id p15-20020a056512234f00b0048d0b669b54mr2866706lfu.118.1660131152866; Wed, 10 Aug 2022 04:32:32 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id p21-20020a2eb7d5000000b0025fde1697b0sm369392ljo.135.2022.08.10.04.32.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 04:32:32 -0700 (PDT) Date: Wed, 10 Aug 2022 14:32:18 +0300 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Cc: Jean Delvare , Guenter Roeck , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 6/7] hwmon: lm90: simplify using devm_regulator_get_enable() Message-ID: <4565950ddca2f78209dad49e169d4af7517db27e.1660127865.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="dUGNtiJXsye5By6f" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --dUGNtiJXsye5By6f 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 --- 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 --dUGNtiJXsye5By6f Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmLzl0EACgkQeFA3/03a ocW8hAgAwkdNU8q2l23A0DVzeCBVBsc0QTY0W7HwHu18UT5Oj+j4xWyA2tP8Q28L NXNG8k+tWvZJFqZepKzi/qnCFE08xUTwED11WkPdOTFfAARqSw/kVDKsfcf5bQw4 rFZtNpF6Wl7i28l5wadqW1K/fWbkKzgxh0kpkSrKl/HoHVcS7UpJIu/TzwT4o1hH ReOkCwl6GMsS8emD29//+PM3WigB5a7gp+mnQiXGjdUTTkEZ40p7ujG5SWobB4Qu aqdE2LfFtp4fvtMLr+9g2hCwyFBOqivBEfDU2wO18z1H3/dqKKakaEzTOfJYr5Wt lMkj6Hvn7O1wCMcyEYoSoTlxM++yVg== =NVIF -----END PGP SIGNATURE----- --dUGNtiJXsye5By6f-- From nobody Mon Apr 13 10:20:06 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 BCC70C3F6B0 for ; Wed, 10 Aug 2022 11:33:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231417AbiHJLdV (ORCPT ); Wed, 10 Aug 2022 07:33:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232134AbiHJLdG (ORCPT ); Wed, 10 Aug 2022 07:33:06 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89CA775FED; Wed, 10 Aug 2022 04:33:05 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id j3so8613315ljo.0; Wed, 10 Aug 2022 04:33: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=g2OJvOZZHZIxUC/pgYnk9p8BpXsVB+Oo8nJt9r6IY80=; b=NSGsGPyT4xwwMmbAE+M4xP1n8h/WRufFIaybXJLwRWeuynTXVnNFE9ZGER+xYFWZzr TX2PM8oTgJ0wo96tXegmpoHDHfmy1/l6BPF2xwjKj/y9gvMJJoxoSHxh82j2WlM1P6nn 5pCPWAdJ/Oko3EUHWbXtBkz3T5fiblQB4VW3pRt9zzCAHeItc6vh1MJ7m/LCV7RfPoST W8c68l23tBQlVRll49YKBbJkjiNgStsDLK9jWKsrfqKZEkcBe/zXUI8rYVB+AUqwZeSo i5jlIHxcn1JzYyXq3dwmDYoJ34C7LbSYRLwUgaLe7Yyom5jTN0Z8kJGUjG2H/EqEXnSv ukEQ== 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=g2OJvOZZHZIxUC/pgYnk9p8BpXsVB+Oo8nJt9r6IY80=; b=ezSwY5ok0KBJxiZNdSY3pv6ngMn4gx+OJfOOfatilgzQi7ip7z/2WRXIraXZATH877 d/tTUAB/BRgFeaVvV44GzX18o2bEgWEvpdCXy7LM3JnEPYWFil5pQ9reu/KzttrrG1ns XdWJTCVHBEQoB9iZ5LNXd5Pn4pHmoZ6fUHM29f2u5fqM4JkvXXPZJWRkIUSt+jWTleWY X1FlwQmS3b/PXH5nkWARhn4uDL6P/YdKWl5ETpEdrsLifRWMPuo/Rqx+Qr0GYDAw0TT2 LCizO5Ih/0Mgy1Loa9FhJVe0OMtRKKXDkxD4HOXGDT1jdNDIOxsuqzNiRFnYqUD0n8ML qj9A== X-Gm-Message-State: ACgBeo1sMIdAADUHMEU3ZqNHahel0jbEYpg7DFMX0HhB2ml70c5AMG97 nRnfQubnEXcB8PRHwen9NIQ= X-Google-Smtp-Source: AA6agR7ZMOfUoxveidPh6nF5e7B+hqw59U+fxlV00cwI92nJPJOyeF5w8Zat6EbqCptnPKDJiw+0kw== X-Received: by 2002:a2e:bf01:0:b0:25f:df1a:f39d with SMTP id c1-20020a2ebf01000000b0025fdf1af39dmr4312867ljr.365.1660131183928; Wed, 10 Aug 2022 04:33:03 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id c6-20020a056512074600b0048b309aeb09sm306204lfs.226.2022.08.10.04.33.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 04:33:03 -0700 (PDT) Date: Wed, 10 Aug 2022 14:32:49 +0300 From: Matti Vaittinen To: matti.vaittinen@fi.rohmeurope.com, mazziesaccount@gmail.com Cc: Alexandru Tachici , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 7/7] adc: ad7192: simplify using devm_regulator_get_enable() Message-ID: <7ca58a7014a2149a3190336247b13e683fdf6e33.1660127865.git.mazziesaccount@gmail.com> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="AlIRRVcwMTECGNfK" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --AlIRRVcwMTECGNfK 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_optional(). Also drop the seemingly unused struct member 'dvdd'. Signed-off-by: Matti Vaittinen --- drivers/iio/adc/ad7192.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 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) { --=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 --AlIRRVcwMTECGNfK Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmLzl2EACgkQeFA3/03a ocWJzggAuNdP+4gZx9YJtU8uytBkhkDgWYzALjcpMwvRUK7cUe2AwcfXRTxrDAFw Gy8Jf1M77P9kTtErYASrn81QYDcudYUqAITwf9HMFMQKJu6LlytffVyDO45E/mkr X68cwNVou5IfMU3++b3yCd5sQ3QL816BmS9NTM5MddX9/oBsoZIFaZLIzcYFIkLg JyBlgMUE6hcNfJAjIuJBMBRwL3+11KLMl4xPCv0Ygxrh5QUrVkeCdAeTGoTPjOrw 953B4+RRtfzdcWM+CfBL97tXscPGquOcZcQFyh6JQD9AOvsghGTFK3Qjool9FTxR 6IAWbNGUgqjPD5nGWy7baDJDQpi+9w== =4mV1 -----END PGP SIGNATURE----- --AlIRRVcwMTECGNfK--