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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxx>
---
 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




[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux