[RFC PATCH 3/5] gnss: ubx: 'vcc' can be optional

Wolfram Sang posted 5 patches 2 years, 8 months ago
There is a newer version of this series
[RFC PATCH 3/5] gnss: ubx: 'vcc' can be optional
Posted by Wolfram Sang 2 years, 8 months ago
There are devices where 'vcc' is always on. The reset pin is used for
silencing the chip. Make the 'vcc' regulator optional.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/gnss/ubx.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/drivers/gnss/ubx.c b/drivers/gnss/ubx.c
index c8d027973b85..d5281bfae9cb 100644
--- a/drivers/gnss/ubx.c
+++ b/drivers/gnss/ubx.c
@@ -25,9 +25,11 @@ static int ubx_set_active(struct gnss_serial *gserial)
 	struct ubx_data *data = gnss_serial_get_drvdata(gserial);
 	int ret;
 
-	ret = regulator_enable(data->vcc);
-	if (ret)
-		return ret;
+	if (data->vcc) {
+		ret = regulator_enable(data->vcc);
+		if (ret)
+			return ret;
+	}
 
 	return 0;
 }
@@ -37,9 +39,11 @@ static int ubx_set_standby(struct gnss_serial *gserial)
 	struct ubx_data *data = gnss_serial_get_drvdata(gserial);
 	int ret;
 
-	ret = regulator_disable(data->vcc);
-	if (ret)
-		return ret;
+	if (data->vcc) {
+		ret = regulator_disable(data->vcc);
+		if (ret)
+			return ret;
+	}
 
 	return 0;
 }
@@ -99,10 +103,13 @@ static int ubx_probe(struct serdev_device *serdev)
 
 	data = gnss_serial_get_drvdata(gserial);
 
-	data->vcc = devm_regulator_get(&serdev->dev, "vcc");
+	data->vcc = devm_regulator_get_optional(&serdev->dev, "vcc");
 	if (IS_ERR(data->vcc)) {
 		ret = PTR_ERR(data->vcc);
-		goto err_free_gserial;
+		if (ret == -ENODEV)
+			data->vcc = NULL;
+		else
+			goto err_free_gserial;
 	}
 
 	ret = devm_regulator_get_enable_optional(&serdev->dev, info->v_bckp_name);
-- 
2.35.1
Re: [RFC PATCH 3/5] gnss: ubx: 'vcc' can be optional
Posted by Johan Hovold 2 years, 7 months ago
On Tue, May 23, 2023 at 08:43:08AM +0200, Wolfram Sang wrote:
> There are devices where 'vcc' is always on. The reset pin is used for
> silencing the chip. Make the 'vcc' regulator optional.

The device still has a vcc supply even if it happens to be always-on on
a particular board (and this should be reflected in the DT).

Johan
Re: [RFC PATCH 3/5] gnss: ubx: 'vcc' can be optional
Posted by Wolfram Sang 2 years, 7 months ago
> The device still has a vcc supply even if it happens to be always-on on
> a particular board (and this should be reflected in the DT).

I'll drop this patch and update the DT.