Commit 3a271275 authored by David Heidelberg's avatar David Heidelberg Committed by Jonathan Cameron

iio: light: al3320a implement devm_add_action_or_reset

Use devm_add_action_or_reset to automatically disable the device
and allow you to get rid of the remove function entirely.
Signed-off-by: default avatarDavid Heidelberg <david@ixit.cz>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent c39a05e3
...@@ -87,6 +87,13 @@ static int al3320a_set_pwr(struct i2c_client *client, bool pwr) ...@@ -87,6 +87,13 @@ static int al3320a_set_pwr(struct i2c_client *client, bool pwr)
return i2c_smbus_write_byte_data(client, AL3320A_REG_CONFIG, val); return i2c_smbus_write_byte_data(client, AL3320A_REG_CONFIG, val);
} }
static void al3320a_set_pwr_off(void *_data)
{
struct al3320a_data *data = _data;
al3320a_set_pwr(data->client, false);
}
static int al3320a_init(struct al3320a_data *data) static int al3320a_init(struct al3320a_data *data)
{ {
int ret; int ret;
...@@ -206,12 +213,14 @@ static int al3320a_probe(struct i2c_client *client, ...@@ -206,12 +213,14 @@ static int al3320a_probe(struct i2c_client *client,
dev_err(&client->dev, "al3320a chip init failed\n"); dev_err(&client->dev, "al3320a chip init failed\n");
return ret; return ret;
} }
return devm_iio_device_register(&client->dev, indio_dev);
}
static int al3320a_remove(struct i2c_client *client) ret = devm_add_action_or_reset(&client->dev,
{ al3320a_set_pwr_off,
return al3320a_set_pwr(client, false); data);
if (ret < 0)
return ret;
return devm_iio_device_register(&client->dev, indio_dev);
} }
static int __maybe_unused al3320a_suspend(struct device *dev) static int __maybe_unused al3320a_suspend(struct device *dev)
...@@ -238,7 +247,6 @@ static struct i2c_driver al3320a_driver = { ...@@ -238,7 +247,6 @@ static struct i2c_driver al3320a_driver = {
.pm = &al3320a_pm_ops, .pm = &al3320a_pm_ops,
}, },
.probe = al3320a_probe, .probe = al3320a_probe,
.remove = al3320a_remove,
.id_table = al3320a_id, .id_table = al3320a_id,
}; };
......
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