mirror of
https://github.com/torvalds/linux.git
synced 2024-11-02 10:11:36 +00:00
iio: bmg160: Remove remaining uses of i2c_client
Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
ebc6eb5907
commit
5d889abbe5
@ -110,6 +110,7 @@ struct bmg160_data {
|
|||||||
int slope_thres;
|
int slope_thres;
|
||||||
bool dready_trigger_on;
|
bool dready_trigger_on;
|
||||||
bool motion_trigger_on;
|
bool motion_trigger_on;
|
||||||
|
int irq;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum bmg160_axis {
|
enum bmg160_axis {
|
||||||
@ -961,18 +962,13 @@ static const struct iio_buffer_setup_ops bmg160_buffer_setup_ops = {
|
|||||||
.postdisable = bmg160_buffer_postdisable,
|
.postdisable = bmg160_buffer_postdisable,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int bmg160_gpio_probe(struct i2c_client *client,
|
static int bmg160_gpio_probe(struct bmg160_data *data)
|
||||||
struct bmg160_data *data)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
struct gpio_desc *gpio;
|
struct gpio_desc *gpio;
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!client)
|
dev = data->dev;
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
dev = &client->dev;
|
|
||||||
|
|
||||||
/* data ready gpio interrupt pin */
|
/* data ready gpio interrupt pin */
|
||||||
gpio = devm_gpiod_get_index(dev, BMG160_GPIO_NAME, 0, GPIOD_IN);
|
gpio = devm_gpiod_get_index(dev, BMG160_GPIO_NAME, 0, GPIOD_IN);
|
||||||
@ -981,11 +977,12 @@ static int bmg160_gpio_probe(struct i2c_client *client,
|
|||||||
return PTR_ERR(gpio);
|
return PTR_ERR(gpio);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gpiod_to_irq(gpio);
|
data->irq = gpiod_to_irq(gpio);
|
||||||
|
|
||||||
dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
|
dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio),
|
||||||
|
data->irq);
|
||||||
|
|
||||||
return ret;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *bmg160_match_acpi_device(struct device *dev)
|
static const char *bmg160_match_acpi_device(struct device *dev)
|
||||||
@ -1007,6 +1004,7 @@ static int bmg160_probe(struct i2c_client *client,
|
|||||||
int ret;
|
int ret;
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
|
struct device *dev = &client->dev;
|
||||||
|
|
||||||
regmap = devm_regmap_init_i2c(client, &bmg160_regmap_i2c_conf);
|
regmap = devm_regmap_init_i2c(client, &bmg160_regmap_i2c_conf);
|
||||||
if (IS_ERR(regmap)) {
|
if (IS_ERR(regmap)) {
|
||||||
@ -1020,8 +1018,9 @@ static int bmg160_probe(struct i2c_client *client,
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
data = iio_priv(indio_dev);
|
data = iio_priv(indio_dev);
|
||||||
dev_set_drvdata(&client->dev, indio_dev);
|
dev_set_drvdata(dev, indio_dev);
|
||||||
data->dev = &client->dev;
|
data->dev = dev;
|
||||||
|
data->irq = client->irq;
|
||||||
|
|
||||||
ret = bmg160_chip_init(data);
|
ret = bmg160_chip_init(data);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@ -1032,22 +1031,22 @@ static int bmg160_probe(struct i2c_client *client,
|
|||||||
if (id)
|
if (id)
|
||||||
name = id->name;
|
name = id->name;
|
||||||
|
|
||||||
if (ACPI_HANDLE(&client->dev))
|
if (ACPI_HANDLE(dev))
|
||||||
name = bmg160_match_acpi_device(&client->dev);
|
name = bmg160_match_acpi_device(dev);
|
||||||
|
|
||||||
indio_dev->dev.parent = &client->dev;
|
indio_dev->dev.parent = dev;
|
||||||
indio_dev->channels = bmg160_channels;
|
indio_dev->channels = bmg160_channels;
|
||||||
indio_dev->num_channels = ARRAY_SIZE(bmg160_channels);
|
indio_dev->num_channels = ARRAY_SIZE(bmg160_channels);
|
||||||
indio_dev->name = name;
|
indio_dev->name = name;
|
||||||
indio_dev->modes = INDIO_DIRECT_MODE;
|
indio_dev->modes = INDIO_DIRECT_MODE;
|
||||||
indio_dev->info = &bmg160_info;
|
indio_dev->info = &bmg160_info;
|
||||||
|
|
||||||
if (client->irq <= 0)
|
if (data->irq <= 0)
|
||||||
client->irq = bmg160_gpio_probe(client, data);
|
bmg160_gpio_probe(data);
|
||||||
|
|
||||||
if (client->irq > 0) {
|
if (data->irq > 0) {
|
||||||
ret = devm_request_threaded_irq(&client->dev,
|
ret = devm_request_threaded_irq(dev,
|
||||||
client->irq,
|
data->irq,
|
||||||
bmg160_data_rdy_trig_poll,
|
bmg160_data_rdy_trig_poll,
|
||||||
bmg160_event_handler,
|
bmg160_event_handler,
|
||||||
IRQF_TRIGGER_RISING,
|
IRQF_TRIGGER_RISING,
|
||||||
@ -1056,28 +1055,28 @@ static int bmg160_probe(struct i2c_client *client,
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
data->dready_trig = devm_iio_trigger_alloc(&client->dev,
|
data->dready_trig = devm_iio_trigger_alloc(dev,
|
||||||
"%s-dev%d",
|
"%s-dev%d",
|
||||||
indio_dev->name,
|
indio_dev->name,
|
||||||
indio_dev->id);
|
indio_dev->id);
|
||||||
if (!data->dready_trig)
|
if (!data->dready_trig)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
data->motion_trig = devm_iio_trigger_alloc(&client->dev,
|
data->motion_trig = devm_iio_trigger_alloc(dev,
|
||||||
"%s-any-motion-dev%d",
|
"%s-any-motion-dev%d",
|
||||||
indio_dev->name,
|
indio_dev->name,
|
||||||
indio_dev->id);
|
indio_dev->id);
|
||||||
if (!data->motion_trig)
|
if (!data->motion_trig)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
data->dready_trig->dev.parent = &client->dev;
|
data->dready_trig->dev.parent = dev;
|
||||||
data->dready_trig->ops = &bmg160_trigger_ops;
|
data->dready_trig->ops = &bmg160_trigger_ops;
|
||||||
iio_trigger_set_drvdata(data->dready_trig, indio_dev);
|
iio_trigger_set_drvdata(data->dready_trig, indio_dev);
|
||||||
ret = iio_trigger_register(data->dready_trig);
|
ret = iio_trigger_register(data->dready_trig);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
data->motion_trig->dev.parent = &client->dev;
|
data->motion_trig->dev.parent = dev;
|
||||||
data->motion_trig->ops = &bmg160_trigger_ops;
|
data->motion_trig->ops = &bmg160_trigger_ops;
|
||||||
iio_trigger_set_drvdata(data->motion_trig, indio_dev);
|
iio_trigger_set_drvdata(data->motion_trig, indio_dev);
|
||||||
ret = iio_trigger_register(data->motion_trig);
|
ret = iio_trigger_register(data->motion_trig);
|
||||||
@ -1092,25 +1091,25 @@ static int bmg160_probe(struct i2c_client *client,
|
|||||||
bmg160_trigger_handler,
|
bmg160_trigger_handler,
|
||||||
&bmg160_buffer_setup_ops);
|
&bmg160_buffer_setup_ops);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&client->dev,
|
dev_err(dev,
|
||||||
"iio triggered buffer setup failed\n");
|
"iio triggered buffer setup failed\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;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pm_runtime_set_active(&client->dev);
|
ret = pm_runtime_set_active(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_iio_unregister;
|
goto err_iio_unregister;
|
||||||
|
|
||||||
pm_runtime_enable(&client->dev);
|
pm_runtime_enable(dev);
|
||||||
pm_runtime_set_autosuspend_delay(&client->dev,
|
pm_runtime_set_autosuspend_delay(dev,
|
||||||
BMG160_AUTO_SUSPEND_DELAY_MS);
|
BMG160_AUTO_SUSPEND_DELAY_MS);
|
||||||
pm_runtime_use_autosuspend(&client->dev);
|
pm_runtime_use_autosuspend(dev);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user