[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230523064310.3005-4-wsa+renesas@sang-engineering.com>
Date: Tue, 23 May 2023 08:43:08 +0200
From: Wolfram Sang <wsa+renesas@...g-engineering.com>
To: linux-renesas-soc@...r.kernel.org
Cc: Johan Hovold <johan@...nel.org>, linux-kernel@...r.kernel.org,
Wolfram Sang <wsa+renesas@...g-engineering.com>
Subject: [RFC PATCH 3/5] gnss: ubx: 'vcc' can be optional
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@...g-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
Powered by blists - more mailing lists