17 #include <linux/kernel.h>
18 #include <linux/slab.h>
19 #include <linux/module.h>
33 static unsigned instances = 1;
37 static struct iio_dev **iio_dummy_devs;
40 static const char *iio_dummy_part_number =
"iio_dummy_part_no";
101 #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
210 static int iio_dummy_read_raw(
struct iio_dev *indio_dev,
222 switch (chan->
type) {
297 static int iio_dummy_write_raw(
struct iio_dev *indio_dev,
320 for (i = 0; i <
ARRAY_SIZE(dummy_scales); i++)
321 if (val == dummy_scales[i].val &&
322 val2 == dummy_scales[i].val2)
338 static const struct iio_info iio_dummy_info = {
340 .read_raw = &iio_dummy_read_raw,
341 .write_raw = &iio_dummy_write_raw,
342 #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
357 static int iio_dummy_init_device(
struct iio_dev *indio_dev)
396 if (indio_dev ==
NULL) {
401 st = iio_priv(indio_dev);
404 iio_dummy_init_device(indio_dev);
417 iio_dummy_devs[
index] = indio_dev;
429 indio_dev->
name = iio_dummy_part_number;
432 indio_dev->
channels = iio_dummy_channels;
439 indio_dev->
info = &iio_dummy_info;
446 goto error_free_device;
455 goto error_unregister_events;
459 goto error_unconfigure_buffer;
462 error_unconfigure_buffer:
464 error_unregister_events:
478 static int iio_dummy_remove(
int index)
519 static __init int iio_dummy_init(
void)
522 if (instances > 10) {
528 iio_dummy_devs = kcalloc(instances,
sizeof(*iio_dummy_devs),
531 for (i = 0; i < instances; i++) {
532 ret = iio_dummy_probe(i);
546 static __exit void iio_dummy_exit(
void)
549 for (i = 0; i < instances; i++)
551 kfree(iio_dummy_devs);