lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <62effa7aa1a2023a77709e6416c57d9cb79a5ccc.1686995765.git.christophe.jaillet@wanadoo.fr>
Date:   Sat, 17 Jun 2023 11:57:09 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     Johan Hovold <johan@...nel.org>,
        Matthias Brugger <matthias.bgg@...il.com>,
        AngeloGioacchino Del Regno 
        <angelogioacchino.delregno@...labora.com>,
        Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>
Cc:     linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        Christophe JAILLET <christophe.jaillet@...adoo.fr>,
        linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org
Subject: [PATCH] gnss: Use devm_regulator_get_enable_optional()

Use devm_regulator_get_enable_optional() instead of hand writing it. It
saves some line of code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
Note that regulator_disable() is now called after gnss_serial_free() in
the error handling path of the probe and in the remove function, but it
looks harmless to me.
---
 drivers/gnss/mtk.c | 26 ++++----------------------
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/gnss/mtk.c b/drivers/gnss/mtk.c
index c62b1211f4fe..d3d31295d4e0 100644
--- a/drivers/gnss/mtk.c
+++ b/drivers/gnss/mtk.c
@@ -17,7 +17,6 @@
 #include "serial.h"
 
 struct mtk_data {
-	struct regulator *vbackup;
 	struct regulator *vcc;
 };
 
@@ -87,30 +86,16 @@ static int mtk_probe(struct serdev_device *serdev)
 		goto err_free_gserial;
 	}
 
-	data->vbackup = devm_regulator_get_optional(&serdev->dev, "vbackup");
-	if (IS_ERR(data->vbackup)) {
-		ret = PTR_ERR(data->vbackup);
-		if (ret == -ENODEV)
-			data->vbackup = NULL;
-		else
-			goto err_free_gserial;
-	}
-
-	if (data->vbackup) {
-		ret = regulator_enable(data->vbackup);
-		if (ret)
-			goto err_free_gserial;
-	}
+	ret = devm_regulator_get_enable_optional(&serdev->dev, "vbackup");
+	if (ret)
+		goto err_free_gserial;
 
 	ret = gnss_serial_register(gserial);
 	if (ret)
-		goto err_disable_vbackup;
+		goto err_free_gserial;
 
 	return 0;
 
-err_disable_vbackup:
-	if (data->vbackup)
-		regulator_disable(data->vbackup);
 err_free_gserial:
 	gnss_serial_free(gserial);
 
@@ -120,11 +105,8 @@ static int mtk_probe(struct serdev_device *serdev)
 static void mtk_remove(struct serdev_device *serdev)
 {
 	struct gnss_serial *gserial = serdev_device_get_drvdata(serdev);
-	struct mtk_data *data = gnss_serial_get_drvdata(gserial);
 
 	gnss_serial_deregister(gserial);
-	if (data->vbackup)
-		regulator_disable(data->vbackup);
 	gnss_serial_free(gserial);
 }
 
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ