Commit eefa008b authored by Jonathan Cameron's avatar Jonathan Cameron

iio: accel: msa311: 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: Dmitry Rokosov <DDRokosov@sberdevices.ru>
Reviewed-by: default avatarDmitry Rokosov <ddrokosov@sberdevices.ru>
Reviewed-by: default avatarNuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20221016163409.320197-6-jic23@kernel.org
parent 1fa4ff1f
......@@ -351,7 +351,6 @@ static const struct regmap_config msa311_regmap_config = {
* @chip_name: Chip name in the format "msa311-%02x" % partid
* @new_data_trig: Optional NEW_DATA interrupt driven trigger used
* to notify external consumers a new sample is ready
* @vdd: Optional external voltage regulator for the device power supply
*/
struct msa311_priv {
struct regmap *regs;
......@@ -362,7 +361,6 @@ struct msa311_priv {
char *chip_name;
struct iio_trigger *new_data_trig;
struct regulator *vdd;
};
enum msa311_si {
......@@ -1146,11 +1144,6 @@ static void msa311_powerdown(void *msa311)
msa311_set_pwr_mode(msa311, MSA311_PWR_MODE_SUSPEND);
}
static void msa311_vdd_disable(void *vdd)
{
regulator_disable(vdd);
}
static int msa311_probe(struct i2c_client *i2c)
{
struct device *dev = &i2c->dev;
......@@ -1173,19 +1166,9 @@ static int msa311_probe(struct i2c_client *i2c)
mutex_init(&msa311->lock);
msa311->vdd = devm_regulator_get(dev, "vdd");
if (IS_ERR(msa311->vdd))
return dev_err_probe(dev, PTR_ERR(msa311->vdd),
"can't get vdd supply\n");
err = regulator_enable(msa311->vdd);
err = devm_regulator_get_enable(dev, "vdd");
if (err)
return dev_err_probe(dev, err, "can't enable vdd supply\n");
err = devm_add_action_or_reset(dev, msa311_vdd_disable, msa311->vdd);
if (err)
return dev_err_probe(dev, err,
"can't add vdd disable action\n");
return dev_err_probe(dev, err, "can't get vdd supply\n");
err = msa311_check_partid(msa311);
if (err)
......
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