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