Commit b620be5f authored by Jonathan Cameron's avatar Jonathan Cameron

iio: light: noa1305: Use devm_regulator_get_enable()

This driver only turns the power on at probe and off via a custom
devm_add_action_or_reset() callback. The new devm_regulator_get_enable()
replaces this boilerplate code.
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Martyn Welch <martyn.welch@collabora.com>
Reviewed-by: default avatarMatti Vaittinen <mazziesaccount@gmail.com>
Reviewed-by: default avatarNuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20221016163409.320197-12-jic23@kernel.org
parent c437c977
......@@ -46,7 +46,6 @@
struct noa1305_priv {
struct i2c_client *client;
struct regmap *regmap;
struct regulator *vin_reg;
};
static int noa1305_measure(struct noa1305_priv *priv)
......@@ -187,13 +186,6 @@ static const struct regmap_config noa1305_regmap_config = {
.writeable_reg = noa1305_writable_reg,
};
static void noa1305_reg_remove(void *data)
{
struct noa1305_priv *priv = data;
regulator_disable(priv->vin_reg);
}
static int noa1305_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
......@@ -216,23 +208,11 @@ static int noa1305_probe(struct i2c_client *client,
priv = iio_priv(indio_dev);
priv->vin_reg = devm_regulator_get(&client->dev, "vin");
if (IS_ERR(priv->vin_reg))
return dev_err_probe(&client->dev, PTR_ERR(priv->vin_reg),
ret = devm_regulator_get_enable(&client->dev, "vin");
if (ret)
return dev_err_probe(&client->dev, ret,
"get regulator vin failed\n");
ret = regulator_enable(priv->vin_reg);
if (ret) {
dev_err(&client->dev, "enable regulator vin failed\n");
return ret;
}
ret = devm_add_action_or_reset(&client->dev, noa1305_reg_remove, priv);
if (ret) {
dev_err(&client->dev, "addition of devm action failed\n");
return ret;
}
i2c_set_clientdata(client, indio_dev);
priv->client = client;
priv->regmap = regmap;
......
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