Commit 96417256 authored by Linus Walleij's avatar Linus Walleij Committed by Jonathan Cameron

iio: accel: bma180: Add dev helper variable

Having a shorthand "dev" instead of &client->dev everywhere
makes the code easier to read (more compact).

Cc: Peter Meerwald <pmeerw@pmeerw.net>
Cc: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent e485e2a2
...@@ -712,12 +712,13 @@ static const struct iio_trigger_ops bma180_trigger_ops = { ...@@ -712,12 +712,13 @@ static const struct iio_trigger_ops bma180_trigger_ops = {
static int bma180_probe(struct i2c_client *client, static int bma180_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct device *dev = &client->dev;
struct bma180_data *data; struct bma180_data *data;
struct iio_dev *indio_dev; struct iio_dev *indio_dev;
enum chip_ids chip; enum chip_ids chip;
int ret; int ret;
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
if (!indio_dev) if (!indio_dev)
return -ENOMEM; return -ENOMEM;
...@@ -725,12 +726,12 @@ static int bma180_probe(struct i2c_client *client, ...@@ -725,12 +726,12 @@ static int bma180_probe(struct i2c_client *client,
i2c_set_clientdata(client, indio_dev); i2c_set_clientdata(client, indio_dev);
data->client = client; data->client = client;
if (client->dev.of_node) if (client->dev.of_node)
chip = (enum chip_ids)of_device_get_match_data(&client->dev); chip = (enum chip_ids)of_device_get_match_data(dev);
else else
chip = id->driver_data; chip = id->driver_data;
data->part_info = &bma180_part_info[chip]; data->part_info = &bma180_part_info[chip];
ret = iio_read_mount_matrix(&client->dev, "mount-matrix", ret = iio_read_mount_matrix(dev, "mount-matrix",
&data->orientation); &data->orientation);
if (ret) if (ret)
return ret; return ret;
...@@ -740,7 +741,7 @@ static int bma180_probe(struct i2c_client *client, ...@@ -740,7 +741,7 @@ static int bma180_probe(struct i2c_client *client,
goto err_chip_disable; goto err_chip_disable;
mutex_init(&data->mutex); mutex_init(&data->mutex);
indio_dev->dev.parent = &client->dev; indio_dev->dev.parent = dev;
indio_dev->channels = data->part_info->channels; indio_dev->channels = data->part_info->channels;
indio_dev->num_channels = data->part_info->num_channels; indio_dev->num_channels = data->part_info->num_channels;
indio_dev->name = id->name; indio_dev->name = id->name;
...@@ -755,15 +756,15 @@ static int bma180_probe(struct i2c_client *client, ...@@ -755,15 +756,15 @@ static int bma180_probe(struct i2c_client *client,
goto err_chip_disable; goto err_chip_disable;
} }
ret = devm_request_irq(&client->dev, client->irq, ret = devm_request_irq(dev, client->irq,
iio_trigger_generic_data_rdy_poll, IRQF_TRIGGER_RISING, iio_trigger_generic_data_rdy_poll, IRQF_TRIGGER_RISING,
"bma180_event", data->trig); "bma180_event", data->trig);
if (ret) { if (ret) {
dev_err(&client->dev, "unable to request IRQ\n"); dev_err(dev, "unable to request IRQ\n");
goto err_trigger_free; goto err_trigger_free;
} }
data->trig->dev.parent = &client->dev; data->trig->dev.parent = dev;
data->trig->ops = &bma180_trigger_ops; data->trig->ops = &bma180_trigger_ops;
iio_trigger_set_drvdata(data->trig, indio_dev); iio_trigger_set_drvdata(data->trig, indio_dev);
indio_dev->trig = iio_trigger_get(data->trig); indio_dev->trig = iio_trigger_get(data->trig);
...@@ -776,13 +777,13 @@ static int bma180_probe(struct i2c_client *client, ...@@ -776,13 +777,13 @@ static int bma180_probe(struct i2c_client *client,
ret = iio_triggered_buffer_setup(indio_dev, NULL, ret = iio_triggered_buffer_setup(indio_dev, NULL,
bma180_trigger_handler, NULL); bma180_trigger_handler, NULL);
if (ret < 0) { if (ret < 0) {
dev_err(&client->dev, "unable to setup iio triggered buffer\n"); dev_err(dev, "unable to setup iio triggered buffer\n");
goto err_trigger_unregister; goto err_trigger_unregister;
} }
ret = iio_device_register(indio_dev); ret = iio_device_register(indio_dev);
if (ret < 0) { if (ret < 0) {
dev_err(&client->dev, "unable to register iio device\n"); dev_err(dev, "unable to register iio device\n");
goto err_buffer_cleanup; goto err_buffer_cleanup;
} }
......
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