From nobody Tue Feb 10 19:01:02 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 4FE42C83F01 for ; Wed, 30 Aug 2023 22:43:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344100AbjH3Wnd (ORCPT ); Wed, 30 Aug 2023 18:43:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343986AbjH3Wnc (ORCPT ); Wed, 30 Aug 2023 18:43:32 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E009CF4 for ; Wed, 30 Aug 2023 15:43:09 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4Rbd324qxyzMG; Wed, 30 Aug 2023 23:38:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1693431534; bh=hUkNLtMYrhMoAqr2vDdOq6o7qYhnoFkBKelx/varQcs=; h=Date:In-Reply-To:References:Subject:From:To:Cc:From; b=Lz6i3AeoqQZg02m5C9/bBSS1UCL3wLwsUk57j7sZ8UtFeVfUiHI+D+zXcIsjzowv5 fE+wSEaXQmX6FyFOwX5uhWqm6ZNIf9D+Tl1Lqf5iukQkYRRdA2jkCAIHEACxFnxLzi WgRth3bJFj+Hr2aRbcMrGYbLRb6VBidgm1cyfIVzJaJolKIbZjSHYgjvmseyj3ADBH X6hLcdC7DDcOK9dMGYiW9A+QpR3tAOW7jE2PX9mnwqlL13l78ySEWl9wixi3ICM9N5 pQDouJnrgQ3px8LULtXIXZnKwgScLRwUo8bULy/9GyZQjBzihGfsDfJ7KR+0JT9nRC 0NTwlJQFzBbkg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Wed, 30 Aug 2023 23:38:54 +0200 Message-Id: In-Reply-To: References: Subject: [PATCH 1/9] regulator/core: _regulator_get: simplify error returns MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove unnecessary stores to `regulator`. Signed-off-by: Micha=C5=82 Miros=C5=82aw --- drivers/regulator/core.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 662711063433..d440cd137c38 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2209,15 +2209,13 @@ struct regulator *_regulator_get(struct device *dev= , const char *id, } =20 if (rdev->exclusive) { - regulator =3D ERR_PTR(-EPERM); put_device(&rdev->dev); - return regulator; + return ERR_PTR(-EPERM); } =20 if (get_type =3D=3D EXCLUSIVE_GET && rdev->open_count) { - regulator =3D ERR_PTR(-EBUSY); put_device(&rdev->dev); - return regulator; + return ERR_PTR(-EBUSY); } =20 mutex_lock(®ulator_list_mutex); @@ -2225,32 +2223,28 @@ struct regulator *_regulator_get(struct device *dev= , const char *id, mutex_unlock(®ulator_list_mutex); =20 if (ret !=3D 0) { - regulator =3D ERR_PTR(-EPROBE_DEFER); put_device(&rdev->dev); - return regulator; + return ERR_PTR(-EPROBE_DEFER); } =20 ret =3D regulator_resolve_supply(rdev); if (ret < 0) { - regulator =3D ERR_PTR(ret); put_device(&rdev->dev); - return regulator; + return ERR_PTR(ret); } =20 if (!try_module_get(rdev->owner)) { - regulator =3D ERR_PTR(-EPROBE_DEFER); put_device(&rdev->dev); - return regulator; + return ERR_PTR(-EPROBE_DEFER); } =20 regulator_lock(rdev); regulator =3D create_regulator(rdev, dev, id); regulator_unlock(rdev); if (regulator =3D=3D NULL) { - regulator =3D ERR_PTR(-ENOMEM); module_put(rdev->owner); put_device(&rdev->dev); - return regulator; + return ERR_PTR(-ENOMEM); } =20 rdev->open_count++; --=20 2.39.2 From nobody Tue Feb 10 19:01:02 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 3C76AC83F14 for ; Wed, 30 Aug 2023 21:40:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241965AbjH3Vkm (ORCPT ); Wed, 30 Aug 2023 17:40:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242037AbjH3Vkk (ORCPT ); Wed, 30 Aug 2023 17:40:40 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E54ECFC for ; Wed, 30 Aug 2023 14:40:10 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4Rbd330fnTzTw; Wed, 30 Aug 2023 23:38:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1693431535; bh=myJ3VN4kme6b3IyeciKx5wc/7mhpCeWqhBkhEBhrxQA=; h=Date:In-Reply-To:References:Subject:From:To:Cc:From; b=V0Vzy/vb1FI56RGjX/1c+/higRB1MqWSNbbmkAPVn6oS2hiGumONNuy5eFHyBt7G0 2O7iqQAZuiUJlLT+SxIX5RBbJtg9AA+eoVpFn7QMIzC8TEBpuEYFrXtmEN2XV/2VOR yaRJWmHsLPqusX5noYPO0JiXbvOoVBlLuAql2VUGAkVzRmi+UW8fUdn4AyUrjofQey pDN1XSVIAPokAFoefVlyf6gSgbn9f3X/DHC9Zw3tJMVT79quyYsRgNR7e+dgmFdc3O mdANqOhrh7qOM4FjuBsY/pFDhX3ioB37SurwQZkrGYg+boH8jwgeDVZf0kXIcbMzD7 WpvHd3CcUcL3A== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Wed, 30 Aug 2023 23:38:54 +0200 Message-Id: <5fb938f4a07063fbca4893db2e6da1b63da87dc9.1693431144.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: Subject: [PATCH 2/9] regulator/core: set_consumer_device_supply: remove `has_dev` MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org `has_dev` is only ever used once to check if the name is non-NULL. Inline the check and make the intent obvious. Signed-off-by: Micha=C5=82 Miros=C5=82aw --- drivers/regulator/core.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index d440cd137c38..a467be1f198b 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1726,16 +1726,10 @@ static int set_consumer_device_supply(struct regula= tor_dev *rdev, const char *supply) { struct regulator_map *node, *new_node; - int has_dev; =20 if (supply =3D=3D NULL) return -EINVAL; =20 - if (consumer_dev_name !=3D NULL) - has_dev =3D 1; - else - has_dev =3D 0; - new_node =3D kzalloc(sizeof(struct regulator_map), GFP_KERNEL); if (new_node =3D=3D NULL) return -ENOMEM; @@ -1743,7 +1737,7 @@ static int set_consumer_device_supply(struct regulato= r_dev *rdev, new_node->regulator =3D rdev; new_node->supply =3D supply; =20 - if (has_dev) { + if (consumer_dev_name !=3D NULL) { new_node->dev_name =3D kstrdup(consumer_dev_name, GFP_KERNEL); if (new_node->dev_name =3D=3D NULL) { kfree(new_node); --=20 2.39.2 From nobody Tue Feb 10 19:01:02 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 86A0FC83F15 for ; Wed, 30 Aug 2023 22:58:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344275AbjH3W6T (ORCPT ); Wed, 30 Aug 2023 18:58:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344145AbjH3W6O (ORCPT ); Wed, 30 Aug 2023 18:58:14 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C66B5CF1 for ; Wed, 30 Aug 2023 15:57:55 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4Rbd332tgczVr; Wed, 30 Aug 2023 23:38:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1693431535; bh=UOv5UYiic2OEW7Z/lmCvmB0e7M+FtpAGvPx/Numsyn0=; h=Date:In-Reply-To:References:Subject:From:To:Cc:From; b=PwjvjomKydj5Jeq8khsxnUiioahd7pSmcddd2rAMKxWz4By16vFZ3oft6gRf8OOQe iiM8Lr0v+IZzRiVdsv6nSBVKe4o0HcVrCPNnfSqT2m+P1iG2dHEIs3c1jbjq8/b282 hwY7zjuS0RSL/c+vYBXrK+z+W+/lJPJ6YEragdyxyWbvYwXfdfnoO5f/lpuuzyuCEf l5VGuP9PF0LX3/pjHa6xUcL9j6X5fX0MQzwaZg/lQEV8atS0V2JRXVvKI/D7DRGH+U Bi3SQFjeJcid+pkm7H/48c3+ygtWcLdyO2DzwkAq6e56g3ZoIwF86q2cKkMDUxsILs kQcvcuxDi5zPw== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Wed, 30 Aug 2023 23:38:55 +0200 Message-Id: <40d2eabfa435b0a8850a1c2264d4b9bf63b6fb74.1693431144.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: Subject: [PATCH 3/9] regulator/core: of_get_child_regulator: remove goto MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Because of_node_put() handles NULL properly (like kfree() et al) we can call it also after the loop ends (due to child =3D=3D NULL). This makes the gotos redundant. Signed-off-by: Micha=C5=82 Miros=C5=82aw --- drivers/regulator/core.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a467be1f198b..3703aa3f5636 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -426,18 +426,15 @@ static struct device_node *of_get_child_regulator(str= uct device_node *parent, =20 for_each_child_of_node(parent, child) { regnode =3D of_parse_phandle(child, prop_name, 0); + if (regnode) + break; =20 - if (!regnode) { - regnode =3D of_get_child_regulator(child, prop_name); - if (regnode) - goto err_node_put; - } else { - goto err_node_put; - } + regnode =3D of_get_child_regulator(child, prop_name); + if (regnode) + break; } - return NULL; =20 -err_node_put: + /* Release the node if the loop was exited early. */ of_node_put(child); return regnode; } --=20 2.39.2 From nobody Tue Feb 10 19:01:02 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 BD68AC6FA8F for ; Wed, 30 Aug 2023 22:58:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344272AbjH3W6Q (ORCPT ); Wed, 30 Aug 2023 18:58:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344001AbjH3W6O (ORCPT ); Wed, 30 Aug 2023 18:58:14 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C663DCEE for ; Wed, 30 Aug 2023 15:57:55 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4Rbd336L6rzbv; Wed, 30 Aug 2023 23:38:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1693431535; bh=FYuckVdeNnQG0dQ1V8vJDI3IwA2LopJS6jGJcl/QN2s=; h=Date:In-Reply-To:References:Subject:From:To:Cc:From; b=rpEDtYWP2WNBQfERxLVeQc7Ps6AGTPfkf8U5JNfxiPD727bblYBeF5p5Nnj6yJBvp wuJxhmn2Cdiz377NkRD3ojJZJx/ecP7xcewtscz5zoqZ7ONZhqudU183/dOCY2hybv oroiQUs9bqypQN1oJsJjEVcA6OjfopOSsnOKUYO2VBbF9ntzNLoZm+2eIRgrHM/iQG X8fI+kn3oi3xzM9m0kqQDNHmoFTbOBpTFGOyOh3EE+/qtwrPYthFxjSSrhEOReDHCR aURefb3mOV2pzSATbAN32V2StpT8tgE5upWxUFUcmXpX/9hPNEr70l22eUxVAndYRz QEnOtg/IH9vsA== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Wed, 30 Aug 2023 23:38:55 +0200 Message-Id: In-Reply-To: References: Subject: [PATCH 4/9] regulator/core: regulator_bulk_get: remove redundant NULL stores MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On error, callers of regulator_bulk_get() pass the error up and don't use the pointers in consumers[]. The function is documented to release all regulators if any request fails. Note: if an i-th regulator_get() failed only the i-th pointer was cleared. This is another suggestion that the clearing was unnecessary. Signed-off-by: Micha=C5=82 Miros=C5=82aw --- drivers/regulator/core.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 3703aa3f5636..63d16fe59e84 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -4829,11 +4829,7 @@ static int _notifier_call_chain(struct regulator_dev= *rdev, int _regulator_bulk_get(struct device *dev, int num_consumers, struct regulator_bulk_data *consumers, enum regulator_get_type get_type) { - int i; - int ret; - - for (i =3D 0; i < num_consumers; i++) - consumers[i].consumer =3D NULL; + int ret, i; =20 for (i =3D 0; i < num_consumers; i++) { consumers[i].consumer =3D _regulator_get(dev, @@ -4842,7 +4838,6 @@ int _regulator_bulk_get(struct device *dev, int num_c= onsumers, ret =3D dev_err_probe(dev, PTR_ERR(consumers[i].consumer), "Failed to get supply '%s'", consumers[i].supply); - consumers[i].consumer =3D NULL; goto err; } =20 --=20 2.39.2 From nobody Tue Feb 10 19:01:02 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 0C1CEC83F01 for ; Wed, 30 Aug 2023 22:47:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242605AbjH3Wru (ORCPT ); Wed, 30 Aug 2023 18:47:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241389AbjH3Wrt (ORCPT ); Wed, 30 Aug 2023 18:47:49 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DEACCF1 for ; Wed, 30 Aug 2023 15:47:41 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4Rbd341VwFzgk; Wed, 30 Aug 2023 23:38:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1693431536; bh=3j5YwA8sQZLPwKcy65ogiVFJLRLsV0GO/Ut6EzwlnMQ=; h=Date:In-Reply-To:References:Subject:From:To:Cc:From; b=BKvxto3e/ZjAZxKx4FTEFDuoMlZOIAIUrlU9OI0wCEyCgbcE9chjRj2nveFserEAo rm3+XV8qEhLdOTCgx4ScIXHWLL9xLoNLti0wkEni52XWYyQ8RmHk0NVoQ48n/rWfz1 +AbnSxOnHiYJmFzpA9UoyW1nV+J+6JetCoblaboPTHtGzAparZBv2cPHCv55+VknNy /P4No4b4/C7a4izgDQvUJ39+n1X+Jd3NSE42h5kbq4moLjqpMZ6NSJXeAYSmo5u6IM Omo2lGAQA9YgnHqep1ZkNwxnk+2rNcYtxpnofc2bfANfSMn5Sk5gdOFsfsnXILeYCK +WilOrOpnSTsg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Wed, 30 Aug 2023 23:38:56 +0200 Message-Id: In-Reply-To: References: Subject: [PATCH 5/9] regulator/core: regulator_ena_gpio_ctrl: pull in ena_gpio state handling MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Deduplicate `ena_gpio_state` handling by pulling it into regulator_ena_gpio_ctrl(). Signed-off-by: Micha=C5=82 Miros=C5=82aw --- drivers/regulator/core.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 63d16fe59e84..c8d1b12ee43b 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -2601,6 +2601,9 @@ static int regulator_ena_gpio_ctrl(struct regulator_d= ev *rdev, bool enable) if (!pin) return -EINVAL; =20 + if (rdev->ena_gpio_state =3D=3D enable) + return 0; + if (enable) { /* Enable GPIO at initial use */ if (pin->enable_count =3D=3D 0) @@ -2608,18 +2611,14 @@ static int regulator_ena_gpio_ctrl(struct regulator= _dev *rdev, bool enable) =20 pin->enable_count++; } else { - if (pin->enable_count > 1) { - pin->enable_count--; - return 0; - } - /* Disable GPIO if not used */ - if (pin->enable_count <=3D 1) { + if (pin->enable_count-- <=3D 1) { gpiod_set_value_cansleep(pin->gpiod, 0); pin->enable_count =3D 0; } } =20 + rdev->ena_gpio_state =3D enable; return 0; } =20 @@ -2720,12 +2719,9 @@ static int _regulator_do_enable(struct regulator_dev= *rdev) } =20 if (rdev->ena_pin) { - if (!rdev->ena_gpio_state) { - ret =3D regulator_ena_gpio_ctrl(rdev, true); - if (ret < 0) - return ret; - rdev->ena_gpio_state =3D 1; - } + ret =3D regulator_ena_gpio_ctrl(rdev, true); + if (ret < 0) + return ret; } else if (rdev->desc->ops->enable) { ret =3D rdev->desc->ops->enable(rdev); if (ret < 0) @@ -2938,13 +2934,9 @@ static int _regulator_do_disable(struct regulator_de= v *rdev) trace_regulator_disable(rdev_get_name(rdev)); =20 if (rdev->ena_pin) { - if (rdev->ena_gpio_state) { - ret =3D regulator_ena_gpio_ctrl(rdev, false); - if (ret < 0) - return ret; - rdev->ena_gpio_state =3D 0; - } - + ret =3D regulator_ena_gpio_ctrl(rdev, false); + if (ret < 0) + return ret; } else if (rdev->desc->ops->disable) { ret =3D rdev->desc->ops->disable(rdev); if (ret !=3D 0) --=20 2.39.2 From nobody Tue Feb 10 19:01:02 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 3FCBEC83F14 for ; Wed, 30 Aug 2023 22:54:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234209AbjH3WyZ (ORCPT ); Wed, 30 Aug 2023 18:54:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230166AbjH3WyX (ORCPT ); Wed, 30 Aug 2023 18:54:23 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3430CE75 for ; Wed, 30 Aug 2023 15:53:56 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4Rbd344GpXzjJ; Wed, 30 Aug 2023 23:38:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1693431536; bh=hkfhe/JYkH9cOp8sfK6wVmut5qBxlqVOGzXU+gWw05A=; h=Date:In-Reply-To:References:Subject:From:To:Cc:From; b=o9AhdExoWOHdimJ4LTYTZDhDpdYGM+By+cxe4w8a9N+N91u6n1y/nn72qhs/3raN8 QBcxcCrfRQEfABvEcukG27T5ChutxzYYsi+fUf3FJIbfj8iNnp7UOKQx7e75bRBY7Z RifXQz78LnuhJivb0pBiJ3Gn5C9QVGQ/ZwtHc7jSMb1bXS9PHAcwnky6v0zrkgzM86 UCBM2xNR8aQDV+OaJfik8rAMxloiH30KiSpMX7lH53csLdgwTueMct+Uh55R1iSUK2 URkdGKGmhVIr0eXfKqR0BJzCUgwI5XnhOnA+XvKp5ORCuCamN57yW147swetuIUkZs CKrnucwUBMmBQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Wed, 30 Aug 2023 23:38:56 +0200 Message-Id: <67b78825385762957b121db2c5d71b119517a7ce.1693431144.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: Subject: [PATCH 6/9] regulator/core: remove regulator_init callback MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are no in-tree users. The only usage went away in 2019 in commit 8c44e448583c ("regulator: stpmic1: Simplify regulators registration"). Signed-off-by: Micha=C5=82 Miros=C5=82aw --- include/linux/regulator/machine.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/ma= chine.h index 621b7f4a3639..2d4ae9c01cde 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h @@ -256,8 +256,7 @@ struct regulator_consumer_supply { * @num_consumer_supplies: Number of consumer device supplies. * @consumer_supplies: Consumer device supply configuration. * - * @regulator_init: Callback invoked when the regulator has been registere= d. - * @driver_data: Data passed to regulator_init. + * @driver_data: Pointer copied to regulator_dev.reg_data. */ struct regulator_init_data { const char *supply_regulator; /* or NULL for system supply */ @@ -267,9 +266,7 @@ struct regulator_init_data { int num_consumer_supplies; struct regulator_consumer_supply *consumer_supplies; =20 - /* optional regulator machine specific init */ - int (*regulator_init)(void *driver_data); - void *driver_data; /* core does not touch this */ + void *driver_data; }; =20 #ifdef CONFIG_REGULATOR --=20 2.39.2 From nobody Tue Feb 10 19:01:02 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 A735EC83F14 for ; Wed, 30 Aug 2023 22:38:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240079AbjH3WiM (ORCPT ); Wed, 30 Aug 2023 18:38:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234089AbjH3WiI (ORCPT ); Wed, 30 Aug 2023 18:38:08 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A87FA9C for ; Wed, 30 Aug 2023 15:37:47 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4Rbd346CkXzkh; Wed, 30 Aug 2023 23:38:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1693431536; bh=xYl17I+K4wwzgyiz7kt9ZmAtiqFq9MsVBbItAFx3V0A=; h=Date:In-Reply-To:References:Subject:From:To:Cc:From; b=r6kVIleCqglHZlbLhc/FYoJBnRTlxyUjY9DAbOgPEpjk3j3YxcdYRANIWQ1MCsVe+ BQ5Idgab6JjUMB1xazx+4K+efQZrWQN6oNqanAcdt7btdSY6IY53OVncN2656Qwt8t DRNBmib0ybN8AJT04SYyHmgI9lyHusKJd9UlRfuzFnaCkSs4Z6+LTNJPE615csmtw7 j8+blDEZOhAPKaP9YbMHD88mRjy01OJfxfS4W+2p1K8gZbNwXQYgO0u2xLAJ/Eyxr8 LVPyJQVTYq/otNwvVoVpdENcQtJRaZ+R6iEtU1MN+XVKHw3F0nwtnQifCy/I0CJv5m owLm8R2n+9uIg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Wed, 30 Aug 2023 23:38:56 +0200 Message-Id: <5bcecac45e38eaec2c7df25996f518444279520c.1693431144.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: Subject: [PATCH 7/9] regulator/core: remove regulator_get_init_drvdata() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are no in-tree users. Signed-off-by: Micha=C5=82 Miros=C5=82aw --- drivers/regulator/core.c | 6 ------ include/linux/regulator/driver.h | 1 - 2 files changed, 7 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index c8d1b12ee43b..7c4ba090d88d 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -5881,12 +5881,6 @@ struct regmap *rdev_get_regmap(struct regulator_dev = *rdev) } EXPORT_SYMBOL_GPL(rdev_get_regmap); =20 -void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data) -{ - return reg_init_data->driver_data; -} -EXPORT_SYMBOL_GPL(regulator_get_init_drvdata); - #ifdef CONFIG_DEBUG_FS static int supply_map_show(struct seq_file *sf, void *data) { diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/dri= ver.h index 4b7eceb3828b..827888b4b16c 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -758,7 +758,6 @@ int regulator_set_active_discharge_regmap(struct regula= tor_dev *rdev, int regulator_set_current_limit_regmap(struct regulator_dev *rdev, int min_uA, int max_uA); int regulator_get_current_limit_regmap(struct regulator_dev *rdev); -void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data= ); int regulator_find_closest_bigger(unsigned int target, const unsigned int = *table, unsigned int num_sel, unsigned int *sel); int regulator_set_ramp_delay_regmap(struct regulator_dev *rdev, int ramp_d= elay); --=20 2.39.2 From nobody Tue Feb 10 19:01:02 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 685BDC83F15 for ; Wed, 30 Aug 2023 22:47:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242629AbjH3Wrw (ORCPT ); Wed, 30 Aug 2023 18:47:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232242AbjH3Wrt (ORCPT ); Wed, 30 Aug 2023 18:47:49 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D929A1 for ; Wed, 30 Aug 2023 15:47:41 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4Rbd353Q2Qztn; Wed, 30 Aug 2023 23:38:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1693431537; bh=0FOuVXjqnIye1fzsxyeQ7447oMaVJyrA0BRuBkQGje8=; h=Date:In-Reply-To:References:Subject:From:To:Cc:From; b=pgSHbI7ytH98CI1tYlJpnH7Asw+T6ndG0u35fEbIv/z3L+QX7klUPLUuzDz+a3Ct+ tNUSBj9gAJxv+6xBFq3V8DloPeUlGFhdwqkmjiC8XGxULU0Oxr/BaqMfmUG64dAh9z +HRkbyBTpoCjMkysZAxCZ6lgWWiik36oClne+ULXFWgg9lXbEqe2lZVgSeeWQbxnuI ztHmNYC1ZMpi2N92Y9XAR43QqN6oYsedU+L5pzMfeACfe145FMoET+A4WXjwDXdI7v Wfk+2wtC2ctVLigF31jOvnRhqac7+uYxYj6ykC8ld++FfKPXjTwyQwZ6ZrJjiZLRuz tqmU+NI6fAKlA== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Wed, 30 Aug 2023 23:38:57 +0200 Message-Id: In-Reply-To: References: Subject: [PATCH 8/9] regulator/core: set_consumer_device_supply: avoid copying const data MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As consumer_dev_name might as well be const, don't copy it if not required. Signed-off-by: Micha=C5=82 Miros=C5=82aw --- drivers/regulator/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 7c4ba090d88d..8ab4de7cadcb 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1735,7 +1735,7 @@ static int set_consumer_device_supply(struct regulato= r_dev *rdev, new_node->supply =3D supply; =20 if (consumer_dev_name !=3D NULL) { - new_node->dev_name =3D kstrdup(consumer_dev_name, GFP_KERNEL); + new_node->dev_name =3D kstrdup_const(consumer_dev_name, GFP_KERNEL); if (new_node->dev_name =3D=3D NULL) { kfree(new_node); return -ENOMEM; @@ -1770,7 +1770,7 @@ static int set_consumer_device_supply(struct regulato= r_dev *rdev, =20 fail: mutex_unlock(®ulator_list_mutex); - kfree(new_node->dev_name); + kfree_const(new_node->dev_name); kfree(new_node); return -EBUSY; } @@ -1782,7 +1782,7 @@ static void unset_regulator_supplies(struct regulator= _dev *rdev) list_for_each_entry_safe(node, n, ®ulator_map_list, list) { if (rdev =3D=3D node->regulator) { list_del(&node->list); - kfree(node->dev_name); + kfree_const(node->dev_name); kfree(node); } } --=20 2.39.2 From nobody Tue Feb 10 19:01:02 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 EDCBAC83F01 for ; Wed, 30 Aug 2023 22:09:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244980AbjH3WJc (ORCPT ); Wed, 30 Aug 2023 18:09:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244924AbjH3WJX (ORCPT ); Wed, 30 Aug 2023 18:09:23 -0400 Received: from rere.qmqm.pl (rere.qmqm.pl [91.227.64.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95695E45 for ; Wed, 30 Aug 2023 15:08:54 -0700 (PDT) Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 4Rbd35658Czv2; Wed, 30 Aug 2023 23:38:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1693431537; bh=2CekRNDkBbHu6pEmNg2eRQDOpdZjkPKnS4qq90AdQJU=; h=Date:In-Reply-To:References:Subject:From:To:Cc:From; b=GBV8lCbuzNK75jX0HPgbylECXFm+1rk+oBaStXHSdAWuSBThBI9eyuYW+I0TepxWC S5ygz5Pq0l3tx9y/Z0QRD13Pp+F8PK1/lwMup5o0N0RQ+joAC4Naa2p3fUNu0bdpFP 0THNoJ1vzE7lcyf7Pds7YdK5FokuRgrVFQn/DyewCP6yYk11hW/pgsCZuW1eXKcmj7 ++b17xbI/ssknVcbAHME21VE6ndzQi3cKEwjvJOfMo/ZVxIEa9H5aV9P4SwiQr5i9S qbedp26ET39Ajl+ObzaoSgFrvQ8emFs3P0Mvpt4Bbc9ak7v3rafRJx4Ix1G6V3sWpq rT2DP7pG3coPw== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.8 at mail Date: Wed, 30 Aug 2023 23:38:57 +0200 Message-Id: <5250762009b124470f07daa947f130ccff518f50.1693431144.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: Subject: [PATCH 9/9] regulator/core: make regulator_class const MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The `struct class` is passed only to class_register() and a const pointer there. Make the data also const. Signed-off-by: Micha=C5=82 Miros=C5=82aw --- drivers/regulator/core.c | 3 ++- drivers/regulator/internal.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 8ab4de7cadcb..fedda29a2176 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -5797,7 +5797,7 @@ static const struct dev_pm_ops __maybe_unused regulat= or_pm_ops =3D { }; #endif =20 -struct class regulator_class =3D { +const struct class regulator_class =3D { .name =3D "regulator", .dev_release =3D regulator_dev_release, .dev_groups =3D regulator_dev_groups, @@ -5805,6 +5805,7 @@ struct class regulator_class =3D { .pm =3D ®ulator_pm_ops, #endif }; + /** * regulator_has_full_constraints - the system has fully specified constra= ints * diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h index fb4433068d29..77a502141089 100644 --- a/drivers/regulator/internal.h +++ b/drivers/regulator/internal.h @@ -58,7 +58,7 @@ struct regulator { struct dentry *debugfs; }; =20 -extern struct class regulator_class; +extern const struct class regulator_class; =20 static inline struct regulator_dev *dev_to_rdev(struct device *dev) { --=20 2.39.2