Commit ac142f2b authored by Wolfram Sang's avatar Wolfram Sang Committed by Johan Hovold

gnss: ubx: use new helper to remove open coded regulator handling

v_bckp shall always be enabled as long as the device exists. We now have
a regulator helper for that, use it.
Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent a39b6ac3
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "serial.h" #include "serial.h"
struct ubx_data { struct ubx_data {
struct regulator *v_bckp;
struct regulator *vcc; struct regulator *vcc;
}; };
...@@ -87,30 +86,16 @@ static int ubx_probe(struct serdev_device *serdev) ...@@ -87,30 +86,16 @@ static int ubx_probe(struct serdev_device *serdev)
goto err_free_gserial; goto err_free_gserial;
} }
data->v_bckp = devm_regulator_get_optional(&serdev->dev, "v-bckp"); ret = devm_regulator_get_enable_optional(&serdev->dev, "v-bckp");
if (IS_ERR(data->v_bckp)) { if (ret < 0 && ret != -ENODEV)
ret = PTR_ERR(data->v_bckp); goto err_free_gserial;
if (ret == -ENODEV)
data->v_bckp = NULL;
else
goto err_free_gserial;
}
if (data->v_bckp) {
ret = regulator_enable(data->v_bckp);
if (ret)
goto err_free_gserial;
}
ret = gnss_serial_register(gserial); ret = gnss_serial_register(gserial);
if (ret) if (ret)
goto err_disable_v_bckp; goto err_free_gserial;
return 0; return 0;
err_disable_v_bckp:
if (data->v_bckp)
regulator_disable(data->v_bckp);
err_free_gserial: err_free_gserial:
gnss_serial_free(gserial); gnss_serial_free(gserial);
...@@ -120,11 +105,8 @@ static int ubx_probe(struct serdev_device *serdev) ...@@ -120,11 +105,8 @@ static int ubx_probe(struct serdev_device *serdev)
static void ubx_remove(struct serdev_device *serdev) static void ubx_remove(struct serdev_device *serdev)
{ {
struct gnss_serial *gserial = serdev_device_get_drvdata(serdev); struct gnss_serial *gserial = serdev_device_get_drvdata(serdev);
struct ubx_data *data = gnss_serial_get_drvdata(gserial);
gnss_serial_deregister(gserial); gnss_serial_deregister(gserial);
if (data->v_bckp)
regulator_disable(data->v_bckp);
gnss_serial_free(gserial); gnss_serial_free(gserial);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment