Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (c) 2011 Jonathan Cameron |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU General Public License version 2 as published by |
| 6 | * the Free Software Foundation. |
| 7 | * |
| 8 | * A reference industrial I/O driver to illustrate the functionality available. |
| 9 | * |
| 10 | * There are numerous real drivers to illustrate the finer points. |
| 11 | * The purpose of this driver is to provide a driver with far more comments |
| 12 | * and explanatory notes than any 'real' driver would have. |
| 13 | * Anyone starting out writing an IIO driver should first make sure they |
| 14 | * understand all of this driver except those bits specifically marked |
| 15 | * as being present to allow us to 'fake' the presence of hardware. |
| 16 | */ |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/slab.h> |
| 19 | #include <linux/module.h> |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 20 | #include <linux/string.h> |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 21 | |
Jonathan Cameron | 06458e2 | 2012-04-25 15:54:58 +0100 | [diff] [blame] | 22 | #include <linux/iio/iio.h> |
| 23 | #include <linux/iio/sysfs.h> |
| 24 | #include <linux/iio/events.h> |
| 25 | #include <linux/iio/buffer.h> |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 26 | #include <linux/iio/sw_device.h> |
Jonathan Cameron | e647700 | 2011-10-14 16:34:14 +0100 | [diff] [blame] | 27 | #include "iio_simple_dummy.h" |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 28 | |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 29 | static struct config_item_type iio_dummy_type = { |
| 30 | .ct_owner = THIS_MODULE, |
| 31 | }; |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * struct iio_dummy_accel_calibscale - realworld to register mapping |
| 35 | * @val: first value in read_raw - here integer part. |
| 36 | * @val2: second value in read_raw etc - here micro part. |
| 37 | * @regval: register value - magic device specific numbers. |
| 38 | */ |
| 39 | struct iio_dummy_accel_calibscale { |
| 40 | int val; |
| 41 | int val2; |
| 42 | int regval; /* what would be written to hardware */ |
| 43 | }; |
| 44 | |
| 45 | static const struct iio_dummy_accel_calibscale dummy_scales[] = { |
| 46 | { 0, 100, 0x8 }, /* 0.000100 */ |
| 47 | { 0, 133, 0x7 }, /* 0.000133 */ |
Alexander Stein | 569c4ac | 2012-12-19 17:56:00 +0000 | [diff] [blame] | 48 | { 733, 13, 0x9 }, /* 733.000013 */ |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 49 | }; |
| 50 | |
Lars-Peter Clausen | bda624b | 2013-10-07 15:11:00 +0100 | [diff] [blame] | 51 | #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS |
| 52 | |
| 53 | /* |
| 54 | * simple event - triggered when value rises above |
| 55 | * a threshold |
| 56 | */ |
| 57 | static const struct iio_event_spec iio_dummy_event = { |
| 58 | .type = IIO_EV_TYPE_THRESH, |
| 59 | .dir = IIO_EV_DIR_RISING, |
| 60 | .mask_separate = BIT(IIO_EV_INFO_VALUE) | BIT(IIO_EV_INFO_ENABLE), |
| 61 | }; |
| 62 | |
Daniel Baluta | 3e34e65 | 2014-11-10 14:45:34 +0200 | [diff] [blame] | 63 | /* |
| 64 | * simple step detect event - triggered when a step is detected |
| 65 | */ |
| 66 | static const struct iio_event_spec step_detect_event = { |
Irina Tirdea | 17a2cbc | 2015-01-11 21:10:12 +0200 | [diff] [blame] | 67 | .type = IIO_EV_TYPE_CHANGE, |
Daniel Baluta | 3e34e65 | 2014-11-10 14:45:34 +0200 | [diff] [blame] | 68 | .dir = IIO_EV_DIR_NONE, |
| 69 | .mask_separate = BIT(IIO_EV_INFO_ENABLE), |
| 70 | }; |
| 71 | |
| 72 | /* |
| 73 | * simple transition event - triggered when the reported running confidence |
| 74 | * value rises above a threshold value |
| 75 | */ |
| 76 | static const struct iio_event_spec iio_running_event = { |
| 77 | .type = IIO_EV_TYPE_THRESH, |
| 78 | .dir = IIO_EV_DIR_RISING, |
| 79 | .mask_separate = BIT(IIO_EV_INFO_VALUE) | BIT(IIO_EV_INFO_ENABLE), |
| 80 | }; |
| 81 | |
| 82 | /* |
| 83 | * simple transition event - triggered when the reported walking confidence |
| 84 | * value falls under a threshold value |
| 85 | */ |
| 86 | static const struct iio_event_spec iio_walking_event = { |
| 87 | .type = IIO_EV_TYPE_THRESH, |
| 88 | .dir = IIO_EV_DIR_FALLING, |
| 89 | .mask_separate = BIT(IIO_EV_INFO_VALUE) | BIT(IIO_EV_INFO_ENABLE), |
| 90 | }; |
Lars-Peter Clausen | bda624b | 2013-10-07 15:11:00 +0100 | [diff] [blame] | 91 | #endif |
| 92 | |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 93 | /* |
| 94 | * iio_dummy_channels - Description of available channels |
| 95 | * |
| 96 | * This array of structures tells the IIO core about what the device |
| 97 | * actually provides for a given channel. |
| 98 | */ |
Lars-Peter Clausen | f4e4b95 | 2012-08-09 08:51:00 +0100 | [diff] [blame] | 99 | static const struct iio_chan_spec iio_dummy_channels[] = { |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 100 | /* indexed ADC channel in_voltage0_raw etc */ |
| 101 | { |
| 102 | .type = IIO_VOLTAGE, |
| 103 | /* Channel has a numeric index of 0 */ |
| 104 | .indexed = 1, |
| 105 | .channel = 0, |
| 106 | /* What other information is available? */ |
Jonathan Cameron | fa357a6 | 2013-02-19 21:12:21 +0000 | [diff] [blame] | 107 | .info_mask_separate = |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 108 | /* |
Lars-Peter Clausen | 41fd935 | 2012-04-15 17:41:27 +0100 | [diff] [blame] | 109 | * in_voltage0_raw |
| 110 | * Raw (unscaled no bias removal etc) measurement |
| 111 | * from the device. |
| 112 | */ |
Jonathan Cameron | fa357a6 | 2013-02-19 21:12:21 +0000 | [diff] [blame] | 113 | BIT(IIO_CHAN_INFO_RAW) | |
Lars-Peter Clausen | 41fd935 | 2012-04-15 17:41:27 +0100 | [diff] [blame] | 114 | /* |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 115 | * in_voltage0_offset |
| 116 | * Offset for userspace to apply prior to scale |
| 117 | * when converting to standard units (microvolts) |
| 118 | */ |
Jonathan Cameron | fa357a6 | 2013-02-19 21:12:21 +0000 | [diff] [blame] | 119 | BIT(IIO_CHAN_INFO_OFFSET) | |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 120 | /* |
| 121 | * in_voltage0_scale |
| 122 | * Multipler for userspace to apply post offset |
| 123 | * when converting to standard units (microvolts) |
| 124 | */ |
Jonathan Cameron | fa357a6 | 2013-02-19 21:12:21 +0000 | [diff] [blame] | 125 | BIT(IIO_CHAN_INFO_SCALE), |
Jonathan Cameron | 6a63aa0 | 2013-09-08 14:57:00 +0100 | [diff] [blame] | 126 | /* |
| 127 | * sampling_frequency |
| 128 | * The frequency in Hz at which the channels are sampled |
| 129 | */ |
| 130 | .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), |
Jonathan Cameron | 9ad2e2e | 2011-10-14 16:34:15 +0100 | [diff] [blame] | 131 | /* The ordering of elements in the buffer via an enum */ |
Alison Schofield | f8087ab | 2015-10-26 13:48:23 -0700 | [diff] [blame] | 132 | .scan_index = DUMMY_INDEX_VOLTAGE_0, |
Jonathan Cameron | 9ad2e2e | 2011-10-14 16:34:15 +0100 | [diff] [blame] | 133 | .scan_type = { /* Description of storage in buffer */ |
| 134 | .sign = 'u', /* unsigned */ |
| 135 | .realbits = 13, /* 13 bits */ |
| 136 | .storagebits = 16, /* 16 bits used for storage */ |
| 137 | .shift = 0, /* zero shift */ |
| 138 | }, |
Jonathan Cameron | e647700 | 2011-10-14 16:34:14 +0100 | [diff] [blame] | 139 | #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS |
Lars-Peter Clausen | bda624b | 2013-10-07 15:11:00 +0100 | [diff] [blame] | 140 | .event_spec = &iio_dummy_event, |
| 141 | .num_event_specs = 1, |
Jonathan Cameron | e647700 | 2011-10-14 16:34:14 +0100 | [diff] [blame] | 142 | #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 143 | }, |
| 144 | /* Differential ADC channel in_voltage1-voltage2_raw etc*/ |
| 145 | { |
| 146 | .type = IIO_VOLTAGE, |
| 147 | .differential = 1, |
| 148 | /* |
| 149 | * Indexing for differential channels uses channel |
| 150 | * for the positive part, channel2 for the negative. |
| 151 | */ |
| 152 | .indexed = 1, |
| 153 | .channel = 1, |
| 154 | .channel2 = 2, |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 155 | /* |
Lars-Peter Clausen | 41fd935 | 2012-04-15 17:41:27 +0100 | [diff] [blame] | 156 | * in_voltage1-voltage2_raw |
| 157 | * Raw (unscaled no bias removal etc) measurement |
| 158 | * from the device. |
| 159 | */ |
Jonathan Cameron | fa357a6 | 2013-02-19 21:12:21 +0000 | [diff] [blame] | 160 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), |
Lars-Peter Clausen | 41fd935 | 2012-04-15 17:41:27 +0100 | [diff] [blame] | 161 | /* |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 162 | * in_voltage-voltage_scale |
| 163 | * Shared version of scale - shared by differential |
| 164 | * input channels of type IIO_VOLTAGE. |
| 165 | */ |
Jonathan Cameron | fa357a6 | 2013-02-19 21:12:21 +0000 | [diff] [blame] | 166 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), |
Jonathan Cameron | 6a63aa0 | 2013-09-08 14:57:00 +0100 | [diff] [blame] | 167 | /* |
| 168 | * sampling_frequency |
| 169 | * The frequency in Hz at which the channels are sampled |
| 170 | */ |
Alison Schofield | f8087ab | 2015-10-26 13:48:23 -0700 | [diff] [blame] | 171 | .scan_index = DUMMY_INDEX_DIFFVOLTAGE_1M2, |
Jonathan Cameron | 9ad2e2e | 2011-10-14 16:34:15 +0100 | [diff] [blame] | 172 | .scan_type = { /* Description of storage in buffer */ |
| 173 | .sign = 's', /* signed */ |
| 174 | .realbits = 12, /* 12 bits */ |
| 175 | .storagebits = 16, /* 16 bits used for storage */ |
| 176 | .shift = 0, /* zero shift */ |
| 177 | }, |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 178 | }, |
| 179 | /* Differential ADC channel in_voltage3-voltage4_raw etc*/ |
| 180 | { |
| 181 | .type = IIO_VOLTAGE, |
| 182 | .differential = 1, |
| 183 | .indexed = 1, |
| 184 | .channel = 3, |
| 185 | .channel2 = 4, |
Jonathan Cameron | fa357a6 | 2013-02-19 21:12:21 +0000 | [diff] [blame] | 186 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), |
| 187 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), |
Jonathan Cameron | 6a63aa0 | 2013-09-08 14:57:00 +0100 | [diff] [blame] | 188 | .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), |
Alison Schofield | f8087ab | 2015-10-26 13:48:23 -0700 | [diff] [blame] | 189 | .scan_index = DUMMY_INDEX_DIFFVOLTAGE_3M4, |
Jonathan Cameron | 9ad2e2e | 2011-10-14 16:34:15 +0100 | [diff] [blame] | 190 | .scan_type = { |
| 191 | .sign = 's', |
| 192 | .realbits = 11, |
| 193 | .storagebits = 16, |
| 194 | .shift = 0, |
| 195 | }, |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 196 | }, |
| 197 | /* |
| 198 | * 'modified' (i.e. axis specified) acceleration channel |
| 199 | * in_accel_z_raw |
| 200 | */ |
| 201 | { |
| 202 | .type = IIO_ACCEL, |
| 203 | .modified = 1, |
| 204 | /* Channel 2 is use for modifiers */ |
| 205 | .channel2 = IIO_MOD_X, |
Jonathan Cameron | fa357a6 | 2013-02-19 21:12:21 +0000 | [diff] [blame] | 206 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 207 | /* |
Jin Feng | ff3fc8e | 2013-04-05 05:51:00 +0100 | [diff] [blame] | 208 | * Internal bias and gain correction values. Applied |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 209 | * by the hardware or driver prior to userspace |
| 210 | * seeing the readings. Typically part of hardware |
| 211 | * calibration. |
| 212 | */ |
Jin Feng | ff3fc8e | 2013-04-05 05:51:00 +0100 | [diff] [blame] | 213 | BIT(IIO_CHAN_INFO_CALIBSCALE) | |
Jonathan Cameron | fa357a6 | 2013-02-19 21:12:21 +0000 | [diff] [blame] | 214 | BIT(IIO_CHAN_INFO_CALIBBIAS), |
Jonathan Cameron | 6a63aa0 | 2013-09-08 14:57:00 +0100 | [diff] [blame] | 215 | .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), |
Alison Schofield | f8087ab | 2015-10-26 13:48:23 -0700 | [diff] [blame] | 216 | .scan_index = DUMMY_INDEX_ACCELX, |
Jonathan Cameron | 9ad2e2e | 2011-10-14 16:34:15 +0100 | [diff] [blame] | 217 | .scan_type = { /* Description of storage in buffer */ |
| 218 | .sign = 's', /* signed */ |
Peter Meerwald | 25c38aa | 2012-06-15 19:27:10 +0200 | [diff] [blame] | 219 | .realbits = 16, /* 16 bits */ |
Jonathan Cameron | 9ad2e2e | 2011-10-14 16:34:15 +0100 | [diff] [blame] | 220 | .storagebits = 16, /* 16 bits used for storage */ |
| 221 | .shift = 0, /* zero shift */ |
| 222 | }, |
| 223 | }, |
| 224 | /* |
| 225 | * Convenience macro for timestamps. 4 is the index in |
| 226 | * the buffer. |
| 227 | */ |
| 228 | IIO_CHAN_SOFT_TIMESTAMP(4), |
| 229 | /* DAC channel out_voltage0_raw */ |
| 230 | { |
| 231 | .type = IIO_VOLTAGE, |
Jonathan Cameron | fa357a6 | 2013-02-19 21:12:21 +0000 | [diff] [blame] | 232 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), |
Lars-Peter Clausen | 4ae0301 | 2014-11-26 18:55:11 +0100 | [diff] [blame] | 233 | .scan_index = -1, /* No buffer support */ |
Jonathan Cameron | 9ad2e2e | 2011-10-14 16:34:15 +0100 | [diff] [blame] | 234 | .output = 1, |
| 235 | .indexed = 1, |
| 236 | .channel = 0, |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 237 | }, |
Daniel Baluta | 3e34e65 | 2014-11-10 14:45:34 +0200 | [diff] [blame] | 238 | { |
| 239 | .type = IIO_STEPS, |
| 240 | .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_ENABLE) | |
| 241 | BIT(IIO_CHAN_INFO_CALIBHEIGHT), |
| 242 | .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), |
Lars-Peter Clausen | 4ae0301 | 2014-11-26 18:55:11 +0100 | [diff] [blame] | 243 | .scan_index = -1, /* No buffer support */ |
Daniel Baluta | 3e34e65 | 2014-11-10 14:45:34 +0200 | [diff] [blame] | 244 | #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS |
| 245 | .event_spec = &step_detect_event, |
| 246 | .num_event_specs = 1, |
| 247 | #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ |
| 248 | }, |
| 249 | { |
| 250 | .type = IIO_ACTIVITY, |
| 251 | .modified = 1, |
| 252 | .channel2 = IIO_MOD_RUNNING, |
| 253 | .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), |
Lars-Peter Clausen | 4ae0301 | 2014-11-26 18:55:11 +0100 | [diff] [blame] | 254 | .scan_index = -1, /* No buffer support */ |
Daniel Baluta | 3e34e65 | 2014-11-10 14:45:34 +0200 | [diff] [blame] | 255 | #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS |
| 256 | .event_spec = &iio_running_event, |
| 257 | .num_event_specs = 1, |
| 258 | #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ |
| 259 | }, |
| 260 | { |
| 261 | .type = IIO_ACTIVITY, |
| 262 | .modified = 1, |
| 263 | .channel2 = IIO_MOD_WALKING, |
| 264 | .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), |
Lars-Peter Clausen | 4ae0301 | 2014-11-26 18:55:11 +0100 | [diff] [blame] | 265 | .scan_index = -1, /* No buffer support */ |
Daniel Baluta | 3e34e65 | 2014-11-10 14:45:34 +0200 | [diff] [blame] | 266 | #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS |
| 267 | .event_spec = &iio_walking_event, |
| 268 | .num_event_specs = 1, |
| 269 | #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ |
| 270 | }, |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 271 | }; |
| 272 | |
| 273 | /** |
| 274 | * iio_dummy_read_raw() - data read function. |
| 275 | * @indio_dev: the struct iio_dev associated with this device instance |
| 276 | * @chan: the channel whose data is to be read |
| 277 | * @val: first element of returned value (typically INT) |
| 278 | * @val2: second element of returned value (typically MICRO) |
Jonathan Cameron | fa357a6 | 2013-02-19 21:12:21 +0000 | [diff] [blame] | 279 | * @mask: what we actually want to read as per the info_mask_* |
| 280 | * in iio_chan_spec. |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 281 | */ |
| 282 | static int iio_dummy_read_raw(struct iio_dev *indio_dev, |
| 283 | struct iio_chan_spec const *chan, |
| 284 | int *val, |
| 285 | int *val2, |
| 286 | long mask) |
| 287 | { |
| 288 | struct iio_dummy_state *st = iio_priv(indio_dev); |
| 289 | int ret = -EINVAL; |
| 290 | |
| 291 | mutex_lock(&st->lock); |
| 292 | switch (mask) { |
Lars-Peter Clausen | 41fd935 | 2012-04-15 17:41:27 +0100 | [diff] [blame] | 293 | case IIO_CHAN_INFO_RAW: /* magic value - channel value read */ |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 294 | switch (chan->type) { |
| 295 | case IIO_VOLTAGE: |
| 296 | if (chan->output) { |
| 297 | /* Set integer part to cached value */ |
| 298 | *val = st->dac_val; |
| 299 | ret = IIO_VAL_INT; |
| 300 | } else if (chan->differential) { |
| 301 | if (chan->channel == 1) |
| 302 | *val = st->differential_adc_val[0]; |
| 303 | else |
| 304 | *val = st->differential_adc_val[1]; |
| 305 | ret = IIO_VAL_INT; |
| 306 | } else { |
| 307 | *val = st->single_ended_adc_val; |
| 308 | ret = IIO_VAL_INT; |
| 309 | } |
| 310 | break; |
| 311 | case IIO_ACCEL: |
| 312 | *val = st->accel_val; |
| 313 | ret = IIO_VAL_INT; |
| 314 | break; |
| 315 | default: |
| 316 | break; |
| 317 | } |
| 318 | break; |
Daniel Baluta | 3e34e65 | 2014-11-10 14:45:34 +0200 | [diff] [blame] | 319 | case IIO_CHAN_INFO_PROCESSED: |
| 320 | switch (chan->type) { |
| 321 | case IIO_STEPS: |
| 322 | *val = st->steps; |
| 323 | ret = IIO_VAL_INT; |
| 324 | break; |
| 325 | case IIO_ACTIVITY: |
| 326 | switch (chan->channel2) { |
| 327 | case IIO_MOD_RUNNING: |
| 328 | *val = st->activity_running; |
| 329 | ret = IIO_VAL_INT; |
| 330 | break; |
| 331 | case IIO_MOD_WALKING: |
| 332 | *val = st->activity_walking; |
| 333 | ret = IIO_VAL_INT; |
| 334 | break; |
| 335 | default: |
| 336 | break; |
| 337 | } |
| 338 | break; |
| 339 | default: |
| 340 | break; |
| 341 | } |
| 342 | break; |
Jonathan Cameron | c8a9f80 | 2011-10-26 17:41:36 +0100 | [diff] [blame] | 343 | case IIO_CHAN_INFO_OFFSET: |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 344 | /* only single ended adc -> 7 */ |
| 345 | *val = 7; |
| 346 | ret = IIO_VAL_INT; |
| 347 | break; |
Jonathan Cameron | c8a9f80 | 2011-10-26 17:41:36 +0100 | [diff] [blame] | 348 | case IIO_CHAN_INFO_SCALE: |
Daniel Baluta | 3e34e65 | 2014-11-10 14:45:34 +0200 | [diff] [blame] | 349 | switch (chan->type) { |
| 350 | case IIO_VOLTAGE: |
| 351 | switch (chan->differential) { |
| 352 | case 0: |
| 353 | /* only single ended adc -> 0.001333 */ |
| 354 | *val = 0; |
| 355 | *val2 = 1333; |
| 356 | ret = IIO_VAL_INT_PLUS_MICRO; |
| 357 | break; |
| 358 | case 1: |
Alison Schofield | 4b60c88 | 2015-10-26 13:50:29 -0700 | [diff] [blame] | 359 | /* all differential adc -> 0.000001344 */ |
Daniel Baluta | 3e34e65 | 2014-11-10 14:45:34 +0200 | [diff] [blame] | 360 | *val = 0; |
| 361 | *val2 = 1344; |
| 362 | ret = IIO_VAL_INT_PLUS_NANO; |
| 363 | } |
Jonathan Cameron | c8a9f80 | 2011-10-26 17:41:36 +0100 | [diff] [blame] | 364 | break; |
Daniel Baluta | 3e34e65 | 2014-11-10 14:45:34 +0200 | [diff] [blame] | 365 | default: |
| 366 | break; |
Jonathan Cameron | c8a9f80 | 2011-10-26 17:41:36 +0100 | [diff] [blame] | 367 | } |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 368 | break; |
Jonathan Cameron | c8a9f80 | 2011-10-26 17:41:36 +0100 | [diff] [blame] | 369 | case IIO_CHAN_INFO_CALIBBIAS: |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 370 | /* only the acceleration axis - read from cache */ |
| 371 | *val = st->accel_calibbias; |
| 372 | ret = IIO_VAL_INT; |
| 373 | break; |
Jonathan Cameron | c8a9f80 | 2011-10-26 17:41:36 +0100 | [diff] [blame] | 374 | case IIO_CHAN_INFO_CALIBSCALE: |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 375 | *val = st->accel_calibscale->val; |
| 376 | *val2 = st->accel_calibscale->val2; |
| 377 | ret = IIO_VAL_INT_PLUS_MICRO; |
| 378 | break; |
Jonathan Cameron | 6a63aa0 | 2013-09-08 14:57:00 +0100 | [diff] [blame] | 379 | case IIO_CHAN_INFO_SAMP_FREQ: |
| 380 | *val = 3; |
| 381 | *val2 = 33; |
| 382 | ret = IIO_VAL_INT_PLUS_NANO; |
| 383 | break; |
Daniel Baluta | 3e34e65 | 2014-11-10 14:45:34 +0200 | [diff] [blame] | 384 | case IIO_CHAN_INFO_ENABLE: |
| 385 | switch (chan->type) { |
| 386 | case IIO_STEPS: |
| 387 | *val = st->steps_enabled; |
| 388 | ret = IIO_VAL_INT; |
| 389 | break; |
| 390 | default: |
| 391 | break; |
| 392 | } |
| 393 | break; |
| 394 | case IIO_CHAN_INFO_CALIBHEIGHT: |
| 395 | switch (chan->type) { |
| 396 | case IIO_STEPS: |
| 397 | *val = st->height; |
| 398 | ret = IIO_VAL_INT; |
| 399 | break; |
| 400 | default: |
| 401 | break; |
| 402 | } |
| 403 | break; |
| 404 | |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 405 | default: |
| 406 | break; |
| 407 | } |
| 408 | mutex_unlock(&st->lock); |
| 409 | return ret; |
| 410 | } |
| 411 | |
| 412 | /** |
| 413 | * iio_dummy_write_raw() - data write function. |
| 414 | * @indio_dev: the struct iio_dev associated with this device instance |
Alexander Stein | 569c4ac | 2012-12-19 17:56:00 +0000 | [diff] [blame] | 415 | * @chan: the channel whose data is to be written |
Peter Meerwald | 25c38aa | 2012-06-15 19:27:10 +0200 | [diff] [blame] | 416 | * @val: first element of value to set (typically INT) |
| 417 | * @val2: second element of value to set (typically MICRO) |
Jonathan Cameron | fa357a6 | 2013-02-19 21:12:21 +0000 | [diff] [blame] | 418 | * @mask: what we actually want to write as per the info_mask_* |
| 419 | * in iio_chan_spec. |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 420 | * |
| 421 | * Note that all raw writes are assumed IIO_VAL_INT and info mask elements |
| 422 | * are assumed to be IIO_INT_PLUS_MICRO unless the callback write_raw_get_fmt |
| 423 | * in struct iio_info is provided by the driver. |
| 424 | */ |
| 425 | static int iio_dummy_write_raw(struct iio_dev *indio_dev, |
| 426 | struct iio_chan_spec const *chan, |
| 427 | int val, |
| 428 | int val2, |
| 429 | long mask) |
| 430 | { |
| 431 | int i; |
| 432 | int ret = 0; |
| 433 | struct iio_dummy_state *st = iio_priv(indio_dev); |
| 434 | |
| 435 | switch (mask) { |
Lars-Peter Clausen | 41fd935 | 2012-04-15 17:41:27 +0100 | [diff] [blame] | 436 | case IIO_CHAN_INFO_RAW: |
Daniel Baluta | 3e34e65 | 2014-11-10 14:45:34 +0200 | [diff] [blame] | 437 | switch (chan->type) { |
| 438 | case IIO_VOLTAGE: |
| 439 | if (chan->output == 0) |
| 440 | return -EINVAL; |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 441 | |
Daniel Baluta | 3e34e65 | 2014-11-10 14:45:34 +0200 | [diff] [blame] | 442 | /* Locking not required as writing single value */ |
| 443 | mutex_lock(&st->lock); |
| 444 | st->dac_val = val; |
| 445 | mutex_unlock(&st->lock); |
| 446 | return 0; |
| 447 | default: |
| 448 | return -EINVAL; |
| 449 | } |
| 450 | case IIO_CHAN_INFO_PROCESSED: |
| 451 | switch (chan->type) { |
| 452 | case IIO_STEPS: |
| 453 | mutex_lock(&st->lock); |
| 454 | st->steps = val; |
| 455 | mutex_unlock(&st->lock); |
| 456 | return 0; |
| 457 | case IIO_ACTIVITY: |
| 458 | if (val < 0) |
| 459 | val = 0; |
| 460 | if (val > 100) |
| 461 | val = 100; |
| 462 | switch (chan->channel2) { |
| 463 | case IIO_MOD_RUNNING: |
| 464 | st->activity_running = val; |
| 465 | return 0; |
| 466 | case IIO_MOD_WALKING: |
| 467 | st->activity_walking = val; |
| 468 | return 0; |
| 469 | default: |
| 470 | return -EINVAL; |
| 471 | } |
| 472 | break; |
| 473 | default: |
| 474 | return -EINVAL; |
| 475 | } |
Jin Feng | ff3fc8e | 2013-04-05 05:51:00 +0100 | [diff] [blame] | 476 | case IIO_CHAN_INFO_CALIBSCALE: |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 477 | mutex_lock(&st->lock); |
| 478 | /* Compare against table - hard matching here */ |
| 479 | for (i = 0; i < ARRAY_SIZE(dummy_scales); i++) |
| 480 | if (val == dummy_scales[i].val && |
| 481 | val2 == dummy_scales[i].val2) |
| 482 | break; |
| 483 | if (i == ARRAY_SIZE(dummy_scales)) |
| 484 | ret = -EINVAL; |
| 485 | else |
| 486 | st->accel_calibscale = &dummy_scales[i]; |
| 487 | mutex_unlock(&st->lock); |
| 488 | return ret; |
Jin Feng | ff3fc8e | 2013-04-05 05:51:00 +0100 | [diff] [blame] | 489 | case IIO_CHAN_INFO_CALIBBIAS: |
| 490 | mutex_lock(&st->lock); |
| 491 | st->accel_calibbias = val; |
| 492 | mutex_unlock(&st->lock); |
| 493 | return 0; |
Daniel Baluta | 3e34e65 | 2014-11-10 14:45:34 +0200 | [diff] [blame] | 494 | case IIO_CHAN_INFO_ENABLE: |
| 495 | switch (chan->type) { |
| 496 | case IIO_STEPS: |
| 497 | mutex_lock(&st->lock); |
| 498 | st->steps_enabled = val; |
| 499 | mutex_unlock(&st->lock); |
| 500 | return 0; |
| 501 | default: |
| 502 | return -EINVAL; |
| 503 | } |
| 504 | case IIO_CHAN_INFO_CALIBHEIGHT: |
| 505 | switch (chan->type) { |
| 506 | case IIO_STEPS: |
| 507 | st->height = val; |
| 508 | return 0; |
| 509 | default: |
| 510 | return -EINVAL; |
| 511 | } |
Jin Feng | ff3fc8e | 2013-04-05 05:51:00 +0100 | [diff] [blame] | 512 | |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 513 | default: |
| 514 | return -EINVAL; |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | /* |
| 519 | * Device type specific information. |
| 520 | */ |
| 521 | static const struct iio_info iio_dummy_info = { |
| 522 | .driver_module = THIS_MODULE, |
| 523 | .read_raw = &iio_dummy_read_raw, |
| 524 | .write_raw = &iio_dummy_write_raw, |
Jonathan Cameron | e647700 | 2011-10-14 16:34:14 +0100 | [diff] [blame] | 525 | #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS |
Lars-Peter Clausen | cb95585 | 2013-12-07 10:45:00 +0000 | [diff] [blame] | 526 | .read_event_config = &iio_simple_dummy_read_event_config, |
| 527 | .write_event_config = &iio_simple_dummy_write_event_config, |
| 528 | .read_event_value = &iio_simple_dummy_read_event_value, |
| 529 | .write_event_value = &iio_simple_dummy_write_event_value, |
Jonathan Cameron | e647700 | 2011-10-14 16:34:14 +0100 | [diff] [blame] | 530 | #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 531 | }; |
| 532 | |
| 533 | /** |
| 534 | * iio_dummy_init_device() - device instance specific init |
| 535 | * @indio_dev: the iio device structure |
| 536 | * |
| 537 | * Most drivers have one of these to set up default values, |
| 538 | * reset the device to known state etc. |
| 539 | */ |
| 540 | static int iio_dummy_init_device(struct iio_dev *indio_dev) |
| 541 | { |
| 542 | struct iio_dummy_state *st = iio_priv(indio_dev); |
| 543 | |
| 544 | st->dac_val = 0; |
| 545 | st->single_ended_adc_val = 73; |
| 546 | st->differential_adc_val[0] = 33; |
| 547 | st->differential_adc_val[1] = -34; |
| 548 | st->accel_val = 34; |
| 549 | st->accel_calibbias = -7; |
| 550 | st->accel_calibscale = &dummy_scales[0]; |
Daniel Baluta | 3e34e65 | 2014-11-10 14:45:34 +0200 | [diff] [blame] | 551 | st->steps = 47; |
| 552 | st->activity_running = 98; |
| 553 | st->activity_walking = 4; |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 554 | |
| 555 | return 0; |
| 556 | } |
| 557 | |
| 558 | /** |
| 559 | * iio_dummy_probe() - device instance probe |
| 560 | * @index: an id number for this instance. |
| 561 | * |
| 562 | * Arguments are bus type specific. |
| 563 | * I2C: iio_dummy_probe(struct i2c_client *client, |
| 564 | * const struct i2c_device_id *id) |
| 565 | * SPI: iio_dummy_probe(struct spi_device *spi) |
| 566 | */ |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 567 | static struct iio_sw_device *iio_dummy_probe(const char *name) |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 568 | { |
| 569 | int ret; |
| 570 | struct iio_dev *indio_dev; |
| 571 | struct iio_dummy_state *st; |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 572 | struct iio_sw_device *swd; |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 573 | |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 574 | swd = kzalloc(sizeof(*swd), GFP_KERNEL); |
| 575 | if (!swd) { |
| 576 | ret = -ENOMEM; |
| 577 | goto error_kzalloc; |
| 578 | } |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 579 | /* |
| 580 | * Allocate an IIO device. |
| 581 | * |
| 582 | * This structure contains all generic state |
| 583 | * information about the device instance. |
| 584 | * It also has a region (accessed by iio_priv() |
| 585 | * for chip specific state information. |
| 586 | */ |
Lars-Peter Clausen | 7cbb753 | 2012-04-26 13:35:01 +0200 | [diff] [blame] | 587 | indio_dev = iio_device_alloc(sizeof(*st)); |
Cristina Opriceana | 8f94c31 | 2015-03-31 12:51:38 +0300 | [diff] [blame] | 588 | if (!indio_dev) { |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 589 | ret = -ENOMEM; |
| 590 | goto error_ret; |
| 591 | } |
| 592 | |
| 593 | st = iio_priv(indio_dev); |
| 594 | mutex_init(&st->lock); |
| 595 | |
| 596 | iio_dummy_init_device(indio_dev); |
| 597 | /* |
| 598 | * With hardware: Set the parent device. |
| 599 | * indio_dev->dev.parent = &spi->dev; |
| 600 | * indio_dev->dev.parent = &client->dev; |
| 601 | */ |
| 602 | |
| 603 | /* |
| 604 | * Make the iio_dev struct available to remove function. |
| 605 | * Bus equivalents |
| 606 | * i2c_set_clientdata(client, indio_dev); |
| 607 | * spi_set_drvdata(spi, indio_dev); |
| 608 | */ |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 609 | swd->device = indio_dev; |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 610 | |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 611 | /* |
| 612 | * Set the device name. |
| 613 | * |
| 614 | * This is typically a part number and obtained from the module |
| 615 | * id table. |
| 616 | * e.g. for i2c and spi: |
| 617 | * indio_dev->name = id->name; |
| 618 | * indio_dev->name = spi_get_device_id(spi)->name; |
| 619 | */ |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 620 | indio_dev->name = kstrdup(name, GFP_KERNEL); |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 621 | |
| 622 | /* Provide description of available channels */ |
| 623 | indio_dev->channels = iio_dummy_channels; |
| 624 | indio_dev->num_channels = ARRAY_SIZE(iio_dummy_channels); |
| 625 | |
| 626 | /* |
| 627 | * Provide device type specific interface functions and |
| 628 | * constant data. |
| 629 | */ |
| 630 | indio_dev->info = &iio_dummy_info; |
| 631 | |
| 632 | /* Specify that device provides sysfs type interfaces */ |
| 633 | indio_dev->modes = INDIO_DIRECT_MODE; |
| 634 | |
Jonathan Cameron | e647700 | 2011-10-14 16:34:14 +0100 | [diff] [blame] | 635 | ret = iio_simple_dummy_events_register(indio_dev); |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 636 | if (ret < 0) |
| 637 | goto error_free_device; |
Jonathan Cameron | 9ad2e2e | 2011-10-14 16:34:15 +0100 | [diff] [blame] | 638 | |
Lars-Peter Clausen | 4ae0301 | 2014-11-26 18:55:11 +0100 | [diff] [blame] | 639 | ret = iio_simple_dummy_configure_buffer(indio_dev); |
Jonathan Cameron | e647700 | 2011-10-14 16:34:14 +0100 | [diff] [blame] | 640 | if (ret < 0) |
| 641 | goto error_unregister_events; |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 642 | |
Lars-Peter Clausen | 3fff227 | 2012-09-12 12:06:00 +0100 | [diff] [blame] | 643 | ret = iio_device_register(indio_dev); |
Jonathan Cameron | 9ad2e2e | 2011-10-14 16:34:15 +0100 | [diff] [blame] | 644 | if (ret < 0) |
| 645 | goto error_unconfigure_buffer; |
| 646 | |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 647 | iio_swd_group_init_type_name(swd, name, &iio_dummy_type); |
| 648 | |
| 649 | return swd; |
Jonathan Cameron | 9ad2e2e | 2011-10-14 16:34:15 +0100 | [diff] [blame] | 650 | error_unconfigure_buffer: |
| 651 | iio_simple_dummy_unconfigure_buffer(indio_dev); |
Jonathan Cameron | e647700 | 2011-10-14 16:34:14 +0100 | [diff] [blame] | 652 | error_unregister_events: |
| 653 | iio_simple_dummy_events_unregister(indio_dev); |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 654 | error_free_device: |
Lars-Peter Clausen | 7cbb753 | 2012-04-26 13:35:01 +0200 | [diff] [blame] | 655 | iio_device_free(indio_dev); |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 656 | error_ret: |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 657 | kfree(swd); |
| 658 | error_kzalloc: |
| 659 | return ERR_PTR(ret); |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | /** |
| 663 | * iio_dummy_remove() - device instance removal function |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 664 | * @swd: pointer to software IIO device abstraction |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 665 | * |
| 666 | * Parameters follow those of iio_dummy_probe for buses. |
| 667 | */ |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 668 | static int iio_dummy_remove(struct iio_sw_device *swd) |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 669 | { |
| 670 | /* |
| 671 | * Get a pointer to the device instance iio_dev structure |
| 672 | * from the bus subsystem. E.g. |
| 673 | * struct iio_dev *indio_dev = i2c_get_clientdata(client); |
| 674 | * struct iio_dev *indio_dev = spi_get_drvdata(spi); |
| 675 | */ |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 676 | struct iio_dev *indio_dev = swd->device; |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 677 | |
| 678 | /* Unregister the device */ |
| 679 | iio_device_unregister(indio_dev); |
| 680 | |
| 681 | /* Device specific code to power down etc */ |
| 682 | |
Jonathan Cameron | 9ad2e2e | 2011-10-14 16:34:15 +0100 | [diff] [blame] | 683 | /* Buffered capture related cleanup */ |
Jonathan Cameron | 9ad2e2e | 2011-10-14 16:34:15 +0100 | [diff] [blame] | 684 | iio_simple_dummy_unconfigure_buffer(indio_dev); |
Jonathan Cameron | e647700 | 2011-10-14 16:34:14 +0100 | [diff] [blame] | 685 | |
Vladimirs Ambrosovs | 62a90da | 2015-05-30 11:20:16 +0300 | [diff] [blame] | 686 | iio_simple_dummy_events_unregister(indio_dev); |
Jonathan Cameron | e647700 | 2011-10-14 16:34:14 +0100 | [diff] [blame] | 687 | |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 688 | /* Free all structures */ |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 689 | kfree(indio_dev->name); |
Lars-Peter Clausen | 7cbb753 | 2012-04-26 13:35:01 +0200 | [diff] [blame] | 690 | iio_device_free(indio_dev); |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 691 | |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 692 | return 0; |
| 693 | } |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 694 | /** |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 695 | * module_iio_sw_device_driver() - device driver registration |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 696 | * |
| 697 | * Varies depending on bus type of the device. As there is no device |
| 698 | * here, call probe directly. For information on device registration |
| 699 | * i2c: |
| 700 | * Documentation/i2c/writing-clients |
| 701 | * spi: |
| 702 | * Documentation/spi/spi-summary |
| 703 | */ |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 704 | static const struct iio_sw_device_ops iio_dummy_device_ops = { |
| 705 | .probe = iio_dummy_probe, |
| 706 | .remove = iio_dummy_remove, |
| 707 | }; |
Jimmy Picard | aff8945 | 2014-06-13 06:56:00 +0100 | [diff] [blame] | 708 | |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 709 | static struct iio_sw_device_type iio_dummy_device = { |
| 710 | .name = "dummy", |
| 711 | .owner = THIS_MODULE, |
| 712 | .ops = &iio_dummy_device_ops, |
| 713 | }; |
Lars-Peter Clausen | 3fff227 | 2012-09-12 12:06:00 +0100 | [diff] [blame] | 714 | |
Daniel Baluta | 3d85fb6f | 2016-04-25 16:15:52 +0300 | [diff] [blame] | 715 | module_iio_sw_device_driver(iio_dummy_device); |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 716 | |
Jonathan Cameron | 0f8c962 | 2012-09-02 21:34:59 +0100 | [diff] [blame] | 717 | MODULE_AUTHOR("Jonathan Cameron <jic23@kernel.org>"); |
Jonathan Cameron | 3a84331 | 2011-10-14 16:34:13 +0100 | [diff] [blame] | 718 | MODULE_DESCRIPTION("IIO dummy driver"); |
| 719 | MODULE_LICENSE("GPL v2"); |