| .. | .. |
|---|
| 6 | 6 | * Author: Matt Ranostay <matt.ranostay@konsulko.com> |
|---|
| 7 | 7 | * |
|---|
| 8 | 8 | * Datasheets: |
|---|
| 9 | | - * http://www.ti.com/product/HDC1000/datasheet |
|---|
| 10 | | - * http://www.ti.com/product/HDC1008/datasheet |
|---|
| 11 | | - * http://www.ti.com/product/HDC1010/datasheet |
|---|
| 12 | | - * http://www.ti.com/product/HDC1050/datasheet |
|---|
| 13 | | - * http://www.ti.com/product/HDC1080/datasheet |
|---|
| 9 | + * https://www.ti.com/product/HDC1000/datasheet |
|---|
| 10 | + * https://www.ti.com/product/HDC1008/datasheet |
|---|
| 11 | + * https://www.ti.com/product/HDC1010/datasheet |
|---|
| 12 | + * https://www.ti.com/product/HDC1050/datasheet |
|---|
| 13 | + * https://www.ti.com/product/HDC1080/datasheet |
|---|
| 14 | 14 | */ |
|---|
| 15 | 15 | |
|---|
| 16 | 16 | #include <linux/delay.h> |
|---|
| 17 | 17 | #include <linux/module.h> |
|---|
| 18 | +#include <linux/mod_devicetable.h> |
|---|
| 18 | 19 | #include <linux/init.h> |
|---|
| 19 | 20 | #include <linux/i2c.h> |
|---|
| 20 | 21 | |
|---|
| .. | .. |
|---|
| 290 | 291 | ret = hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE, |
|---|
| 291 | 292 | HDC100X_REG_CONFIG_ACQ_MODE); |
|---|
| 292 | 293 | mutex_unlock(&data->lock); |
|---|
| 293 | | - if (ret) |
|---|
| 294 | | - return ret; |
|---|
| 295 | 294 | |
|---|
| 296 | | - return iio_triggered_buffer_postenable(indio_dev); |
|---|
| 295 | + return ret; |
|---|
| 297 | 296 | } |
|---|
| 298 | 297 | |
|---|
| 299 | 298 | static int hdc100x_buffer_predisable(struct iio_dev *indio_dev) |
|---|
| 300 | 299 | { |
|---|
| 301 | 300 | struct hdc100x_data *data = iio_priv(indio_dev); |
|---|
| 302 | 301 | int ret; |
|---|
| 303 | | - |
|---|
| 304 | | - /* First detach poll func, then reset ACQ mode. OK to disable buffer */ |
|---|
| 305 | | - ret = iio_triggered_buffer_predisable(indio_dev); |
|---|
| 306 | | - if (ret) |
|---|
| 307 | | - return ret; |
|---|
| 308 | 302 | |
|---|
| 309 | 303 | mutex_lock(&data->lock); |
|---|
| 310 | 304 | ret = hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE, 0); |
|---|
| .. | .. |
|---|
| 377 | 371 | data->client = client; |
|---|
| 378 | 372 | mutex_init(&data->lock); |
|---|
| 379 | 373 | |
|---|
| 380 | | - indio_dev->dev.parent = &client->dev; |
|---|
| 381 | 374 | indio_dev->name = dev_name(&client->dev); |
|---|
| 382 | 375 | indio_dev->modes = INDIO_DIRECT_MODE; |
|---|
| 383 | 376 | indio_dev->info = &hdc100x_info; |
|---|
| .. | .. |
|---|
| 391 | 384 | hdc100x_set_it_time(data, 1, hdc100x_int_time[1][0]); |
|---|
| 392 | 385 | hdc100x_update_config(data, HDC100X_REG_CONFIG_ACQ_MODE, 0); |
|---|
| 393 | 386 | |
|---|
| 394 | | - ret = iio_triggered_buffer_setup(indio_dev, NULL, |
|---|
| 387 | + ret = devm_iio_triggered_buffer_setup(&client->dev, |
|---|
| 388 | + indio_dev, NULL, |
|---|
| 395 | 389 | hdc100x_trigger_handler, |
|---|
| 396 | 390 | &hdc_buffer_setup_ops); |
|---|
| 397 | 391 | if (ret < 0) { |
|---|
| 398 | 392 | dev_err(&client->dev, "iio triggered buffer setup failed\n"); |
|---|
| 399 | 393 | return ret; |
|---|
| 400 | 394 | } |
|---|
| 401 | | - ret = iio_device_register(indio_dev); |
|---|
| 402 | | - if (ret < 0) |
|---|
| 403 | | - iio_triggered_buffer_cleanup(indio_dev); |
|---|
| 404 | 395 | |
|---|
| 405 | | - return ret; |
|---|
| 406 | | -} |
|---|
| 407 | | - |
|---|
| 408 | | -static int hdc100x_remove(struct i2c_client *client) |
|---|
| 409 | | -{ |
|---|
| 410 | | - struct iio_dev *indio_dev = i2c_get_clientdata(client); |
|---|
| 411 | | - |
|---|
| 412 | | - iio_device_unregister(indio_dev); |
|---|
| 413 | | - iio_triggered_buffer_cleanup(indio_dev); |
|---|
| 414 | | - |
|---|
| 415 | | - return 0; |
|---|
| 396 | + return devm_iio_device_register(&client->dev, indio_dev); |
|---|
| 416 | 397 | } |
|---|
| 417 | 398 | |
|---|
| 418 | 399 | static const struct i2c_device_id hdc100x_id[] = { |
|---|
| .. | .. |
|---|
| 439 | 420 | static struct i2c_driver hdc100x_driver = { |
|---|
| 440 | 421 | .driver = { |
|---|
| 441 | 422 | .name = "hdc100x", |
|---|
| 442 | | - .of_match_table = of_match_ptr(hdc100x_dt_ids), |
|---|
| 423 | + .of_match_table = hdc100x_dt_ids, |
|---|
| 443 | 424 | }, |
|---|
| 444 | 425 | .probe = hdc100x_probe, |
|---|
| 445 | | - .remove = hdc100x_remove, |
|---|
| 446 | 426 | .id_table = hdc100x_id, |
|---|
| 447 | 427 | }; |
|---|
| 448 | 428 | module_i2c_driver(hdc100x_driver); |
|---|