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: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Martyn Welch <martyn.welch@collabora.com> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20221016163409.320197-12-jic23@kernel.org
This commit is contained in:
Родитель
c437c977c1
Коммит
b620be5f32
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче