diff options
author | Jonathan Cameron <jic23@cam.ac.uk> | 2011-05-18 09:42:37 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-05-19 19:15:05 -0400 |
commit | 6fe8135fccd66aedcc55ded70824342587fd2499 (patch) | |
tree | 3afc7acfd0edc052ba93241761e935af9a3b6ebc | |
parent | a3f02370c9fa6d85fbee2c11649ebc9c84bae919 (diff) |
staging:iio: implement an iio_info structure to take some of the constant elements out of iio_dev.
This was suggested by Arnd Bergmann, Other elements may well
move in here in future, but it definitely makes sense for these.
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
61 files changed, 964 insertions, 669 deletions
diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c index 59b6ac2ca545..e4c49f00d132 100644 --- a/drivers/staging/iio/accel/adis16201_core.c +++ b/drivers/staging/iio/accel/adis16201_core.c | |||
@@ -457,6 +457,13 @@ static const struct attribute_group adis16201_attribute_group = { | |||
457 | .attrs = adis16201_attributes, | 457 | .attrs = adis16201_attributes, |
458 | }; | 458 | }; |
459 | 459 | ||
460 | static const struct iio_info adis16201_info = { | ||
461 | .attrs = &adis16201_attribute_group, | ||
462 | .read_raw = &adis16201_read_raw, | ||
463 | .write_raw = &adis16201_write_raw, | ||
464 | .driver_module = THIS_MODULE, | ||
465 | }; | ||
466 | |||
460 | static int __devinit adis16201_probe(struct spi_device *spi) | 467 | static int __devinit adis16201_probe(struct spi_device *spi) |
461 | { | 468 | { |
462 | int ret, regdone = 0; | 469 | int ret, regdone = 0; |
@@ -490,13 +497,11 @@ static int __devinit adis16201_probe(struct spi_device *spi) | |||
490 | 497 | ||
491 | st->indio_dev->name = spi->dev.driver->name; | 498 | st->indio_dev->name = spi->dev.driver->name; |
492 | st->indio_dev->dev.parent = &spi->dev; | 499 | st->indio_dev->dev.parent = &spi->dev; |
493 | st->indio_dev->attrs = &adis16201_attribute_group; | 500 | st->indio_dev->info = &adis16201_info; |
501 | |||
494 | st->indio_dev->channels = adis16201_channels; | 502 | st->indio_dev->channels = adis16201_channels; |
495 | st->indio_dev->num_channels = ARRAY_SIZE(adis16201_channels); | 503 | st->indio_dev->num_channels = ARRAY_SIZE(adis16201_channels); |
496 | st->indio_dev->read_raw = &adis16201_read_raw; | ||
497 | st->indio_dev->write_raw = &adis16201_write_raw; | ||
498 | st->indio_dev->dev_data = (void *)(st); | 504 | st->indio_dev->dev_data = (void *)(st); |
499 | st->indio_dev->driver_module = THIS_MODULE; | ||
500 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 505 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
501 | 506 | ||
502 | ret = adis16201_configure_ring(st->indio_dev); | 507 | ret = adis16201_configure_ring(st->indio_dev); |
diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c index 1694a0c9929e..36be4d5dc614 100644 --- a/drivers/staging/iio/accel/adis16203_core.c +++ b/drivers/staging/iio/accel/adis16203_core.c | |||
@@ -408,6 +408,13 @@ static const struct attribute_group adis16203_attribute_group = { | |||
408 | .attrs = adis16203_attributes, | 408 | .attrs = adis16203_attributes, |
409 | }; | 409 | }; |
410 | 410 | ||
411 | static const struct iio_info adis16203_info = { | ||
412 | .attrs = &adis16203_attribute_group, | ||
413 | .read_raw = &adis16203_read_raw, | ||
414 | .write_raw = &adis16203_write_raw, | ||
415 | .driver_module = THIS_MODULE, | ||
416 | }; | ||
417 | |||
411 | static int __devinit adis16203_probe(struct spi_device *spi) | 418 | static int __devinit adis16203_probe(struct spi_device *spi) |
412 | { | 419 | { |
413 | int ret, regdone = 0; | 420 | int ret, regdone = 0; |
@@ -440,13 +447,10 @@ static int __devinit adis16203_probe(struct spi_device *spi) | |||
440 | } | 447 | } |
441 | st->indio_dev->name = spi->dev.driver->name; | 448 | st->indio_dev->name = spi->dev.driver->name; |
442 | st->indio_dev->dev.parent = &spi->dev; | 449 | st->indio_dev->dev.parent = &spi->dev; |
443 | st->indio_dev->attrs = &adis16203_attribute_group; | ||
444 | st->indio_dev->channels = adis16203_channels; | 450 | st->indio_dev->channels = adis16203_channels; |
445 | st->indio_dev->num_channels = ARRAY_SIZE(adis16203_channels); | 451 | st->indio_dev->num_channels = ARRAY_SIZE(adis16203_channels); |
446 | st->indio_dev->read_raw = &adis16203_read_raw; | 452 | st->indio_dev->info = &adis16203_info; |
447 | st->indio_dev->write_raw = &adis16203_write_raw; | ||
448 | st->indio_dev->dev_data = (void *)(st); | 453 | st->indio_dev->dev_data = (void *)(st); |
449 | st->indio_dev->driver_module = THIS_MODULE; | ||
450 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 454 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
451 | 455 | ||
452 | ret = adis16203_configure_ring(st->indio_dev); | 456 | ret = adis16203_configure_ring(st->indio_dev); |
diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c index 4e4944cf106e..16806704bf48 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c | |||
@@ -473,6 +473,13 @@ static const struct attribute_group adis16204_attribute_group = { | |||
473 | .attrs = adis16204_attributes, | 473 | .attrs = adis16204_attributes, |
474 | }; | 474 | }; |
475 | 475 | ||
476 | static const struct iio_info adis16204_info = { | ||
477 | .attrs = &adis16204_attribute_group, | ||
478 | .read_raw = &adis16204_read_raw, | ||
479 | .write_raw = &adis16204_write_raw, | ||
480 | .driver_module = THIS_MODULE, | ||
481 | }; | ||
482 | |||
476 | static int __devinit adis16204_probe(struct spi_device *spi) | 483 | static int __devinit adis16204_probe(struct spi_device *spi) |
477 | { | 484 | { |
478 | int ret, regdone = 0; | 485 | int ret, regdone = 0; |
@@ -506,13 +513,10 @@ static int __devinit adis16204_probe(struct spi_device *spi) | |||
506 | 513 | ||
507 | st->indio_dev->name = spi->dev.driver->name; | 514 | st->indio_dev->name = spi->dev.driver->name; |
508 | st->indio_dev->dev.parent = &spi->dev; | 515 | st->indio_dev->dev.parent = &spi->dev; |
509 | st->indio_dev->attrs = &adis16204_attribute_group; | 516 | st->indio_dev->info = &adis16204_info; |
510 | st->indio_dev->channels = adis16204_channels; | 517 | st->indio_dev->channels = adis16204_channels; |
511 | st->indio_dev->num_channels = ARRAY_SIZE(adis16204_channels); | 518 | st->indio_dev->num_channels = ARRAY_SIZE(adis16204_channels); |
512 | st->indio_dev->read_raw = &adis16204_read_raw; | ||
513 | st->indio_dev->write_raw = &adis16204_write_raw; | ||
514 | st->indio_dev->dev_data = (void *)(st); | 519 | st->indio_dev->dev_data = (void *)(st); |
515 | st->indio_dev->driver_module = THIS_MODULE; | ||
516 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 520 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
517 | 521 | ||
518 | ret = adis16204_configure_ring(st->indio_dev); | 522 | ret = adis16204_configure_ring(st->indio_dev); |
diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c index d48babe97977..c423cc960254 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c | |||
@@ -456,6 +456,13 @@ static const struct attribute_group adis16209_attribute_group = { | |||
456 | .attrs = adis16209_attributes, | 456 | .attrs = adis16209_attributes, |
457 | }; | 457 | }; |
458 | 458 | ||
459 | static const struct iio_info adis16209_info = { | ||
460 | .attrs = &adis16209_attribute_group, | ||
461 | .read_raw = &adis16209_read_raw, | ||
462 | .write_raw = &adis16209_write_raw, | ||
463 | .driver_module = THIS_MODULE, | ||
464 | }; | ||
465 | |||
459 | static int __devinit adis16209_probe(struct spi_device *spi) | 466 | static int __devinit adis16209_probe(struct spi_device *spi) |
460 | { | 467 | { |
461 | int ret, regdone = 0; | 468 | int ret, regdone = 0; |
@@ -489,13 +496,10 @@ static int __devinit adis16209_probe(struct spi_device *spi) | |||
489 | 496 | ||
490 | st->indio_dev->name = spi->dev.driver->name; | 497 | st->indio_dev->name = spi->dev.driver->name; |
491 | st->indio_dev->dev.parent = &spi->dev; | 498 | st->indio_dev->dev.parent = &spi->dev; |
492 | st->indio_dev->attrs = &adis16209_attribute_group; | 499 | st->indio_dev->info = &adis16209_info; |
493 | st->indio_dev->channels = adis16209_channels; | 500 | st->indio_dev->channels = adis16209_channels; |
494 | st->indio_dev->num_channels = ARRAY_SIZE(adis16209_channels); | 501 | st->indio_dev->num_channels = ARRAY_SIZE(adis16209_channels); |
495 | st->indio_dev->read_raw = &adis16209_read_raw; | ||
496 | st->indio_dev->write_raw = &adis16209_write_raw; | ||
497 | st->indio_dev->dev_data = (void *)(st); | 502 | st->indio_dev->dev_data = (void *)(st); |
498 | st->indio_dev->driver_module = THIS_MODULE; | ||
499 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 503 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
500 | 504 | ||
501 | ret = adis16209_configure_ring(st->indio_dev); | 505 | ret = adis16209_configure_ring(st->indio_dev); |
diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c index 7af48b8cb073..605a75ea3996 100644 --- a/drivers/staging/iio/accel/adis16220_core.c +++ b/drivers/staging/iio/accel/adis16220_core.c | |||
@@ -544,6 +544,10 @@ static const struct attribute_group adis16220_attribute_group = { | |||
544 | .attrs = adis16220_attributes, | 544 | .attrs = adis16220_attributes, |
545 | }; | 545 | }; |
546 | 546 | ||
547 | static const struct iio_info adis16220_info = { | ||
548 | .attrs = &adis16220_attribute_group, | ||
549 | .driver_module = THIS_MODULE, | ||
550 | }; | ||
547 | static int __devinit adis16220_probe(struct spi_device *spi) | 551 | static int __devinit adis16220_probe(struct spi_device *spi) |
548 | { | 552 | { |
549 | int ret, regdone = 0; | 553 | int ret, regdone = 0; |
@@ -577,9 +581,8 @@ static int __devinit adis16220_probe(struct spi_device *spi) | |||
577 | 581 | ||
578 | st->indio_dev->name = spi->dev.driver->name; | 582 | st->indio_dev->name = spi->dev.driver->name; |
579 | st->indio_dev->dev.parent = &spi->dev; | 583 | st->indio_dev->dev.parent = &spi->dev; |
580 | st->indio_dev->attrs = &adis16220_attribute_group; | 584 | st->indio_dev->info = &adis16220_info; |
581 | st->indio_dev->dev_data = (void *)(st); | 585 | st->indio_dev->dev_data = (void *)(st); |
582 | st->indio_dev->driver_module = THIS_MODULE; | ||
583 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 586 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
584 | 587 | ||
585 | ret = iio_device_register(st->indio_dev); | 588 | ret = iio_device_register(st->indio_dev); |
diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c index 537e0f22743e..ac6038557b0d 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c | |||
@@ -507,6 +507,13 @@ static const struct attribute_group adis16240_attribute_group = { | |||
507 | .attrs = adis16240_attributes, | 507 | .attrs = adis16240_attributes, |
508 | }; | 508 | }; |
509 | 509 | ||
510 | static const struct iio_info adis16240_info = { | ||
511 | .attrs = &adis16240_attribute_group, | ||
512 | .read_raw = &adis16240_read_raw, | ||
513 | .write_raw = &adis16240_write_raw, | ||
514 | .driver_module = THIS_MODULE, | ||
515 | }; | ||
516 | |||
510 | static int __devinit adis16240_probe(struct spi_device *spi) | 517 | static int __devinit adis16240_probe(struct spi_device *spi) |
511 | { | 518 | { |
512 | int ret, regdone = 0; | 519 | int ret, regdone = 0; |
@@ -540,13 +547,10 @@ static int __devinit adis16240_probe(struct spi_device *spi) | |||
540 | 547 | ||
541 | st->indio_dev->name = spi->dev.driver->name; | 548 | st->indio_dev->name = spi->dev.driver->name; |
542 | st->indio_dev->dev.parent = &spi->dev; | 549 | st->indio_dev->dev.parent = &spi->dev; |
543 | st->indio_dev->attrs = &adis16240_attribute_group; | 550 | st->indio_dev->info = &adis16240_info; |
544 | st->indio_dev->channels = adis16240_channels; | 551 | st->indio_dev->channels = adis16240_channels; |
545 | st->indio_dev->num_channels = ARRAY_SIZE(adis16240_channels); | 552 | st->indio_dev->num_channels = ARRAY_SIZE(adis16240_channels); |
546 | st->indio_dev->read_raw = &adis16240_read_raw; | ||
547 | st->indio_dev->write_raw = &adis16240_write_raw; | ||
548 | st->indio_dev->dev_data = (void *)(st); | 553 | st->indio_dev->dev_data = (void *)(st); |
549 | st->indio_dev->driver_module = THIS_MODULE; | ||
550 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 554 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
551 | 555 | ||
552 | ret = adis16240_configure_ring(st->indio_dev); | 556 | ret = adis16240_configure_ring(st->indio_dev); |
diff --git a/drivers/staging/iio/accel/kxsd9.c b/drivers/staging/iio/accel/kxsd9.c index 431aa0f886f1..973156e75773 100644 --- a/drivers/staging/iio/accel/kxsd9.c +++ b/drivers/staging/iio/accel/kxsd9.c | |||
@@ -301,6 +301,11 @@ error_ret: | |||
301 | 301 | ||
302 | }; | 302 | }; |
303 | 303 | ||
304 | static const struct iio_info kxsd9_info = { | ||
305 | .attrs = &kxsd9_attribute_group, | ||
306 | .driver_module = THIS_MODULE, | ||
307 | }; | ||
308 | |||
304 | static int __devinit kxsd9_probe(struct spi_device *spi) | 309 | static int __devinit kxsd9_probe(struct spi_device *spi) |
305 | { | 310 | { |
306 | 311 | ||
@@ -335,13 +340,8 @@ static int __devinit kxsd9_probe(struct spi_device *spi) | |||
335 | goto error_free_tx; | 340 | goto error_free_tx; |
336 | } | 341 | } |
337 | st->indio_dev->dev.parent = &spi->dev; | 342 | st->indio_dev->dev.parent = &spi->dev; |
338 | /* for now */ | 343 | st->indio_dev->info = &kxsd9_info; |
339 | st->indio_dev->num_interrupt_lines = 0; | ||
340 | st->indio_dev->event_attrs = NULL; | ||
341 | |||
342 | st->indio_dev->attrs = &kxsd9_attribute_group; | ||
343 | st->indio_dev->dev_data = (void *)(st); | 344 | st->indio_dev->dev_data = (void *)(st); |
344 | st->indio_dev->driver_module = THIS_MODULE; | ||
345 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 345 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
346 | 346 | ||
347 | ret = iio_device_register(st->indio_dev); | 347 | ret = iio_device_register(st->indio_dev); |
diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c index 942139a02ed7..ba5bc679204f 100644 --- a/drivers/staging/iio/accel/lis3l02dq_core.c +++ b/drivers/staging/iio/accel/lis3l02dq_core.c | |||
@@ -651,6 +651,18 @@ static const struct attribute_group lis3l02dq_attribute_group = { | |||
651 | .attrs = lis3l02dq_attributes, | 651 | .attrs = lis3l02dq_attributes, |
652 | }; | 652 | }; |
653 | 653 | ||
654 | static const struct iio_info lis3l02dq_info = { | ||
655 | .num_interrupt_lines = 1, | ||
656 | .read_raw = &lis3l02dq_read_raw, | ||
657 | .write_raw = &lis3l02dq_write_raw, | ||
658 | .read_event_value = &lis3l02dq_read_thresh, | ||
659 | .write_event_value = &lis3l02dq_write_thresh, | ||
660 | .write_event_config = &lis3l02dq_write_event_config, | ||
661 | .read_event_config = &lis3l02dq_read_event_config, | ||
662 | .driver_module = THIS_MODULE, | ||
663 | .attrs = &lis3l02dq_attribute_group, | ||
664 | }; | ||
665 | |||
654 | static int __devinit lis3l02dq_probe(struct spi_device *spi) | 666 | static int __devinit lis3l02dq_probe(struct spi_device *spi) |
655 | { | 667 | { |
656 | int ret, regdone = 0; | 668 | int ret, regdone = 0; |
@@ -670,17 +682,10 @@ static int __devinit lis3l02dq_probe(struct spi_device *spi) | |||
670 | mutex_init(&st->buf_lock); | 682 | mutex_init(&st->buf_lock); |
671 | indio_dev->name = spi->dev.driver->name; | 683 | indio_dev->name = spi->dev.driver->name; |
672 | indio_dev->dev.parent = &spi->dev; | 684 | indio_dev->dev.parent = &spi->dev; |
673 | indio_dev->num_interrupt_lines = 1; | 685 | indio_dev->info = &lis3l02dq_info; |
674 | indio_dev->channels = lis3l02dq_channels; | 686 | indio_dev->channels = lis3l02dq_channels; |
675 | indio_dev->num_channels = ARRAY_SIZE(lis3l02dq_channels); | 687 | indio_dev->num_channels = ARRAY_SIZE(lis3l02dq_channels); |
676 | indio_dev->read_raw = &lis3l02dq_read_raw; | 688 | |
677 | indio_dev->write_raw = &lis3l02dq_write_raw; | ||
678 | indio_dev->read_event_value = &lis3l02dq_read_thresh; | ||
679 | indio_dev->write_event_value = &lis3l02dq_write_thresh; | ||
680 | indio_dev->write_event_config = &lis3l02dq_write_event_config; | ||
681 | indio_dev->read_event_config = &lis3l02dq_read_event_config; | ||
682 | indio_dev->attrs = &lis3l02dq_attribute_group; | ||
683 | indio_dev->driver_module = THIS_MODULE; | ||
684 | indio_dev->modes = INDIO_DIRECT_MODE; | 689 | indio_dev->modes = INDIO_DIRECT_MODE; |
685 | 690 | ||
686 | ret = lis3l02dq_configure_ring(indio_dev); | 691 | ret = lis3l02dq_configure_ring(indio_dev); |
diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index 5de07fd76328..f213b8698eb2 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c | |||
@@ -1100,6 +1100,28 @@ error_ret: | |||
1100 | return ret; | 1100 | return ret; |
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | static const struct iio_info sca3000_info = { | ||
1104 | .attrs = &sca3000_attribute_group, | ||
1105 | .read_raw = &sca3000_read_raw, | ||
1106 | .num_interrupt_lines = 1, | ||
1107 | .event_attrs = &sca3000_event_attribute_group, | ||
1108 | .read_event_value = &sca3000_read_thresh, | ||
1109 | .write_event_value = &sca3000_write_thresh, | ||
1110 | .read_event_config = &sca3000_read_event_config, | ||
1111 | .write_event_config = &sca3000_write_event_config, | ||
1112 | .driver_module = THIS_MODULE, | ||
1113 | }; | ||
1114 | |||
1115 | static const struct iio_info sca3000_info_with_temp = { | ||
1116 | .attrs = &sca3000_attribute_group_with_temp, | ||
1117 | .read_raw = &sca3000_read_raw, | ||
1118 | .read_event_value = &sca3000_read_thresh, | ||
1119 | .write_event_value = &sca3000_write_thresh, | ||
1120 | .read_event_config = &sca3000_read_event_config, | ||
1121 | .write_event_config = &sca3000_write_event_config, | ||
1122 | .driver_module = THIS_MODULE, | ||
1123 | }; | ||
1124 | |||
1103 | static int __devinit sca3000_probe(struct spi_device *spi) | 1125 | static int __devinit sca3000_probe(struct spi_device *spi) |
1104 | { | 1126 | { |
1105 | int ret, regdone = 0; | 1127 | int ret, regdone = 0; |
@@ -1124,20 +1146,13 @@ static int __devinit sca3000_probe(struct spi_device *spi) | |||
1124 | } | 1146 | } |
1125 | st->indio_dev->dev.parent = &spi->dev; | 1147 | st->indio_dev->dev.parent = &spi->dev; |
1126 | st->indio_dev->name = spi_get_device_id(spi)->name; | 1148 | st->indio_dev->name = spi_get_device_id(spi)->name; |
1127 | st->indio_dev->num_interrupt_lines = 1; | ||
1128 | st->indio_dev->event_attrs = &sca3000_event_attribute_group; | ||
1129 | if (st->info->temp_output) | 1149 | if (st->info->temp_output) |
1130 | st->indio_dev->attrs = &sca3000_attribute_group_with_temp; | 1150 | st->indio_dev->info = &sca3000_info_with_temp; |
1131 | else { | 1151 | else { |
1132 | st->indio_dev->attrs = &sca3000_attribute_group; | 1152 | st->indio_dev->info = &sca3000_info; |
1133 | st->indio_dev->channels = sca3000_channels; | 1153 | st->indio_dev->channels = sca3000_channels; |
1134 | st->indio_dev->num_channels = ARRAY_SIZE(sca3000_channels); | 1154 | st->indio_dev->num_channels = ARRAY_SIZE(sca3000_channels); |
1135 | } | 1155 | } |
1136 | st->indio_dev->read_raw = &sca3000_read_raw; | ||
1137 | st->indio_dev->read_event_value = &sca3000_read_thresh; | ||
1138 | st->indio_dev->write_event_value = &sca3000_write_thresh; | ||
1139 | st->indio_dev->read_event_config = &sca3000_read_event_config; | ||
1140 | st->indio_dev->write_event_config = &sca3000_write_event_config; | ||
1141 | st->indio_dev->dev_data = (void *)(st); | 1156 | st->indio_dev->dev_data = (void *)(st); |
1142 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 1157 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
1143 | 1158 | ||
diff --git a/drivers/staging/iio/adc/ad7150.c b/drivers/staging/iio/adc/ad7150.c index e23bb9960019..ca32b6778a9e 100644 --- a/drivers/staging/iio/adc/ad7150.c +++ b/drivers/staging/iio/adc/ad7150.c | |||
@@ -700,6 +700,12 @@ static struct attribute_group ad7150_event_attribute_group = { | |||
700 | .attrs = ad7150_event_attributes, | 700 | .attrs = ad7150_event_attributes, |
701 | }; | 701 | }; |
702 | 702 | ||
703 | static const struct iio_info ad7150_info = { | ||
704 | .attrs = &ad7150_attribute_group, | ||
705 | .num_interrupt_lines = 1, | ||
706 | .event_attrs = &ad7150_event_attribute_group, | ||
707 | .driver_module = THIS_MODULE, | ||
708 | }; | ||
703 | /* | 709 | /* |
704 | * device probe and remove | 710 | * device probe and remove |
705 | */ | 711 | */ |
@@ -725,14 +731,13 @@ static int __devinit ad7150_probe(struct i2c_client *client, | |||
725 | goto error_free_chip; | 731 | goto error_free_chip; |
726 | } | 732 | } |
727 | 733 | ||
728 | /* Echipabilish that the iio_dev is a child of the i2c device */ | 734 | /* Establish that the iio_dev is a child of the i2c device */ |
729 | chip->indio_dev->name = id->name; | 735 | chip->indio_dev->name = id->name; |
730 | chip->indio_dev->dev.parent = &client->dev; | 736 | chip->indio_dev->dev.parent = &client->dev; |
731 | chip->indio_dev->attrs = &ad7150_attribute_group; | 737 | |
732 | chip->indio_dev->event_attrs = &ad7150_event_attribute_group; | 738 | chip->indio_dev->info = &ad7150_info; |
733 | chip->indio_dev->dev_data = (void *)(chip); | 739 | chip->indio_dev->dev_data = (void *)(chip); |
734 | chip->indio_dev->driver_module = THIS_MODULE; | 740 | |
735 | chip->indio_dev->num_interrupt_lines = 1; | ||
736 | chip->indio_dev->modes = INDIO_DIRECT_MODE; | 741 | chip->indio_dev->modes = INDIO_DIRECT_MODE; |
737 | 742 | ||
738 | ret = iio_device_register(chip->indio_dev); | 743 | ret = iio_device_register(chip->indio_dev); |
diff --git a/drivers/staging/iio/adc/ad7152.c b/drivers/staging/iio/adc/ad7152.c index e53e3e9e586d..7a38bcbbe1af 100644 --- a/drivers/staging/iio/adc/ad7152.c +++ b/drivers/staging/iio/adc/ad7152.c | |||
@@ -497,6 +497,10 @@ static const struct attribute_group ad7152_attribute_group = { | |||
497 | .attrs = ad7152_attributes, | 497 | .attrs = ad7152_attributes, |
498 | }; | 498 | }; |
499 | 499 | ||
500 | static const struct iio_info ad7152_info = { | ||
501 | .attrs = &ad7152_attribute_group, | ||
502 | .driver_module = THIS_MODULE, | ||
503 | }; | ||
500 | /* | 504 | /* |
501 | * device probe and remove | 505 | * device probe and remove |
502 | */ | 506 | */ |
@@ -525,9 +529,8 @@ static int __devinit ad7152_probe(struct i2c_client *client, | |||
525 | /* Echipabilish that the iio_dev is a child of the i2c device */ | 529 | /* Echipabilish that the iio_dev is a child of the i2c device */ |
526 | chip->indio_dev->name = id->name; | 530 | chip->indio_dev->name = id->name; |
527 | chip->indio_dev->dev.parent = &client->dev; | 531 | chip->indio_dev->dev.parent = &client->dev; |
528 | chip->indio_dev->attrs = &ad7152_attribute_group; | 532 | chip->indio_dev->info = &ad7152_info; |
529 | chip->indio_dev->dev_data = (void *)(chip); | 533 | chip->indio_dev->dev_data = (void *)(chip); |
530 | chip->indio_dev->driver_module = THIS_MODULE; | ||
531 | chip->indio_dev->modes = INDIO_DIRECT_MODE; | 534 | chip->indio_dev->modes = INDIO_DIRECT_MODE; |
532 | 535 | ||
533 | ret = iio_device_register(chip->indio_dev); | 536 | ret = iio_device_register(chip->indio_dev); |
diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c index 0e4c7283bb07..1be3453479b7 100644 --- a/drivers/staging/iio/adc/ad7291.c +++ b/drivers/staging/iio/adc/ad7291.c | |||
@@ -778,6 +778,12 @@ static struct attribute_group ad7291_event_attribute_group = { | |||
778 | .attrs = ad7291_event_attributes, | 778 | .attrs = ad7291_event_attributes, |
779 | }; | 779 | }; |
780 | 780 | ||
781 | static const struct iio_info ad7291_info = { | ||
782 | .attrs = &ad7291_attribute_group, | ||
783 | .num_interrupt_lines = 1, | ||
784 | .event_attrs = &ad7291_event_attribute_group, | ||
785 | }; | ||
786 | |||
781 | /* | 787 | /* |
782 | * device probe and remove | 788 | * device probe and remove |
783 | */ | 789 | */ |
@@ -807,11 +813,8 @@ static int __devinit ad7291_probe(struct i2c_client *client, | |||
807 | 813 | ||
808 | chip->indio_dev->name = id->name; | 814 | chip->indio_dev->name = id->name; |
809 | chip->indio_dev->dev.parent = &client->dev; | 815 | chip->indio_dev->dev.parent = &client->dev; |
810 | chip->indio_dev->attrs = &ad7291_attribute_group; | 816 | chip->indio_dev->info = &ad7291_info; |
811 | chip->indio_dev->event_attrs = &ad7291_event_attribute_group; | ||
812 | chip->indio_dev->dev_data = (void *)chip; | 817 | chip->indio_dev->dev_data = (void *)chip; |
813 | chip->indio_dev->driver_module = THIS_MODULE; | ||
814 | chip->indio_dev->num_interrupt_lines = 1; | ||
815 | chip->indio_dev->modes = INDIO_DIRECT_MODE; | 818 | chip->indio_dev->modes = INDIO_DIRECT_MODE; |
816 | 819 | ||
817 | ret = iio_device_register(chip->indio_dev); | 820 | ret = iio_device_register(chip->indio_dev); |
diff --git a/drivers/staging/iio/adc/ad7298_core.c b/drivers/staging/iio/adc/ad7298_core.c index 83b3d158353f..b8e4ae29b0b5 100644 --- a/drivers/staging/iio/adc/ad7298_core.c +++ b/drivers/staging/iio/adc/ad7298_core.c | |||
@@ -156,6 +156,11 @@ static int ad7298_read_raw(struct iio_dev *dev_info, | |||
156 | return -EINVAL; | 156 | return -EINVAL; |
157 | } | 157 | } |
158 | 158 | ||
159 | static const struct iio_info ad7298_info = { | ||
160 | .read_raw = &ad7298_read_raw, | ||
161 | .driver_module = THIS_MODULE, | ||
162 | }; | ||
163 | |||
159 | static int __devinit ad7298_probe(struct spi_device *spi) | 164 | static int __devinit ad7298_probe(struct spi_device *spi) |
160 | { | 165 | { |
161 | struct ad7298_platform_data *pdata = spi->dev.platform_data; | 166 | struct ad7298_platform_data *pdata = spi->dev.platform_data; |
@@ -181,11 +186,10 @@ static int __devinit ad7298_probe(struct spi_device *spi) | |||
181 | 186 | ||
182 | indio_dev->name = spi_get_device_id(spi)->name; | 187 | indio_dev->name = spi_get_device_id(spi)->name; |
183 | indio_dev->dev.parent = &spi->dev; | 188 | indio_dev->dev.parent = &spi->dev; |
184 | indio_dev->driver_module = THIS_MODULE; | ||
185 | indio_dev->modes = INDIO_DIRECT_MODE; | 189 | indio_dev->modes = INDIO_DIRECT_MODE; |
186 | indio_dev->channels = ad7298_channels; | 190 | indio_dev->channels = ad7298_channels; |
187 | indio_dev->num_channels = ARRAY_SIZE(ad7298_channels); | 191 | indio_dev->num_channels = ARRAY_SIZE(ad7298_channels); |
188 | indio_dev->read_raw = &ad7298_read_raw; | 192 | indio_dev->info = &ad7298_info; |
189 | 193 | ||
190 | /* Setup default message */ | 194 | /* Setup default message */ |
191 | 195 | ||
diff --git a/drivers/staging/iio/adc/ad7314.c b/drivers/staging/iio/adc/ad7314.c index a1f1b4379c66..98bb16fcff26 100644 --- a/drivers/staging/iio/adc/ad7314.c +++ b/drivers/staging/iio/adc/ad7314.c | |||
@@ -191,6 +191,10 @@ static const struct attribute_group ad7314_attribute_group = { | |||
191 | .attrs = ad7314_attributes, | 191 | .attrs = ad7314_attributes, |
192 | }; | 192 | }; |
193 | 193 | ||
194 | static const struct iio_info ad7314_info = { | ||
195 | .attrs = &ad7314_attribute_group, | ||
196 | .driver_module = THIS_MODULE, | ||
197 | }; | ||
194 | /* | 198 | /* |
195 | * device probe and remove | 199 | * device probe and remove |
196 | */ | 200 | */ |
@@ -218,9 +222,8 @@ static int __devinit ad7314_probe(struct spi_device *spi_dev) | |||
218 | 222 | ||
219 | chip->indio_dev->name = spi_get_device_id(spi_dev)->name; | 223 | chip->indio_dev->name = spi_get_device_id(spi_dev)->name; |
220 | chip->indio_dev->dev.parent = &spi_dev->dev; | 224 | chip->indio_dev->dev.parent = &spi_dev->dev; |
221 | chip->indio_dev->attrs = &ad7314_attribute_group; | 225 | chip->indio_dev->info = &ad7314_info; |
222 | chip->indio_dev->dev_data = (void *)chip; | 226 | chip->indio_dev->dev_data = (void *)chip; |
223 | chip->indio_dev->driver_module = THIS_MODULE; | ||
224 | 227 | ||
225 | ret = iio_device_register(chip->indio_dev); | 228 | ret = iio_device_register(chip->indio_dev); |
226 | if (ret) | 229 | if (ret) |
diff --git a/drivers/staging/iio/adc/ad7476_core.c b/drivers/staging/iio/adc/ad7476_core.c index 5b41e0101e55..50cedb422839 100644 --- a/drivers/staging/iio/adc/ad7476_core.c +++ b/drivers/staging/iio/adc/ad7476_core.c | |||
@@ -118,6 +118,11 @@ static const struct ad7476_chip_info ad7476_chip_info_tbl[] = { | |||
118 | }, | 118 | }, |
119 | }; | 119 | }; |
120 | 120 | ||
121 | static const struct iio_info ad7476_info = { | ||
122 | .driver_module = THIS_MODULE, | ||
123 | .read_raw = &ad7476_read_raw, | ||
124 | }; | ||
125 | |||
121 | static int __devinit ad7476_probe(struct spi_device *spi) | 126 | static int __devinit ad7476_probe(struct spi_device *spi) |
122 | { | 127 | { |
123 | struct ad7476_platform_data *pdata = spi->dev.platform_data; | 128 | struct ad7476_platform_data *pdata = spi->dev.platform_data; |
@@ -165,11 +170,10 @@ static int __devinit ad7476_probe(struct spi_device *spi) | |||
165 | st->indio_dev->dev.parent = &spi->dev; | 170 | st->indio_dev->dev.parent = &spi->dev; |
166 | st->indio_dev->name = spi_get_device_id(spi)->name; | 171 | st->indio_dev->name = spi_get_device_id(spi)->name; |
167 | st->indio_dev->dev_data = (void *)(st); | 172 | st->indio_dev->dev_data = (void *)(st); |
168 | st->indio_dev->driver_module = THIS_MODULE; | ||
169 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 173 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
170 | st->indio_dev->channels = st->chip_info->channel; | 174 | st->indio_dev->channels = st->chip_info->channel; |
171 | st->indio_dev->num_channels = 2; | 175 | st->indio_dev->num_channels = 2; |
172 | st->indio_dev->read_raw = &ad7476_read_raw; | 176 | st->indio_dev->info = &ad7476_info; |
173 | /* Setup default message */ | 177 | /* Setup default message */ |
174 | 178 | ||
175 | st->xfer.rx_buf = &st->data; | 179 | st->xfer.rx_buf = &st->data; |
diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c index fb96802819fc..459371ae4dcc 100644 --- a/drivers/staging/iio/adc/ad7606_core.c +++ b/drivers/staging/iio/adc/ad7606_core.c | |||
@@ -426,6 +426,12 @@ static irqreturn_t ad7606_interrupt(int irq, void *dev_id) | |||
426 | return IRQ_HANDLED; | 426 | return IRQ_HANDLED; |
427 | }; | 427 | }; |
428 | 428 | ||
429 | static const struct iio_info ad7606_info = { | ||
430 | .driver_module = THIS_MODULE, | ||
431 | .read_raw = &ad7606_read_raw, | ||
432 | .attrs = &ad7606_attribute_group, | ||
433 | }; | ||
434 | |||
429 | struct iio_dev *ad7606_probe(struct device *dev, int irq, | 435 | struct iio_dev *ad7606_probe(struct device *dev, int irq, |
430 | void __iomem *base_address, | 436 | void __iomem *base_address, |
431 | unsigned id, | 437 | unsigned id, |
@@ -470,13 +476,11 @@ struct iio_dev *ad7606_probe(struct device *dev, int irq, | |||
470 | st->chip_info = &ad7606_chip_info_tbl[id]; | 476 | st->chip_info = &ad7606_chip_info_tbl[id]; |
471 | 477 | ||
472 | indio_dev->dev.parent = dev; | 478 | indio_dev->dev.parent = dev; |
473 | indio_dev->attrs = &ad7606_attribute_group; | 479 | indio_dev->info = &ad7606_info; |
474 | indio_dev->driver_module = THIS_MODULE; | ||
475 | indio_dev->modes = INDIO_DIRECT_MODE; | 480 | indio_dev->modes = INDIO_DIRECT_MODE; |
476 | indio_dev->name = st->chip_info->name; | 481 | indio_dev->name = st->chip_info->name; |
477 | indio_dev->channels = st->chip_info->channels; | 482 | indio_dev->channels = st->chip_info->channels; |
478 | indio_dev->num_channels = st->chip_info->num_channels; | 483 | indio_dev->num_channels = st->chip_info->num_channels; |
479 | indio_dev->read_raw = &ad7606_read_raw; | ||
480 | 484 | ||
481 | init_waitqueue_head(&st->wq_data_avail); | 485 | init_waitqueue_head(&st->wq_data_avail); |
482 | 486 | ||
diff --git a/drivers/staging/iio/adc/ad7745.c b/drivers/staging/iio/adc/ad7745.c index 98b510dcecc8..1944223ef163 100644 --- a/drivers/staging/iio/adc/ad7745.c +++ b/drivers/staging/iio/adc/ad7745.c | |||
@@ -565,6 +565,12 @@ static struct attribute_group ad774x_event_attribute_group = { | |||
565 | .attrs = ad774x_event_attributes, | 565 | .attrs = ad774x_event_attributes, |
566 | }; | 566 | }; |
567 | 567 | ||
568 | static const struct iio_info ad774x_info = { | ||
569 | .attrs = &ad774x_event_attribute_group, | ||
570 | .event_attrs = &ad774x_event_attribute_group, | ||
571 | .num_interrupt_lines = 1, | ||
572 | .driver_module = THIS_MODULE, | ||
573 | }; | ||
568 | /* | 574 | /* |
569 | * device probe and remove | 575 | * device probe and remove |
570 | */ | 576 | */ |
@@ -593,11 +599,8 @@ static int __devinit ad774x_probe(struct i2c_client *client, | |||
593 | /* Establish that the iio_dev is a child of the i2c device */ | 599 | /* Establish that the iio_dev is a child of the i2c device */ |
594 | chip->indio_dev->name = id->name; | 600 | chip->indio_dev->name = id->name; |
595 | chip->indio_dev->dev.parent = &client->dev; | 601 | chip->indio_dev->dev.parent = &client->dev; |
596 | chip->indio_dev->attrs = &ad774x_attribute_group; | 602 | chip->indio_dev->info = &ad774x_info; |
597 | chip->indio_dev->event_attrs = &ad774x_event_attribute_group; | ||
598 | chip->indio_dev->dev_data = (void *)(chip); | 603 | chip->indio_dev->dev_data = (void *)(chip); |
599 | chip->indio_dev->driver_module = THIS_MODULE; | ||
600 | chip->indio_dev->num_interrupt_lines = 1; | ||
601 | chip->indio_dev->modes = INDIO_DIRECT_MODE; | 604 | chip->indio_dev->modes = INDIO_DIRECT_MODE; |
602 | 605 | ||
603 | ret = iio_device_register(chip->indio_dev); | 606 | ret = iio_device_register(chip->indio_dev); |
diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index 713e202b9395..e0c7b6cc05c7 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c | |||
@@ -151,6 +151,11 @@ static irqreturn_t ad7780_interrupt(int irq, void *dev_id) | |||
151 | return IRQ_HANDLED; | 151 | return IRQ_HANDLED; |
152 | }; | 152 | }; |
153 | 153 | ||
154 | static const struct iio_info ad7780_info = { | ||
155 | .read_raw = &ad7780_read_raw, | ||
156 | .driver_module = THIS_MODULE, | ||
157 | }; | ||
158 | |||
154 | static int __devinit ad7780_probe(struct spi_device *spi) | 159 | static int __devinit ad7780_probe(struct spi_device *spi) |
155 | { | 160 | { |
156 | struct ad7780_platform_data *pdata = spi->dev.platform_data; | 161 | struct ad7780_platform_data *pdata = spi->dev.platform_data; |
@@ -195,11 +200,10 @@ static int __devinit ad7780_probe(struct spi_device *spi) | |||
195 | 200 | ||
196 | indio_dev->dev.parent = &spi->dev; | 201 | indio_dev->dev.parent = &spi->dev; |
197 | indio_dev->name = spi_get_device_id(spi)->name; | 202 | indio_dev->name = spi_get_device_id(spi)->name; |
198 | indio_dev->driver_module = THIS_MODULE; | ||
199 | indio_dev->modes = INDIO_DIRECT_MODE; | 203 | indio_dev->modes = INDIO_DIRECT_MODE; |
200 | indio_dev->channels = &st->chip_info->channel; | 204 | indio_dev->channels = &st->chip_info->channel; |
201 | indio_dev->num_channels = 1; | 205 | indio_dev->num_channels = 1; |
202 | indio_dev->read_raw = &ad7780_read_raw; | 206 | indio_dev->info = &ad7780_info; |
203 | 207 | ||
204 | init_waitqueue_head(&st->wq_data_avail); | 208 | init_waitqueue_head(&st->wq_data_avail); |
205 | 209 | ||
diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 873fe2bf8312..11379e469b07 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c | |||
@@ -331,6 +331,13 @@ static struct attribute_group ad7816_event_attribute_group = { | |||
331 | .attrs = ad7816_event_attributes, | 331 | .attrs = ad7816_event_attributes, |
332 | }; | 332 | }; |
333 | 333 | ||
334 | static const struct iio_info ad7816_info = { | ||
335 | .attrs = &ad7816_attribute_group, | ||
336 | .num_interrupt_lines = 1, | ||
337 | .event_attrs = &ad7816_event_attribute_group, | ||
338 | .driver_module = THIS_MODULE, | ||
339 | }; | ||
340 | |||
334 | /* | 341 | /* |
335 | * device probe and remove | 342 | * device probe and remove |
336 | */ | 343 | */ |
@@ -391,11 +398,8 @@ static int __devinit ad7816_probe(struct spi_device *spi_dev) | |||
391 | } | 398 | } |
392 | chip->indio_dev->name = spi_get_device_id(spi_dev)->name; | 399 | chip->indio_dev->name = spi_get_device_id(spi_dev)->name; |
393 | chip->indio_dev->dev.parent = &spi_dev->dev; | 400 | chip->indio_dev->dev.parent = &spi_dev->dev; |
394 | chip->indio_dev->attrs = &ad7816_attribute_group; | 401 | chip->indio_dev->info = &ad7816_info; |
395 | chip->indio_dev->event_attrs = &ad7816_event_attribute_group; | ||
396 | chip->indio_dev->dev_data = (void *)chip; | 402 | chip->indio_dev->dev_data = (void *)chip; |
397 | chip->indio_dev->driver_module = THIS_MODULE; | ||
398 | chip->indio_dev->num_interrupt_lines = 1; | ||
399 | chip->indio_dev->modes = INDIO_DIRECT_MODE; | 403 | chip->indio_dev->modes = INDIO_DIRECT_MODE; |
400 | 404 | ||
401 | ret = iio_device_register(chip->indio_dev); | 405 | ret = iio_device_register(chip->indio_dev); |
diff --git a/drivers/staging/iio/adc/ad7887_core.c b/drivers/staging/iio/adc/ad7887_core.c index 6773fe1bf059..de14b174cef7 100644 --- a/drivers/staging/iio/adc/ad7887_core.c +++ b/drivers/staging/iio/adc/ad7887_core.c | |||
@@ -83,6 +83,11 @@ static const struct ad7887_chip_info ad7887_chip_info_tbl[] = { | |||
83 | }, | 83 | }, |
84 | }; | 84 | }; |
85 | 85 | ||
86 | static const struct iio_info ad7887_info = { | ||
87 | .read_raw = &ad7887_read_raw, | ||
88 | .driver_module = THIS_MODULE, | ||
89 | }; | ||
90 | |||
86 | static int __devinit ad7887_probe(struct spi_device *spi) | 91 | static int __devinit ad7887_probe(struct spi_device *spi) |
87 | { | 92 | { |
88 | struct ad7887_platform_data *pdata = spi->dev.platform_data; | 93 | struct ad7887_platform_data *pdata = spi->dev.platform_data; |
@@ -114,8 +119,7 @@ static int __devinit ad7887_probe(struct spi_device *spi) | |||
114 | indio_dev->dev.parent = &spi->dev; | 119 | indio_dev->dev.parent = &spi->dev; |
115 | indio_dev->name = spi_get_device_id(spi)->name; | 120 | indio_dev->name = spi_get_device_id(spi)->name; |
116 | indio_dev->dev_data = (void *)(st); | 121 | indio_dev->dev_data = (void *)(st); |
117 | indio_dev->read_raw = &ad7887_read_raw; | 122 | indio_dev->info = &ad7887_info; |
118 | indio_dev->driver_module = THIS_MODULE; | ||
119 | indio_dev->modes = INDIO_DIRECT_MODE; | 123 | indio_dev->modes = INDIO_DIRECT_MODE; |
120 | 124 | ||
121 | /* Setup default message */ | 125 | /* Setup default message */ |
diff --git a/drivers/staging/iio/adc/ad799x.h b/drivers/staging/iio/adc/ad799x.h index 0a8d6e21c00b..0dc9b4c73a33 100644 --- a/drivers/staging/iio/adc/ad799x.h +++ b/drivers/staging/iio/adc/ad799x.h | |||
@@ -97,9 +97,8 @@ struct ad799x_chip_info { | |||
97 | struct iio_chan_spec channel[9]; | 97 | struct iio_chan_spec channel[9]; |
98 | int num_channels; | 98 | int num_channels; |
99 | u16 int_vref_mv; | 99 | u16 int_vref_mv; |
100 | bool monitor_mode; | ||
101 | u16 default_config; | 100 | u16 default_config; |
102 | struct attribute_group *event_attrs; | 101 | const struct iio_info *info; |
103 | }; | 102 | }; |
104 | 103 | ||
105 | struct ad799x_state { | 104 | struct ad799x_state { |
diff --git a/drivers/staging/iio/adc/ad799x_core.c b/drivers/staging/iio/adc/ad799x_core.c index a105910bd71d..29bfbcf82064 100644 --- a/drivers/staging/iio/adc/ad799x_core.c +++ b/drivers/staging/iio/adc/ad799x_core.c | |||
@@ -459,6 +459,25 @@ static struct attribute_group ad7992_event_attrs_group = { | |||
459 | .attrs = ad7992_event_attributes, | 459 | .attrs = ad7992_event_attributes, |
460 | }; | 460 | }; |
461 | 461 | ||
462 | static const struct iio_info ad7991_info = { | ||
463 | .read_raw = &ad799x_read_raw, | ||
464 | .driver_module = THIS_MODULE, | ||
465 | }; | ||
466 | |||
467 | static const struct iio_info ad7992_info = { | ||
468 | .read_raw = &ad799x_read_raw, | ||
469 | .num_interrupt_lines = 1, | ||
470 | .event_attrs = &ad7992_event_attrs_group, | ||
471 | .driver_module = THIS_MODULE, | ||
472 | }; | ||
473 | |||
474 | static const struct iio_info ad7993_4_7_8_info = { | ||
475 | .read_raw = &ad799x_read_raw, | ||
476 | .num_interrupt_lines = 1, | ||
477 | .event_attrs = &ad7993_4_7_8_event_attrs_group, | ||
478 | .driver_module = THIS_MODULE, | ||
479 | }; | ||
480 | |||
462 | static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { | 481 | static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { |
463 | [ad7991] = { | 482 | [ad7991] = { |
464 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, | 483 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, |
@@ -476,6 +495,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { | |||
476 | .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), | 495 | .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), |
477 | .num_channels = 5, | 496 | .num_channels = 5, |
478 | .int_vref_mv = 4096, | 497 | .int_vref_mv = 4096, |
498 | .info = &ad7991_info, | ||
479 | }, | 499 | }, |
480 | [ad7995] = { | 500 | [ad7995] = { |
481 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, | 501 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, |
@@ -493,6 +513,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { | |||
493 | .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), | 513 | .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), |
494 | .num_channels = 5, | 514 | .num_channels = 5, |
495 | .int_vref_mv = 1024, | 515 | .int_vref_mv = 1024, |
516 | .info = &ad7991_info, | ||
496 | }, | 517 | }, |
497 | [ad7999] = { | 518 | [ad7999] = { |
498 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, | 519 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, |
@@ -510,6 +531,7 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { | |||
510 | .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), | 531 | .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), |
511 | .num_channels = 5, | 532 | .num_channels = 5, |
512 | .int_vref_mv = 1024, | 533 | .int_vref_mv = 1024, |
534 | .info = &ad7991_info, | ||
513 | }, | 535 | }, |
514 | [ad7992] = { | 536 | [ad7992] = { |
515 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, | 537 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, |
@@ -521,9 +543,8 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { | |||
521 | .channel[2] = IIO_CHAN_SOFT_TIMESTAMP(2), | 543 | .channel[2] = IIO_CHAN_SOFT_TIMESTAMP(2), |
522 | .num_channels = 3, | 544 | .num_channels = 3, |
523 | .int_vref_mv = 4096, | 545 | .int_vref_mv = 4096, |
524 | .monitor_mode = true, | ||
525 | .default_config = AD7998_ALERT_EN, | 546 | .default_config = AD7998_ALERT_EN, |
526 | .event_attrs = &ad7992_event_attrs_group, | 547 | .info = &ad7992_info, |
527 | }, | 548 | }, |
528 | [ad7993] = { | 549 | [ad7993] = { |
529 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, | 550 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, |
@@ -541,9 +562,8 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { | |||
541 | .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), | 562 | .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), |
542 | .num_channels = 5, | 563 | .num_channels = 5, |
543 | .int_vref_mv = 1024, | 564 | .int_vref_mv = 1024, |
544 | .monitor_mode = true, | ||
545 | .default_config = AD7998_ALERT_EN, | 565 | .default_config = AD7998_ALERT_EN, |
546 | .event_attrs = &ad7993_4_7_8_event_attrs_group, | 566 | .info = &ad7993_4_7_8_info, |
547 | }, | 567 | }, |
548 | [ad7994] = { | 568 | [ad7994] = { |
549 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, | 569 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, |
@@ -561,9 +581,8 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { | |||
561 | .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), | 581 | .channel[4] = IIO_CHAN_SOFT_TIMESTAMP(4), |
562 | .num_channels = 5, | 582 | .num_channels = 5, |
563 | .int_vref_mv = 4096, | 583 | .int_vref_mv = 4096, |
564 | .monitor_mode = true, | ||
565 | .default_config = AD7998_ALERT_EN, | 584 | .default_config = AD7998_ALERT_EN, |
566 | .event_attrs = &ad7993_4_7_8_event_attrs_group, | 585 | .info = &ad7993_4_7_8_info, |
567 | }, | 586 | }, |
568 | [ad7997] = { | 587 | [ad7997] = { |
569 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, | 588 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, |
@@ -593,9 +612,8 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { | |||
593 | .channel[8] = IIO_CHAN_SOFT_TIMESTAMP(8), | 612 | .channel[8] = IIO_CHAN_SOFT_TIMESTAMP(8), |
594 | .num_channels = 9, | 613 | .num_channels = 9, |
595 | .int_vref_mv = 1024, | 614 | .int_vref_mv = 1024, |
596 | .monitor_mode = true, | ||
597 | .default_config = AD7998_ALERT_EN, | 615 | .default_config = AD7998_ALERT_EN, |
598 | .event_attrs = &ad7993_4_7_8_event_attrs_group, | 616 | .info = &ad7993_4_7_8_info, |
599 | }, | 617 | }, |
600 | [ad7998] = { | 618 | [ad7998] = { |
601 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, | 619 | .channel[0] = IIO_CHAN(IIO_IN, 0, 1, 0, NULL, 0, 0, |
@@ -625,9 +643,8 @@ static const struct ad799x_chip_info ad799x_chip_info_tbl[] = { | |||
625 | .channel[8] = IIO_CHAN_SOFT_TIMESTAMP(8), | 643 | .channel[8] = IIO_CHAN_SOFT_TIMESTAMP(8), |
626 | .num_channels = 9, | 644 | .num_channels = 9, |
627 | .int_vref_mv = 4096, | 645 | .int_vref_mv = 4096, |
628 | .monitor_mode = true, | ||
629 | .default_config = AD7998_ALERT_EN, | 646 | .default_config = AD7998_ALERT_EN, |
630 | .event_attrs = &ad7993_4_7_8_event_attrs_group, | 647 | .info = &ad7993_4_7_8_info, |
631 | }, | 648 | }, |
632 | }; | 649 | }; |
633 | 650 | ||
@@ -667,15 +684,13 @@ static int __devinit ad799x_probe(struct i2c_client *client, | |||
667 | 684 | ||
668 | indio_dev->dev.parent = &client->dev; | 685 | indio_dev->dev.parent = &client->dev; |
669 | indio_dev->name = id->name; | 686 | indio_dev->name = id->name; |
670 | indio_dev->event_attrs = st->chip_info->event_attrs; | 687 | indio_dev->info = st->chip_info->info; |
671 | indio_dev->name = id->name; | 688 | indio_dev->name = id->name; |
672 | indio_dev->dev_data = (void *)(st); | 689 | indio_dev->dev_data = (void *)(st); |
673 | indio_dev->driver_module = THIS_MODULE; | 690 | |
674 | indio_dev->modes = INDIO_DIRECT_MODE; | 691 | indio_dev->modes = INDIO_DIRECT_MODE; |
675 | indio_dev->num_interrupt_lines = 1; | ||
676 | indio_dev->channels = st->chip_info->channel; | 692 | indio_dev->channels = st->chip_info->channel; |
677 | indio_dev->num_channels = st->chip_info->num_channels; | 693 | indio_dev->num_channels = st->chip_info->num_channels; |
678 | indio_dev->read_raw = &ad799x_read_raw; | ||
679 | 694 | ||
680 | ret = ad799x_register_ring_funcs_and_init(indio_dev); | 695 | ret = ad799x_register_ring_funcs_and_init(indio_dev); |
681 | if (ret) | 696 | if (ret) |
@@ -692,7 +707,7 @@ static int __devinit ad799x_probe(struct i2c_client *client, | |||
692 | if (ret) | 707 | if (ret) |
693 | goto error_cleanup_ring; | 708 | goto error_cleanup_ring; |
694 | 709 | ||
695 | if (client->irq > 0 && st->chip_info->monitor_mode) { | 710 | if (client->irq > 0) { |
696 | ret = request_threaded_irq(client->irq, | 711 | ret = request_threaded_irq(client->irq, |
697 | NULL, | 712 | NULL, |
698 | ad799x_event_handler, | 713 | ad799x_event_handler, |
@@ -727,7 +742,7 @@ static __devexit int ad799x_remove(struct i2c_client *client) | |||
727 | struct iio_dev *indio_dev = i2c_get_clientdata(client); | 742 | struct iio_dev *indio_dev = i2c_get_clientdata(client); |
728 | struct ad799x_state *st = iio_priv(indio_dev); | 743 | struct ad799x_state *st = iio_priv(indio_dev); |
729 | 744 | ||
730 | if (client->irq > 0 && st->chip_info->monitor_mode) | 745 | if (client->irq > 0) |
731 | free_irq(client->irq, indio_dev); | 746 | free_irq(client->irq, indio_dev); |
732 | 747 | ||
733 | iio_ring_buffer_unregister(indio_dev->ring); | 748 | iio_ring_buffer_unregister(indio_dev->ring); |
diff --git a/drivers/staging/iio/adc/adt7310.c b/drivers/staging/iio/adc/adt7310.c index e405fc311d4d..68eca0b99ac0 100644 --- a/drivers/staging/iio/adc/adt7310.c +++ b/drivers/staging/iio/adc/adt7310.c | |||
@@ -746,6 +746,13 @@ static struct attribute_group adt7310_event_attribute_group[ADT7310_IRQS] = { | |||
746 | } | 746 | } |
747 | }; | 747 | }; |
748 | 748 | ||
749 | static const struct iio_info adt7310_info = { | ||
750 | .attrs = &adt7310_attribute_group, | ||
751 | .num_interrupt_lines = ADT7310_IRQS, | ||
752 | .event_attrs = adt7310_event_attribute_group, | ||
753 | .driver_module = THIS_MODULE, | ||
754 | }; | ||
755 | |||
749 | /* | 756 | /* |
750 | * device probe and remove | 757 | * device probe and remove |
751 | */ | 758 | */ |
@@ -775,11 +782,8 @@ static int __devinit adt7310_probe(struct spi_device *spi_dev) | |||
775 | 782 | ||
776 | chip->indio_dev->dev.parent = &spi_dev->dev; | 783 | chip->indio_dev->dev.parent = &spi_dev->dev; |
777 | chip->indio_dev->name = spi_get_device_id(spi_dev)->name; | 784 | chip->indio_dev->name = spi_get_device_id(spi_dev)->name; |
778 | chip->indio_dev->attrs = &adt7310_attribute_group; | 785 | chip->indio_dev->info = &adt7310_info; |
779 | chip->indio_dev->event_attrs = adt7310_event_attribute_group; | ||
780 | chip->indio_dev->dev_data = (void *)chip; | 786 | chip->indio_dev->dev_data = (void *)chip; |
781 | chip->indio_dev->driver_module = THIS_MODULE; | ||
782 | chip->indio_dev->num_interrupt_lines = ADT7310_IRQS; | ||
783 | chip->indio_dev->modes = INDIO_DIRECT_MODE; | 787 | chip->indio_dev->modes = INDIO_DIRECT_MODE; |
784 | 788 | ||
785 | ret = iio_device_register(chip->indio_dev); | 789 | ret = iio_device_register(chip->indio_dev); |
diff --git a/drivers/staging/iio/adc/adt7410.c b/drivers/staging/iio/adc/adt7410.c index 85b5c1acc631..c40a84f9c2ff 100644 --- a/drivers/staging/iio/adc/adt7410.c +++ b/drivers/staging/iio/adc/adt7410.c | |||
@@ -713,6 +713,13 @@ static struct attribute_group adt7410_event_attribute_group[ADT7410_IRQS] = { | |||
713 | } | 713 | } |
714 | }; | 714 | }; |
715 | 715 | ||
716 | static const struct iio_info adt7410_info = { | ||
717 | .attrs = &adt7410_attribute_group, | ||
718 | .num_interrupt_lines = ADT7410_IRQS, | ||
719 | .event_attrs = adt7410_event_attribute_group, | ||
720 | .driver_module = THIS_MODULE, | ||
721 | }; | ||
722 | |||
716 | /* | 723 | /* |
717 | * device probe and remove | 724 | * device probe and remove |
718 | */ | 725 | */ |
@@ -741,11 +748,8 @@ static int __devinit adt7410_probe(struct i2c_client *client, | |||
741 | } | 748 | } |
742 | chip->indio_dev->name = id->name; | 749 | chip->indio_dev->name = id->name; |
743 | chip->indio_dev->dev.parent = &client->dev; | 750 | chip->indio_dev->dev.parent = &client->dev; |
744 | chip->indio_dev->attrs = &adt7410_attribute_group; | 751 | chip->indio_dev->info = &adt7410_info; |
745 | chip->indio_dev->event_attrs = adt7410_event_attribute_group; | ||
746 | chip->indio_dev->dev_data = (void *)chip; | 752 | chip->indio_dev->dev_data = (void *)chip; |
747 | chip->indio_dev->driver_module = THIS_MODULE; | ||
748 | chip->indio_dev->num_interrupt_lines = ADT7410_IRQS; | ||
749 | chip->indio_dev->modes = INDIO_DIRECT_MODE; | 753 | chip->indio_dev->modes = INDIO_DIRECT_MODE; |
750 | 754 | ||
751 | ret = iio_device_register(chip->indio_dev); | 755 | ret = iio_device_register(chip->indio_dev); |
diff --git a/drivers/staging/iio/adc/adt75.c b/drivers/staging/iio/adc/adt75.c index 2a44428a1075..1171fb9c178f 100644 --- a/drivers/staging/iio/adc/adt75.c +++ b/drivers/staging/iio/adc/adt75.c | |||
@@ -534,6 +534,13 @@ static struct attribute_group adt75_event_attribute_group = { | |||
534 | .attrs = adt75_event_attributes, | 534 | .attrs = adt75_event_attributes, |
535 | }; | 535 | }; |
536 | 536 | ||
537 | static const struct iio_info adt75_info = { | ||
538 | .attrs = &adt75_attribute_group, | ||
539 | .num_interrupt_lines = 1, | ||
540 | .event_attrs = &adt75_event_attribute_group, | ||
541 | .driver_module = THIS_MODULE, | ||
542 | }; | ||
543 | |||
537 | /* | 544 | /* |
538 | * device probe and remove | 545 | * device probe and remove |
539 | */ | 546 | */ |
@@ -562,11 +569,8 @@ static int __devinit adt75_probe(struct i2c_client *client, | |||
562 | 569 | ||
563 | chip->indio_dev->name = id->name; | 570 | chip->indio_dev->name = id->name; |
564 | chip->indio_dev->dev.parent = &client->dev; | 571 | chip->indio_dev->dev.parent = &client->dev; |
565 | chip->indio_dev->attrs = &adt75_attribute_group; | 572 | chip->indio_dev->info = &adt75_info; |
566 | chip->indio_dev->event_attrs = &adt75_event_attribute_group; | ||
567 | chip->indio_dev->dev_data = (void *)chip; | 573 | chip->indio_dev->dev_data = (void *)chip; |
568 | chip->indio_dev->driver_module = THIS_MODULE; | ||
569 | chip->indio_dev->num_interrupt_lines = 1; | ||
570 | chip->indio_dev->modes = INDIO_DIRECT_MODE; | 574 | chip->indio_dev->modes = INDIO_DIRECT_MODE; |
571 | 575 | ||
572 | ret = iio_device_register(chip->indio_dev); | 576 | ret = iio_device_register(chip->indio_dev); |
diff --git a/drivers/staging/iio/adc/max1363.h b/drivers/staging/iio/adc/max1363.h index 15227bd571dc..5243b5a3f9a5 100644 --- a/drivers/staging/iio/adc/max1363.h +++ b/drivers/staging/iio/adc/max1363.h | |||
@@ -154,7 +154,7 @@ enum max1363_modes { | |||
154 | * @name: indentification string for chip | 154 | * @name: indentification string for chip |
155 | * @bits: accuracy of the adc in bits | 155 | * @bits: accuracy of the adc in bits |
156 | * @int_vref_mv: the internal reference voltage | 156 | * @int_vref_mv: the internal reference voltage |
157 | * @monitor_mode: whether the chip supports monitor interrupts | 157 | * @info: iio core function callbacks structure |
158 | * @mode_list: array of available scan modes | 158 | * @mode_list: array of available scan modes |
159 | * @num_modes: the number of scan modes available | 159 | * @num_modes: the number of scan modes available |
160 | * @default_mode: the scan mode in which the chip starts up | 160 | * @default_mode: the scan mode in which the chip starts up |
@@ -162,14 +162,14 @@ enum max1363_modes { | |||
162 | * @num_channels: number of channels | 162 | * @num_channels: number of channels |
163 | */ | 163 | */ |
164 | struct max1363_chip_info { | 164 | struct max1363_chip_info { |
165 | u8 bits; | 165 | const struct iio_info *info; |
166 | u16 int_vref_mv; | ||
167 | bool monitor_mode; | ||
168 | const enum max1363_modes *mode_list; | ||
169 | int num_modes; | ||
170 | enum max1363_modes default_mode; | ||
171 | struct iio_chan_spec *channels; | 166 | struct iio_chan_spec *channels; |
172 | int num_channels; | 167 | int num_channels; |
168 | const enum max1363_modes *mode_list; | ||
169 | enum max1363_modes default_mode; | ||
170 | u16 int_vref_mv; | ||
171 | u8 num_modes; | ||
172 | u8 bits; | ||
173 | }; | 173 | }; |
174 | 174 | ||
175 | /** | 175 | /** |
diff --git a/drivers/staging/iio/adc/max1363_core.c b/drivers/staging/iio/adc/max1363_core.c index 0c80abb7e753..8d09bf3d450a 100644 --- a/drivers/staging/iio/adc/max1363_core.c +++ b/drivers/staging/iio/adc/max1363_core.c | |||
@@ -472,47 +472,409 @@ enum { max1361, | |||
472 | max11647 | 472 | max11647 |
473 | }; | 473 | }; |
474 | 474 | ||
475 | static const int max1363_monitor_speeds[] = { 133000, 665000, 33300, 16600, | ||
476 | 8300, 4200, 2000, 1000 }; | ||
477 | |||
478 | static ssize_t max1363_monitor_show_freq(struct device *dev, | ||
479 | struct device_attribute *attr, | ||
480 | char *buf) | ||
481 | { | ||
482 | struct max1363_state *st = iio_priv(dev_get_drvdata(dev)); | ||
483 | return sprintf(buf, "%d\n", max1363_monitor_speeds[st->monitor_speed]); | ||
484 | } | ||
485 | |||
486 | static ssize_t max1363_monitor_store_freq(struct device *dev, | ||
487 | struct device_attribute *attr, | ||
488 | const char *buf, | ||
489 | size_t len) | ||
490 | { | ||
491 | struct iio_dev *indio_dev = dev_get_drvdata(dev); | ||
492 | struct max1363_state *st = iio_priv(indio_dev); | ||
493 | int i, ret; | ||
494 | unsigned long val; | ||
495 | bool found = false; | ||
496 | |||
497 | ret = strict_strtoul(buf, 10, &val); | ||
498 | if (ret) | ||
499 | return -EINVAL; | ||
500 | for (i = 0; i < ARRAY_SIZE(max1363_monitor_speeds); i++) | ||
501 | if (val == max1363_monitor_speeds[i]) { | ||
502 | found = true; | ||
503 | break; | ||
504 | } | ||
505 | if (!found) | ||
506 | return -EINVAL; | ||
507 | |||
508 | mutex_lock(&indio_dev->mlock); | ||
509 | st->monitor_speed = i; | ||
510 | mutex_unlock(&indio_dev->mlock); | ||
511 | |||
512 | return 0; | ||
513 | } | ||
514 | |||
515 | static IIO_DEV_ATTR_SAMP_FREQ(S_IRUGO | S_IWUSR, | ||
516 | max1363_monitor_show_freq, | ||
517 | max1363_monitor_store_freq); | ||
518 | |||
519 | static IIO_CONST_ATTR(sampling_frequency_available, | ||
520 | "133000 665000 33300 16600 8300 4200 2000 1000"); | ||
521 | |||
522 | static int max1363_read_thresh(struct iio_dev *indio_dev, | ||
523 | int event_code, | ||
524 | int *val) | ||
525 | { | ||
526 | struct max1363_state *st = iio_priv(indio_dev); | ||
527 | if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_FALLING) | ||
528 | *val = st->thresh_low[IIO_EVENT_CODE_EXTRACT_NUM(event_code)]; | ||
529 | else | ||
530 | *val = st->thresh_high[IIO_EVENT_CODE_EXTRACT_NUM(event_code)]; | ||
531 | return 0; | ||
532 | } | ||
533 | |||
534 | static int max1363_write_thresh(struct iio_dev *indio_dev, | ||
535 | int event_code, | ||
536 | int val) | ||
537 | { | ||
538 | struct max1363_state *st = iio_priv(indio_dev); | ||
539 | /* make it handle signed correctly as well */ | ||
540 | switch (st->chip_info->bits) { | ||
541 | case 10: | ||
542 | if (val > 0x3FF) | ||
543 | return -EINVAL; | ||
544 | break; | ||
545 | case 12: | ||
546 | if (val > 0xFFF) | ||
547 | return -EINVAL; | ||
548 | break; | ||
549 | } | ||
550 | |||
551 | switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) { | ||
552 | case IIO_EV_DIR_FALLING: | ||
553 | st->thresh_low[IIO_EVENT_CODE_EXTRACT_NUM(event_code)] = val; | ||
554 | break; | ||
555 | case IIO_EV_DIR_RISING: | ||
556 | st->thresh_high[IIO_EVENT_CODE_EXTRACT_NUM(event_code)] = val; | ||
557 | break; | ||
558 | } | ||
559 | |||
560 | return 0; | ||
561 | } | ||
562 | |||
563 | static irqreturn_t max1363_event_handler(int irq, void *private) | ||
564 | { | ||
565 | struct iio_dev *indio_dev = private; | ||
566 | struct max1363_state *st = iio_priv(indio_dev); | ||
567 | s64 timestamp = iio_get_time_ns(); | ||
568 | u8 rx; | ||
569 | u8 tx[2] = { st->setupbyte, | ||
570 | MAX1363_MON_INT_ENABLE | (st->monitor_speed << 1) | 0xF0 }; | ||
571 | |||
572 | i2c_master_recv(st->client, &rx, 1); | ||
573 | /* todo - begging for use of for_each_set_bit */ | ||
574 | if (rx & (1 << 0)) | ||
575 | iio_push_event(indio_dev, 0, | ||
576 | IIO_EVENT_CODE_IN_LOW_THRESH(3), | ||
577 | timestamp); | ||
578 | if (rx & (1 << 1)) | ||
579 | iio_push_event(indio_dev, 0, | ||
580 | IIO_EVENT_CODE_IN_HIGH_THRESH(3), | ||
581 | timestamp); | ||
582 | if (rx & (1 << 2)) | ||
583 | iio_push_event(indio_dev, 0, | ||
584 | IIO_EVENT_CODE_IN_LOW_THRESH(2), | ||
585 | timestamp); | ||
586 | if (rx & (1 << 3)) | ||
587 | iio_push_event(indio_dev, 0, | ||
588 | IIO_EVENT_CODE_IN_HIGH_THRESH(2), | ||
589 | timestamp); | ||
590 | if (rx & (1 << 4)) | ||
591 | iio_push_event(indio_dev, 0, | ||
592 | IIO_EVENT_CODE_IN_LOW_THRESH(1), | ||
593 | timestamp); | ||
594 | if (rx & (1 << 5)) | ||
595 | iio_push_event(indio_dev, 0, | ||
596 | IIO_EVENT_CODE_IN_HIGH_THRESH(1), | ||
597 | timestamp); | ||
598 | if (rx & (1 << 6)) | ||
599 | iio_push_event(indio_dev, 0, | ||
600 | IIO_EVENT_CODE_IN_LOW_THRESH(0), | ||
601 | timestamp); | ||
602 | if (rx & (1 << 7)) | ||
603 | iio_push_event(indio_dev, 0, | ||
604 | IIO_EVENT_CODE_IN_HIGH_THRESH(0), | ||
605 | timestamp); | ||
606 | i2c_master_send(st->client, tx, 2); | ||
607 | |||
608 | return IRQ_HANDLED; | ||
609 | } | ||
610 | |||
611 | static int max1363_read_event_config(struct iio_dev *indio_dev, | ||
612 | int event_code) | ||
613 | { | ||
614 | struct max1363_state *st = iio_priv(indio_dev); | ||
615 | |||
616 | int val; | ||
617 | int number = IIO_EVENT_CODE_EXTRACT_NUM(event_code); | ||
618 | mutex_lock(&indio_dev->mlock); | ||
619 | if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_FALLING) | ||
620 | val = (1 << number) & st->mask_low; | ||
621 | else | ||
622 | val = (1 << number) & st->mask_high; | ||
623 | mutex_unlock(&indio_dev->mlock); | ||
624 | |||
625 | return val; | ||
626 | } | ||
627 | |||
628 | static int max1363_monitor_mode_update(struct max1363_state *st, int enabled) | ||
629 | { | ||
630 | u8 *tx_buf; | ||
631 | int ret, i = 3, j; | ||
632 | unsigned long numelements; | ||
633 | int len; | ||
634 | long modemask; | ||
635 | |||
636 | if (!enabled) { | ||
637 | /* transition to ring capture is not currently supported */ | ||
638 | st->setupbyte &= ~MAX1363_SETUP_MONITOR_SETUP; | ||
639 | st->configbyte &= ~MAX1363_SCAN_MASK; | ||
640 | st->monitor_on = false; | ||
641 | return max1363_write_basic_config(st->client, | ||
642 | st->setupbyte, | ||
643 | st->configbyte); | ||
644 | } | ||
645 | |||
646 | /* Ensure we are in the relevant mode */ | ||
647 | st->setupbyte |= MAX1363_SETUP_MONITOR_SETUP; | ||
648 | st->configbyte &= ~(MAX1363_CHANNEL_SEL_MASK | ||
649 | | MAX1363_SCAN_MASK | ||
650 | | MAX1363_SE_DE_MASK); | ||
651 | st->configbyte |= MAX1363_CONFIG_SCAN_MONITOR_MODE; | ||
652 | if ((st->mask_low | st->mask_high) & 0x0F) { | ||
653 | st->configbyte |= max1363_mode_table[s0to3].conf; | ||
654 | modemask = max1363_mode_table[s0to3].modemask; | ||
655 | } else if ((st->mask_low | st->mask_high) & 0x30) { | ||
656 | st->configbyte |= max1363_mode_table[d0m1to2m3].conf; | ||
657 | modemask = max1363_mode_table[d0m1to2m3].modemask; | ||
658 | } else { | ||
659 | st->configbyte |= max1363_mode_table[d1m0to3m2].conf; | ||
660 | modemask = max1363_mode_table[d1m0to3m2].modemask; | ||
661 | } | ||
662 | numelements = hweight_long(modemask); | ||
663 | len = 3 * numelements + 3; | ||
664 | tx_buf = kmalloc(len, GFP_KERNEL); | ||
665 | if (!tx_buf) { | ||
666 | ret = -ENOMEM; | ||
667 | goto error_ret; | ||
668 | } | ||
669 | tx_buf[0] = st->configbyte; | ||
670 | tx_buf[1] = st->setupbyte; | ||
671 | tx_buf[2] = (st->monitor_speed << 1); | ||
672 | |||
673 | /* | ||
674 | * So we need to do yet another bit of nefarious scan mode | ||
675 | * setup to match what we need. | ||
676 | */ | ||
677 | for (j = 0; j < 8; j++) | ||
678 | if (modemask & (1 << j)) { | ||
679 | /* Establish the mode is in the scan */ | ||
680 | if (st->mask_low & (1 << j)) { | ||
681 | tx_buf[i] = (st->thresh_low[j] >> 4) & 0xFF; | ||
682 | tx_buf[i + 1] = (st->thresh_low[j] << 4) & 0xF0; | ||
683 | } else if (j < 4) { | ||
684 | tx_buf[i] = 0; | ||
685 | tx_buf[i + 1] = 0; | ||
686 | } else { | ||
687 | tx_buf[i] = 0x80; | ||
688 | tx_buf[i + 1] = 0; | ||
689 | } | ||
690 | if (st->mask_high & (1 << j)) { | ||
691 | tx_buf[i + 1] |= | ||
692 | (st->thresh_high[j] >> 8) & 0x0F; | ||
693 | tx_buf[i + 2] = st->thresh_high[j] & 0xFF; | ||
694 | } else if (j < 4) { | ||
695 | tx_buf[i + 1] |= 0x0F; | ||
696 | tx_buf[i + 2] = 0xFF; | ||
697 | } else { | ||
698 | tx_buf[i + 1] |= 0x07; | ||
699 | tx_buf[i + 2] = 0xFF; | ||
700 | } | ||
701 | i += 3; | ||
702 | } | ||
703 | |||
704 | |||
705 | ret = i2c_master_send(st->client, tx_buf, len); | ||
706 | if (ret < 0) | ||
707 | goto error_ret; | ||
708 | if (ret != len) { | ||
709 | ret = -EIO; | ||
710 | goto error_ret; | ||
711 | } | ||
712 | |||
713 | /* | ||
714 | * Now that we hopefully have sensible thresholds in place it is | ||
715 | * time to turn the interrupts on. | ||
716 | * It is unclear from the data sheet if this should be necessary | ||
717 | * (i.e. whether monitor mode setup is atomic) but it appears to | ||
718 | * be in practice. | ||
719 | */ | ||
720 | tx_buf[0] = st->setupbyte; | ||
721 | tx_buf[1] = MAX1363_MON_INT_ENABLE | (st->monitor_speed << 1) | 0xF0; | ||
722 | ret = i2c_master_send(st->client, tx_buf, 2); | ||
723 | if (ret < 0) | ||
724 | goto error_ret; | ||
725 | if (ret != 2) { | ||
726 | ret = -EIO; | ||
727 | goto error_ret; | ||
728 | } | ||
729 | ret = 0; | ||
730 | st->monitor_on = true; | ||
731 | error_ret: | ||
732 | |||
733 | kfree(tx_buf); | ||
734 | |||
735 | return ret; | ||
736 | } | ||
737 | |||
738 | /* | ||
739 | * To keep this manageable we always use one of 3 scan modes. | ||
740 | * Scan 0...3, 0-1,2-3 and 1-0,3-2 | ||
741 | */ | ||
742 | |||
743 | static inline int __max1363_check_event_mask(int thismask, int checkmask) | ||
744 | { | ||
745 | int ret = 0; | ||
746 | /* Is it unipolar */ | ||
747 | if (thismask < 4) { | ||
748 | if (checkmask & ~0x0F) { | ||
749 | ret = -EBUSY; | ||
750 | goto error_ret; | ||
751 | } | ||
752 | } else if (thismask < 6) { | ||
753 | if (checkmask & ~0x30) { | ||
754 | ret = -EBUSY; | ||
755 | goto error_ret; | ||
756 | } | ||
757 | } else if (checkmask & ~0xC0) | ||
758 | ret = -EBUSY; | ||
759 | error_ret: | ||
760 | return ret; | ||
761 | } | ||
762 | |||
763 | static int max1363_write_event_config(struct iio_dev *indio_dev, | ||
764 | int event_code, | ||
765 | int state) | ||
766 | { | ||
767 | int ret = 0; | ||
768 | struct max1363_state *st = iio_priv(indio_dev); | ||
769 | u16 unifiedmask; | ||
770 | int number = IIO_EVENT_CODE_EXTRACT_NUM(event_code); | ||
771 | |||
772 | mutex_lock(&indio_dev->mlock); | ||
773 | unifiedmask = st->mask_low | st->mask_high; | ||
774 | if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_FALLING) { | ||
775 | |||
776 | if (state == 0) | ||
777 | st->mask_low &= ~(1 << number); | ||
778 | else { | ||
779 | ret = __max1363_check_event_mask((1 << number), | ||
780 | unifiedmask); | ||
781 | if (ret) | ||
782 | goto error_ret; | ||
783 | st->mask_low |= (1 << number); | ||
784 | } | ||
785 | } else { | ||
786 | if (state == 0) | ||
787 | st->mask_high &= ~(1 << number); | ||
788 | else { | ||
789 | ret = __max1363_check_event_mask((1 << number), | ||
790 | unifiedmask); | ||
791 | if (ret) | ||
792 | goto error_ret; | ||
793 | st->mask_high |= (1 << number); | ||
794 | } | ||
795 | } | ||
796 | |||
797 | max1363_monitor_mode_update(st, !!(st->mask_high | st->mask_low)); | ||
798 | error_ret: | ||
799 | mutex_unlock(&indio_dev->mlock); | ||
800 | |||
801 | return ret; | ||
802 | } | ||
803 | |||
804 | /* | ||
805 | * As with scan_elements, only certain sets of these can | ||
806 | * be combined. | ||
807 | */ | ||
808 | static struct attribute *max1363_event_attributes[] = { | ||
809 | &iio_dev_attr_sampling_frequency.dev_attr.attr, | ||
810 | &iio_const_attr_sampling_frequency_available.dev_attr.attr, | ||
811 | NULL, | ||
812 | }; | ||
813 | |||
814 | static struct attribute_group max1363_event_attribute_group = { | ||
815 | .attrs = max1363_event_attributes, | ||
816 | }; | ||
817 | |||
818 | #define MAX1363_EVENT_FUNCS \ | ||
819 | |||
820 | |||
821 | static const struct iio_info max1238_info = { | ||
822 | .read_raw = &max1363_read_raw, | ||
823 | .driver_module = THIS_MODULE, | ||
824 | }; | ||
825 | |||
826 | static const struct iio_info max1363_info = { | ||
827 | .read_event_value = &max1363_read_thresh, | ||
828 | .write_event_value = &max1363_write_thresh, | ||
829 | .read_event_config = &max1363_read_event_config, | ||
830 | .write_event_config = &max1363_write_event_config, | ||
831 | .read_raw = &max1363_read_raw, | ||
832 | .driver_module = THIS_MODULE, | ||
833 | .num_interrupt_lines = 1, | ||
834 | .event_attrs = &max1363_event_attribute_group, | ||
835 | }; | ||
836 | |||
475 | /* max1363 and max1368 tested - rest from data sheet */ | 837 | /* max1363 and max1368 tested - rest from data sheet */ |
476 | static const struct max1363_chip_info max1363_chip_info_tbl[] = { | 838 | static const struct max1363_chip_info max1363_chip_info_tbl[] = { |
477 | [max1361] = { | 839 | [max1361] = { |
478 | .bits = 10, | 840 | .bits = 10, |
479 | .int_vref_mv = 2048, | 841 | .int_vref_mv = 2048, |
480 | .monitor_mode = 1, | ||
481 | .mode_list = max1363_mode_list, | 842 | .mode_list = max1363_mode_list, |
482 | .num_modes = ARRAY_SIZE(max1363_mode_list), | 843 | .num_modes = ARRAY_SIZE(max1363_mode_list), |
483 | .default_mode = s0to3, | 844 | .default_mode = s0to3, |
484 | .channels = max1361_channels, | 845 | .channels = max1361_channels, |
485 | .num_channels = ARRAY_SIZE(max1361_channels), | 846 | .num_channels = ARRAY_SIZE(max1361_channels), |
847 | .info = &max1363_info, | ||
486 | }, | 848 | }, |
487 | [max1362] = { | 849 | [max1362] = { |
488 | .bits = 10, | 850 | .bits = 10, |
489 | .int_vref_mv = 4096, | 851 | .int_vref_mv = 4096, |
490 | .monitor_mode = 1, | ||
491 | .mode_list = max1363_mode_list, | 852 | .mode_list = max1363_mode_list, |
492 | .num_modes = ARRAY_SIZE(max1363_mode_list), | 853 | .num_modes = ARRAY_SIZE(max1363_mode_list), |
493 | .default_mode = s0to3, | 854 | .default_mode = s0to3, |
494 | .channels = max1361_channels, | 855 | .channels = max1361_channels, |
495 | .num_channels = ARRAY_SIZE(max1361_channels), | 856 | .num_channels = ARRAY_SIZE(max1361_channels), |
857 | .info = &max1363_info, | ||
496 | }, | 858 | }, |
497 | [max1363] = { | 859 | [max1363] = { |
498 | .bits = 12, | 860 | .bits = 12, |
499 | .int_vref_mv = 2048, | 861 | .int_vref_mv = 2048, |
500 | .monitor_mode = 1, | ||
501 | .mode_list = max1363_mode_list, | 862 | .mode_list = max1363_mode_list, |
502 | .num_modes = ARRAY_SIZE(max1363_mode_list), | 863 | .num_modes = ARRAY_SIZE(max1363_mode_list), |
503 | .default_mode = s0to3, | 864 | .default_mode = s0to3, |
504 | .channels = max1363_channels, | 865 | .channels = max1363_channels, |
505 | .num_channels = ARRAY_SIZE(max1363_channels), | 866 | .num_channels = ARRAY_SIZE(max1363_channels), |
867 | .info = &max1363_info, | ||
506 | }, | 868 | }, |
507 | [max1364] = { | 869 | [max1364] = { |
508 | .bits = 12, | 870 | .bits = 12, |
509 | .int_vref_mv = 4096, | 871 | .int_vref_mv = 4096, |
510 | .monitor_mode = 1, | ||
511 | .mode_list = max1363_mode_list, | 872 | .mode_list = max1363_mode_list, |
512 | .num_modes = ARRAY_SIZE(max1363_mode_list), | 873 | .num_modes = ARRAY_SIZE(max1363_mode_list), |
513 | .default_mode = s0to3, | 874 | .default_mode = s0to3, |
514 | .channels = max1363_channels, | 875 | .channels = max1363_channels, |
515 | .num_channels = ARRAY_SIZE(max1363_channels), | 876 | .num_channels = ARRAY_SIZE(max1363_channels), |
877 | .info = &max1363_info, | ||
516 | }, | 878 | }, |
517 | [max1036] = { | 879 | [max1036] = { |
518 | .bits = 8, | 880 | .bits = 8, |
@@ -520,6 +882,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
520 | .mode_list = max1236_mode_list, | 882 | .mode_list = max1236_mode_list, |
521 | .num_modes = ARRAY_SIZE(max1236_mode_list), | 883 | .num_modes = ARRAY_SIZE(max1236_mode_list), |
522 | .default_mode = s0to3, | 884 | .default_mode = s0to3, |
885 | .info = &max1238_info, | ||
523 | .channels = max1036_channels, | 886 | .channels = max1036_channels, |
524 | .num_channels = ARRAY_SIZE(max1036_channels), | 887 | .num_channels = ARRAY_SIZE(max1036_channels), |
525 | }, | 888 | }, |
@@ -529,6 +892,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
529 | .mode_list = max1236_mode_list, | 892 | .mode_list = max1236_mode_list, |
530 | .num_modes = ARRAY_SIZE(max1236_mode_list), | 893 | .num_modes = ARRAY_SIZE(max1236_mode_list), |
531 | .default_mode = s0to3, | 894 | .default_mode = s0to3, |
895 | .info = &max1238_info, | ||
532 | .channels = max1036_channels, | 896 | .channels = max1036_channels, |
533 | .num_channels = ARRAY_SIZE(max1036_channels), | 897 | .num_channels = ARRAY_SIZE(max1036_channels), |
534 | }, | 898 | }, |
@@ -538,6 +902,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
538 | .mode_list = max1238_mode_list, | 902 | .mode_list = max1238_mode_list, |
539 | .num_modes = ARRAY_SIZE(max1238_mode_list), | 903 | .num_modes = ARRAY_SIZE(max1238_mode_list), |
540 | .default_mode = s0to11, | 904 | .default_mode = s0to11, |
905 | .info = &max1238_info, | ||
541 | .channels = max1038_channels, | 906 | .channels = max1038_channels, |
542 | .num_channels = ARRAY_SIZE(max1038_channels), | 907 | .num_channels = ARRAY_SIZE(max1038_channels), |
543 | }, | 908 | }, |
@@ -547,6 +912,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
547 | .mode_list = max1238_mode_list, | 912 | .mode_list = max1238_mode_list, |
548 | .num_modes = ARRAY_SIZE(max1238_mode_list), | 913 | .num_modes = ARRAY_SIZE(max1238_mode_list), |
549 | .default_mode = s0to11, | 914 | .default_mode = s0to11, |
915 | .info = &max1238_info, | ||
550 | .channels = max1038_channels, | 916 | .channels = max1038_channels, |
551 | .num_channels = ARRAY_SIZE(max1038_channels), | 917 | .num_channels = ARRAY_SIZE(max1038_channels), |
552 | }, | 918 | }, |
@@ -556,6 +922,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
556 | .mode_list = max1236_mode_list, | 922 | .mode_list = max1236_mode_list, |
557 | .num_modes = ARRAY_SIZE(max1236_mode_list), | 923 | .num_modes = ARRAY_SIZE(max1236_mode_list), |
558 | .default_mode = s0to3, | 924 | .default_mode = s0to3, |
925 | .info = &max1238_info, | ||
559 | .channels = max1136_channels, | 926 | .channels = max1136_channels, |
560 | .num_channels = ARRAY_SIZE(max1136_channels), | 927 | .num_channels = ARRAY_SIZE(max1136_channels), |
561 | }, | 928 | }, |
@@ -565,6 +932,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
565 | .mode_list = max1236_mode_list, | 932 | .mode_list = max1236_mode_list, |
566 | .num_modes = ARRAY_SIZE(max1236_mode_list), | 933 | .num_modes = ARRAY_SIZE(max1236_mode_list), |
567 | .default_mode = s0to3, | 934 | .default_mode = s0to3, |
935 | .info = &max1238_info, | ||
568 | .channels = max1136_channels, | 936 | .channels = max1136_channels, |
569 | .num_channels = ARRAY_SIZE(max1136_channels), | 937 | .num_channels = ARRAY_SIZE(max1136_channels), |
570 | }, | 938 | }, |
@@ -574,6 +942,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
574 | .mode_list = max1238_mode_list, | 942 | .mode_list = max1238_mode_list, |
575 | .num_modes = ARRAY_SIZE(max1238_mode_list), | 943 | .num_modes = ARRAY_SIZE(max1238_mode_list), |
576 | .default_mode = s0to11, | 944 | .default_mode = s0to11, |
945 | .info = &max1238_info, | ||
577 | .channels = max1138_channels, | 946 | .channels = max1138_channels, |
578 | .num_channels = ARRAY_SIZE(max1138_channels), | 947 | .num_channels = ARRAY_SIZE(max1138_channels), |
579 | }, | 948 | }, |
@@ -583,6 +952,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
583 | .mode_list = max1238_mode_list, | 952 | .mode_list = max1238_mode_list, |
584 | .num_modes = ARRAY_SIZE(max1238_mode_list), | 953 | .num_modes = ARRAY_SIZE(max1238_mode_list), |
585 | .default_mode = s0to11, | 954 | .default_mode = s0to11, |
955 | .info = &max1238_info, | ||
586 | .channels = max1138_channels, | 956 | .channels = max1138_channels, |
587 | .num_channels = ARRAY_SIZE(max1138_channels), | 957 | .num_channels = ARRAY_SIZE(max1138_channels), |
588 | }, | 958 | }, |
@@ -592,6 +962,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
592 | .mode_list = max1236_mode_list, | 962 | .mode_list = max1236_mode_list, |
593 | .num_modes = ARRAY_SIZE(max1236_mode_list), | 963 | .num_modes = ARRAY_SIZE(max1236_mode_list), |
594 | .default_mode = s0to3, | 964 | .default_mode = s0to3, |
965 | .info = &max1238_info, | ||
595 | .channels = max1236_channels, | 966 | .channels = max1236_channels, |
596 | .num_channels = ARRAY_SIZE(max1236_channels), | 967 | .num_channels = ARRAY_SIZE(max1236_channels), |
597 | }, | 968 | }, |
@@ -601,6 +972,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
601 | .mode_list = max1236_mode_list, | 972 | .mode_list = max1236_mode_list, |
602 | .num_modes = ARRAY_SIZE(max1236_mode_list), | 973 | .num_modes = ARRAY_SIZE(max1236_mode_list), |
603 | .default_mode = s0to3, | 974 | .default_mode = s0to3, |
975 | .info = &max1238_info, | ||
604 | .channels = max1236_channels, | 976 | .channels = max1236_channels, |
605 | .num_channels = ARRAY_SIZE(max1236_channels), | 977 | .num_channels = ARRAY_SIZE(max1236_channels), |
606 | }, | 978 | }, |
@@ -610,6 +982,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
610 | .mode_list = max1238_mode_list, | 982 | .mode_list = max1238_mode_list, |
611 | .num_modes = ARRAY_SIZE(max1238_mode_list), | 983 | .num_modes = ARRAY_SIZE(max1238_mode_list), |
612 | .default_mode = s0to11, | 984 | .default_mode = s0to11, |
985 | .info = &max1238_info, | ||
613 | .channels = max1238_channels, | 986 | .channels = max1238_channels, |
614 | .num_channels = ARRAY_SIZE(max1238_channels), | 987 | .num_channels = ARRAY_SIZE(max1238_channels), |
615 | }, | 988 | }, |
@@ -619,6 +992,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
619 | .mode_list = max1238_mode_list, | 992 | .mode_list = max1238_mode_list, |
620 | .num_modes = ARRAY_SIZE(max1238_mode_list), | 993 | .num_modes = ARRAY_SIZE(max1238_mode_list), |
621 | .default_mode = s0to11, | 994 | .default_mode = s0to11, |
995 | .info = &max1238_info, | ||
622 | .channels = max1238_channels, | 996 | .channels = max1238_channels, |
623 | .num_channels = ARRAY_SIZE(max1238_channels), | 997 | .num_channels = ARRAY_SIZE(max1238_channels), |
624 | }, | 998 | }, |
@@ -628,6 +1002,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
628 | .mode_list = max11607_mode_list, | 1002 | .mode_list = max11607_mode_list, |
629 | .num_modes = ARRAY_SIZE(max11607_mode_list), | 1003 | .num_modes = ARRAY_SIZE(max11607_mode_list), |
630 | .default_mode = s0to3, | 1004 | .default_mode = s0to3, |
1005 | .info = &max1238_info, | ||
631 | .channels = max1036_channels, | 1006 | .channels = max1036_channels, |
632 | .num_channels = ARRAY_SIZE(max1036_channels), | 1007 | .num_channels = ARRAY_SIZE(max1036_channels), |
633 | }, | 1008 | }, |
@@ -637,6 +1012,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
637 | .mode_list = max11607_mode_list, | 1012 | .mode_list = max11607_mode_list, |
638 | .num_modes = ARRAY_SIZE(max11607_mode_list), | 1013 | .num_modes = ARRAY_SIZE(max11607_mode_list), |
639 | .default_mode = s0to3, | 1014 | .default_mode = s0to3, |
1015 | .info = &max1238_info, | ||
640 | .channels = max1036_channels, | 1016 | .channels = max1036_channels, |
641 | .num_channels = ARRAY_SIZE(max1036_channels), | 1017 | .num_channels = ARRAY_SIZE(max1036_channels), |
642 | }, | 1018 | }, |
@@ -646,6 +1022,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
646 | .mode_list = max11608_mode_list, | 1022 | .mode_list = max11608_mode_list, |
647 | .num_modes = ARRAY_SIZE(max11608_mode_list), | 1023 | .num_modes = ARRAY_SIZE(max11608_mode_list), |
648 | .default_mode = s0to7, | 1024 | .default_mode = s0to7, |
1025 | .info = &max1238_info, | ||
649 | .channels = max11602_channels, | 1026 | .channels = max11602_channels, |
650 | .num_channels = ARRAY_SIZE(max11602_channels), | 1027 | .num_channels = ARRAY_SIZE(max11602_channels), |
651 | }, | 1028 | }, |
@@ -655,6 +1032,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
655 | .mode_list = max11608_mode_list, | 1032 | .mode_list = max11608_mode_list, |
656 | .num_modes = ARRAY_SIZE(max11608_mode_list), | 1033 | .num_modes = ARRAY_SIZE(max11608_mode_list), |
657 | .default_mode = s0to7, | 1034 | .default_mode = s0to7, |
1035 | .info = &max1238_info, | ||
658 | .channels = max11602_channels, | 1036 | .channels = max11602_channels, |
659 | .num_channels = ARRAY_SIZE(max11602_channels), | 1037 | .num_channels = ARRAY_SIZE(max11602_channels), |
660 | }, | 1038 | }, |
@@ -664,6 +1042,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
664 | .mode_list = max1238_mode_list, | 1042 | .mode_list = max1238_mode_list, |
665 | .num_modes = ARRAY_SIZE(max1238_mode_list), | 1043 | .num_modes = ARRAY_SIZE(max1238_mode_list), |
666 | .default_mode = s0to11, | 1044 | .default_mode = s0to11, |
1045 | .info = &max1238_info, | ||
667 | .channels = max1238_channels, | 1046 | .channels = max1238_channels, |
668 | .num_channels = ARRAY_SIZE(max1238_channels), | 1047 | .num_channels = ARRAY_SIZE(max1238_channels), |
669 | }, | 1048 | }, |
@@ -673,6 +1052,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
673 | .mode_list = max1238_mode_list, | 1052 | .mode_list = max1238_mode_list, |
674 | .num_modes = ARRAY_SIZE(max1238_mode_list), | 1053 | .num_modes = ARRAY_SIZE(max1238_mode_list), |
675 | .default_mode = s0to11, | 1054 | .default_mode = s0to11, |
1055 | .info = &max1238_info, | ||
676 | .channels = max1238_channels, | 1056 | .channels = max1238_channels, |
677 | .num_channels = ARRAY_SIZE(max1238_channels), | 1057 | .num_channels = ARRAY_SIZE(max1238_channels), |
678 | }, | 1058 | }, |
@@ -682,6 +1062,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
682 | .mode_list = max11607_mode_list, | 1062 | .mode_list = max11607_mode_list, |
683 | .num_modes = ARRAY_SIZE(max11607_mode_list), | 1063 | .num_modes = ARRAY_SIZE(max11607_mode_list), |
684 | .default_mode = s0to3, | 1064 | .default_mode = s0to3, |
1065 | .info = &max1238_info, | ||
685 | .channels = max1136_channels, | 1066 | .channels = max1136_channels, |
686 | .num_channels = ARRAY_SIZE(max1136_channels), | 1067 | .num_channels = ARRAY_SIZE(max1136_channels), |
687 | }, | 1068 | }, |
@@ -691,6 +1072,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
691 | .mode_list = max11607_mode_list, | 1072 | .mode_list = max11607_mode_list, |
692 | .num_modes = ARRAY_SIZE(max11607_mode_list), | 1073 | .num_modes = ARRAY_SIZE(max11607_mode_list), |
693 | .default_mode = s0to3, | 1074 | .default_mode = s0to3, |
1075 | .info = &max1238_info, | ||
694 | .channels = max1136_channels, | 1076 | .channels = max1136_channels, |
695 | .num_channels = ARRAY_SIZE(max1136_channels), | 1077 | .num_channels = ARRAY_SIZE(max1136_channels), |
696 | }, | 1078 | }, |
@@ -700,6 +1082,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
700 | .mode_list = max11608_mode_list, | 1082 | .mode_list = max11608_mode_list, |
701 | .num_modes = ARRAY_SIZE(max11608_mode_list), | 1083 | .num_modes = ARRAY_SIZE(max11608_mode_list), |
702 | .default_mode = s0to7, | 1084 | .default_mode = s0to7, |
1085 | .info = &max1238_info, | ||
703 | .channels = max11608_channels, | 1086 | .channels = max11608_channels, |
704 | .num_channels = ARRAY_SIZE(max11608_channels), | 1087 | .num_channels = ARRAY_SIZE(max11608_channels), |
705 | }, | 1088 | }, |
@@ -709,6 +1092,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
709 | .mode_list = max11608_mode_list, | 1092 | .mode_list = max11608_mode_list, |
710 | .num_modes = ARRAY_SIZE(max11608_mode_list), | 1093 | .num_modes = ARRAY_SIZE(max11608_mode_list), |
711 | .default_mode = s0to7, | 1094 | .default_mode = s0to7, |
1095 | .info = &max1238_info, | ||
712 | .channels = max11608_channels, | 1096 | .channels = max11608_channels, |
713 | .num_channels = ARRAY_SIZE(max11608_channels), | 1097 | .num_channels = ARRAY_SIZE(max11608_channels), |
714 | }, | 1098 | }, |
@@ -718,6 +1102,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
718 | .mode_list = max1238_mode_list, | 1102 | .mode_list = max1238_mode_list, |
719 | .num_modes = ARRAY_SIZE(max1238_mode_list), | 1103 | .num_modes = ARRAY_SIZE(max1238_mode_list), |
720 | .default_mode = s0to11, | 1104 | .default_mode = s0to11, |
1105 | .info = &max1238_info, | ||
721 | .channels = max1238_channels, | 1106 | .channels = max1238_channels, |
722 | .num_channels = ARRAY_SIZE(max1238_channels), | 1107 | .num_channels = ARRAY_SIZE(max1238_channels), |
723 | }, | 1108 | }, |
@@ -727,6 +1112,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
727 | .mode_list = max1238_mode_list, | 1112 | .mode_list = max1238_mode_list, |
728 | .num_modes = ARRAY_SIZE(max1238_mode_list), | 1113 | .num_modes = ARRAY_SIZE(max1238_mode_list), |
729 | .default_mode = s0to11, | 1114 | .default_mode = s0to11, |
1115 | .info = &max1238_info, | ||
730 | .channels = max1238_channels, | 1116 | .channels = max1238_channels, |
731 | .num_channels = ARRAY_SIZE(max1238_channels), | 1117 | .num_channels = ARRAY_SIZE(max1238_channels), |
732 | }, | 1118 | }, |
@@ -736,6 +1122,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
736 | .mode_list = max11607_mode_list, | 1122 | .mode_list = max11607_mode_list, |
737 | .num_modes = ARRAY_SIZE(max11607_mode_list), | 1123 | .num_modes = ARRAY_SIZE(max11607_mode_list), |
738 | .default_mode = s0to3, | 1124 | .default_mode = s0to3, |
1125 | .info = &max1238_info, | ||
739 | .channels = max1363_channels, | 1126 | .channels = max1363_channels, |
740 | .num_channels = ARRAY_SIZE(max1363_channels), | 1127 | .num_channels = ARRAY_SIZE(max1363_channels), |
741 | }, | 1128 | }, |
@@ -745,6 +1132,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
745 | .mode_list = max11607_mode_list, | 1132 | .mode_list = max11607_mode_list, |
746 | .num_modes = ARRAY_SIZE(max11607_mode_list), | 1133 | .num_modes = ARRAY_SIZE(max11607_mode_list), |
747 | .default_mode = s0to3, | 1134 | .default_mode = s0to3, |
1135 | .info = &max1238_info, | ||
748 | .channels = max1363_channels, | 1136 | .channels = max1363_channels, |
749 | .num_channels = ARRAY_SIZE(max1363_channels), | 1137 | .num_channels = ARRAY_SIZE(max1363_channels), |
750 | }, | 1138 | }, |
@@ -754,6 +1142,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
754 | .mode_list = max11608_mode_list, | 1142 | .mode_list = max11608_mode_list, |
755 | .num_modes = ARRAY_SIZE(max11608_mode_list), | 1143 | .num_modes = ARRAY_SIZE(max11608_mode_list), |
756 | .default_mode = s0to7, | 1144 | .default_mode = s0to7, |
1145 | .info = &max1238_info, | ||
757 | .channels = max11614_channels, | 1146 | .channels = max11614_channels, |
758 | .num_channels = ARRAY_SIZE(max11614_channels), | 1147 | .num_channels = ARRAY_SIZE(max11614_channels), |
759 | }, | 1148 | }, |
@@ -763,6 +1152,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
763 | .mode_list = max11608_mode_list, | 1152 | .mode_list = max11608_mode_list, |
764 | .num_modes = ARRAY_SIZE(max11608_mode_list), | 1153 | .num_modes = ARRAY_SIZE(max11608_mode_list), |
765 | .default_mode = s0to7, | 1154 | .default_mode = s0to7, |
1155 | .info = &max1238_info, | ||
766 | .channels = max11614_channels, | 1156 | .channels = max11614_channels, |
767 | .num_channels = ARRAY_SIZE(max11614_channels), | 1157 | .num_channels = ARRAY_SIZE(max11614_channels), |
768 | }, | 1158 | }, |
@@ -772,6 +1162,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
772 | .mode_list = max1238_mode_list, | 1162 | .mode_list = max1238_mode_list, |
773 | .num_modes = ARRAY_SIZE(max1238_mode_list), | 1163 | .num_modes = ARRAY_SIZE(max1238_mode_list), |
774 | .default_mode = s0to11, | 1164 | .default_mode = s0to11, |
1165 | .info = &max1238_info, | ||
775 | .channels = max1238_channels, | 1166 | .channels = max1238_channels, |
776 | .num_channels = ARRAY_SIZE(max1238_channels), | 1167 | .num_channels = ARRAY_SIZE(max1238_channels), |
777 | }, | 1168 | }, |
@@ -781,6 +1172,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
781 | .mode_list = max1238_mode_list, | 1172 | .mode_list = max1238_mode_list, |
782 | .num_modes = ARRAY_SIZE(max1238_mode_list), | 1173 | .num_modes = ARRAY_SIZE(max1238_mode_list), |
783 | .default_mode = s0to11, | 1174 | .default_mode = s0to11, |
1175 | .info = &max1238_info, | ||
784 | .channels = max1238_channels, | 1176 | .channels = max1238_channels, |
785 | .num_channels = ARRAY_SIZE(max1238_channels), | 1177 | .num_channels = ARRAY_SIZE(max1238_channels), |
786 | }, | 1178 | }, |
@@ -790,6 +1182,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
790 | .mode_list = max11644_mode_list, | 1182 | .mode_list = max11644_mode_list, |
791 | .num_modes = ARRAY_SIZE(max11644_mode_list), | 1183 | .num_modes = ARRAY_SIZE(max11644_mode_list), |
792 | .default_mode = s0to1, | 1184 | .default_mode = s0to1, |
1185 | .info = &max1238_info, | ||
793 | .channels = max11644_channels, | 1186 | .channels = max11644_channels, |
794 | .num_channels = ARRAY_SIZE(max11644_channels), | 1187 | .num_channels = ARRAY_SIZE(max11644_channels), |
795 | }, | 1188 | }, |
@@ -799,6 +1192,7 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
799 | .mode_list = max11644_mode_list, | 1192 | .mode_list = max11644_mode_list, |
800 | .num_modes = ARRAY_SIZE(max11644_mode_list), | 1193 | .num_modes = ARRAY_SIZE(max11644_mode_list), |
801 | .default_mode = s0to1, | 1194 | .default_mode = s0to1, |
1195 | .info = &max1238_info, | ||
802 | .channels = max11644_channels, | 1196 | .channels = max11644_channels, |
803 | .num_channels = ARRAY_SIZE(max11644_channels), | 1197 | .num_channels = ARRAY_SIZE(max11644_channels), |
804 | }, | 1198 | }, |
@@ -808,7 +1202,8 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
808 | .mode_list = max11644_mode_list, | 1202 | .mode_list = max11644_mode_list, |
809 | .num_modes = ARRAY_SIZE(max11644_mode_list), | 1203 | .num_modes = ARRAY_SIZE(max11644_mode_list), |
810 | .default_mode = s0to1, | 1204 | .default_mode = s0to1, |
811 | .channels = max11644_channels, | 1205 | .info = &max1238_info, |
1206 | .channels = max11646_channels, | ||
812 | .num_channels = ARRAY_SIZE(max11646_channels), | 1207 | .num_channels = ARRAY_SIZE(max11646_channels), |
813 | }, | 1208 | }, |
814 | [max11647] = { | 1209 | [max11647] = { |
@@ -817,353 +1212,13 @@ static const struct max1363_chip_info max1363_chip_info_tbl[] = { | |||
817 | .mode_list = max11644_mode_list, | 1212 | .mode_list = max11644_mode_list, |
818 | .num_modes = ARRAY_SIZE(max11644_mode_list), | 1213 | .num_modes = ARRAY_SIZE(max11644_mode_list), |
819 | .default_mode = s0to1, | 1214 | .default_mode = s0to1, |
820 | .channels = max11644_channels, | 1215 | .info = &max1238_info, |
1216 | .channels = max11646_channels, | ||
821 | .num_channels = ARRAY_SIZE(max11646_channels), | 1217 | .num_channels = ARRAY_SIZE(max11646_channels), |
822 | }, | 1218 | }, |
823 | }; | 1219 | }; |
824 | 1220 | ||
825 | static const int max1363_monitor_speeds[] = { 133000, 665000, 33300, 16600, | ||
826 | 8300, 4200, 2000, 1000 }; | ||
827 | |||
828 | static ssize_t max1363_monitor_show_freq(struct device *dev, | ||
829 | struct device_attribute *attr, | ||
830 | char *buf) | ||
831 | { | ||
832 | struct max1363_state *st = iio_priv(dev_get_drvdata(dev)); | ||
833 | return sprintf(buf, "%d\n", max1363_monitor_speeds[st->monitor_speed]); | ||
834 | } | ||
835 | |||
836 | static ssize_t max1363_monitor_store_freq(struct device *dev, | ||
837 | struct device_attribute *attr, | ||
838 | const char *buf, | ||
839 | size_t len) | ||
840 | { | ||
841 | struct iio_dev *indio_dev = dev_get_drvdata(dev); | ||
842 | struct max1363_state *st = iio_priv(indio_dev); | ||
843 | int i, ret; | ||
844 | unsigned long val; | ||
845 | bool found = false; | ||
846 | |||
847 | ret = strict_strtoul(buf, 10, &val); | ||
848 | if (ret) | ||
849 | return -EINVAL; | ||
850 | for (i = 0; i < ARRAY_SIZE(max1363_monitor_speeds); i++) | ||
851 | if (val == max1363_monitor_speeds[i]) { | ||
852 | found = true; | ||
853 | break; | ||
854 | } | ||
855 | if (!found) | ||
856 | return -EINVAL; | ||
857 | |||
858 | mutex_lock(&indio_dev->mlock); | ||
859 | st->monitor_speed = i; | ||
860 | mutex_unlock(&indio_dev->mlock); | ||
861 | |||
862 | return 0; | ||
863 | } | ||
864 | |||
865 | static IIO_DEV_ATTR_SAMP_FREQ(S_IRUGO | S_IWUSR, | ||
866 | max1363_monitor_show_freq, | ||
867 | max1363_monitor_store_freq); | ||
868 | |||
869 | static IIO_CONST_ATTR(sampling_frequency_available, | ||
870 | "133000 665000 33300 16600 8300 4200 2000 1000"); | ||
871 | |||
872 | static int max1363_read_thresh(struct iio_dev *indio_dev, | ||
873 | int event_code, | ||
874 | int *val) | ||
875 | { | ||
876 | struct max1363_state *st = iio_priv(indio_dev); | ||
877 | if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_FALLING) | ||
878 | *val = st->thresh_low[IIO_EVENT_CODE_EXTRACT_NUM(event_code)]; | ||
879 | else | ||
880 | *val = st->thresh_high[IIO_EVENT_CODE_EXTRACT_NUM(event_code)]; | ||
881 | return 0; | ||
882 | } | ||
883 | |||
884 | static int max1363_write_thresh(struct iio_dev *indio_dev, | ||
885 | int event_code, | ||
886 | int val) | ||
887 | { | ||
888 | struct max1363_state *st = iio_priv(indio_dev); | ||
889 | /* make it handle signed correctly as well */ | ||
890 | switch (st->chip_info->bits) { | ||
891 | case 10: | ||
892 | if (val > 0x3FF) | ||
893 | return -EINVAL; | ||
894 | break; | ||
895 | case 12: | ||
896 | if (val > 0xFFF) | ||
897 | return -EINVAL; | ||
898 | break; | ||
899 | } | ||
900 | |||
901 | switch (IIO_EVENT_CODE_EXTRACT_DIR(event_code)) { | ||
902 | case IIO_EV_DIR_FALLING: | ||
903 | st->thresh_low[IIO_EVENT_CODE_EXTRACT_NUM(event_code)] = val; | ||
904 | break; | ||
905 | case IIO_EV_DIR_RISING: | ||
906 | st->thresh_high[IIO_EVENT_CODE_EXTRACT_NUM(event_code)] = val; | ||
907 | break; | ||
908 | } | ||
909 | |||
910 | return 0; | ||
911 | } | ||
912 | 1221 | ||
913 | static irqreturn_t max1363_event_handler(int irq, void *private) | ||
914 | { | ||
915 | struct iio_dev *indio_dev = private; | ||
916 | struct max1363_state *st = iio_priv(indio_dev); | ||
917 | s64 timestamp = iio_get_time_ns(); | ||
918 | u8 rx; | ||
919 | u8 tx[2] = { st->setupbyte, | ||
920 | MAX1363_MON_INT_ENABLE | (st->monitor_speed << 1) | 0xF0 }; | ||
921 | |||
922 | i2c_master_recv(st->client, &rx, 1); | ||
923 | /* todo - begging for use of for_each_set_bit */ | ||
924 | if (rx & (1 << 0)) | ||
925 | iio_push_event(indio_dev, 0, | ||
926 | IIO_EVENT_CODE_IN_LOW_THRESH(3), | ||
927 | timestamp); | ||
928 | if (rx & (1 << 1)) | ||
929 | iio_push_event(indio_dev, 0, | ||
930 | IIO_EVENT_CODE_IN_HIGH_THRESH(3), | ||
931 | timestamp); | ||
932 | if (rx & (1 << 2)) | ||
933 | iio_push_event(indio_dev, 0, | ||
934 | IIO_EVENT_CODE_IN_LOW_THRESH(2), | ||
935 | timestamp); | ||
936 | if (rx & (1 << 3)) | ||
937 | iio_push_event(indio_dev, 0, | ||
938 | IIO_EVENT_CODE_IN_HIGH_THRESH(2), | ||
939 | timestamp); | ||
940 | if (rx & (1 << 4)) | ||
941 | iio_push_event(indio_dev, 0, | ||
942 | IIO_EVENT_CODE_IN_LOW_THRESH(1), | ||
943 | timestamp); | ||
944 | if (rx & (1 << 5)) | ||
945 | iio_push_event(indio_dev, 0, | ||
946 | IIO_EVENT_CODE_IN_HIGH_THRESH(1), | ||
947 | timestamp); | ||
948 | if (rx & (1 << 6)) | ||
949 | iio_push_event(indio_dev, 0, | ||
950 | IIO_EVENT_CODE_IN_LOW_THRESH(0), | ||
951 | timestamp); | ||
952 | if (rx & (1 << 7)) | ||
953 | iio_push_event(indio_dev, 0, | ||
954 | IIO_EVENT_CODE_IN_HIGH_THRESH(0), | ||
955 | timestamp); | ||
956 | i2c_master_send(st->client, tx, 2); | ||
957 | |||
958 | return IRQ_HANDLED; | ||
959 | } | ||
960 | |||
961 | static int max1363_read_event_config(struct iio_dev *indio_dev, | ||
962 | int event_code) | ||
963 | { | ||
964 | struct max1363_state *st = iio_priv(indio_dev); | ||
965 | |||
966 | int val; | ||
967 | int number = IIO_EVENT_CODE_EXTRACT_NUM(event_code); | ||
968 | mutex_lock(&indio_dev->mlock); | ||
969 | if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_FALLING) | ||
970 | val = (1 << number) & st->mask_low; | ||
971 | else | ||
972 | val = (1 << number) & st->mask_high; | ||
973 | mutex_unlock(&indio_dev->mlock); | ||
974 | |||
975 | return val; | ||
976 | } | ||
977 | |||
978 | static int max1363_monitor_mode_update(struct max1363_state *st, int enabled) | ||
979 | { | ||
980 | u8 *tx_buf; | ||
981 | int ret, i = 3, j; | ||
982 | unsigned long numelements; | ||
983 | int len; | ||
984 | long modemask; | ||
985 | |||
986 | if (!enabled) { | ||
987 | /* transition to ring capture is not currently supported */ | ||
988 | st->setupbyte &= ~MAX1363_SETUP_MONITOR_SETUP; | ||
989 | st->configbyte &= ~MAX1363_SCAN_MASK; | ||
990 | st->monitor_on = false; | ||
991 | return max1363_write_basic_config(st->client, | ||
992 | st->setupbyte, | ||
993 | st->configbyte); | ||
994 | } | ||
995 | |||
996 | /* Ensure we are in the relevant mode */ | ||
997 | st->setupbyte |= MAX1363_SETUP_MONITOR_SETUP; | ||
998 | st->configbyte &= ~(MAX1363_CHANNEL_SEL_MASK | ||
999 | | MAX1363_SCAN_MASK | ||
1000 | | MAX1363_SE_DE_MASK); | ||
1001 | st->configbyte |= MAX1363_CONFIG_SCAN_MONITOR_MODE; | ||
1002 | if ((st->mask_low | st->mask_high) & 0x0F) { | ||
1003 | st->configbyte |= max1363_mode_table[s0to3].conf; | ||
1004 | modemask = max1363_mode_table[s0to3].modemask; | ||
1005 | } else if ((st->mask_low | st->mask_high) & 0x30) { | ||
1006 | st->configbyte |= max1363_mode_table[d0m1to2m3].conf; | ||
1007 | modemask = max1363_mode_table[d0m1to2m3].modemask; | ||
1008 | } else { | ||
1009 | st->configbyte |= max1363_mode_table[d1m0to3m2].conf; | ||
1010 | modemask = max1363_mode_table[d1m0to3m2].modemask; | ||
1011 | } | ||
1012 | numelements = hweight_long(modemask); | ||
1013 | len = 3 * numelements + 3; | ||
1014 | tx_buf = kmalloc(len, GFP_KERNEL); | ||
1015 | if (!tx_buf) { | ||
1016 | ret = -ENOMEM; | ||
1017 | goto error_ret; | ||
1018 | } | ||
1019 | tx_buf[0] = st->configbyte; | ||
1020 | tx_buf[1] = st->setupbyte; | ||
1021 | tx_buf[2] = (st->monitor_speed << 1); | ||
1022 | |||
1023 | /* | ||
1024 | * So we need to do yet another bit of nefarious scan mode | ||
1025 | * setup to match what we need. | ||
1026 | */ | ||
1027 | for (j = 0; j < 8; j++) | ||
1028 | if (modemask & (1 << j)) { | ||
1029 | /* Establish the mode is in the scan */ | ||
1030 | if (st->mask_low & (1 << j)) { | ||
1031 | tx_buf[i] = (st->thresh_low[j] >> 4) & 0xFF; | ||
1032 | tx_buf[i + 1] = (st->thresh_low[j] << 4) & 0xF0; | ||
1033 | } else if (j < 4) { | ||
1034 | tx_buf[i] = 0; | ||
1035 | tx_buf[i + 1] = 0; | ||
1036 | } else { | ||
1037 | tx_buf[i] = 0x80; | ||
1038 | tx_buf[i + 1] = 0; | ||
1039 | } | ||
1040 | if (st->mask_high & (1 << j)) { | ||
1041 | tx_buf[i + 1] |= | ||
1042 | (st->thresh_high[j] >> 8) & 0x0F; | ||
1043 | tx_buf[i + 2] = st->thresh_high[j] & 0xFF; | ||
1044 | } else if (j < 4) { | ||
1045 | tx_buf[i + 1] |= 0x0F; | ||
1046 | tx_buf[i + 2] = 0xFF; | ||
1047 | } else { | ||
1048 | tx_buf[i + 1] |= 0x07; | ||
1049 | tx_buf[i + 2] = 0xFF; | ||
1050 | } | ||
1051 | i += 3; | ||
1052 | } | ||
1053 | |||
1054 | |||
1055 | ret = i2c_master_send(st->client, tx_buf, len); | ||
1056 | if (ret < 0) | ||
1057 | goto error_ret; | ||
1058 | if (ret != len) { | ||
1059 | ret = -EIO; | ||
1060 | goto error_ret; | ||
1061 | } | ||
1062 | |||
1063 | /* | ||
1064 | * Now that we hopefully have sensible thresholds in place it is | ||
1065 | * time to turn the interrupts on. | ||
1066 | * It is unclear from the data sheet if this should be necessary | ||
1067 | * (i.e. whether monitor mode setup is atomic) but it appears to | ||
1068 | * be in practice. | ||
1069 | */ | ||
1070 | tx_buf[0] = st->setupbyte; | ||
1071 | tx_buf[1] = MAX1363_MON_INT_ENABLE | (st->monitor_speed << 1) | 0xF0; | ||
1072 | ret = i2c_master_send(st->client, tx_buf, 2); | ||
1073 | if (ret < 0) | ||
1074 | goto error_ret; | ||
1075 | if (ret != 2) { | ||
1076 | ret = -EIO; | ||
1077 | goto error_ret; | ||
1078 | } | ||
1079 | ret = 0; | ||
1080 | st->monitor_on = true; | ||
1081 | error_ret: | ||
1082 | |||
1083 | kfree(tx_buf); | ||
1084 | |||
1085 | return ret; | ||
1086 | } | ||
1087 | |||
1088 | /* | ||
1089 | * To keep this manageable we always use one of 3 scan modes. | ||
1090 | * Scan 0...3, 0-1,2-3 and 1-0,3-2 | ||
1091 | */ | ||
1092 | |||
1093 | static inline int __max1363_check_event_mask(int thismask, int checkmask) | ||
1094 | { | ||
1095 | int ret = 0; | ||
1096 | /* Is it unipolar */ | ||
1097 | if (thismask < 4) { | ||
1098 | if (checkmask & ~0x0F) { | ||
1099 | ret = -EBUSY; | ||
1100 | goto error_ret; | ||
1101 | } | ||
1102 | } else if (thismask < 6) { | ||
1103 | if (checkmask & ~0x30) { | ||
1104 | ret = -EBUSY; | ||
1105 | goto error_ret; | ||
1106 | } | ||
1107 | } else if (checkmask & ~0xC0) | ||
1108 | ret = -EBUSY; | ||
1109 | error_ret: | ||
1110 | return ret; | ||
1111 | } | ||
1112 | |||
1113 | static int max1363_write_event_config(struct iio_dev *indio_dev, | ||
1114 | int event_code, | ||
1115 | int state) | ||
1116 | { | ||
1117 | int ret = 0; | ||
1118 | struct max1363_state *st = iio_priv(indio_dev); | ||
1119 | u16 unifiedmask; | ||
1120 | int number = IIO_EVENT_CODE_EXTRACT_NUM(event_code); | ||
1121 | |||
1122 | mutex_lock(&indio_dev->mlock); | ||
1123 | unifiedmask = st->mask_low | st->mask_high; | ||
1124 | if (IIO_EVENT_CODE_EXTRACT_DIR(event_code) == IIO_EV_DIR_FALLING) { | ||
1125 | |||
1126 | if (state == 0) | ||
1127 | st->mask_low &= ~(1 << number); | ||
1128 | else { | ||
1129 | ret = __max1363_check_event_mask((1 << number), | ||
1130 | unifiedmask); | ||
1131 | if (ret) | ||
1132 | goto error_ret; | ||
1133 | st->mask_low |= (1 << number); | ||
1134 | } | ||
1135 | } else { | ||
1136 | if (state == 0) | ||
1137 | st->mask_high &= ~(1 << number); | ||
1138 | else { | ||
1139 | ret = __max1363_check_event_mask((1 << number), | ||
1140 | unifiedmask); | ||
1141 | if (ret) | ||
1142 | goto error_ret; | ||
1143 | st->mask_high |= (1 << number); | ||
1144 | } | ||
1145 | } | ||
1146 | |||
1147 | max1363_monitor_mode_update(st, !!(st->mask_high | st->mask_low)); | ||
1148 | error_ret: | ||
1149 | mutex_unlock(&indio_dev->mlock); | ||
1150 | |||
1151 | return ret; | ||
1152 | } | ||
1153 | |||
1154 | /* | ||
1155 | * As with scan_elements, only certain sets of these can | ||
1156 | * be combined. | ||
1157 | */ | ||
1158 | static struct attribute *max1363_event_attributes[] = { | ||
1159 | &iio_dev_attr_sampling_frequency.dev_attr.attr, | ||
1160 | &iio_const_attr_sampling_frequency_available.dev_attr.attr, | ||
1161 | NULL, | ||
1162 | }; | ||
1163 | |||
1164 | static struct attribute_group max1363_event_attribute_group = { | ||
1165 | .attrs = max1363_event_attributes, | ||
1166 | }; | ||
1167 | 1222 | ||
1168 | static int max1363_initial_setup(struct max1363_state *st) | 1223 | static int max1363_initial_setup(struct max1363_state *st) |
1169 | { | 1224 | { |
@@ -1224,22 +1279,9 @@ static int __devinit max1363_probe(struct i2c_client *client, | |||
1224 | /* Estabilish that the iio_dev is a child of the i2c device */ | 1279 | /* Estabilish that the iio_dev is a child of the i2c device */ |
1225 | indio_dev->dev.parent = &client->dev; | 1280 | indio_dev->dev.parent = &client->dev; |
1226 | indio_dev->name = id->name; | 1281 | indio_dev->name = id->name; |
1227 | indio_dev->read_event_value = &max1363_read_thresh; | ||
1228 | indio_dev->write_event_value = &max1363_write_thresh; | ||
1229 | indio_dev->read_event_config = &max1363_read_event_config; | ||
1230 | indio_dev->write_event_config = &max1363_write_event_config; | ||
1231 | indio_dev->channels = st->chip_info->channels; | ||
1232 | indio_dev->num_channels = st->chip_info->num_channels; | ||
1233 | indio_dev->read_raw = &max1363_read_raw; | ||
1234 | /* Todo: this shouldn't be here. */ | ||
1235 | indio_dev->driver_module = THIS_MODULE; | ||
1236 | indio_dev->modes = INDIO_DIRECT_MODE; | ||
1237 | if (st->chip_info->monitor_mode && client->irq) { | ||
1238 | indio_dev->num_interrupt_lines = 1; | ||
1239 | indio_dev->event_attrs | ||
1240 | = &max1363_event_attribute_group; | ||
1241 | } | ||
1242 | 1282 | ||
1283 | indio_dev->info = st->chip_info->info; | ||
1284 | indio_dev->modes = INDIO_DIRECT_MODE; | ||
1243 | ret = max1363_initial_setup(st); | 1285 | ret = max1363_initial_setup(st); |
1244 | if (ret) | 1286 | if (ret) |
1245 | goto error_free_available_scan_masks; | 1287 | goto error_free_available_scan_masks; |
@@ -1258,7 +1300,7 @@ static int __devinit max1363_probe(struct i2c_client *client, | |||
1258 | if (ret) | 1300 | if (ret) |
1259 | goto error_cleanup_ring; | 1301 | goto error_cleanup_ring; |
1260 | 1302 | ||
1261 | if (st->chip_info->monitor_mode && client->irq) { | 1303 | if (client->irq) { |
1262 | ret = request_threaded_irq(st->client->irq, | 1304 | ret = request_threaded_irq(st->client->irq, |
1263 | NULL, | 1305 | NULL, |
1264 | &max1363_event_handler, | 1306 | &max1363_event_handler, |
@@ -1298,7 +1340,7 @@ static int max1363_remove(struct i2c_client *client) | |||
1298 | struct max1363_state *st = iio_priv(indio_dev); | 1340 | struct max1363_state *st = iio_priv(indio_dev); |
1299 | struct regulator *reg = st->reg; | 1341 | struct regulator *reg = st->reg; |
1300 | 1342 | ||
1301 | if (st->chip_info->monitor_mode && client->irq) | 1343 | if (client->irq) |
1302 | free_irq(st->client->irq, indio_dev); | 1344 | free_irq(st->client->irq, indio_dev); |
1303 | iio_ring_buffer_unregister(indio_dev->ring); | 1345 | iio_ring_buffer_unregister(indio_dev->ring); |
1304 | max1363_ring_cleanup(indio_dev); | 1346 | max1363_ring_cleanup(indio_dev); |
diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index b71994ee8845..7097deb0f309 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c | |||
@@ -2106,6 +2106,20 @@ int adt7316_enable(struct device *dev) | |||
2106 | EXPORT_SYMBOL(adt7316_enable); | 2106 | EXPORT_SYMBOL(adt7316_enable); |
2107 | #endif | 2107 | #endif |
2108 | 2108 | ||
2109 | static const struct iio_info adt7316_info = { | ||
2110 | .attrs = &adt7316_attribute_group, | ||
2111 | .num_interrupt_lines = 1, | ||
2112 | .event_attrs = &adt7316_event_attribute_group, | ||
2113 | .driver_module = THIS_MODULE, | ||
2114 | }; | ||
2115 | |||
2116 | static const struct iio_info adt7516_info = { | ||
2117 | .attrs = &adt7516_attribute_group, | ||
2118 | .num_interrupt_lines = 1, | ||
2119 | .event_attrs = &adt7516_event_attribute_group, | ||
2120 | .driver_module = THIS_MODULE, | ||
2121 | }; | ||
2122 | |||
2109 | /* | 2123 | /* |
2110 | * device probe and remove | 2124 | * device probe and remove |
2111 | */ | 2125 | */ |
@@ -2150,17 +2164,12 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus, | |||
2150 | } | 2164 | } |
2151 | 2165 | ||
2152 | chip->indio_dev->dev.parent = dev; | 2166 | chip->indio_dev->dev.parent = dev; |
2153 | if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) { | 2167 | if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) |
2154 | chip->indio_dev->attrs = &adt7516_attribute_group; | 2168 | chip->indio_dev->info = &adt7516_info; |
2155 | chip->indio_dev->event_attrs = &adt7516_event_attribute_group; | 2169 | else |
2156 | } else { | 2170 | chip->indio_dev->info = &adt7316_info; |
2157 | chip->indio_dev->attrs = &adt7316_attribute_group; | ||
2158 | chip->indio_dev->event_attrs = &adt7316_event_attribute_group; | ||
2159 | } | ||
2160 | chip->indio_dev->name = name; | 2171 | chip->indio_dev->name = name; |
2161 | chip->indio_dev->dev_data = (void *)chip; | 2172 | chip->indio_dev->dev_data = (void *)chip; |
2162 | chip->indio_dev->driver_module = THIS_MODULE; | ||
2163 | chip->indio_dev->num_interrupt_lines = 1; | ||
2164 | chip->indio_dev->modes = INDIO_DIRECT_MODE; | 2173 | chip->indio_dev->modes = INDIO_DIRECT_MODE; |
2165 | 2174 | ||
2166 | ret = iio_device_register(chip->indio_dev); | 2175 | ret = iio_device_register(chip->indio_dev); |
diff --git a/drivers/staging/iio/dac/ad5446.c b/drivers/staging/iio/dac/ad5446.c index 22646a617806..86cb08ce199b 100644 --- a/drivers/staging/iio/dac/ad5446.c +++ b/drivers/staging/iio/dac/ad5446.c | |||
@@ -334,6 +334,11 @@ static const struct ad5446_chip_info ad5446_chip_info_tbl[] = { | |||
334 | }, | 334 | }, |
335 | }; | 335 | }; |
336 | 336 | ||
337 | static const struct iio_info ad5446_info = { | ||
338 | .attrs = &ad5446_attribute_group, | ||
339 | .driver_module = THIS_MODULE, | ||
340 | }; | ||
341 | |||
337 | static int __devinit ad5446_probe(struct spi_device *spi) | 342 | static int __devinit ad5446_probe(struct spi_device *spi) |
338 | { | 343 | { |
339 | struct ad5446_state *st; | 344 | struct ad5446_state *st; |
@@ -370,9 +375,8 @@ static int __devinit ad5446_probe(struct spi_device *spi) | |||
370 | /* Estabilish that the iio_dev is a child of the spi device */ | 375 | /* Estabilish that the iio_dev is a child of the spi device */ |
371 | st->indio_dev->dev.parent = &spi->dev; | 376 | st->indio_dev->dev.parent = &spi->dev; |
372 | st->indio_dev->name = spi_get_device_id(spi)->name; | 377 | st->indio_dev->name = spi_get_device_id(spi)->name; |
373 | st->indio_dev->attrs = &ad5446_attribute_group; | 378 | st->indio_dev->info = &ad5446_info; |
374 | st->indio_dev->dev_data = (void *)(st); | 379 | st->indio_dev->dev_data = (void *)(st); |
375 | st->indio_dev->driver_module = THIS_MODULE; | ||
376 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 380 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
377 | 381 | ||
378 | /* Setup default message */ | 382 | /* Setup default message */ |
diff --git a/drivers/staging/iio/dac/ad5504.c b/drivers/staging/iio/dac/ad5504.c index 351a9d330fab..ed029cdff300 100644 --- a/drivers/staging/iio/dac/ad5504.c +++ b/drivers/staging/iio/dac/ad5504.c | |||
@@ -260,6 +260,20 @@ static irqreturn_t ad5504_event_handler(int irq, void *private) | |||
260 | return IRQ_HANDLED; | 260 | return IRQ_HANDLED; |
261 | } | 261 | } |
262 | 262 | ||
263 | static const struct iio_info ad5504_info = { | ||
264 | .attrs = &ad5504_attribute_group, | ||
265 | .num_interrupt_lines = 1, | ||
266 | .event_attrs = &ad5504_ev_attribute_group, | ||
267 | .driver_module = THIS_MODULE, | ||
268 | }; | ||
269 | |||
270 | static const struct iio_info ad5501_info = { | ||
271 | .attrs = &ad5501_attribute_group, | ||
272 | .num_interrupt_lines = 1, | ||
273 | .event_attrs = &ad5504_ev_attribute_group, | ||
274 | .driver_module = THIS_MODULE, | ||
275 | }; | ||
276 | |||
263 | static int __devinit ad5504_probe(struct spi_device *spi) | 277 | static int __devinit ad5504_probe(struct spi_device *spi) |
264 | { | 278 | { |
265 | struct ad5504_platform_data *pdata = spi->dev.platform_data; | 279 | struct ad5504_platform_data *pdata = spi->dev.platform_data; |
@@ -298,14 +312,12 @@ static int __devinit ad5504_probe(struct spi_device *spi) | |||
298 | } | 312 | } |
299 | st->indio_dev->dev.parent = &spi->dev; | 313 | st->indio_dev->dev.parent = &spi->dev; |
300 | st->indio_dev->name = spi_get_device_id(st->spi)->name; | 314 | st->indio_dev->name = spi_get_device_id(st->spi)->name; |
301 | st->indio_dev->attrs = spi_get_device_id(st->spi)->driver_data | 315 | if (spi_get_device_id(st->spi)->driver_data == ID_AD5501) |
302 | == ID_AD5501 ? &ad5501_attribute_group : | 316 | st->indio_dev->info = &ad5501_info; |
303 | &ad5504_attribute_group; | 317 | else |
318 | st->indio_dev->info = &ad5504_info; | ||
304 | st->indio_dev->dev_data = (void *)(st); | 319 | st->indio_dev->dev_data = (void *)(st); |
305 | st->indio_dev->driver_module = THIS_MODULE; | ||
306 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 320 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
307 | st->indio_dev->num_interrupt_lines = 1; | ||
308 | st->indio_dev->event_attrs = &ad5504_ev_attribute_group, | ||
309 | 321 | ||
310 | ret = iio_device_register(st->indio_dev); | 322 | ret = iio_device_register(st->indio_dev); |
311 | if (ret) | 323 | if (ret) |
diff --git a/drivers/staging/iio/dac/ad5624r_spi.c b/drivers/staging/iio/dac/ad5624r_spi.c index b0e25e25a267..c679981f0143 100644 --- a/drivers/staging/iio/dac/ad5624r_spi.c +++ b/drivers/staging/iio/dac/ad5624r_spi.c | |||
@@ -218,6 +218,11 @@ static const struct attribute_group ad5624r_attribute_group = { | |||
218 | .attrs = ad5624r_attributes, | 218 | .attrs = ad5624r_attributes, |
219 | }; | 219 | }; |
220 | 220 | ||
221 | static const struct iio_info ad5624r_info = { | ||
222 | .attrs = &ad5624r_attribute_group, | ||
223 | .driver_module = THIS_MODULE, | ||
224 | }; | ||
225 | |||
221 | static int __devinit ad5624r_probe(struct spi_device *spi) | 226 | static int __devinit ad5624r_probe(struct spi_device *spi) |
222 | { | 227 | { |
223 | struct ad5624r_state *st; | 228 | struct ad5624r_state *st; |
@@ -255,9 +260,8 @@ static int __devinit ad5624r_probe(struct spi_device *spi) | |||
255 | } | 260 | } |
256 | st->indio_dev->dev.parent = &spi->dev; | 261 | st->indio_dev->dev.parent = &spi->dev; |
257 | st->indio_dev->name = spi_get_device_id(spi)->name; | 262 | st->indio_dev->name = spi_get_device_id(spi)->name; |
258 | st->indio_dev->attrs = &ad5624r_attribute_group; | 263 | st->indio_dev->info = &ad5624r_info; |
259 | st->indio_dev->dev_data = (void *)(st); | 264 | st->indio_dev->dev_data = (void *)(st); |
260 | st->indio_dev->driver_module = THIS_MODULE; | ||
261 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 265 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
262 | 266 | ||
263 | ret = iio_device_register(st->indio_dev); | 267 | ret = iio_device_register(st->indio_dev); |
diff --git a/drivers/staging/iio/dac/ad5791.c b/drivers/staging/iio/dac/ad5791.c index acfd13bdecc1..4eda25cba870 100644 --- a/drivers/staging/iio/dac/ad5791.c +++ b/drivers/staging/iio/dac/ad5791.c | |||
@@ -287,6 +287,11 @@ static const struct ad5791_chip_info ad5791_chip_info_tbl[] = { | |||
287 | }, | 287 | }, |
288 | }; | 288 | }; |
289 | 289 | ||
290 | static const struct iio_info ad5791_info = { | ||
291 | .attrs = &ad5791_attribute_group, | ||
292 | .driver_module = THIS_MODULE, | ||
293 | }; | ||
294 | |||
290 | static int __devinit ad5791_probe(struct spi_device *spi) | 295 | static int __devinit ad5791_probe(struct spi_device *spi) |
291 | { | 296 | { |
292 | struct ad5791_platform_data *pdata = spi->dev.platform_data; | 297 | struct ad5791_platform_data *pdata = spi->dev.platform_data; |
@@ -353,8 +358,7 @@ static int __devinit ad5791_probe(struct spi_device *spi) | |||
353 | } | 358 | } |
354 | st->indio_dev->dev.parent = &spi->dev; | 359 | st->indio_dev->dev.parent = &spi->dev; |
355 | st->indio_dev->dev_data = (void *)(st); | 360 | st->indio_dev->dev_data = (void *)(st); |
356 | st->indio_dev->attrs = &ad5791_attribute_group; | 361 | st->indio_dev->info = &ad5791_info; |
357 | st->indio_dev->driver_module = THIS_MODULE; | ||
358 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 362 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
359 | 363 | ||
360 | ret = iio_device_register(st->indio_dev); | 364 | ret = iio_device_register(st->indio_dev); |
diff --git a/drivers/staging/iio/dac/max517.c b/drivers/staging/iio/dac/max517.c index 3eb48b65c15e..881768df47a6 100644 --- a/drivers/staging/iio/dac/max517.c +++ b/drivers/staging/iio/dac/max517.c | |||
@@ -189,6 +189,16 @@ static int max517_resume(struct i2c_client *client) | |||
189 | return i2c_master_send(client, &outbuf, 1); | 189 | return i2c_master_send(client, &outbuf, 1); |
190 | } | 190 | } |
191 | 191 | ||
192 | static const struct iio_info max517_info = { | ||
193 | .attrs = &max517_attribute_group, | ||
194 | .driver_module = THIS_MODULE, | ||
195 | }; | ||
196 | |||
197 | static const struct iio_info max518_info = { | ||
198 | .attrs = &max517_attribute_group, | ||
199 | .driver_module = THIS_MODULE, | ||
200 | }; | ||
201 | |||
192 | static int max517_probe(struct i2c_client *client, | 202 | static int max517_probe(struct i2c_client *client, |
193 | const struct i2c_device_id *id) | 203 | const struct i2c_device_id *id) |
194 | { | 204 | { |
@@ -217,11 +227,10 @@ static int max517_probe(struct i2c_client *client, | |||
217 | 227 | ||
218 | /* reduced attribute set for MAX517 */ | 228 | /* reduced attribute set for MAX517 */ |
219 | if (id->driver_data == ID_MAX517) | 229 | if (id->driver_data == ID_MAX517) |
220 | data->indio_dev->attrs = &max517_attribute_group; | 230 | data->indio_dev->info = &max517_info; |
221 | else | 231 | else |
222 | data->indio_dev->attrs = &max518_attribute_group; | 232 | data->indio_dev->info = &max518_info; |
223 | data->indio_dev->dev_data = (void *)(data); | 233 | data->indio_dev->dev_data = (void *)(data); |
224 | data->indio_dev->driver_module = THIS_MODULE; | ||
225 | data->indio_dev->modes = INDIO_DIRECT_MODE; | 234 | data->indio_dev->modes = INDIO_DIRECT_MODE; |
226 | 235 | ||
227 | /* | 236 | /* |
diff --git a/drivers/staging/iio/dds/ad5930.c b/drivers/staging/iio/dds/ad5930.c index 5d98f93ca84e..490c3637bc8e 100644 --- a/drivers/staging/iio/dds/ad5930.c +++ b/drivers/staging/iio/dds/ad5930.c | |||
@@ -87,6 +87,12 @@ static const struct attribute_group ad5930_attribute_group = { | |||
87 | .attrs = ad5930_attributes, | 87 | .attrs = ad5930_attributes, |
88 | }; | 88 | }; |
89 | 89 | ||
90 | static const struct iio_info ad5930_info = { | ||
91 | .attrs = &ad5930_attribute_group, | ||
92 | |||
93 | .driver_module = THIS_MODULE, | ||
94 | }; | ||
95 | |||
90 | static int __devinit ad5930_probe(struct spi_device *spi) | 96 | static int __devinit ad5930_probe(struct spi_device *spi) |
91 | { | 97 | { |
92 | struct ad5930_state *st; | 98 | struct ad5930_state *st; |
@@ -108,12 +114,8 @@ static int __devinit ad5930_probe(struct spi_device *spi) | |||
108 | goto error_free_st; | 114 | goto error_free_st; |
109 | } | 115 | } |
110 | st->idev->dev.parent = &spi->dev; | 116 | st->idev->dev.parent = &spi->dev; |
111 | st->idev->num_interrupt_lines = 0; | ||
112 | st->idev->event_attrs = NULL; | ||
113 | |||
114 | st->idev->attrs = &ad5930_attribute_group; | ||
115 | st->idev->dev_data = (void *)(st); | 117 | st->idev->dev_data = (void *)(st); |
116 | st->idev->driver_module = THIS_MODULE; | 118 | st->idev->info = &ad5930_info; |
117 | st->idev->modes = INDIO_DIRECT_MODE; | 119 | st->idev->modes = INDIO_DIRECT_MODE; |
118 | 120 | ||
119 | ret = iio_device_register(st->idev); | 121 | ret = iio_device_register(st->idev); |
diff --git a/drivers/staging/iio/dds/ad9832.c b/drivers/staging/iio/dds/ad9832.c index 4b5721cbac66..e8fe1426a329 100644 --- a/drivers/staging/iio/dds/ad9832.c +++ b/drivers/staging/iio/dds/ad9832.c | |||
@@ -195,6 +195,11 @@ static const struct attribute_group ad9832_attribute_group = { | |||
195 | .attrs = ad9832_attributes, | 195 | .attrs = ad9832_attributes, |
196 | }; | 196 | }; |
197 | 197 | ||
198 | static const struct iio_info ad9832_info = { | ||
199 | .attrs = &ad9832_attribute_group, | ||
200 | .driver_module = THIS_MODULE, | ||
201 | }; | ||
202 | |||
198 | static int __devinit ad9832_probe(struct spi_device *spi) | 203 | static int __devinit ad9832_probe(struct spi_device *spi) |
199 | { | 204 | { |
200 | struct ad9832_platform_data *pdata = spi->dev.platform_data; | 205 | struct ad9832_platform_data *pdata = spi->dev.platform_data; |
@@ -232,9 +237,8 @@ static int __devinit ad9832_probe(struct spi_device *spi) | |||
232 | 237 | ||
233 | st->indio_dev->dev.parent = &spi->dev; | 238 | st->indio_dev->dev.parent = &spi->dev; |
234 | st->indio_dev->name = spi_get_device_id(spi)->name; | 239 | st->indio_dev->name = spi_get_device_id(spi)->name; |
235 | st->indio_dev->attrs = &ad9832_attribute_group; | 240 | st->indio_dev->info = &ad9832_info; |
236 | st->indio_dev->dev_data = (void *) st; | 241 | st->indio_dev->dev_data = (void *) st; |
237 | st->indio_dev->driver_module = THIS_MODULE; | ||
238 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 242 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
239 | 243 | ||
240 | /* Setup default messages */ | 244 | /* Setup default messages */ |
diff --git a/drivers/staging/iio/dds/ad9834.c b/drivers/staging/iio/dds/ad9834.c index e5303e6139ae..0ebe8d58e92e 100644 --- a/drivers/staging/iio/dds/ad9834.c +++ b/drivers/staging/iio/dds/ad9834.c | |||
@@ -305,6 +305,11 @@ static const struct attribute_group ad9834_attribute_group = { | |||
305 | .is_visible = ad9834_attr_is_visible, | 305 | .is_visible = ad9834_attr_is_visible, |
306 | }; | 306 | }; |
307 | 307 | ||
308 | static const struct iio_info ad9834_info = { | ||
309 | .attrs = &ad9834_attribute_group, | ||
310 | .driver_module = THIS_MODULE, | ||
311 | }; | ||
312 | |||
308 | static int __devinit ad9834_probe(struct spi_device *spi) | 313 | static int __devinit ad9834_probe(struct spi_device *spi) |
309 | { | 314 | { |
310 | struct ad9834_platform_data *pdata = spi->dev.platform_data; | 315 | struct ad9834_platform_data *pdata = spi->dev.platform_data; |
@@ -344,9 +349,8 @@ static int __devinit ad9834_probe(struct spi_device *spi) | |||
344 | 349 | ||
345 | st->indio_dev->dev.parent = &spi->dev; | 350 | st->indio_dev->dev.parent = &spi->dev; |
346 | st->indio_dev->name = spi_get_device_id(spi)->name; | 351 | st->indio_dev->name = spi_get_device_id(spi)->name; |
347 | st->indio_dev->attrs = &ad9834_attribute_group; | 352 | st->indio_dev->info = &ad9834_info; |
348 | st->indio_dev->dev_data = (void *) st; | 353 | st->indio_dev->dev_data = (void *) st; |
349 | st->indio_dev->driver_module = THIS_MODULE; | ||
350 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 354 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
351 | 355 | ||
352 | /* Setup default messages */ | 356 | /* Setup default messages */ |
diff --git a/drivers/staging/iio/dds/ad9850.c b/drivers/staging/iio/dds/ad9850.c index 34bc0e6950d2..b580d852a1ee 100644 --- a/drivers/staging/iio/dds/ad9850.c +++ b/drivers/staging/iio/dds/ad9850.c | |||
@@ -73,6 +73,11 @@ static const struct attribute_group ad9850_attribute_group = { | |||
73 | .attrs = ad9850_attributes, | 73 | .attrs = ad9850_attributes, |
74 | }; | 74 | }; |
75 | 75 | ||
76 | static const struct iio_info ad9850_info = { | ||
77 | .attrs = &ad9850_attribute_group, | ||
78 | .driver_module = THIS_MODULE, | ||
79 | }; | ||
80 | |||
76 | static int __devinit ad9850_probe(struct spi_device *spi) | 81 | static int __devinit ad9850_probe(struct spi_device *spi) |
77 | { | 82 | { |
78 | struct ad9850_state *st; | 83 | struct ad9850_state *st; |
@@ -94,12 +99,9 @@ static int __devinit ad9850_probe(struct spi_device *spi) | |||
94 | goto error_free_st; | 99 | goto error_free_st; |
95 | } | 100 | } |
96 | st->idev->dev.parent = &spi->dev; | 101 | st->idev->dev.parent = &spi->dev; |
97 | st->idev->num_interrupt_lines = 0; | ||
98 | st->idev->event_attrs = NULL; | ||
99 | 102 | ||
100 | st->idev->attrs = &ad9850_attribute_group; | 103 | st->idev->info = &ad9850_info; |
101 | st->idev->dev_data = (void *)(st); | 104 | st->idev->dev_data = (void *)(st); |
102 | st->idev->driver_module = THIS_MODULE; | ||
103 | st->idev->modes = INDIO_DIRECT_MODE; | 105 | st->idev->modes = INDIO_DIRECT_MODE; |
104 | 106 | ||
105 | ret = iio_device_register(st->idev); | 107 | ret = iio_device_register(st->idev); |
diff --git a/drivers/staging/iio/dds/ad9852.c b/drivers/staging/iio/dds/ad9852.c index 899a72acd8f6..08020f96300a 100644 --- a/drivers/staging/iio/dds/ad9852.c +++ b/drivers/staging/iio/dds/ad9852.c | |||
@@ -222,6 +222,11 @@ static const struct attribute_group ad9852_attribute_group = { | |||
222 | .attrs = ad9852_attributes, | 222 | .attrs = ad9852_attributes, |
223 | }; | 223 | }; |
224 | 224 | ||
225 | static const struct iio_info ad9852_info = { | ||
226 | .attrs = &ad9852_attribute_group, | ||
227 | .driver_module = THIS_MODULE, | ||
228 | }; | ||
229 | |||
225 | static int __devinit ad9852_probe(struct spi_device *spi) | 230 | static int __devinit ad9852_probe(struct spi_device *spi) |
226 | { | 231 | { |
227 | struct ad9852_state *st; | 232 | struct ad9852_state *st; |
@@ -243,12 +248,9 @@ static int __devinit ad9852_probe(struct spi_device *spi) | |||
243 | goto error_free_st; | 248 | goto error_free_st; |
244 | } | 249 | } |
245 | st->idev->dev.parent = &spi->dev; | 250 | st->idev->dev.parent = &spi->dev; |
246 | st->idev->num_interrupt_lines = 0; | ||
247 | st->idev->event_attrs = NULL; | ||
248 | 251 | ||
249 | st->idev->attrs = &ad9852_attribute_group; | 252 | st->idev->info = &ad9852_info; |
250 | st->idev->dev_data = (void *)(st); | 253 | st->idev->dev_data = (void *)(st); |
251 | st->idev->driver_module = THIS_MODULE; | ||
252 | st->idev->modes = INDIO_DIRECT_MODE; | 254 | st->idev->modes = INDIO_DIRECT_MODE; |
253 | 255 | ||
254 | ret = iio_device_register(st->idev); | 256 | ret = iio_device_register(st->idev); |
diff --git a/drivers/staging/iio/dds/ad9910.c b/drivers/staging/iio/dds/ad9910.c index fddb6e7c7edc..97d75d755824 100644 --- a/drivers/staging/iio/dds/ad9910.c +++ b/drivers/staging/iio/dds/ad9910.c | |||
@@ -357,6 +357,11 @@ static const struct attribute_group ad9910_attribute_group = { | |||
357 | .attrs = ad9910_attributes, | 357 | .attrs = ad9910_attributes, |
358 | }; | 358 | }; |
359 | 359 | ||
360 | static const struct iio_info ad9910_info = { | ||
361 | .attrs = &ad9910_attribute_group, | ||
362 | .driver_module = THIS_MODULE, | ||
363 | }; | ||
364 | |||
360 | static int __devinit ad9910_probe(struct spi_device *spi) | 365 | static int __devinit ad9910_probe(struct spi_device *spi) |
361 | { | 366 | { |
362 | struct ad9910_state *st; | 367 | struct ad9910_state *st; |
@@ -378,12 +383,9 @@ static int __devinit ad9910_probe(struct spi_device *spi) | |||
378 | goto error_free_st; | 383 | goto error_free_st; |
379 | } | 384 | } |
380 | st->idev->dev.parent = &spi->dev; | 385 | st->idev->dev.parent = &spi->dev; |
381 | st->idev->num_interrupt_lines = 0; | ||
382 | st->idev->event_attrs = NULL; | ||
383 | 386 | ||
384 | st->idev->attrs = &ad9910_attribute_group; | 387 | st->idev->info = &ad9910_info; |
385 | st->idev->dev_data = (void *)(st); | 388 | st->idev->dev_data = (void *)(st); |
386 | st->idev->driver_module = THIS_MODULE; | ||
387 | st->idev->modes = INDIO_DIRECT_MODE; | 389 | st->idev->modes = INDIO_DIRECT_MODE; |
388 | 390 | ||
389 | ret = iio_device_register(st->idev); | 391 | ret = iio_device_register(st->idev); |
diff --git a/drivers/staging/iio/dds/ad9951.c b/drivers/staging/iio/dds/ad9951.c index a9e56c6e0fa7..d4dfcd41d5f9 100644 --- a/drivers/staging/iio/dds/ad9951.c +++ b/drivers/staging/iio/dds/ad9951.c | |||
@@ -166,6 +166,11 @@ static const struct attribute_group ad9951_attribute_group = { | |||
166 | .attrs = ad9951_attributes, | 166 | .attrs = ad9951_attributes, |
167 | }; | 167 | }; |
168 | 168 | ||
169 | static const struct iio_info ad9951_info = { | ||
170 | .attrs = &ad9951_attribute_group, | ||
171 | .driver_module = THIS_MODULE, | ||
172 | }; | ||
173 | |||
169 | static int __devinit ad9951_probe(struct spi_device *spi) | 174 | static int __devinit ad9951_probe(struct spi_device *spi) |
170 | { | 175 | { |
171 | struct ad9951_state *st; | 176 | struct ad9951_state *st; |
@@ -187,12 +192,9 @@ static int __devinit ad9951_probe(struct spi_device *spi) | |||
187 | goto error_free_st; | 192 | goto error_free_st; |
188 | } | 193 | } |
189 | st->idev->dev.parent = &spi->dev; | 194 | st->idev->dev.parent = &spi->dev; |
190 | st->idev->num_interrupt_lines = 0; | ||
191 | st->idev->event_attrs = NULL; | ||
192 | 195 | ||
193 | st->idev->attrs = &ad9951_attribute_group; | 196 | st->idev->info = &ad9951_info; |
194 | st->idev->dev_data = (void *)(st); | 197 | st->idev->dev_data = (void *)(st); |
195 | st->idev->driver_module = THIS_MODULE; | ||
196 | st->idev->modes = INDIO_DIRECT_MODE; | 198 | st->idev->modes = INDIO_DIRECT_MODE; |
197 | 199 | ||
198 | ret = iio_device_register(st->idev); | 200 | ret = iio_device_register(st->idev); |
diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c index e1f8a708c630..edf9e3bf3efd 100644 --- a/drivers/staging/iio/gyro/adis16060_core.c +++ b/drivers/staging/iio/gyro/adis16060_core.c | |||
@@ -133,6 +133,11 @@ static const struct attribute_group adis16060_attribute_group = { | |||
133 | .attrs = adis16060_attributes, | 133 | .attrs = adis16060_attributes, |
134 | }; | 134 | }; |
135 | 135 | ||
136 | static const struct iio_info adis16060_info = { | ||
137 | .attrs = &adis16060_attribute_group, | ||
138 | .driver_module = THIS_MODULE, | ||
139 | }; | ||
140 | |||
136 | static int __devinit adis16060_r_probe(struct spi_device *spi) | 141 | static int __devinit adis16060_r_probe(struct spi_device *spi) |
137 | { | 142 | { |
138 | int ret, regdone = 0; | 143 | int ret, regdone = 0; |
@@ -154,9 +159,8 @@ static int __devinit adis16060_r_probe(struct spi_device *spi) | |||
154 | } | 159 | } |
155 | 160 | ||
156 | st->indio_dev->dev.parent = &spi->dev; | 161 | st->indio_dev->dev.parent = &spi->dev; |
157 | st->indio_dev->attrs = &adis16060_attribute_group; | 162 | st->indio_dev->info = &adis16060_info; |
158 | st->indio_dev->dev_data = (void *)(st); | 163 | st->indio_dev->dev_data = (void *)(st); |
159 | st->indio_dev->driver_module = THIS_MODULE; | ||
160 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 164 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
161 | 165 | ||
162 | ret = iio_device_register(st->indio_dev); | 166 | ret = iio_device_register(st->indio_dev); |
diff --git a/drivers/staging/iio/gyro/adis16080_core.c b/drivers/staging/iio/gyro/adis16080_core.c index fb48e9b3e03a..d42690bea066 100644 --- a/drivers/staging/iio/gyro/adis16080_core.c +++ b/drivers/staging/iio/gyro/adis16080_core.c | |||
@@ -123,6 +123,11 @@ static const struct attribute_group adis16080_attribute_group = { | |||
123 | .attrs = adis16080_attributes, | 123 | .attrs = adis16080_attributes, |
124 | }; | 124 | }; |
125 | 125 | ||
126 | static const struct iio_info adis16080_info = { | ||
127 | .attrs = &adis16080_attribute_group, | ||
128 | .driver_module = THIS_MODULE, | ||
129 | }; | ||
130 | |||
126 | static int __devinit adis16080_probe(struct spi_device *spi) | 131 | static int __devinit adis16080_probe(struct spi_device *spi) |
127 | { | 132 | { |
128 | int ret, regdone = 0; | 133 | int ret, regdone = 0; |
@@ -146,9 +151,8 @@ static int __devinit adis16080_probe(struct spi_device *spi) | |||
146 | 151 | ||
147 | st->indio_dev->name = spi->dev.driver->name; | 152 | st->indio_dev->name = spi->dev.driver->name; |
148 | st->indio_dev->dev.parent = &spi->dev; | 153 | st->indio_dev->dev.parent = &spi->dev; |
149 | st->indio_dev->attrs = &adis16080_attribute_group; | 154 | st->indio_dev->info = &adis16080_info; |
150 | st->indio_dev->dev_data = (void *)(st); | 155 | st->indio_dev->dev_data = (void *)(st); |
151 | st->indio_dev->driver_module = THIS_MODULE; | ||
152 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 156 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
153 | 157 | ||
154 | ret = iio_device_register(st->indio_dev); | 158 | ret = iio_device_register(st->indio_dev); |
diff --git a/drivers/staging/iio/gyro/adis16130_core.c b/drivers/staging/iio/gyro/adis16130_core.c index c2f338c7faf0..14d5a34ab441 100644 --- a/drivers/staging/iio/gyro/adis16130_core.c +++ b/drivers/staging/iio/gyro/adis16130_core.c | |||
@@ -175,6 +175,11 @@ static const struct attribute_group adis16130_attribute_group = { | |||
175 | .attrs = adis16130_attributes, | 175 | .attrs = adis16130_attributes, |
176 | }; | 176 | }; |
177 | 177 | ||
178 | static const struct iio_info adis16130_info = { | ||
179 | .attrs = &adis16130_attribute_group, | ||
180 | .driver_module = THIS_MODULE, | ||
181 | }; | ||
182 | |||
178 | static int __devinit adis16130_probe(struct spi_device *spi) | 183 | static int __devinit adis16130_probe(struct spi_device *spi) |
179 | { | 184 | { |
180 | int ret; | 185 | int ret; |
@@ -196,9 +201,8 @@ static int __devinit adis16130_probe(struct spi_device *spi) | |||
196 | 201 | ||
197 | st->indio_dev->name = spi->dev.driver->name; | 202 | st->indio_dev->name = spi->dev.driver->name; |
198 | st->indio_dev->dev.parent = &spi->dev; | 203 | st->indio_dev->dev.parent = &spi->dev; |
199 | st->indio_dev->attrs = &adis16130_attribute_group; | 204 | st->indio_dev->info = &adis16130_info; |
200 | st->indio_dev->dev_data = (void *)(st); | 205 | st->indio_dev->dev_data = (void *)(st); |
201 | st->indio_dev->driver_module = THIS_MODULE; | ||
202 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 206 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
203 | st->mode = 1; | 207 | st->mode = 1; |
204 | 208 | ||
diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c index 0eb6a87bca45..3dc9a272749d 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c | |||
@@ -565,6 +565,13 @@ static const struct attribute_group adis16260_attribute_group = { | |||
565 | .attrs = adis16260_attributes, | 565 | .attrs = adis16260_attributes, |
566 | }; | 566 | }; |
567 | 567 | ||
568 | static const struct iio_info adis16260_info = { | ||
569 | .attrs = &adis16260_attribute_group, | ||
570 | .read_raw = &adis16260_read_raw, | ||
571 | .write_raw = &adis16260_write_raw, | ||
572 | .driver_module = THIS_MODULE, | ||
573 | }; | ||
574 | |||
568 | static int __devinit adis16260_probe(struct spi_device *spi) | 575 | static int __devinit adis16260_probe(struct spi_device *spi) |
569 | { | 576 | { |
570 | int ret, regdone = 0; | 577 | int ret, regdone = 0; |
@@ -601,7 +608,7 @@ static int __devinit adis16260_probe(struct spi_device *spi) | |||
601 | 608 | ||
602 | st->indio_dev->name = spi_get_device_id(st->us)->name; | 609 | st->indio_dev->name = spi_get_device_id(st->us)->name; |
603 | st->indio_dev->dev.parent = &spi->dev; | 610 | st->indio_dev->dev.parent = &spi->dev; |
604 | st->indio_dev->attrs = &adis16260_attribute_group; | 611 | st->indio_dev->info = &adis16260_info; |
605 | st->indio_dev->num_channels | 612 | st->indio_dev->num_channels |
606 | = ARRAY_SIZE(adis16260_channels_x); | 613 | = ARRAY_SIZE(adis16260_channels_x); |
607 | if (pd && pd->direction) | 614 | if (pd && pd->direction) |
@@ -621,10 +628,7 @@ static int __devinit adis16260_probe(struct spi_device *spi) | |||
621 | else | 628 | else |
622 | st->indio_dev->channels = adis16260_channels_x; | 629 | st->indio_dev->channels = adis16260_channels_x; |
623 | 630 | ||
624 | st->indio_dev->read_raw = &adis16260_read_raw; | ||
625 | st->indio_dev->write_raw = &adis16260_write_raw; | ||
626 | st->indio_dev->dev_data = (void *)(st); | 631 | st->indio_dev->dev_data = (void *)(st); |
627 | st->indio_dev->driver_module = THIS_MODULE; | ||
628 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 632 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
629 | 633 | ||
630 | ret = adis16260_configure_ring(st->indio_dev); | 634 | ret = adis16260_configure_ring(st->indio_dev); |
diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c index 7a9d7c258dcf..3714e4aadc23 100644 --- a/drivers/staging/iio/gyro/adxrs450_core.c +++ b/drivers/staging/iio/gyro/adxrs450_core.c | |||
@@ -349,6 +349,11 @@ static const struct attribute_group adxrs450_attribute_group = { | |||
349 | .attrs = adxrs450_attributes, | 349 | .attrs = adxrs450_attributes, |
350 | }; | 350 | }; |
351 | 351 | ||
352 | static const struct iio_info adxrs450_info = { | ||
353 | .attrs = &adxrs450_attribute_group, | ||
354 | .driver_module = THIS_MODULE, | ||
355 | }; | ||
356 | |||
352 | static int __devinit adxrs450_probe(struct spi_device *spi) | 357 | static int __devinit adxrs450_probe(struct spi_device *spi) |
353 | { | 358 | { |
354 | int ret, regdone = 0; | 359 | int ret, regdone = 0; |
@@ -381,9 +386,8 @@ static int __devinit adxrs450_probe(struct spi_device *spi) | |||
381 | } | 386 | } |
382 | 387 | ||
383 | st->indio_dev->dev.parent = &spi->dev; | 388 | st->indio_dev->dev.parent = &spi->dev; |
384 | st->indio_dev->attrs = &adxrs450_attribute_group; | 389 | st->indio_dev->info = &adxrs450_info; |
385 | st->indio_dev->dev_data = (void *)(st); | 390 | st->indio_dev->dev_data = (void *)(st); |
386 | st->indio_dev->driver_module = THIS_MODULE; | ||
387 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 391 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
388 | 392 | ||
389 | ret = iio_device_register(st->indio_dev); | 393 | ret = iio_device_register(st->indio_dev); |
diff --git a/drivers/staging/iio/iio.h b/drivers/staging/iio/iio.h index 4dc4ff0232a4..38f1425f4645 100644 --- a/drivers/staging/iio/iio.h +++ b/drivers/staging/iio/iio.h | |||
@@ -202,6 +202,61 @@ static inline s64 iio_get_time_ns(void) | |||
202 | * call to iio_device_register. */ | 202 | * call to iio_device_register. */ |
203 | #define IIO_VAL_INT 1 | 203 | #define IIO_VAL_INT 1 |
204 | #define IIO_VAL_INT_PLUS_MICRO 2 | 204 | #define IIO_VAL_INT_PLUS_MICRO 2 |
205 | |||
206 | /** | ||
207 | * struct iio_info - constant information about device | ||
208 | * @driver_module: module structure used to ensure correct | ||
209 | * ownership of chrdevs etc | ||
210 | * @num_interrupt_lines:number of physical interrupt lines from device | ||
211 | * @event_attrs: event control attributes | ||
212 | * @attrs: general purpose device attributes | ||
213 | * @read_raw: function to request a value from the device. | ||
214 | * mask specifies which value. Note 0 means a reading of | ||
215 | * the channel in question. Return value will specify the | ||
216 | * type of value returned by the device. val and val2 will | ||
217 | * contain the elements making up the returned value. | ||
218 | * @write_raw: function to write a value to the device. | ||
219 | * Parameters are the same as for read_raw. | ||
220 | * @read_event_config: find out if the event is enabled. | ||
221 | * @write_event_config: set if the event is enabled. | ||
222 | * @read_event_value: read a value associated with the event. Meaning | ||
223 | * is event dependant. event_code specifies which event. | ||
224 | * @write_event_value: write the value associate with the event. | ||
225 | * Meaning is event dependent. | ||
226 | **/ | ||
227 | struct iio_info { | ||
228 | struct module *driver_module; | ||
229 | int num_interrupt_lines; | ||
230 | struct attribute_group *event_attrs; | ||
231 | const struct attribute_group *attrs; | ||
232 | |||
233 | int (*read_raw)(struct iio_dev *indio_dev, | ||
234 | struct iio_chan_spec const *chan, | ||
235 | int *val, | ||
236 | int *val2, | ||
237 | long mask); | ||
238 | |||
239 | int (*write_raw)(struct iio_dev *indio_dev, | ||
240 | struct iio_chan_spec const *chan, | ||
241 | int val, | ||
242 | int val2, | ||
243 | long mask); | ||
244 | |||
245 | int (*read_event_config)(struct iio_dev *indio_dev, | ||
246 | int event_code); | ||
247 | |||
248 | int (*write_event_config)(struct iio_dev *indio_dev, | ||
249 | int event_code, | ||
250 | int state); | ||
251 | |||
252 | int (*read_event_value)(struct iio_dev *indio_dev, | ||
253 | int event_code, | ||
254 | int *val); | ||
255 | int (*write_event_value)(struct iio_dev *indio_dev, | ||
256 | int event_code, | ||
257 | int val); | ||
258 | }; | ||
259 | |||
205 | /** | 260 | /** |
206 | * struct iio_dev - industrial I/O device | 261 | * struct iio_dev - industrial I/O device |
207 | * @id: [INTERN] used to identify device internally | 262 | * @id: [INTERN] used to identify device internally |
@@ -210,11 +265,6 @@ static inline s64 iio_get_time_ns(void) | |||
210 | * @currentmode: [DRIVER] current operating mode | 265 | * @currentmode: [DRIVER] current operating mode |
211 | * @dev: [DRIVER] device structure, should be assigned a parent | 266 | * @dev: [DRIVER] device structure, should be assigned a parent |
212 | * and owner | 267 | * and owner |
213 | * @attrs: [DRIVER] general purpose device attributes | ||
214 | * @driver_module: [DRIVER] module structure used to ensure correct | ||
215 | * ownership of chrdevs etc | ||
216 | * @num_interrupt_lines:[DRIVER] number of physical interrupt lines from device | ||
217 | * @event_attrs: [DRIVER] event control attributes | ||
218 | * @event_interfaces: [INTERN] event chrdevs associated with interrupt lines | 268 | * @event_interfaces: [INTERN] event chrdevs associated with interrupt lines |
219 | * @ring: [DRIVER] any ring buffer present | 269 | * @ring: [DRIVER] any ring buffer present |
220 | * @mlock: [INTERN] lock used to prevent simultaneous device state | 270 | * @mlock: [INTERN] lock used to prevent simultaneous device state |
@@ -227,19 +277,6 @@ static inline s64 iio_get_time_ns(void) | |||
227 | * @channel_attr_list: [INTERN] keep track of automatically created channel | 277 | * @channel_attr_list: [INTERN] keep track of automatically created channel |
228 | * attributes. | 278 | * attributes. |
229 | * @name: [DRIVER] name of the device. | 279 | * @name: [DRIVER] name of the device. |
230 | * @read_raw: [DRIVER] function to request a value from the device. | ||
231 | * mask specifies which value. Note 0 means a reading of | ||
232 | * the channel in question. Return value will specify the | ||
233 | * type of value returned by the device. val and val2 will | ||
234 | * contain the elements making up the returned value. | ||
235 | * @write_raw: [DRIVER] function to write a value to the device. | ||
236 | * Parameters are the same as for read_raw. | ||
237 | * @read_event_config: [DRIVER] find out if the event is enabled. | ||
238 | * @write_event_config: [DRIVER] set if the event is enabled. | ||
239 | * @read_event_value: [DRIVER] read a value associated with the event. Meaning | ||
240 | * is event dependant. event_code specifies which event. | ||
241 | * @write_event_value: [DRIVER] write the value associate with the event. | ||
242 | * Meaning is event dependent. | ||
243 | **/ | 280 | **/ |
244 | struct iio_dev { | 281 | struct iio_dev { |
245 | int id; | 282 | int id; |
@@ -247,11 +284,7 @@ struct iio_dev { | |||
247 | int modes; | 284 | int modes; |
248 | int currentmode; | 285 | int currentmode; |
249 | struct device dev; | 286 | struct device dev; |
250 | const struct attribute_group *attrs; | ||
251 | struct module *driver_module; | ||
252 | 287 | ||
253 | int num_interrupt_lines; | ||
254 | struct attribute_group *event_attrs; | ||
255 | struct iio_event_interface *event_interfaces; | 288 | struct iio_event_interface *event_interfaces; |
256 | 289 | ||
257 | struct iio_ring_buffer *ring; | 290 | struct iio_ring_buffer *ring; |
@@ -263,34 +296,10 @@ struct iio_dev { | |||
263 | 296 | ||
264 | struct iio_chan_spec const *channels; | 297 | struct iio_chan_spec const *channels; |
265 | int num_channels; | 298 | int num_channels; |
266 | struct list_head channel_attr_list; | ||
267 | 299 | ||
300 | struct list_head channel_attr_list; | ||
268 | const char *name; | 301 | const char *name; |
269 | int (*read_raw)(struct iio_dev *indio_dev, | 302 | const struct iio_info *info; |
270 | struct iio_chan_spec const *chan, | ||
271 | int *val, | ||
272 | int *val2, | ||
273 | long mask); | ||
274 | |||
275 | int (*write_raw)(struct iio_dev *indio_dev, | ||
276 | struct iio_chan_spec const *chan, | ||
277 | int val, | ||
278 | int val2, | ||
279 | long mask); | ||
280 | |||
281 | int (*read_event_config)(struct iio_dev *indio_dev, | ||
282 | int event_code); | ||
283 | |||
284 | int (*write_event_config)(struct iio_dev *indio_dev, | ||
285 | int event_code, | ||
286 | int state); | ||
287 | |||
288 | int (*read_event_value)(struct iio_dev *indio_dev, | ||
289 | int event_code, | ||
290 | int *val); | ||
291 | int (*write_event_value)(struct iio_dev *indio_dev, | ||
292 | int event_code, | ||
293 | int val); | ||
294 | }; | 303 | }; |
295 | 304 | ||
296 | /** | 305 | /** |
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c index 0067bc70acba..fe89802e3fe7 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c | |||
@@ -770,7 +770,12 @@ static struct adis16400_chip_info adis16400_chips[] = { | |||
770 | } | 770 | } |
771 | }; | 771 | }; |
772 | 772 | ||
773 | 773 | static const struct iio_info adis16400_info = { | |
774 | .driver_module = THIS_MODULE, | ||
775 | .read_raw = &adis16400_read_raw, | ||
776 | .write_raw = &adis16400_write_raw, | ||
777 | .attrs = &adis16400_attribute_group, | ||
778 | }; | ||
774 | 779 | ||
775 | static int __devinit adis16400_probe(struct spi_device *spi) | 780 | static int __devinit adis16400_probe(struct spi_device *spi) |
776 | { | 781 | { |
@@ -792,12 +797,9 @@ static int __devinit adis16400_probe(struct spi_device *spi) | |||
792 | st->variant = &adis16400_chips[spi_get_device_id(spi)->driver_data]; | 797 | st->variant = &adis16400_chips[spi_get_device_id(spi)->driver_data]; |
793 | indio_dev->dev.parent = &spi->dev; | 798 | indio_dev->dev.parent = &spi->dev; |
794 | indio_dev->name = spi_get_device_id(spi)->name; | 799 | indio_dev->name = spi_get_device_id(spi)->name; |
795 | indio_dev->attrs = &adis16400_attribute_group; | ||
796 | indio_dev->channels = st->variant->channels; | 800 | indio_dev->channels = st->variant->channels; |
797 | indio_dev->num_channels = st->variant->num_channels; | 801 | indio_dev->num_channels = st->variant->num_channels; |
798 | indio_dev->read_raw = &adis16400_read_raw; | 802 | indio_dev->info = &adis16400_info; |
799 | indio_dev->write_raw = &adis16400_write_raw; | ||
800 | indio_dev->driver_module = THIS_MODULE; | ||
801 | indio_dev->modes = INDIO_DIRECT_MODE; | 803 | indio_dev->modes = INDIO_DIRECT_MODE; |
802 | 804 | ||
803 | ret = adis16400_configure_ring(indio_dev); | 805 | ret = adis16400_configure_ring(indio_dev); |
diff --git a/drivers/staging/iio/industrialio-core.c b/drivers/staging/iio/industrialio-core.c index 9218fee8c26f..94d3bfaa061d 100644 --- a/drivers/staging/iio/industrialio-core.c +++ b/drivers/staging/iio/industrialio-core.c | |||
@@ -383,8 +383,8 @@ static ssize_t iio_read_channel_info(struct device *dev, | |||
383 | struct iio_dev *indio_dev = dev_get_drvdata(dev); | 383 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
384 | struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); | 384 | struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); |
385 | int val, val2; | 385 | int val, val2; |
386 | int ret = indio_dev->read_raw(indio_dev, this_attr->c, | 386 | int ret = indio_dev->info->read_raw(indio_dev, this_attr->c, |
387 | &val, &val2, this_attr->address); | 387 | &val, &val2, this_attr->address); |
388 | 388 | ||
389 | if (ret < 0) | 389 | if (ret < 0) |
390 | return ret; | 390 | return ret; |
@@ -411,7 +411,7 @@ static ssize_t iio_write_channel_info(struct device *dev, | |||
411 | bool integer_part = true, negative = false; | 411 | bool integer_part = true, negative = false; |
412 | 412 | ||
413 | /* Assumes decimal - precision based on number of digits */ | 413 | /* Assumes decimal - precision based on number of digits */ |
414 | if (!indio_dev->write_raw) | 414 | if (!indio_dev->info->write_raw) |
415 | return -EINVAL; | 415 | return -EINVAL; |
416 | if (buf[0] == '-') { | 416 | if (buf[0] == '-') { |
417 | negative = true; | 417 | negative = true; |
@@ -446,8 +446,8 @@ static ssize_t iio_write_channel_info(struct device *dev, | |||
446 | micro = -micro; | 446 | micro = -micro; |
447 | } | 447 | } |
448 | 448 | ||
449 | ret = indio_dev->write_raw(indio_dev, this_attr->c, | 449 | ret = indio_dev->info->write_raw(indio_dev, this_attr->c, |
450 | integer, micro, this_attr->address); | 450 | integer, micro, this_attr->address); |
451 | if (ret) | 451 | if (ret) |
452 | return ret; | 452 | return ret; |
453 | 453 | ||
@@ -707,8 +707,9 @@ static int iio_device_register_sysfs(struct iio_dev *dev_info) | |||
707 | int i, ret = 0; | 707 | int i, ret = 0; |
708 | struct iio_dev_attr *p, *n; | 708 | struct iio_dev_attr *p, *n; |
709 | 709 | ||
710 | if (dev_info->attrs) { | 710 | if (dev_info->info->attrs) { |
711 | ret = sysfs_create_group(&dev_info->dev.kobj, dev_info->attrs); | 711 | ret = sysfs_create_group(&dev_info->dev.kobj, |
712 | dev_info->info->attrs); | ||
712 | if (ret) { | 713 | if (ret) { |
713 | dev_err(dev_info->dev.parent, | 714 | dev_err(dev_info->dev.parent, |
714 | "Failed to register sysfs hooks\n"); | 715 | "Failed to register sysfs hooks\n"); |
@@ -744,8 +745,8 @@ error_clear_attrs: | |||
744 | list_del(&p->l); | 745 | list_del(&p->l); |
745 | iio_device_remove_and_free_read_attr(dev_info, p); | 746 | iio_device_remove_and_free_read_attr(dev_info, p); |
746 | } | 747 | } |
747 | if (dev_info->attrs) | 748 | if (dev_info->info->attrs) |
748 | sysfs_remove_group(&dev_info->dev.kobj, dev_info->attrs); | 749 | sysfs_remove_group(&dev_info->dev.kobj, dev_info->info->attrs); |
749 | error_ret: | 750 | error_ret: |
750 | return ret; | 751 | return ret; |
751 | 752 | ||
@@ -764,8 +765,8 @@ static void iio_device_unregister_sysfs(struct iio_dev *dev_info) | |||
764 | iio_device_remove_and_free_read_attr(dev_info, p); | 765 | iio_device_remove_and_free_read_attr(dev_info, p); |
765 | } | 766 | } |
766 | 767 | ||
767 | if (dev_info->attrs) | 768 | if (dev_info->info->attrs) |
768 | sysfs_remove_group(&dev_info->dev.kobj, dev_info->attrs); | 769 | sysfs_remove_group(&dev_info->dev.kobj, dev_info->info->attrs); |
769 | } | 770 | } |
770 | 771 | ||
771 | /* Return a negative errno on failure */ | 772 | /* Return a negative errno on failure */ |
@@ -824,8 +825,9 @@ static ssize_t iio_ev_state_store(struct device *dev, | |||
824 | if (ret < 0) | 825 | if (ret < 0) |
825 | return ret; | 826 | return ret; |
826 | 827 | ||
827 | ret = indio_dev->write_event_config(indio_dev, this_attr->address, | 828 | ret = indio_dev->info->write_event_config(indio_dev, |
828 | val); | 829 | this_attr->address, |
830 | val); | ||
829 | return (ret < 0) ? ret : len; | 831 | return (ret < 0) ? ret : len; |
830 | } | 832 | } |
831 | 833 | ||
@@ -835,7 +837,8 @@ static ssize_t iio_ev_state_show(struct device *dev, | |||
835 | { | 837 | { |
836 | struct iio_dev *indio_dev = dev_get_drvdata(dev); | 838 | struct iio_dev *indio_dev = dev_get_drvdata(dev); |
837 | struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); | 839 | struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); |
838 | int val = indio_dev->read_event_config(indio_dev, this_attr->address); | 840 | int val = indio_dev->info->read_event_config(indio_dev, |
841 | this_attr->address); | ||
839 | 842 | ||
840 | if (val < 0) | 843 | if (val < 0) |
841 | return val; | 844 | return val; |
@@ -851,8 +854,8 @@ static ssize_t iio_ev_value_show(struct device *dev, | |||
851 | struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); | 854 | struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); |
852 | int val, ret; | 855 | int val, ret; |
853 | 856 | ||
854 | ret = indio_dev->read_event_value(indio_dev, | 857 | ret = indio_dev->info->read_event_value(indio_dev, |
855 | this_attr->address, &val); | 858 | this_attr->address, &val); |
856 | if (ret < 0) | 859 | if (ret < 0) |
857 | return ret; | 860 | return ret; |
858 | 861 | ||
@@ -873,8 +876,8 @@ static ssize_t iio_ev_value_store(struct device *dev, | |||
873 | if (ret) | 876 | if (ret) |
874 | return ret; | 877 | return ret; |
875 | 878 | ||
876 | ret = indio_dev->write_event_value(indio_dev, this_attr->address, | 879 | ret = indio_dev->info->write_event_value(indio_dev, this_attr->address, |
877 | val); | 880 | val); |
878 | if (ret < 0) | 881 | if (ret < 0) |
879 | return ret; | 882 | return ret; |
880 | 883 | ||
@@ -930,8 +933,7 @@ static int iio_device_add_event_sysfs(struct iio_dev *dev_info, | |||
930 | extending the bitmask - but | 933 | extending the bitmask - but |
931 | how far*/ | 934 | how far*/ |
932 | 0, | 935 | 0, |
933 | &dev_info->event_interfaces[0] | 936 | &dev_info->event_interfaces[0].dev, |
934 | .dev, | ||
935 | &dev_info->event_interfaces[0]. | 937 | &dev_info->event_interfaces[0]. |
936 | dev_attr_list); | 938 | dev_attr_list); |
937 | kfree(postfix); | 939 | kfree(postfix); |
@@ -1015,23 +1017,23 @@ static int iio_device_register_eventset(struct iio_dev *dev_info) | |||
1015 | { | 1017 | { |
1016 | int ret = 0, i, j; | 1018 | int ret = 0, i, j; |
1017 | 1019 | ||
1018 | if (dev_info->num_interrupt_lines == 0) | 1020 | if (dev_info->info->num_interrupt_lines == 0) |
1019 | return 0; | 1021 | return 0; |
1020 | 1022 | ||
1021 | dev_info->event_interfaces = | 1023 | dev_info->event_interfaces = |
1022 | kzalloc(sizeof(struct iio_event_interface) | 1024 | kzalloc(sizeof(struct iio_event_interface) |
1023 | *dev_info->num_interrupt_lines, | 1025 | *dev_info->info->num_interrupt_lines, |
1024 | GFP_KERNEL); | 1026 | GFP_KERNEL); |
1025 | if (dev_info->event_interfaces == NULL) { | 1027 | if (dev_info->event_interfaces == NULL) { |
1026 | ret = -ENOMEM; | 1028 | ret = -ENOMEM; |
1027 | goto error_ret; | 1029 | goto error_ret; |
1028 | } | 1030 | } |
1029 | 1031 | ||
1030 | for (i = 0; i < dev_info->num_interrupt_lines; i++) { | 1032 | for (i = 0; i < dev_info->info->num_interrupt_lines; i++) { |
1031 | ret = iio_setup_ev_int(&dev_info->event_interfaces[i], | 1033 | ret = iio_setup_ev_int(&dev_info->event_interfaces[i], |
1032 | dev_name(&dev_info->dev), | 1034 | dev_name(&dev_info->dev), |
1033 | i, | 1035 | i, |
1034 | dev_info->driver_module, | 1036 | dev_info->info->driver_module, |
1035 | &dev_info->dev); | 1037 | &dev_info->dev); |
1036 | if (ret) { | 1038 | if (ret) { |
1037 | dev_err(&dev_info->dev, | 1039 | dev_err(&dev_info->dev, |
@@ -1042,11 +1044,12 @@ static int iio_device_register_eventset(struct iio_dev *dev_info) | |||
1042 | dev_set_drvdata(&dev_info->event_interfaces[i].dev, | 1044 | dev_set_drvdata(&dev_info->event_interfaces[i].dev, |
1043 | (void *)dev_info); | 1045 | (void *)dev_info); |
1044 | 1046 | ||
1045 | if (dev_info->event_attrs != NULL) | 1047 | if (dev_info->info->event_attrs != NULL) |
1046 | ret = sysfs_create_group(&dev_info | 1048 | ret = sysfs_create_group(&dev_info |
1047 | ->event_interfaces[i] | 1049 | ->event_interfaces[i] |
1048 | .dev.kobj, | 1050 | .dev.kobj, |
1049 | &dev_info->event_attrs[i]); | 1051 | &dev_info->info |
1052 | ->event_attrs[i]); | ||
1050 | 1053 | ||
1051 | if (ret) { | 1054 | if (ret) { |
1052 | dev_err(&dev_info->dev, | 1055 | dev_err(&dev_info->dev, |
@@ -1055,7 +1058,7 @@ static int iio_device_register_eventset(struct iio_dev *dev_info) | |||
1055 | } | 1058 | } |
1056 | } | 1059 | } |
1057 | 1060 | ||
1058 | for (i = 0; i < dev_info->num_interrupt_lines; i++) { | 1061 | for (i = 0; i < dev_info->info->num_interrupt_lines; i++) { |
1059 | ret = __iio_add_event_config_attrs(dev_info, i); | 1062 | ret = __iio_add_event_config_attrs(dev_info, i); |
1060 | if (ret) | 1063 | if (ret) |
1061 | goto error_unregister_config_attrs; | 1064 | goto error_unregister_config_attrs; |
@@ -1066,13 +1069,13 @@ static int iio_device_register_eventset(struct iio_dev *dev_info) | |||
1066 | error_unregister_config_attrs: | 1069 | error_unregister_config_attrs: |
1067 | for (j = 0; j < i; j++) | 1070 | for (j = 0; j < i; j++) |
1068 | __iio_remove_event_config_attrs(dev_info, i); | 1071 | __iio_remove_event_config_attrs(dev_info, i); |
1069 | i = dev_info->num_interrupt_lines - 1; | 1072 | i = dev_info->info->num_interrupt_lines - 1; |
1070 | error_remove_sysfs_interfaces: | 1073 | error_remove_sysfs_interfaces: |
1071 | for (j = 0; j < i; j++) | 1074 | for (j = 0; j < i; j++) |
1072 | if (dev_info->event_attrs != NULL) | 1075 | if (dev_info->info->event_attrs != NULL) |
1073 | sysfs_remove_group(&dev_info | 1076 | sysfs_remove_group(&dev_info |
1074 | ->event_interfaces[j].dev.kobj, | 1077 | ->event_interfaces[j].dev.kobj, |
1075 | &dev_info->event_attrs[j]); | 1078 | &dev_info->info->event_attrs[j]); |
1076 | error_free_setup_ev_ints: | 1079 | error_free_setup_ev_ints: |
1077 | for (j = 0; j < i; j++) | 1080 | for (j = 0; j < i; j++) |
1078 | iio_free_ev_int(&dev_info->event_interfaces[j]); | 1081 | iio_free_ev_int(&dev_info->event_interfaces[j]); |
@@ -1086,17 +1089,17 @@ static void iio_device_unregister_eventset(struct iio_dev *dev_info) | |||
1086 | { | 1089 | { |
1087 | int i; | 1090 | int i; |
1088 | 1091 | ||
1089 | if (dev_info->num_interrupt_lines == 0) | 1092 | if (dev_info->info->num_interrupt_lines == 0) |
1090 | return; | 1093 | return; |
1091 | for (i = 0; i < dev_info->num_interrupt_lines; i++) { | 1094 | for (i = 0; i < dev_info->info->num_interrupt_lines; i++) { |
1092 | __iio_remove_event_config_attrs(dev_info, i); | 1095 | __iio_remove_event_config_attrs(dev_info, i); |
1093 | if (dev_info->event_attrs != NULL) | 1096 | if (dev_info->info->event_attrs != NULL) |
1094 | sysfs_remove_group(&dev_info | 1097 | sysfs_remove_group(&dev_info |
1095 | ->event_interfaces[i].dev.kobj, | 1098 | ->event_interfaces[i].dev.kobj, |
1096 | &dev_info->event_attrs[i]); | 1099 | &dev_info->info->event_attrs[i]); |
1097 | } | 1100 | } |
1098 | 1101 | ||
1099 | for (i = 0; i < dev_info->num_interrupt_lines; i++) | 1102 | for (i = 0; i < dev_info->info->num_interrupt_lines; i++) |
1100 | iio_free_ev_int(&dev_info->event_interfaces[i]); | 1103 | iio_free_ev_int(&dev_info->event_interfaces[i]); |
1101 | kfree(dev_info->event_interfaces); | 1104 | kfree(dev_info->event_interfaces); |
1102 | } | 1105 | } |
diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index 307c66426dc7..4794ffd5e446 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c | |||
@@ -455,6 +455,11 @@ static int isl29018_chip_init(struct i2c_client *client) | |||
455 | return 0; | 455 | return 0; |
456 | } | 456 | } |
457 | 457 | ||
458 | static const struct iio_info isl29108_info = { | ||
459 | .attrs = &isl29108_group, | ||
460 | .driver_module = THIS_MODULE, | ||
461 | }; | ||
462 | |||
458 | static int __devinit isl29018_probe(struct i2c_client *client, | 463 | static int __devinit isl29018_probe(struct i2c_client *client, |
459 | const struct i2c_device_id *id) | 464 | const struct i2c_device_id *id) |
460 | { | 465 | { |
@@ -485,11 +490,10 @@ static int __devinit isl29018_probe(struct i2c_client *client, | |||
485 | dev_err(&client->dev, "iio allocation fails\n"); | 490 | dev_err(&client->dev, "iio allocation fails\n"); |
486 | goto exit_free; | 491 | goto exit_free; |
487 | } | 492 | } |
488 | chip->indio_dev->attrs = &isl29108_group; | 493 | chip->indio_dev->info = &isl29108_info; |
489 | chip->indio_dev->name = id->name; | 494 | chip->indio_dev->name = id->name; |
490 | chip->indio_dev->dev.parent = &client->dev; | 495 | chip->indio_dev->dev.parent = &client->dev; |
491 | chip->indio_dev->dev_data = (void *)(chip); | 496 | chip->indio_dev->dev_data = (void *)(chip); |
492 | chip->indio_dev->driver_module = THIS_MODULE; | ||
493 | chip->indio_dev->modes = INDIO_DIRECT_MODE; | 497 | chip->indio_dev->modes = INDIO_DIRECT_MODE; |
494 | err = iio_device_register(chip->indio_dev); | 498 | err = iio_device_register(chip->indio_dev); |
495 | if (err) { | 499 | if (err) { |
diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c index ded305321c0a..9cffa2ecb0ee 100644 --- a/drivers/staging/iio/light/tsl2563.c +++ b/drivers/staging/iio/light/tsl2563.c | |||
@@ -688,6 +688,21 @@ error_ret: | |||
688 | /*--------------------------------------------------------------*/ | 688 | /*--------------------------------------------------------------*/ |
689 | static struct i2c_driver tsl2563_i2c_driver; | 689 | static struct i2c_driver tsl2563_i2c_driver; |
690 | 690 | ||
691 | static const struct iio_info tsl2563_info_no_irq = { | ||
692 | .driver_module = THIS_MODULE, | ||
693 | }; | ||
694 | |||
695 | static const struct iio_info tsl2563_info = { | ||
696 | .driver_module = THIS_MODULE, | ||
697 | .num_interrupt_lines = 1, | ||
698 | .read_raw = &tsl2563_read_raw, | ||
699 | .write_raw = &tsl2563_write_raw, | ||
700 | .read_event_value = &tsl2563_read_thresh, | ||
701 | .write_event_value = &tsl2563_write_thresh, | ||
702 | .read_event_config = &tsl2563_read_interrupt_config, | ||
703 | .write_event_config = &tsl2563_write_interrupt_config, | ||
704 | }; | ||
705 | |||
691 | static int __devinit tsl2563_probe(struct i2c_client *client, | 706 | static int __devinit tsl2563_probe(struct i2c_client *client, |
692 | const struct i2c_device_id *device_id) | 707 | const struct i2c_device_id *device_id) |
693 | { | 708 | { |
@@ -736,17 +751,12 @@ static int __devinit tsl2563_probe(struct i2c_client *client, | |||
736 | indio_dev->name = client->name; | 751 | indio_dev->name = client->name; |
737 | indio_dev->channels = tsl2563_channels; | 752 | indio_dev->channels = tsl2563_channels; |
738 | indio_dev->num_channels = ARRAY_SIZE(tsl2563_channels); | 753 | indio_dev->num_channels = ARRAY_SIZE(tsl2563_channels); |
739 | indio_dev->read_raw = &tsl2563_read_raw; | ||
740 | indio_dev->write_raw = &tsl2563_write_raw; | ||
741 | indio_dev->read_event_value = &tsl2563_read_thresh; | ||
742 | indio_dev->write_event_value = &tsl2563_write_thresh; | ||
743 | indio_dev->read_event_config = &tsl2563_read_interrupt_config; | ||
744 | indio_dev->write_event_config = &tsl2563_write_interrupt_config; | ||
745 | indio_dev->dev.parent = &client->dev; | 754 | indio_dev->dev.parent = &client->dev; |
746 | indio_dev->driver_module = THIS_MODULE; | ||
747 | indio_dev->modes = INDIO_DIRECT_MODE; | 755 | indio_dev->modes = INDIO_DIRECT_MODE; |
748 | if (client->irq) | 756 | if (client->irq) |
749 | indio_dev->num_interrupt_lines = 1; | 757 | indio_dev->info = &tsl2563_info; |
758 | else | ||
759 | indio_dev->info = &tsl2563_info_no_irq; | ||
750 | ret = iio_device_register(indio_dev); | 760 | ret = iio_device_register(indio_dev); |
751 | if (ret) | 761 | if (ret) |
752 | goto fail1; | 762 | goto fail1; |
diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c index b87ccd5a2f50..5694610da1ca 100644 --- a/drivers/staging/iio/light/tsl2583.c +++ b/drivers/staging/iio/light/tsl2583.c | |||
@@ -786,6 +786,11 @@ static int taos_tsl258x_device(unsigned char *bufp) | |||
786 | return ((bufp[TSL258X_CHIPID] & 0xf0) == 0x90); | 786 | return ((bufp[TSL258X_CHIPID] & 0xf0) == 0x90); |
787 | } | 787 | } |
788 | 788 | ||
789 | static const struct iio_info tsl2583_info = { | ||
790 | .attrs = &tsl2583_attribute_group, | ||
791 | .driver_module = THIS_MODULE, | ||
792 | }; | ||
793 | |||
789 | /* | 794 | /* |
790 | * Client probe function - When a valid device is found, the driver's device | 795 | * Client probe function - When a valid device is found, the driver's device |
791 | * data structure is updated, and initialization completes successfully. | 796 | * data structure is updated, and initialization completes successfully. |
@@ -854,10 +859,9 @@ static int __devinit taos_probe(struct i2c_client *clientp, | |||
854 | goto fail1; | 859 | goto fail1; |
855 | } | 860 | } |
856 | 861 | ||
857 | chip->iio_dev->attrs = &tsl2583_attribute_group; | 862 | chip->iio_dev->info = &tsl2583_info; |
858 | chip->iio_dev->dev.parent = &clientp->dev; | 863 | chip->iio_dev->dev.parent = &clientp->dev; |
859 | chip->iio_dev->dev_data = (void *)(chip); | 864 | chip->iio_dev->dev_data = (void *)(chip); |
860 | chip->iio_dev->driver_module = THIS_MODULE; | ||
861 | chip->iio_dev->modes = INDIO_DIRECT_MODE; | 865 | chip->iio_dev->modes = INDIO_DIRECT_MODE; |
862 | ret = iio_device_register(chip->iio_dev); | 866 | ret = iio_device_register(chip->iio_dev); |
863 | if (ret) { | 867 | if (ret) { |
diff --git a/drivers/staging/iio/magnetometer/ak8975.c b/drivers/staging/iio/magnetometer/ak8975.c index 2226b88882d8..700f96c70273 100644 --- a/drivers/staging/iio/magnetometer/ak8975.c +++ b/drivers/staging/iio/magnetometer/ak8975.c | |||
@@ -474,6 +474,11 @@ static struct attribute_group ak8975_attr_group = { | |||
474 | .attrs = ak8975_attr, | 474 | .attrs = ak8975_attr, |
475 | }; | 475 | }; |
476 | 476 | ||
477 | static const struct iio_info ak8975_info = { | ||
478 | .attrs = &ak8975_attr_group, | ||
479 | .driver_module = THIS_MODULE, | ||
480 | }; | ||
481 | |||
477 | static int ak8975_probe(struct i2c_client *client, | 482 | static int ak8975_probe(struct i2c_client *client, |
478 | const struct i2c_device_id *id) | 483 | const struct i2c_device_id *id) |
479 | { | 484 | { |
@@ -533,9 +538,8 @@ static int ak8975_probe(struct i2c_client *client, | |||
533 | } | 538 | } |
534 | 539 | ||
535 | data->indio_dev->dev.parent = &client->dev; | 540 | data->indio_dev->dev.parent = &client->dev; |
536 | data->indio_dev->attrs = &ak8975_attr_group; | 541 | data->indio_dev->info = &ak8975_info; |
537 | data->indio_dev->dev_data = (void *)(data); | 542 | data->indio_dev->dev_data = (void *)(data); |
538 | data->indio_dev->driver_module = THIS_MODULE; | ||
539 | data->indio_dev->modes = INDIO_DIRECT_MODE; | 543 | data->indio_dev->modes = INDIO_DIRECT_MODE; |
540 | 544 | ||
541 | err = iio_device_register(data->indio_dev); | 545 | err = iio_device_register(data->indio_dev); |
diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index d0676e99f157..dd9a3bb6aa01 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c | |||
@@ -529,6 +529,11 @@ static void hmc5843_init_client(struct i2c_client *client) | |||
529 | pr_info("HMC5843 initialized\n"); | 529 | pr_info("HMC5843 initialized\n"); |
530 | } | 530 | } |
531 | 531 | ||
532 | static const struct iio_info hmc5843_info = { | ||
533 | .attrs = &hmc5843_group, | ||
534 | .driver_module = THIS_MODULE, | ||
535 | }; | ||
536 | |||
532 | static int hmc5843_probe(struct i2c_client *client, | 537 | static int hmc5843_probe(struct i2c_client *client, |
533 | const struct i2c_device_id *id) | 538 | const struct i2c_device_id *id) |
534 | { | 539 | { |
@@ -557,10 +562,9 @@ static int hmc5843_probe(struct i2c_client *client, | |||
557 | err = -ENOMEM; | 562 | err = -ENOMEM; |
558 | goto exit_free1; | 563 | goto exit_free1; |
559 | } | 564 | } |
560 | data->indio_dev->attrs = &hmc5843_group; | 565 | data->indio_dev->info = &hmc5843_info; |
561 | data->indio_dev->dev.parent = &client->dev; | 566 | data->indio_dev->dev.parent = &client->dev; |
562 | data->indio_dev->dev_data = (void *)(data); | 567 | data->indio_dev->dev_data = (void *)(data); |
563 | data->indio_dev->driver_module = THIS_MODULE; | ||
564 | data->indio_dev->modes = INDIO_DIRECT_MODE; | 568 | data->indio_dev->modes = INDIO_DIRECT_MODE; |
565 | err = iio_device_register(data->indio_dev); | 569 | err = iio_device_register(data->indio_dev); |
566 | if (err) | 570 | if (err) |
diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c index 8b6bf508e41b..6c9c23fc4aed 100644 --- a/drivers/staging/iio/meter/ade7753.c +++ b/drivers/staging/iio/meter/ade7753.c | |||
@@ -504,6 +504,11 @@ static const struct attribute_group ade7753_attribute_group = { | |||
504 | .attrs = ade7753_attributes, | 504 | .attrs = ade7753_attributes, |
505 | }; | 505 | }; |
506 | 506 | ||
507 | static const struct iio_info ade7753_info = { | ||
508 | .attrs = &ade7753_attribute_group, | ||
509 | .driver_module = THIS_MODULE, | ||
510 | }; | ||
511 | |||
507 | static int __devinit ade7753_probe(struct spi_device *spi) | 512 | static int __devinit ade7753_probe(struct spi_device *spi) |
508 | { | 513 | { |
509 | int ret, regdone = 0; | 514 | int ret, regdone = 0; |
@@ -537,9 +542,8 @@ static int __devinit ade7753_probe(struct spi_device *spi) | |||
537 | 542 | ||
538 | st->indio_dev->name = spi->dev.driver->name; | 543 | st->indio_dev->name = spi->dev.driver->name; |
539 | st->indio_dev->dev.parent = &spi->dev; | 544 | st->indio_dev->dev.parent = &spi->dev; |
540 | st->indio_dev->attrs = &ade7753_attribute_group; | 545 | st->indio_dev->info = &ade7753_info; |
541 | st->indio_dev->dev_data = (void *)(st); | 546 | st->indio_dev->dev_data = (void *)(st); |
542 | st->indio_dev->driver_module = THIS_MODULE; | ||
543 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 547 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
544 | 548 | ||
545 | ret = iio_device_register(st->indio_dev); | 549 | ret = iio_device_register(st->indio_dev); |
diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c index 4179325c8d78..378f2c87086f 100644 --- a/drivers/staging/iio/meter/ade7754.c +++ b/drivers/staging/iio/meter/ade7754.c | |||
@@ -527,7 +527,10 @@ static const struct attribute_group ade7754_attribute_group = { | |||
527 | .attrs = ade7754_attributes, | 527 | .attrs = ade7754_attributes, |
528 | }; | 528 | }; |
529 | 529 | ||
530 | 530 | static const struct iio_info ade7754_info = { | |
531 | .attrs = &ade7754_attribute_group, | ||
532 | .driver_module = THIS_MODULE, | ||
533 | }; | ||
531 | 534 | ||
532 | static int __devinit ade7754_probe(struct spi_device *spi) | 535 | static int __devinit ade7754_probe(struct spi_device *spi) |
533 | { | 536 | { |
@@ -562,9 +565,8 @@ static int __devinit ade7754_probe(struct spi_device *spi) | |||
562 | 565 | ||
563 | st->indio_dev->name = spi->dev.driver->name; | 566 | st->indio_dev->name = spi->dev.driver->name; |
564 | st->indio_dev->dev.parent = &spi->dev; | 567 | st->indio_dev->dev.parent = &spi->dev; |
565 | st->indio_dev->attrs = &ade7754_attribute_group; | 568 | st->indio_dev->info = &ade7754_info; |
566 | st->indio_dev->dev_data = (void *)(st); | 569 | st->indio_dev->dev_data = (void *)(st); |
567 | st->indio_dev->driver_module = THIS_MODULE; | ||
568 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 570 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
569 | 571 | ||
570 | ret = iio_device_register(st->indio_dev); | 572 | ret = iio_device_register(st->indio_dev); |
diff --git a/drivers/staging/iio/meter/ade7758_core.c b/drivers/staging/iio/meter/ade7758_core.c index d9dfd8321222..299b95434e20 100644 --- a/drivers/staging/iio/meter/ade7758_core.c +++ b/drivers/staging/iio/meter/ade7758_core.c | |||
@@ -725,6 +725,11 @@ static struct iio_chan_spec ade7758_channels[] = { | |||
725 | IIO_CHAN_SOFT_TIMESTAMP(15), | 725 | IIO_CHAN_SOFT_TIMESTAMP(15), |
726 | }; | 726 | }; |
727 | 727 | ||
728 | static const struct iio_info ade7758_info = { | ||
729 | .attrs = &ade7758_attribute_group, | ||
730 | .driver_module = THIS_MODULE, | ||
731 | }; | ||
732 | |||
728 | static int __devinit ade7758_probe(struct spi_device *spi) | 733 | static int __devinit ade7758_probe(struct spi_device *spi) |
729 | { | 734 | { |
730 | int i, ret, regdone = 0; | 735 | int i, ret, regdone = 0; |
@@ -757,8 +762,7 @@ static int __devinit ade7758_probe(struct spi_device *spi) | |||
757 | 762 | ||
758 | indio_dev->name = spi->dev.driver->name; | 763 | indio_dev->name = spi->dev.driver->name; |
759 | indio_dev->dev.parent = &spi->dev; | 764 | indio_dev->dev.parent = &spi->dev; |
760 | indio_dev->attrs = &ade7758_attribute_group; | 765 | indio_dev->info = &ade7758_info; |
761 | indio_dev->driver_module = THIS_MODULE; | ||
762 | indio_dev->modes = INDIO_DIRECT_MODE; | 766 | indio_dev->modes = INDIO_DIRECT_MODE; |
763 | 767 | ||
764 | for (i = 0; i < AD7758_NUM_WAVESRC; i++) | 768 | for (i = 0; i < AD7758_NUM_WAVESRC; i++) |
diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c index 86fe0ae22df0..730f6d9074a6 100644 --- a/drivers/staging/iio/meter/ade7759.c +++ b/drivers/staging/iio/meter/ade7759.c | |||
@@ -450,6 +450,11 @@ static const struct attribute_group ade7759_attribute_group = { | |||
450 | .attrs = ade7759_attributes, | 450 | .attrs = ade7759_attributes, |
451 | }; | 451 | }; |
452 | 452 | ||
453 | static const struct iio_info ade7759_info = { | ||
454 | .attrs = &ade7759_attribute_group, | ||
455 | .driver_module = THIS_MODULE, | ||
456 | }; | ||
457 | |||
453 | static int __devinit ade7759_probe(struct spi_device *spi) | 458 | static int __devinit ade7759_probe(struct spi_device *spi) |
454 | { | 459 | { |
455 | int ret; | 460 | int ret; |
@@ -483,11 +488,9 @@ static int __devinit ade7759_probe(struct spi_device *spi) | |||
483 | 488 | ||
484 | st->indio_dev->name = spi->dev.driver->name; | 489 | st->indio_dev->name = spi->dev.driver->name; |
485 | st->indio_dev->dev.parent = &spi->dev; | 490 | st->indio_dev->dev.parent = &spi->dev; |
486 | st->indio_dev->num_interrupt_lines = 1; | ||
487 | 491 | ||
488 | st->indio_dev->attrs = &ade7759_attribute_group; | 492 | st->indio_dev->info = &ade7759_info; |
489 | st->indio_dev->dev_data = (void *)(st); | 493 | st->indio_dev->dev_data = (void *)(st); |
490 | st->indio_dev->driver_module = THIS_MODULE; | ||
491 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 494 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
492 | 495 | ||
493 | ret = iio_device_register(st->indio_dev); | 496 | ret = iio_device_register(st->indio_dev); |
diff --git a/drivers/staging/iio/meter/ade7854.c b/drivers/staging/iio/meter/ade7854.c index d3f1df71c7f7..44cd3ec546ae 100644 --- a/drivers/staging/iio/meter/ade7854.c +++ b/drivers/staging/iio/meter/ade7854.c | |||
@@ -551,6 +551,11 @@ static const struct attribute_group ade7854_attribute_group = { | |||
551 | .attrs = ade7854_attributes, | 551 | .attrs = ade7854_attributes, |
552 | }; | 552 | }; |
553 | 553 | ||
554 | static const struct iio_info ade7854_info = { | ||
555 | .attrs = &ade7854_attribute_group, | ||
556 | .driver_module = THIS_MODULE, | ||
557 | }; | ||
558 | |||
554 | int ade7854_probe(struct ade7854_state *st, struct device *dev) | 559 | int ade7854_probe(struct ade7854_state *st, struct device *dev) |
555 | { | 560 | { |
556 | int ret; | 561 | int ret; |
@@ -575,9 +580,8 @@ int ade7854_probe(struct ade7854_state *st, struct device *dev) | |||
575 | } | 580 | } |
576 | 581 | ||
577 | st->indio_dev->dev.parent = dev; | 582 | st->indio_dev->dev.parent = dev; |
578 | st->indio_dev->attrs = &ade7854_attribute_group; | 583 | st->indio_dev->info = &ade7854_info; |
579 | st->indio_dev->dev_data = (void *)(st); | 584 | st->indio_dev->dev_data = (void *)(st); |
580 | st->indio_dev->driver_module = THIS_MODULE; | ||
581 | st->indio_dev->modes = INDIO_DIRECT_MODE; | 585 | st->indio_dev->modes = INDIO_DIRECT_MODE; |
582 | 586 | ||
583 | ret = iio_device_register(st->indio_dev); | 587 | ret = iio_device_register(st->indio_dev); |
diff --git a/drivers/staging/iio/resolver/ad2s120x.c b/drivers/staging/iio/resolver/ad2s120x.c index e0237ff81054..f83e1422fd29 100644 --- a/drivers/staging/iio/resolver/ad2s120x.c +++ b/drivers/staging/iio/resolver/ad2s120x.c | |||
@@ -209,10 +209,14 @@ static struct attribute *ad2s120x_attributes[] = { | |||
209 | }; | 209 | }; |
210 | 210 | ||
211 | static const struct attribute_group ad2s120x_attribute_group = { | 211 | static const struct attribute_group ad2s120x_attribute_group = { |
212 | .name = DRV_NAME, | ||
213 | .attrs = ad2s120x_attributes, | 212 | .attrs = ad2s120x_attributes, |
214 | }; | 213 | }; |
215 | 214 | ||
215 | static const struct iio_info ad2s120x_info = { | ||
216 | .attrs = &ad2s120x_attribute_group, | ||
217 | .driver_module = THIS_MODULE, | ||
218 | }; | ||
219 | |||
216 | static int __devinit ad2s120x_probe(struct spi_device *spi) | 220 | static int __devinit ad2s120x_probe(struct spi_device *spi) |
217 | { | 221 | { |
218 | struct ad2s120x_state *st; | 222 | struct ad2s120x_state *st; |
@@ -246,12 +250,9 @@ static int __devinit ad2s120x_probe(struct spi_device *spi) | |||
246 | goto error_free_st; | 250 | goto error_free_st; |
247 | } | 251 | } |
248 | st->idev->dev.parent = &spi->dev; | 252 | st->idev->dev.parent = &spi->dev; |
249 | st->idev->num_interrupt_lines = 0; | ||
250 | st->idev->event_attrs = NULL; | ||
251 | 253 | ||
252 | st->idev->attrs = &ad2s120x_attribute_group; | 254 | st->idev->info = &ad2s120x_info; |
253 | st->idev->dev_data = (void *)(st); | 255 | st->idev->dev_data = (void *)(st); |
254 | st->idev->driver_module = THIS_MODULE; | ||
255 | st->idev->modes = INDIO_DIRECT_MODE; | 256 | st->idev->modes = INDIO_DIRECT_MODE; |
256 | 257 | ||
257 | ret = iio_device_register(st->idev); | 258 | ret = iio_device_register(st->idev); |
diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index dc7cae80cf3a..09f4fcfda73a 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c | |||
@@ -755,6 +755,11 @@ error_ret: | |||
755 | return ret; | 755 | return ret; |
756 | } | 756 | } |
757 | 757 | ||
758 | static const struct iio_info ad2s1210_info = { | ||
759 | .attrs = &ad2s1210_attribute_group, | ||
760 | .driver_module = THIS_MODULE, | ||
761 | }; | ||
762 | |||
758 | static int __devinit ad2s1210_probe(struct spi_device *spi) | 763 | static int __devinit ad2s1210_probe(struct spi_device *spi) |
759 | { | 764 | { |
760 | struct ad2s1210_state *st; | 765 | struct ad2s1210_state *st; |
@@ -806,12 +811,9 @@ static int __devinit ad2s1210_probe(struct spi_device *spi) | |||
806 | goto error_free_st; | 811 | goto error_free_st; |
807 | } | 812 | } |
808 | st->idev->dev.parent = &spi->dev; | 813 | st->idev->dev.parent = &spi->dev; |
809 | st->idev->num_interrupt_lines = 0; | ||
810 | st->idev->event_attrs = NULL; | ||
811 | 814 | ||
812 | st->idev->attrs = &ad2s1210_attribute_group; | 815 | st->idev->info = &ad2s1210_info; |
813 | st->idev->dev_data = (void *)(st); | 816 | st->idev->dev_data = (void *)(st); |
814 | st->idev->driver_module = THIS_MODULE; | ||
815 | st->idev->modes = INDIO_DIRECT_MODE; | 817 | st->idev->modes = INDIO_DIRECT_MODE; |
816 | 818 | ||
817 | ret = iio_device_register(st->idev); | 819 | ret = iio_device_register(st->idev); |
diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index e300adeefa8b..9b72a952f2bc 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c | |||
@@ -75,6 +75,11 @@ static const struct attribute_group ad2s90_attribute_group = { | |||
75 | .attrs = ad2s90_attributes, | 75 | .attrs = ad2s90_attributes, |
76 | }; | 76 | }; |
77 | 77 | ||
78 | static const struct iio_info ad2s90_info = { | ||
79 | .attrs = &ad2s90_attribute_group, | ||
80 | .driver_module = THIS_MODULE, | ||
81 | }; | ||
82 | |||
78 | static int __devinit ad2s90_probe(struct spi_device *spi) | 83 | static int __devinit ad2s90_probe(struct spi_device *spi) |
79 | { | 84 | { |
80 | struct ad2s90_state *st; | 85 | struct ad2s90_state *st; |
@@ -96,12 +101,9 @@ static int __devinit ad2s90_probe(struct spi_device *spi) | |||
96 | goto error_free_st; | 101 | goto error_free_st; |
97 | } | 102 | } |
98 | st->idev->dev.parent = &spi->dev; | 103 | st->idev->dev.parent = &spi->dev; |
99 | st->idev->num_interrupt_lines = 0; | ||
100 | st->idev->event_attrs = NULL; | ||
101 | 104 | ||
102 | st->idev->attrs = &ad2s90_attribute_group; | 105 | st->idev->info = &ad2s90_info; |
103 | st->idev->dev_data = (void *)(st); | 106 | st->idev->dev_data = (void *)(st); |
104 | st->idev->driver_module = THIS_MODULE; | ||
105 | st->idev->modes = INDIO_DIRECT_MODE; | 107 | st->idev->modes = INDIO_DIRECT_MODE; |
106 | 108 | ||
107 | ret = iio_device_register(st->idev); | 109 | ret = iio_device_register(st->idev); |