Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'iio-for-3.14b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

2nd round of new IIO drivers, features and cleanups for the 3.14 cycle.

New drivers

* HID inclinometer driver.

* DHT11 humidity driver. Note that previous humidity drivers have been in
hwmon, but no one was ever entirely happy with that, and they should find
a more comfortable home in IIO (their original placement in hwmon was my
fault - oops). As this is our first humidity driver, core support is also
added.

New features

* Two of mxs-lradc channels are internally wired to a temperature sensor,
make this explicit in the driver by providing the relevant temperature
channel.

* Add support for blocking IO on buffers.

* Add a data_available call back to the interface between buffer implementations
and the core. This is much cleaner than the old, 'stufftoread' flag.
Implemented in the kfifo buffer.

Cleanups

* Last user of the old event configuration interface is converted and the
old interface dropped. Nice to be rid of this thanks to Lars-Peter's hard
work!

* Replace all remaining instances of the IIO_ST macro with explicit filling
of the scan_type structure within struct iio_chan_spec. This macro was a
bad idea, that rapidly ceased to cover all elements of the structure.
Miss reading of the macro arguements has led to a number of bugs so lets
just get rid of it. The final removal patch is awaiting for some fixes
to make their way into mainline.
In a couple of drivers, no elements of scan_type were even being used so
in those case, it has been dropped entirely.

* Drop a couple of of_match_ptr helper uses in drivers where devicetree is
not optional and hence the structures being protected by this always exist.

* Fix up some cases where data was read from a device in a particular
byte order, but he code placed it into a s16 or similar. These were
highlighted by Sparse.

* Use the new ATTRIBUTE_GROUPS macro to drop some boiler plate in the triggers
core code.

* ad7746 and ad7280a - stop storing buffers on the stack, giving cleaner code
and possibly avoiding issues with i2c bus drivers that assume they can dma
directly into the buffer. Note that this cannot currently happen as the the
i2c_smbus_read_i2c_block_data function has a memcpy from the buffer actually
passed to the bus driver. I missed this element of the commit message
and don't think it is major enough to rebase the iio tree.

* ad5791 and ad5504 stop storing buffers on the stack for an SPI driver.
Unlike the i2c drivers, this is a real issue for SPI drivers which can dma
directly into the buffer supplied.

+1240 -376
+13
Documentation/ABI/testing/sysfs-bus-iio
··· 197 197 Raw pressure measurement from channel Y. Units after 198 198 application of scale and offset are kilopascal. 199 199 200 + What: /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_raw 201 + KernelVersion: 3.14 202 + Contact: linux-iio@vger.kernel.org 203 + Description: 204 + Raw humidity measurement of air. Units after application of 205 + scale and offset are milli percent. 206 + 207 + What: /sys/bus/iio/devices/iio:deviceX/in_humidityrelative_input 208 + KernelVersion: 3.14 209 + Contact: linux-iio@vger.kernel.org 210 + Description: 211 + Scaled humidity measurement in milli percent. 212 + 200 213 What: /sys/bus/iio/devices/iio:deviceX/in_accel_offset 201 214 What: /sys/bus/iio/devices/iio:deviceX/in_accel_x_offset 202 215 What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_offset
+14
Documentation/devicetree/bindings/iio/humidity/dht11.txt
··· 1 + * DHT11 humidity/temperature sensor (and compatibles like DHT22) 2 + 3 + Required properties: 4 + - compatible: Should be "dht11" 5 + - gpios: Should specify the GPIO connected to the sensor's data 6 + line, see "gpios property" in 7 + Documentation/devicetree/bindings/gpio/gpio.txt. 8 + 9 + Example: 10 + 11 + humidity_sensor { 12 + compatible = "dht11"; 13 + gpios = <&gpio0 6 0>; 14 + }
+2
drivers/iio/Kconfig
··· 65 65 source "drivers/iio/dac/Kconfig" 66 66 source "drivers/iio/frequency/Kconfig" 67 67 source "drivers/iio/gyro/Kconfig" 68 + source "drivers/iio/humidity/Kconfig" 68 69 source "drivers/iio/imu/Kconfig" 69 70 source "drivers/iio/light/Kconfig" 70 71 source "drivers/iio/magnetometer/Kconfig" 72 + source "drivers/iio/orientation/Kconfig" 71 73 if IIO_TRIGGER 72 74 source "drivers/iio/trigger/Kconfig" 73 75 endif #IIO_TRIGGER
+2
drivers/iio/Makefile
··· 18 18 obj-y += dac/ 19 19 obj-y += gyro/ 20 20 obj-y += frequency/ 21 + obj-y += humidity/ 21 22 obj-y += imu/ 22 23 obj-y += light/ 23 24 obj-y += magnetometer/ 25 + obj-y += orientation/ 24 26 obj-y += pressure/ 25 27 obj-y += temperature/ 26 28 obj-y += trigger/
+6 -1
drivers/iio/accel/bma180.c
··· 455 455 BIT(IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY), \ 456 456 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ 457 457 .scan_index = (_index), \ 458 - .scan_type = IIO_ST('s', 14, 16, 2), \ 458 + .scan_type = { \ 459 + .sign = 's', \ 460 + .realbits = 14, \ 461 + .storagebits = 16, \ 462 + .shift = 2, \ 463 + }, \ 459 464 .ext_info = bma180_ext_info, \ 460 465 } 461 466
+12 -9
drivers/iio/adc/ad7266.c
··· 43 43 * The buffer needs to be large enough to hold two samples (4 bytes) and 44 44 * the naturally aligned timestamp (8 bytes). 45 45 */ 46 - uint8_t data[ALIGN(4, sizeof(s64)) + sizeof(s64)] ____cacheline_aligned; 46 + struct { 47 + __be16 sample[2]; 48 + s64 timestamp; 49 + } data ____cacheline_aligned; 47 50 }; 48 51 49 52 static int ad7266_wakeup(struct ad7266_state *st) 50 53 { 51 54 /* Any read with >= 2 bytes will wake the device */ 52 - return spi_read(st->spi, st->data, 2); 55 + return spi_read(st->spi, &st->data.sample[0], 2); 53 56 } 54 57 55 58 static int ad7266_powerdown(struct ad7266_state *st) 56 59 { 57 60 /* Any read with < 2 bytes will powerdown the device */ 58 - return spi_read(st->spi, st->data, 1); 61 + return spi_read(st->spi, &st->data.sample[0], 1); 59 62 } 60 63 61 64 static int ad7266_preenable(struct iio_dev *indio_dev) ··· 87 84 struct ad7266_state *st = iio_priv(indio_dev); 88 85 int ret; 89 86 90 - ret = spi_read(st->spi, st->data, 4); 87 + ret = spi_read(st->spi, st->data.sample, 4); 91 88 if (ret == 0) { 92 - iio_push_to_buffers_with_timestamp(indio_dev, st->data, 89 + iio_push_to_buffers_with_timestamp(indio_dev, &st->data, 93 90 pf->timestamp); 94 91 } 95 92 ··· 140 137 ad7266_select_input(st, address); 141 138 142 139 ret = spi_sync(st->spi, &st->single_msg); 143 - *val = be16_to_cpu(st->data[address % 2]); 140 + *val = be16_to_cpu(st->data.sample[address % 2]); 144 141 145 142 return ret; 146 143 } ··· 445 442 ad7266_init_channels(indio_dev); 446 443 447 444 /* wakeup */ 448 - st->single_xfer[0].rx_buf = &st->data; 445 + st->single_xfer[0].rx_buf = &st->data.sample[0]; 449 446 st->single_xfer[0].len = 2; 450 447 st->single_xfer[0].cs_change = 1; 451 448 /* conversion */ 452 - st->single_xfer[1].rx_buf = &st->data; 449 + st->single_xfer[1].rx_buf = st->data.sample; 453 450 st->single_xfer[1].len = 4; 454 451 st->single_xfer[1].cs_change = 1; 455 452 /* powerdown */ 456 - st->single_xfer[2].tx_buf = &st->data; 453 + st->single_xfer[2].tx_buf = &st->data.sample[0]; 457 454 st->single_xfer[2].len = 1; 458 455 459 456 spi_message_init(&st->single_msg);
+4 -4
drivers/iio/adc/max1363.c
··· 1039 1039 }; 1040 1040 1041 1041 static const struct iio_info max1363_info = { 1042 - .read_event_value_new = &max1363_read_thresh, 1043 - .write_event_value_new = &max1363_write_thresh, 1044 - .read_event_config_new = &max1363_read_event_config, 1045 - .write_event_config_new = &max1363_write_event_config, 1042 + .read_event_value = &max1363_read_thresh, 1043 + .write_event_value = &max1363_write_thresh, 1044 + .read_event_config = &max1363_read_event_config, 1045 + .write_event_config = &max1363_write_event_config, 1046 1046 .read_raw = &max1363_read_raw, 1047 1047 .update_scan_mode = &max1363_update_scan_mode, 1048 1048 .driver_module = THIS_MODULE,
+6 -1
drivers/iio/dac/ad5064.c
··· 299 299 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ 300 300 BIT(IIO_CHAN_INFO_SCALE), \ 301 301 .address = addr, \ 302 - .scan_type = IIO_ST('u', (bits), 16, 20 - (bits)), \ 302 + .scan_type = { \ 303 + .sign = 'u', \ 304 + .realbits = (bits), \ 305 + .storagebits = 16, \ 306 + .shift = 20 - bits, \ 307 + }, \ 303 308 .ext_info = ad5064_ext_info, \ 304 309 } 305 310
+6 -1
drivers/iio/dac/ad5360.c
··· 107 107 BIT(IIO_CHAN_INFO_OFFSET) | \ 108 108 BIT(IIO_CHAN_INFO_CALIBSCALE) | \ 109 109 BIT(IIO_CHAN_INFO_CALIBBIAS), \ 110 - .scan_type = IIO_ST('u', (bits), 16, 16 - (bits)) \ 110 + .scan_type = { \ 111 + .sign = 'u', \ 112 + .realbits = (bits), \ 113 + .storagebits = 16, \ 114 + .shift = 16 - (bits), \ 115 + }, \ 111 116 } 112 117 113 118 static const struct ad5360_chip_info ad5360_chip_info_tbl[] = {
+6 -1
drivers/iio/dac/ad5380.c
··· 261 261 BIT(IIO_CHAN_INFO_CALIBSCALE) | \ 262 262 BIT(IIO_CHAN_INFO_CALIBBIAS), \ 263 263 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ 264 - .scan_type = IIO_ST('u', (_bits), 16, 14 - (_bits)), \ 264 + .scan_type = { \ 265 + .sign = 'u', \ 266 + .realbits = (_bits), \ 267 + .storagebits = 16, \ 268 + .shift = 14 - (_bits), \ 269 + }, \ 265 270 .ext_info = ad5380_ext_info, \ 266 271 } 267 272
+9 -5
drivers/iio/dac/ad5421.c
··· 75 75 * transfer buffers to live in their own cache lines. 76 76 */ 77 77 union { 78 - u32 d32; 78 + __be32 d32; 79 79 u8 d8[4]; 80 80 } data[2] ____cacheline_aligned; 81 81 }; ··· 114 114 BIT(IIO_CHAN_INFO_CALIBBIAS), 115 115 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | 116 116 BIT(IIO_CHAN_INFO_OFFSET), 117 - .scan_type = IIO_ST('u', 16, 16, 0), 117 + .scan_type = { 118 + .sign = 'u', 119 + .realbits = 16, 120 + .storagebits = 16, 121 + }, 118 122 .event_spec = ad5421_current_event, 119 123 .num_event_specs = ARRAY_SIZE(ad5421_current_event), 120 124 }, ··· 462 458 static const struct iio_info ad5421_info = { 463 459 .read_raw = ad5421_read_raw, 464 460 .write_raw = ad5421_write_raw, 465 - .read_event_config_new = ad5421_read_event_config, 466 - .write_event_config_new = ad5421_write_event_config, 467 - .read_event_value_new = ad5421_read_event_value, 461 + .read_event_config = ad5421_read_event_config, 462 + .write_event_config = ad5421_write_event_config, 463 + .read_event_value = ad5421_read_event_value, 468 464 .driver_module = THIS_MODULE, 469 465 }; 470 466
+7 -2
drivers/iio/dac/ad5446.c
··· 139 139 { }, 140 140 }; 141 141 142 - #define _AD5446_CHANNEL(bits, storage, shift, ext) { \ 142 + #define _AD5446_CHANNEL(bits, storage, _shift, ext) { \ 143 143 .type = IIO_VOLTAGE, \ 144 144 .indexed = 1, \ 145 145 .output = 1, \ 146 146 .channel = 0, \ 147 147 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ 148 148 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ 149 - .scan_type = IIO_ST('u', (bits), (storage), (shift)), \ 149 + .scan_type = { \ 150 + .sign = 'u', \ 151 + .realbits = (bits), \ 152 + .storagebits = (storage), \ 153 + .shift = (_shift), \ 154 + }, \ 150 155 .ext_info = (ext), \ 151 156 } 152 157
+6 -1
drivers/iio/dac/ad5449.c
··· 204 204 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ 205 205 BIT(IIO_CHAN_INFO_SCALE), \ 206 206 .address = (chan), \ 207 - .scan_type = IIO_ST('u', (bits), 16, 12 - (bits)), \ 207 + .scan_type = { \ 208 + .sign = 'u', \ 209 + .realbits = (bits), \ 210 + .storagebits = 16, \ 211 + .shift = 12 - (bits), \ 212 + }, \ 208 213 } 209 214 210 215 #define DECLARE_AD5449_CHANNELS(name, bits) \
+24 -20
drivers/iio/dac/ad5504.c
··· 47 47 * @vref_mv: actual reference voltage used 48 48 * @pwr_down_mask power down mask 49 49 * @pwr_down_mode current power down mode 50 + * @data: transfer buffer 50 51 */ 51 - 52 52 struct ad5504_state { 53 53 struct spi_device *spi; 54 54 struct regulator *reg; 55 55 unsigned short vref_mv; 56 56 unsigned pwr_down_mask; 57 57 unsigned pwr_down_mode; 58 + 59 + __be16 data[2] ____cacheline_aligned; 58 60 }; 59 61 60 62 /** ··· 68 66 ID_AD5501, 69 67 }; 70 68 71 - static int ad5504_spi_write(struct spi_device *spi, u8 addr, u16 val) 69 + static int ad5504_spi_write(struct ad5504_state *st, u8 addr, u16 val) 72 70 { 73 - u16 tmp = cpu_to_be16(AD5504_CMD_WRITE | 74 - AD5504_ADDR(addr) | 71 + st->data[0] = cpu_to_be16(AD5504_CMD_WRITE | AD5504_ADDR(addr) | 75 72 (val & AD5504_RES_MASK)); 76 73 77 - return spi_write(spi, (u8 *)&tmp, 2); 74 + return spi_write(st->spi, &st->data[0], 2); 78 75 } 79 76 80 - static int ad5504_spi_read(struct spi_device *spi, u8 addr) 77 + static int ad5504_spi_read(struct ad5504_state *st, u8 addr) 81 78 { 82 - u16 tmp = cpu_to_be16(AD5504_CMD_READ | AD5504_ADDR(addr)); 83 - u16 val; 84 79 int ret; 85 - struct spi_transfer t = { 86 - .tx_buf = &tmp, 87 - .rx_buf = &val, 88 - .len = 2, 89 - }; 90 - ret = spi_sync_transfer(spi, &t, 1); 80 + struct spi_transfer t = { 81 + .tx_buf = &st->data[0], 82 + .rx_buf = &st->data[1], 83 + .len = 2, 84 + }; 91 85 86 + st->data[0] = cpu_to_be16(AD5504_CMD_READ | AD5504_ADDR(addr)); 87 + ret = spi_sync_transfer(st->spi, &t, 1); 92 88 if (ret < 0) 93 89 return ret; 94 90 95 - return be16_to_cpu(val) & AD5504_RES_MASK; 91 + return be16_to_cpu(st->data[1]) & AD5504_RES_MASK; 96 92 } 97 93 98 94 static int ad5504_read_raw(struct iio_dev *indio_dev, ··· 104 104 105 105 switch (m) { 106 106 case IIO_CHAN_INFO_RAW: 107 - ret = ad5504_spi_read(st->spi, chan->address); 107 + ret = ad5504_spi_read(st, chan->address); 108 108 if (ret < 0) 109 109 return ret; 110 110 ··· 133 133 if (val >= (1 << chan->scan_type.realbits) || val < 0) 134 134 return -EINVAL; 135 135 136 - return ad5504_spi_write(st->spi, chan->address, val); 136 + return ad5504_spi_write(st, chan->address, val); 137 137 default: 138 138 ret = -EINVAL; 139 139 } ··· 197 197 else 198 198 st->pwr_down_mask &= ~(1 << chan->channel); 199 199 200 - ret = ad5504_spi_write(st->spi, AD5504_ADDR_CTRL, 200 + ret = ad5504_spi_write(st, AD5504_ADDR_CTRL, 201 201 AD5504_DAC_PWRDWN_MODE(st->pwr_down_mode) | 202 202 AD5504_DAC_PWR(st->pwr_down_mask)); 203 203 204 204 /* writes to the CTRL register must be followed by a NOOP */ 205 - ad5504_spi_write(st->spi, AD5504_ADDR_NOOP, 0); 205 + ad5504_spi_write(st, AD5504_ADDR_NOOP, 0); 206 206 207 207 return ret ? ret : len; 208 208 } ··· 261 261 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ 262 262 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ 263 263 .address = AD5504_ADDR_DAC(_chan), \ 264 - .scan_type = IIO_ST('u', 12, 16, 0), \ 264 + .scan_type = { \ 265 + .sign = 'u', \ 266 + .realbits = 12, \ 267 + .storagebits = 16, \ 268 + }, \ 265 269 .ext_info = ad5504_ext_info, \ 266 270 } 267 271
+6 -1
drivers/iio/dac/ad5624r_spi.c
··· 176 176 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ 177 177 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ 178 178 .address = (_chan), \ 179 - .scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)), \ 179 + .scan_type = { \ 180 + .sign = 'u', \ 181 + .realbits = (_bits), \ 182 + .storagebits = 16, \ 183 + .shift = 16 - (_bits), \ 184 + }, \ 180 185 .ext_info = ad5624r_ext_info, \ 181 186 } 182 187
+8 -3
drivers/iio/dac/ad5686.c
··· 78 78 */ 79 79 80 80 union { 81 - u32 d32; 81 + __be32 d32; 82 82 u8 d8[4]; 83 83 } data[3] ____cacheline_aligned; 84 84 }; ··· 267 267 { }, 268 268 }; 269 269 270 - #define AD5868_CHANNEL(chan, bits, shift) { \ 270 + #define AD5868_CHANNEL(chan, bits, _shift) { \ 271 271 .type = IIO_VOLTAGE, \ 272 272 .indexed = 1, \ 273 273 .output = 1, \ ··· 275 275 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ 276 276 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),\ 277 277 .address = AD5686_ADDR_DAC(chan), \ 278 - .scan_type = IIO_ST('u', bits, 16, shift), \ 278 + .scan_type = { \ 279 + .sign = 'u', \ 280 + .realbits = (bits), \ 281 + .storagebits = 16, \ 282 + .shift = (_shift), \ 283 + }, \ 279 284 .ext_info = ad5686_ext_info, \ 280 285 } 281 286
+7 -2
drivers/iio/dac/ad5755.c
··· 97 97 */ 98 98 99 99 union { 100 - u32 d32; 100 + __be32 d32; 101 101 u8 d8[4]; 102 102 } data[2] ____cacheline_aligned; 103 103 }; ··· 392 392 BIT(IIO_CHAN_INFO_OFFSET) | \ 393 393 BIT(IIO_CHAN_INFO_CALIBSCALE) | \ 394 394 BIT(IIO_CHAN_INFO_CALIBBIAS), \ 395 - .scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)), \ 395 + .scan_type = { \ 396 + .sign = 'u', \ 397 + .realbits = (_bits), \ 398 + .storagebits = 16, \ 399 + .shift = 16 - (_bits), \ 400 + }, \ 396 401 .ext_info = ad5755_ext_info, \ 397 402 } 398 403
+6 -1
drivers/iio/dac/ad5764.c
··· 83 83 BIT(IIO_CHAN_INFO_CALIBSCALE) | \ 84 84 BIT(IIO_CHAN_INFO_CALIBBIAS), \ 85 85 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET), \ 86 - .scan_type = IIO_ST('u', (_bits), 16, 16 - (_bits)) \ 86 + .scan_type = { \ 87 + .sign = 'u', \ 88 + .realbits = (_bits), \ 89 + .storagebits = 16, \ 90 + .shift = 16 - (_bits), \ 91 + }, \ 87 92 } 88 93 89 94 #define DECLARE_AD5764_CHANNELS(_name, _bits) \
+28 -27
drivers/iio/dac/ad5791.c
··· 91 91 unsigned ctrl; 92 92 unsigned pwr_down_mode; 93 93 bool pwr_down; 94 + 95 + union { 96 + __be32 d32; 97 + u8 d8[4]; 98 + } data[3] ____cacheline_aligned; 94 99 }; 95 100 96 101 /** ··· 109 104 ID_AD5791, 110 105 }; 111 106 112 - static int ad5791_spi_write(struct spi_device *spi, u8 addr, u32 val) 107 + static int ad5791_spi_write(struct ad5791_state *st, u8 addr, u32 val) 113 108 { 114 - union { 115 - u32 d32; 116 - u8 d8[4]; 117 - } data; 118 - 119 - data.d32 = cpu_to_be32(AD5791_CMD_WRITE | 109 + st->data[0].d32 = cpu_to_be32(AD5791_CMD_WRITE | 120 110 AD5791_ADDR(addr) | 121 111 (val & AD5791_DAC_MASK)); 122 112 123 - return spi_write(spi, &data.d8[1], 3); 113 + return spi_write(st->spi, &st->data[0].d8[1], 3); 124 114 } 125 115 126 - static int ad5791_spi_read(struct spi_device *spi, u8 addr, u32 *val) 116 + static int ad5791_spi_read(struct ad5791_state *st, u8 addr, u32 *val) 127 117 { 128 - union { 129 - u32 d32; 130 - u8 d8[4]; 131 - } data[3]; 132 118 int ret; 133 119 struct spi_transfer xfers[] = { 134 120 { 135 - .tx_buf = &data[0].d8[1], 121 + .tx_buf = &st->data[0].d8[1], 136 122 .bits_per_word = 8, 137 123 .len = 3, 138 124 .cs_change = 1, 139 125 }, { 140 - .tx_buf = &data[1].d8[1], 141 - .rx_buf = &data[2].d8[1], 126 + .tx_buf = &st->data[1].d8[1], 127 + .rx_buf = &st->data[2].d8[1], 142 128 .bits_per_word = 8, 143 129 .len = 3, 144 130 }, 145 131 }; 146 132 147 - data[0].d32 = cpu_to_be32(AD5791_CMD_READ | 133 + st->data[0].d32 = cpu_to_be32(AD5791_CMD_READ | 148 134 AD5791_ADDR(addr)); 149 - data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP)); 135 + st->data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP)); 150 136 151 - ret = spi_sync_transfer(spi, xfers, ARRAY_SIZE(xfers)); 137 + ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers)); 152 138 153 - *val = be32_to_cpu(data[2].d32); 139 + *val = be32_to_cpu(st->data[2].d32); 154 140 155 141 return ret; 156 142 } ··· 206 210 } 207 211 st->pwr_down = pwr_down; 208 212 209 - ret = ad5791_spi_write(st->spi, AD5791_ADDR_CTRL, st->ctrl); 213 + ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl); 210 214 211 215 return ret ? ret : len; 212 216 } ··· 259 263 260 264 switch (m) { 261 265 case IIO_CHAN_INFO_RAW: 262 - ret = ad5791_spi_read(st->spi, chan->address, val); 266 + ret = ad5791_spi_read(st, chan->address, val); 263 267 if (ret) 264 268 return ret; 265 269 *val &= AD5791_DAC_MASK; ··· 293 297 { }, 294 298 }; 295 299 296 - #define AD5791_CHAN(bits, shift) { \ 300 + #define AD5791_CHAN(bits, _shift) { \ 297 301 .type = IIO_VOLTAGE, \ 298 302 .output = 1, \ 299 303 .indexed = 1, \ ··· 302 306 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ 303 307 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ 304 308 BIT(IIO_CHAN_INFO_OFFSET), \ 305 - .scan_type = IIO_ST('u', bits, 24, shift), \ 309 + .scan_type = { \ 310 + .sign = 'u', \ 311 + .realbits = (bits), \ 312 + .storagebits = 24, \ 313 + .shift = (_shift), \ 314 + }, \ 306 315 .ext_info = ad5791_ext_info, \ 307 316 } 308 317 ··· 331 330 val &= AD5791_RES_MASK(chan->scan_type.realbits); 332 331 val <<= chan->scan_type.shift; 333 332 334 - return ad5791_spi_write(st->spi, chan->address, val); 333 + return ad5791_spi_write(st, chan->address, val); 335 334 336 335 default: 337 336 return -EINVAL; ··· 394 393 dev_warn(&spi->dev, "reference voltage unspecified\n"); 395 394 } 396 395 397 - ret = ad5791_spi_write(spi, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET); 396 + ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET); 398 397 if (ret) 399 398 goto error_disable_reg_neg; 400 399 ··· 406 405 | ((pdata && pdata->use_rbuf_gain2) ? 0 : AD5791_CTRL_RBUF) | 407 406 AD5791_CTRL_BIN2SC; 408 407 409 - ret = ad5791_spi_write(spi, AD5791_ADDR_CTRL, st->ctrl | 408 + ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl | 410 409 AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI); 411 410 if (ret) 412 411 goto error_disable_reg_neg;
-1
drivers/iio/dac/max517.c
··· 146 146 .channel = (chan), \ 147 147 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ 148 148 BIT(IIO_CHAN_INFO_SCALE), \ 149 - .scan_type = IIO_ST('u', 8, 8, 0), \ 150 149 } 151 150 152 151 static const struct iio_chan_spec max517_channels[] = {
-1
drivers/iio/dac/mcp4725.c
··· 209 209 .channel = 0, 210 210 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), 211 211 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), 212 - .scan_type = IIO_ST('u', 12, 16, 0), 213 212 .ext_info = mcp4725_ext_info, 214 213 }; 215 214
+15
drivers/iio/humidity/Kconfig
··· 1 + # 2 + # humidity sensor drivers 3 + # 4 + menu "Humidity sensors" 5 + 6 + config DHT11 7 + tristate "DHT11 (and compatible sensors) driver" 8 + depends on GPIOLIB 9 + help 10 + This driver supports reading data via a single interrupt 11 + generating GPIO line. Currently tested are DHT11 and DHT22. 12 + Other sensors should work as well as long as they speak the 13 + same protocol. 14 + 15 + endmenu
+5
drivers/iio/humidity/Makefile
··· 1 + # 2 + # Makefile for IIO humidity sensor drivers 3 + # 4 + 5 + obj-$(CONFIG_DHT11) += dht11.o
+294
drivers/iio/humidity/dht11.c
··· 1 + /* 2 + * DHT11/DHT22 bit banging GPIO driver 3 + * 4 + * Copyright (c) Harald Geyer <harald@ccbib.org> 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the terms of the GNU General Public License as published by 8 + * the Free Software Foundation; either version 2 of the License, or 9 + * (at your option) any later version. 10 + * 11 + * This program is distributed in the hope that it will be useful, 12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 + * GNU General Public License for more details. 15 + */ 16 + 17 + #include <linux/err.h> 18 + #include <linux/interrupt.h> 19 + #include <linux/device.h> 20 + #include <linux/kernel.h> 21 + #include <linux/printk.h> 22 + #include <linux/slab.h> 23 + #include <linux/of.h> 24 + #include <linux/of_device.h> 25 + #include <linux/sysfs.h> 26 + #include <linux/io.h> 27 + #include <linux/module.h> 28 + #include <linux/platform_device.h> 29 + #include <linux/wait.h> 30 + #include <linux/bitops.h> 31 + #include <linux/completion.h> 32 + #include <linux/delay.h> 33 + #include <linux/gpio.h> 34 + #include <linux/of_gpio.h> 35 + 36 + #include <linux/iio/iio.h> 37 + 38 + #define DRIVER_NAME "dht11" 39 + 40 + #define DHT11_DATA_VALID_TIME 2000000000 /* 2s in ns */ 41 + 42 + #define DHT11_EDGES_PREAMBLE 4 43 + #define DHT11_BITS_PER_READ 40 44 + #define DHT11_EDGES_PER_READ (2*DHT11_BITS_PER_READ + DHT11_EDGES_PREAMBLE + 1) 45 + 46 + /* Data transmission timing (nano seconds) */ 47 + #define DHT11_START_TRANSMISSION 18 /* ms */ 48 + #define DHT11_SENSOR_RESPONSE 80000 49 + #define DHT11_START_BIT 50000 50 + #define DHT11_DATA_BIT_LOW 27000 51 + #define DHT11_DATA_BIT_HIGH 70000 52 + 53 + struct dht11 { 54 + struct device *dev; 55 + 56 + int gpio; 57 + int irq; 58 + 59 + struct completion completion; 60 + 61 + s64 timestamp; 62 + int temperature; 63 + int humidity; 64 + 65 + /* num_edges: -1 means "no transmission in progress" */ 66 + int num_edges; 67 + struct {s64 ts; int value; } edges[DHT11_EDGES_PER_READ]; 68 + }; 69 + 70 + static unsigned char dht11_decode_byte(int *timing, int threshold) 71 + { 72 + unsigned char ret = 0; 73 + int i; 74 + 75 + for (i = 0; i < 8; ++i) { 76 + ret <<= 1; 77 + if (timing[i] >= threshold) 78 + ++ret; 79 + } 80 + 81 + return ret; 82 + } 83 + 84 + static int dht11_decode(struct dht11 *dht11, int offset) 85 + { 86 + int i, t, timing[DHT11_BITS_PER_READ], threshold, 87 + timeres = DHT11_SENSOR_RESPONSE; 88 + unsigned char temp_int, temp_dec, hum_int, hum_dec, checksum; 89 + 90 + /* Calculate timestamp resolution */ 91 + for (i = 0; i < dht11->num_edges; ++i) { 92 + t = dht11->edges[i].ts - dht11->edges[i-1].ts; 93 + if (t > 0 && t < timeres) 94 + timeres = t; 95 + } 96 + if (2*timeres > DHT11_DATA_BIT_HIGH) { 97 + pr_err("dht11: timeresolution %d too bad for decoding\n", 98 + timeres); 99 + return -EIO; 100 + } 101 + threshold = DHT11_DATA_BIT_HIGH / timeres; 102 + if (DHT11_DATA_BIT_LOW/timeres + 1 >= threshold) 103 + pr_err("dht11: WARNING: decoding ambiguous\n"); 104 + 105 + /* scale down with timeres and check validity */ 106 + for (i = 0; i < DHT11_BITS_PER_READ; ++i) { 107 + t = dht11->edges[offset + 2*i + 2].ts - 108 + dht11->edges[offset + 2*i + 1].ts; 109 + if (!dht11->edges[offset + 2*i + 1].value) 110 + return -EIO; /* lost synchronisation */ 111 + timing[i] = t / timeres; 112 + } 113 + 114 + hum_int = dht11_decode_byte(timing, threshold); 115 + hum_dec = dht11_decode_byte(&timing[8], threshold); 116 + temp_int = dht11_decode_byte(&timing[16], threshold); 117 + temp_dec = dht11_decode_byte(&timing[24], threshold); 118 + checksum = dht11_decode_byte(&timing[32], threshold); 119 + 120 + if (((hum_int + hum_dec + temp_int + temp_dec) & 0xff) != checksum) 121 + return -EIO; 122 + 123 + dht11->timestamp = iio_get_time_ns(); 124 + if (hum_int < 20) { /* DHT22 */ 125 + dht11->temperature = (((temp_int & 0x7f) << 8) + temp_dec) * 126 + ((temp_int & 0x80) ? -100 : 100); 127 + dht11->humidity = ((hum_int << 8) + hum_dec) * 100; 128 + } else if (temp_dec == 0 && hum_dec == 0) { /* DHT11 */ 129 + dht11->temperature = temp_int * 1000; 130 + dht11->humidity = hum_int * 1000; 131 + } else { 132 + dev_err(dht11->dev, 133 + "Don't know how to decode data: %d %d %d %d\n", 134 + hum_int, hum_dec, temp_int, temp_dec); 135 + return -EIO; 136 + } 137 + 138 + return 0; 139 + } 140 + 141 + static int dht11_read_raw(struct iio_dev *iio_dev, 142 + const struct iio_chan_spec *chan, 143 + int *val, int *val2, long m) 144 + { 145 + struct dht11 *dht11 = iio_priv(iio_dev); 146 + int ret; 147 + 148 + if (dht11->timestamp + DHT11_DATA_VALID_TIME < iio_get_time_ns()) { 149 + reinit_completion(&dht11->completion); 150 + 151 + dht11->num_edges = 0; 152 + ret = gpio_direction_output(dht11->gpio, 0); 153 + if (ret) 154 + goto err; 155 + msleep(DHT11_START_TRANSMISSION); 156 + ret = gpio_direction_input(dht11->gpio); 157 + if (ret) 158 + goto err; 159 + 160 + ret = wait_for_completion_killable_timeout(&dht11->completion, 161 + HZ); 162 + if (ret == 0 && dht11->num_edges < DHT11_EDGES_PER_READ - 1) { 163 + dev_err(&iio_dev->dev, 164 + "Only %d signal edges detected\n", 165 + dht11->num_edges); 166 + ret = -ETIMEDOUT; 167 + } 168 + if (ret < 0) 169 + goto err; 170 + 171 + ret = dht11_decode(dht11, 172 + dht11->num_edges == DHT11_EDGES_PER_READ ? 173 + DHT11_EDGES_PREAMBLE : 174 + DHT11_EDGES_PREAMBLE - 2); 175 + if (ret) 176 + goto err; 177 + } 178 + 179 + ret = IIO_VAL_INT; 180 + if (chan->type == IIO_TEMP) 181 + *val = dht11->temperature; 182 + else if (chan->type == IIO_HUMIDITYRELATIVE) 183 + *val = dht11->humidity; 184 + else 185 + ret = -EINVAL; 186 + err: 187 + dht11->num_edges = -1; 188 + return ret; 189 + } 190 + 191 + static const struct iio_info dht11_iio_info = { 192 + .driver_module = THIS_MODULE, 193 + .read_raw = dht11_read_raw, 194 + }; 195 + 196 + /* 197 + * IRQ handler called on GPIO edges 198 + */ 199 + static irqreturn_t dht11_handle_irq(int irq, void *data) 200 + { 201 + struct iio_dev *iio = data; 202 + struct dht11 *dht11 = iio_priv(iio); 203 + 204 + /* TODO: Consider making the handler safe for IRQ sharing */ 205 + if (dht11->num_edges < DHT11_EDGES_PER_READ && dht11->num_edges >= 0) { 206 + dht11->edges[dht11->num_edges].ts = iio_get_time_ns(); 207 + dht11->edges[dht11->num_edges++].value = 208 + gpio_get_value(dht11->gpio); 209 + 210 + if (dht11->num_edges >= DHT11_EDGES_PER_READ) 211 + complete(&dht11->completion); 212 + } 213 + 214 + return IRQ_HANDLED; 215 + } 216 + 217 + static const struct iio_chan_spec dht11_chan_spec[] = { 218 + { .type = IIO_TEMP, 219 + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), }, 220 + { .type = IIO_HUMIDITYRELATIVE, 221 + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), } 222 + }; 223 + 224 + static const struct of_device_id dht11_dt_ids[] = { 225 + { .compatible = "dht11", }, 226 + { } 227 + }; 228 + MODULE_DEVICE_TABLE(of, dht11_dt_ids); 229 + 230 + static int dht11_probe(struct platform_device *pdev) 231 + { 232 + struct device *dev = &pdev->dev; 233 + struct device_node *node = dev->of_node; 234 + struct dht11 *dht11; 235 + struct iio_dev *iio; 236 + int ret; 237 + 238 + iio = devm_iio_device_alloc(dev, sizeof(*dht11)); 239 + if (!iio) { 240 + dev_err(dev, "Failed to allocate IIO device\n"); 241 + return -ENOMEM; 242 + } 243 + 244 + dht11 = iio_priv(iio); 245 + dht11->dev = dev; 246 + 247 + dht11->gpio = ret = of_get_gpio(node, 0); 248 + if (ret < 0) 249 + return ret; 250 + ret = devm_gpio_request_one(dev, dht11->gpio, GPIOF_IN, pdev->name); 251 + if (ret) 252 + return ret; 253 + 254 + dht11->irq = gpio_to_irq(dht11->gpio); 255 + if (dht11->irq < 0) { 256 + dev_err(dev, "GPIO %d has no interrupt\n", dht11->gpio); 257 + return -EINVAL; 258 + } 259 + ret = devm_request_irq(dev, dht11->irq, dht11_handle_irq, 260 + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, 261 + pdev->name, iio); 262 + if (ret) 263 + return ret; 264 + 265 + dht11->timestamp = iio_get_time_ns() - DHT11_DATA_VALID_TIME - 1; 266 + dht11->num_edges = -1; 267 + 268 + platform_set_drvdata(pdev, iio); 269 + 270 + init_completion(&dht11->completion); 271 + iio->name = pdev->name; 272 + iio->dev.parent = &pdev->dev; 273 + iio->info = &dht11_iio_info; 274 + iio->modes = INDIO_DIRECT_MODE; 275 + iio->channels = dht11_chan_spec; 276 + iio->num_channels = ARRAY_SIZE(dht11_chan_spec); 277 + 278 + return devm_iio_device_register(dev, iio); 279 + } 280 + 281 + static struct platform_driver dht11_driver = { 282 + .driver = { 283 + .name = DRIVER_NAME, 284 + .owner = THIS_MODULE, 285 + .of_match_table = dht11_dt_ids, 286 + }, 287 + .probe = dht11_probe, 288 + }; 289 + 290 + module_platform_driver(dht11_driver); 291 + 292 + MODULE_AUTHOR("Harald Geyer <harald@ccbib.org>"); 293 + MODULE_DESCRIPTION("DHT11 humidity/temperature sensor driver"); 294 + MODULE_LICENSE("GPL v2");
+31 -2
drivers/iio/industrialio-buffer.c
··· 37 37 return !list_empty(&buf->buffer_list); 38 38 } 39 39 40 + static bool iio_buffer_data_available(struct iio_buffer *buf) 41 + { 42 + if (buf->access->data_available) 43 + return buf->access->data_available(buf); 44 + 45 + return buf->stufftoread; 46 + } 47 + 40 48 /** 41 49 * iio_buffer_read_first_n_outer() - chrdev read for buffer access 42 50 * ··· 56 48 { 57 49 struct iio_dev *indio_dev = filp->private_data; 58 50 struct iio_buffer *rb = indio_dev->buffer; 51 + int ret; 59 52 60 53 if (!indio_dev->info) 61 54 return -ENODEV; 62 55 63 56 if (!rb || !rb->access->read_first_n) 64 57 return -EINVAL; 65 - return rb->access->read_first_n(rb, n, buf); 58 + 59 + do { 60 + if (!iio_buffer_data_available(rb)) { 61 + if (filp->f_flags & O_NONBLOCK) 62 + return -EAGAIN; 63 + 64 + ret = wait_event_interruptible(rb->pollq, 65 + iio_buffer_data_available(rb) || 66 + indio_dev->info == NULL); 67 + if (ret) 68 + return ret; 69 + if (indio_dev->info == NULL) 70 + return -ENODEV; 71 + } 72 + 73 + ret = rb->access->read_first_n(rb, n, buf); 74 + if (ret == 0 && (filp->f_flags & O_NONBLOCK)) 75 + ret = -EAGAIN; 76 + } while (ret == 0); 77 + 78 + return ret; 66 79 } 67 80 68 81 /** ··· 99 70 return -ENODEV; 100 71 101 72 poll_wait(filp, &rb->pollq, wait); 102 - if (rb->stufftoread) 73 + if (iio_buffer_data_available(rb)) 103 74 return POLLIN | POLLRDNORM; 104 75 /* need a way of knowing if there may be enough data... */ 105 76 return 0;
+1
drivers/iio/industrialio-core.c
··· 69 69 [IIO_ALTVOLTAGE] = "altvoltage", 70 70 [IIO_CCT] = "cct", 71 71 [IIO_PRESSURE] = "pressure", 72 + [IIO_HUMIDITYRELATIVE] = "humidityrelative", 72 73 }; 73 74 74 75 static const char * const iio_modifier_names[] = {
+22 -132
drivers/iio/industrialio-event.c
··· 242 242 if (ret < 0) 243 243 return ret; 244 244 245 - if (indio_dev->info->write_event_config) 246 - ret = indio_dev->info->write_event_config(indio_dev, 247 - this_attr->address, val); 248 - else 249 - ret = indio_dev->info->write_event_config_new(indio_dev, 250 - this_attr->c, iio_ev_attr_type(this_attr), 251 - iio_ev_attr_dir(this_attr), val); 245 + ret = indio_dev->info->write_event_config(indio_dev, 246 + this_attr->c, iio_ev_attr_type(this_attr), 247 + iio_ev_attr_dir(this_attr), val); 252 248 253 249 return (ret < 0) ? ret : len; 254 250 } ··· 257 261 struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); 258 262 int val; 259 263 260 - if (indio_dev->info->read_event_config) 261 - val = indio_dev->info->read_event_config(indio_dev, 262 - this_attr->address); 263 - else 264 - val = indio_dev->info->read_event_config_new(indio_dev, 265 - this_attr->c, iio_ev_attr_type(this_attr), 266 - iio_ev_attr_dir(this_attr)); 264 + val = indio_dev->info->read_event_config(indio_dev, 265 + this_attr->c, iio_ev_attr_type(this_attr), 266 + iio_ev_attr_dir(this_attr)); 267 267 if (val < 0) 268 268 return val; 269 269 else ··· 275 283 int val, val2; 276 284 int ret; 277 285 278 - if (indio_dev->info->read_event_value) { 279 - ret = indio_dev->info->read_event_value(indio_dev, 280 - this_attr->address, &val); 281 - if (ret < 0) 282 - return ret; 283 - return sprintf(buf, "%d\n", val); 284 - } else { 285 - ret = indio_dev->info->read_event_value_new(indio_dev, 286 - this_attr->c, iio_ev_attr_type(this_attr), 287 - iio_ev_attr_dir(this_attr), iio_ev_attr_info(this_attr), 288 - &val, &val2); 289 - if (ret < 0) 290 - return ret; 291 - return iio_format_value(buf, ret, val, val2); 292 - } 286 + ret = indio_dev->info->read_event_value(indio_dev, 287 + this_attr->c, iio_ev_attr_type(this_attr), 288 + iio_ev_attr_dir(this_attr), iio_ev_attr_info(this_attr), 289 + &val, &val2); 290 + if (ret < 0) 291 + return ret; 292 + return iio_format_value(buf, ret, val, val2); 293 293 } 294 294 295 295 static ssize_t iio_ev_value_store(struct device *dev, ··· 294 310 int val, val2; 295 311 int ret; 296 312 297 - if (!indio_dev->info->write_event_value && 298 - !indio_dev->info->write_event_value_new) 313 + if (!indio_dev->info->write_event_value) 299 314 return -EINVAL; 300 315 301 - if (indio_dev->info->write_event_value) { 302 - ret = kstrtoint(buf, 10, &val); 303 - if (ret) 304 - return ret; 305 - ret = indio_dev->info->write_event_value(indio_dev, 306 - this_attr->address, val); 307 - } else { 308 - ret = iio_str_to_fixpoint(buf, 100000, &val, &val2); 309 - if (ret) 310 - return ret; 311 - ret = indio_dev->info->write_event_value_new(indio_dev, 312 - this_attr->c, iio_ev_attr_type(this_attr), 313 - iio_ev_attr_dir(this_attr), iio_ev_attr_info(this_attr), 314 - val, val2); 315 - } 316 + ret = iio_str_to_fixpoint(buf, 100000, &val, &val2); 317 + if (ret) 318 + return ret; 319 + ret = indio_dev->info->write_event_value(indio_dev, 320 + this_attr->c, iio_ev_attr_type(this_attr), 321 + iio_ev_attr_dir(this_attr), iio_ev_attr_info(this_attr), 322 + val, val2); 316 323 if (ret < 0) 317 324 return ret; 318 325 ··· 352 377 return attrcount; 353 378 } 354 379 355 - static int iio_device_add_event_sysfs_new(struct iio_dev *indio_dev, 380 + static int iio_device_add_event_sysfs(struct iio_dev *indio_dev, 356 381 struct iio_chan_spec const *chan) 357 382 { 358 383 int ret = 0, i, attrcount = 0; ··· 395 420 return ret; 396 421 } 397 422 398 - static int iio_device_add_event_sysfs_old(struct iio_dev *indio_dev, 399 - struct iio_chan_spec const *chan) 400 - { 401 - int ret = 0, i, attrcount = 0; 402 - u64 mask = 0; 403 - char *postfix; 404 - if (!chan->event_mask) 405 - return 0; 406 - 407 - for_each_set_bit(i, &chan->event_mask, sizeof(chan->event_mask)*8) { 408 - postfix = kasprintf(GFP_KERNEL, "%s_%s_en", 409 - iio_ev_type_text[i/IIO_EV_DIR_MAX], 410 - iio_ev_dir_text[i%IIO_EV_DIR_MAX]); 411 - if (postfix == NULL) { 412 - ret = -ENOMEM; 413 - goto error_ret; 414 - } 415 - if (chan->modified) 416 - mask = IIO_MOD_EVENT_CODE(chan->type, 0, chan->channel2, 417 - i/IIO_EV_DIR_MAX, 418 - i%IIO_EV_DIR_MAX); 419 - else if (chan->differential) 420 - mask = IIO_EVENT_CODE(chan->type, 421 - 0, 0, 422 - i%IIO_EV_DIR_MAX, 423 - i/IIO_EV_DIR_MAX, 424 - 0, 425 - chan->channel, 426 - chan->channel2); 427 - else 428 - mask = IIO_UNMOD_EVENT_CODE(chan->type, 429 - chan->channel, 430 - i/IIO_EV_DIR_MAX, 431 - i%IIO_EV_DIR_MAX); 432 - 433 - ret = __iio_add_chan_devattr(postfix, 434 - chan, 435 - &iio_ev_state_show, 436 - iio_ev_state_store, 437 - mask, 438 - 0, 439 - &indio_dev->dev, 440 - &indio_dev->event_interface-> 441 - dev_attr_list); 442 - kfree(postfix); 443 - if (ret) 444 - goto error_ret; 445 - attrcount++; 446 - postfix = kasprintf(GFP_KERNEL, "%s_%s_value", 447 - iio_ev_type_text[i/IIO_EV_DIR_MAX], 448 - iio_ev_dir_text[i%IIO_EV_DIR_MAX]); 449 - if (postfix == NULL) { 450 - ret = -ENOMEM; 451 - goto error_ret; 452 - } 453 - ret = __iio_add_chan_devattr(postfix, chan, 454 - iio_ev_value_show, 455 - iio_ev_value_store, 456 - mask, 457 - 0, 458 - &indio_dev->dev, 459 - &indio_dev->event_interface-> 460 - dev_attr_list); 461 - kfree(postfix); 462 - if (ret) 463 - goto error_ret; 464 - attrcount++; 465 - } 466 - ret = attrcount; 467 - error_ret: 468 - return ret; 469 - } 470 - 471 - 472 - static int iio_device_add_event_sysfs(struct iio_dev *indio_dev, 473 - struct iio_chan_spec const *chan) 474 - { 475 - if (chan->event_mask) 476 - return iio_device_add_event_sysfs_old(indio_dev, chan); 477 - else 478 - return iio_device_add_event_sysfs_new(indio_dev, chan); 479 - } 480 - 481 423 static inline int __iio_add_event_config_attrs(struct iio_dev *indio_dev) 482 424 { 483 425 int j, ret, attrcount = 0; ··· 415 523 int j; 416 524 417 525 for (j = 0; j < indio_dev->num_channels; j++) { 418 - if (indio_dev->channels[j].event_mask != 0) 419 - return true; 420 526 if (indio_dev->channels[j].num_event_specs != 0) 421 527 return true; 422 528 }
+2 -10
drivers/iio/industrialio-trigger.c
··· 55 55 &dev_attr_name.attr, 56 56 NULL, 57 57 }; 58 - 59 - static struct attribute_group iio_trig_attr_group = { 60 - .attrs = iio_trig_dev_attrs, 61 - }; 62 - 63 - static const struct attribute_group *iio_trig_attr_groups[] = { 64 - &iio_trig_attr_group, 65 - NULL 66 - }; 58 + ATTRIBUTE_GROUPS(iio_trig_dev); 67 59 68 60 int iio_trigger_register(struct iio_trigger *trig_info) 69 61 { ··· 395 403 396 404 static struct device_type iio_trig_type = { 397 405 .release = iio_trig_release, 398 - .groups = iio_trig_attr_groups, 406 + .groups = iio_trig_dev_groups, 399 407 }; 400 408 401 409 static void iio_trig_subirqmask(struct irq_data *d)
+14 -9
drivers/iio/kfifo_buf.c
··· 42 42 } else { 43 43 kfifo_reset_out(&buf->kf); 44 44 } 45 - r->stufftoread = false; 46 45 mutex_unlock(&buf->user_lock); 47 46 48 47 return ret; ··· 107 108 ret = kfifo_in(&kf->kf, data, 1); 108 109 if (ret != 1) 109 110 return -EBUSY; 110 - r->stufftoread = true; 111 + 111 112 wake_up_interruptible_poll(&r->pollq, POLLIN | POLLRDNORM); 112 113 113 114 return 0; ··· 126 127 ret = -EINVAL; 127 128 else 128 129 ret = kfifo_to_user(&kf->kf, buf, n, &copied); 129 - 130 - if (kfifo_is_empty(&kf->kf)) 131 - r->stufftoread = false; 132 - /* verify it is still empty to avoid race */ 133 - if (!kfifo_is_empty(&kf->kf)) 134 - r->stufftoread = true; 135 - 136 130 mutex_unlock(&kf->user_lock); 137 131 if (ret < 0) 138 132 return ret; 139 133 140 134 return copied; 135 + } 136 + 137 + static bool iio_kfifo_buf_data_available(struct iio_buffer *r) 138 + { 139 + struct iio_kfifo *kf = iio_to_kfifo(r); 140 + bool empty; 141 + 142 + mutex_lock(&kf->user_lock); 143 + empty = kfifo_is_empty(&kf->kf); 144 + mutex_unlock(&kf->user_lock); 145 + 146 + return !empty; 141 147 } 142 148 143 149 static void iio_kfifo_buffer_release(struct iio_buffer *buffer) ··· 157 153 static const struct iio_buffer_access_funcs kfifo_access_funcs = { 158 154 .store_to = &iio_store_to_kfifo, 159 155 .read_first_n = &iio_read_first_n_kfifo, 156 + .data_available = iio_kfifo_buf_data_available, 160 157 .request_update = &iio_request_update_kfifo, 161 158 .get_bytes_per_datum = &iio_get_bytes_per_datum_kfifo, 162 159 .set_bytes_per_datum = &iio_set_bytes_per_datum_kfifo,
+6 -1
drivers/iio/light/adjd_s311.c
··· 155 155 BIT(IIO_CHAN_INFO_INT_TIME), \ 156 156 .channel2 = (IIO_MOD_LIGHT_##_color), \ 157 157 .scan_index = (_scan_idx), \ 158 - .scan_type = IIO_ST('u', 10, 16, 0), \ 158 + .scan_type = { \ 159 + .sign = 'u', \ 160 + .realbits = 10, \ 161 + .storagebits = 16, \ 162 + .endianness = IIO_CPU, \ 163 + }, \ 159 164 } 160 165 161 166 static const struct iio_chan_spec adjd_s311_channels[] = {
+4 -4
drivers/iio/light/apds9300.c
··· 344 344 static const struct iio_info apds9300_info = { 345 345 .driver_module = THIS_MODULE, 346 346 .read_raw = apds9300_read_raw, 347 - .read_event_value_new = apds9300_read_thresh, 348 - .write_event_value_new = apds9300_write_thresh, 349 - .read_event_config_new = apds9300_read_interrupt_config, 350 - .write_event_config_new = apds9300_write_interrupt_config, 347 + .read_event_value = apds9300_read_thresh, 348 + .write_event_value = apds9300_write_thresh, 349 + .read_event_config = apds9300_read_interrupt_config, 350 + .write_event_config = apds9300_write_interrupt_config, 351 351 }; 352 352 353 353 static const struct iio_event_spec apds9300_event_spec[] = {
+29 -6
drivers/iio/light/cm36651.c
··· 488 488 } 489 489 490 490 static int cm36651_read_prox_thresh(struct iio_dev *indio_dev, 491 - u64 event_code, int *val) 491 + const struct iio_chan_spec *chan, 492 + enum iio_event_type type, 493 + enum iio_event_direction dir, 494 + enum iio_event_info info, 495 + int *val, int *val2) 492 496 { 493 497 struct cm36651_data *cm36651 = iio_priv(indio_dev); 494 498 ··· 502 498 } 503 499 504 500 static int cm36651_write_prox_thresh(struct iio_dev *indio_dev, 505 - u64 event_code, int val) 501 + const struct iio_chan_spec *chan, 502 + enum iio_event_type type, 503 + enum iio_event_direction dir, 504 + enum iio_event_info info, 505 + int val, int val2) 506 506 { 507 507 struct cm36651_data *cm36651 = iio_priv(indio_dev); 508 508 struct i2c_client *client = cm36651->client; ··· 528 520 } 529 521 530 522 static int cm36651_write_prox_event_config(struct iio_dev *indio_dev, 531 - u64 event_code, int state) 523 + const struct iio_chan_spec *chan, 524 + enum iio_event_type type, 525 + enum iio_event_direction dir, 526 + int state) 532 527 { 533 528 struct cm36651_data *cm36651 = iio_priv(indio_dev); 534 529 int cmd, ret = -EINVAL; ··· 547 536 } 548 537 549 538 static int cm36651_read_prox_event_config(struct iio_dev *indio_dev, 550 - u64 event_code) 539 + const struct iio_chan_spec *chan, 540 + enum iio_event_type type, 541 + enum iio_event_direction dir) 551 542 { 552 543 struct cm36651_data *cm36651 = iio_priv(indio_dev); 553 544 int event_en; ··· 572 559 .channel2 = IIO_MOD_LIGHT_##_color, \ 573 560 } \ 574 561 562 + static const struct iio_event_spec cm36651_event_spec[] = { 563 + { 564 + .type = IIO_EV_TYPE_THRESH, 565 + .dir = IIO_EV_DIR_EITHER, 566 + .mask_separate = BIT(IIO_EV_INFO_VALUE) | 567 + BIT(IIO_EV_INFO_ENABLE), 568 + } 569 + }; 570 + 575 571 static const struct iio_chan_spec cm36651_channels[] = { 576 572 { 577 573 .type = IIO_PROXIMITY, 578 574 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | 579 575 BIT(IIO_CHAN_INFO_INT_TIME), 580 - .event_mask = IIO_EV_BIT(IIO_EV_TYPE_THRESH, IIO_EV_DIR_EITHER) 576 + .event_spec = cm36651_event_spec, 577 + .num_event_specs = ARRAY_SIZE(cm36651_event_spec), 581 578 }, 582 579 CM36651_LIGHT_CHANNEL(RED, CM36651_LIGHT_CHANNEL_IDX_RED), 583 580 CM36651_LIGHT_CHANNEL(GREEN, CM36651_LIGHT_CHANNEL_IDX_GREEN), ··· 716 693 static struct i2c_driver cm36651_driver = { 717 694 .driver = { 718 695 .name = "cm36651", 719 - .of_match_table = of_match_ptr(cm36651_of_match), 696 + .of_match_table = cm36651_of_match, 720 697 .owner = THIS_MODULE, 721 698 }, 722 699 .probe = cm36651_probe,
+4 -4
drivers/iio/light/gp2ap020a00f.c
··· 1388 1388 1389 1389 static const struct iio_info gp2ap020a00f_info = { 1390 1390 .read_raw = &gp2ap020a00f_read_raw, 1391 - .read_event_value_new = &gp2ap020a00f_read_event_val, 1392 - .read_event_config_new = &gp2ap020a00f_read_event_config, 1393 - .write_event_value_new = &gp2ap020a00f_write_event_val, 1394 - .write_event_config_new = &gp2ap020a00f_write_event_config, 1391 + .read_event_value = &gp2ap020a00f_read_event_val, 1392 + .read_event_config = &gp2ap020a00f_read_event_config, 1393 + .write_event_value = &gp2ap020a00f_write_event_val, 1394 + .write_event_config = &gp2ap020a00f_write_event_config, 1395 1395 .driver_module = THIS_MODULE, 1396 1396 }; 1397 1397
+6 -1
drivers/iio/light/tcs3472.c
··· 67 67 .channel2 = IIO_MOD_LIGHT_##_color, \ 68 68 .address = _addr, \ 69 69 .scan_index = _si, \ 70 - .scan_type = IIO_ST('u', 16, 16, 0), \ 70 + .scan_type = { \ 71 + .sign = 'u', \ 72 + .realbits = 16, \ 73 + .storagebits = 16, \ 74 + .endianness = IIO_CPU, \ 75 + }, \ 71 76 } 72 77 73 78 static const int tcs3472_agains[] = { 1, 4, 16, 60 };
+4 -4
drivers/iio/light/tsl2563.c
··· 702 702 .driver_module = THIS_MODULE, 703 703 .read_raw = &tsl2563_read_raw, 704 704 .write_raw = &tsl2563_write_raw, 705 - .read_event_value_new = &tsl2563_read_thresh, 706 - .write_event_value_new = &tsl2563_write_thresh, 707 - .read_event_config_new = &tsl2563_read_interrupt_config, 708 - .write_event_config_new = &tsl2563_write_interrupt_config, 705 + .read_event_value = &tsl2563_read_thresh, 706 + .write_event_value = &tsl2563_write_thresh, 707 + .read_event_config = &tsl2563_read_interrupt_config, 708 + .write_event_config = &tsl2563_write_interrupt_config, 709 709 }; 710 710 711 711 static int tsl2563_probe(struct i2c_client *client,
+1 -1
drivers/iio/light/vcnl4000.c
··· 56 56 u8 rdy_mask, u8 data_reg, int *val) 57 57 { 58 58 int tries = 20; 59 - u16 buf; 59 + __be16 buf; 60 60 int ret; 61 61 62 62 ret = i2c_smbus_write_byte_data(data->client, VCNL4000_COMMAND,
+5 -1
drivers/iio/magnetometer/mag3110.c
··· 266 266 .type = IIO_TEMP, 267 267 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), 268 268 .scan_index = 3, 269 - .scan_type = IIO_ST('s', 8, 8, 0), 269 + .scan_type = { 270 + .sign = 's', 271 + .realbits = 8, 272 + .storagebits = 8, 273 + }, 270 274 }, 271 275 IIO_CHAN_SOFT_TIMESTAMP(4), 272 276 };
+19
drivers/iio/orientation/Kconfig
··· 1 + # 2 + # Inclinometer sensors 3 + # 4 + # When adding new entries keep the list in alphabetical order 5 + 6 + menu "Inclinometer sensors" 7 + 8 + config HID_SENSOR_INCLINOMETER_3D 9 + depends on HID_SENSOR_HUB 10 + select IIO_BUFFER 11 + select IIO_TRIGGERED_BUFFER 12 + select HID_SENSOR_IIO_COMMON 13 + select HID_SENSOR_IIO_TRIGGER 14 + tristate "HID Inclinometer 3D" 15 + help 16 + Say yes here to build support for the HID SENSOR 17 + Inclinometer 3D. 18 + 19 + endmenu
+6
drivers/iio/orientation/Makefile
··· 1 + # 2 + # Makefile for industrial I/O Inclinometer sensor drivers 3 + # 4 + 5 + # When adding new entries keep the list in alphabetical order 6 + obj-$(CONFIG_HID_SENSOR_INCLINOMETER_3D) += hid-sensor-incl-3d.o
+428
drivers/iio/orientation/hid-sensor-incl-3d.c
··· 1 + /* 2 + * HID Sensors Driver 3 + * Copyright (c) 2013, Intel Corporation. 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms and conditions of the GNU General Public License, 7 + * version 2, as published by the Free Software Foundation. 8 + * 9 + * This program is distributed in the hope it will be useful, but WITHOUT 10 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 + * more details. 13 + * 14 + * You should have received a copy of the GNU General Public License along with 15 + * this program; if not, write to the Free Software Foundation, Inc. 16 + * 17 + */ 18 + 19 + #include <linux/device.h> 20 + #include <linux/platform_device.h> 21 + #include <linux/module.h> 22 + #include <linux/interrupt.h> 23 + #include <linux/irq.h> 24 + #include <linux/slab.h> 25 + #include <linux/hid-sensor-hub.h> 26 + #include <linux/iio/iio.h> 27 + #include <linux/iio/sysfs.h> 28 + #include <linux/iio/buffer.h> 29 + #include <linux/iio/trigger_consumer.h> 30 + #include <linux/iio/triggered_buffer.h> 31 + #include "../common/hid-sensors/hid-sensor-trigger.h" 32 + 33 + enum incl_3d_channel { 34 + CHANNEL_SCAN_INDEX_X, 35 + CHANNEL_SCAN_INDEX_Y, 36 + CHANNEL_SCAN_INDEX_Z, 37 + INCLI_3D_CHANNEL_MAX, 38 + }; 39 + 40 + struct incl_3d_state { 41 + struct hid_sensor_hub_callbacks callbacks; 42 + struct hid_sensor_common common_attributes; 43 + struct hid_sensor_hub_attribute_info incl[INCLI_3D_CHANNEL_MAX]; 44 + u32 incl_val[INCLI_3D_CHANNEL_MAX]; 45 + }; 46 + 47 + static const u32 incl_3d_addresses[INCLI_3D_CHANNEL_MAX] = { 48 + HID_USAGE_SENSOR_ORIENT_TILT_X, 49 + HID_USAGE_SENSOR_ORIENT_TILT_Y, 50 + HID_USAGE_SENSOR_ORIENT_TILT_Z 51 + }; 52 + 53 + /* Channel definitions */ 54 + static const struct iio_chan_spec incl_3d_channels[] = { 55 + { 56 + .type = IIO_INCLI, 57 + .modified = 1, 58 + .channel2 = IIO_MOD_X, 59 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), 60 + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | 61 + BIT(IIO_CHAN_INFO_SCALE) | 62 + BIT(IIO_CHAN_INFO_SAMP_FREQ) | 63 + BIT(IIO_CHAN_INFO_HYSTERESIS), 64 + .scan_index = CHANNEL_SCAN_INDEX_X, 65 + }, { 66 + .type = IIO_INCLI, 67 + .modified = 1, 68 + .channel2 = IIO_MOD_Y, 69 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), 70 + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | 71 + BIT(IIO_CHAN_INFO_SCALE) | 72 + BIT(IIO_CHAN_INFO_SAMP_FREQ) | 73 + BIT(IIO_CHAN_INFO_HYSTERESIS), 74 + .scan_index = CHANNEL_SCAN_INDEX_Y, 75 + }, { 76 + .type = IIO_INCLI, 77 + .modified = 1, 78 + .channel2 = IIO_MOD_Z, 79 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), 80 + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | 81 + BIT(IIO_CHAN_INFO_SCALE) | 82 + BIT(IIO_CHAN_INFO_SAMP_FREQ) | 83 + BIT(IIO_CHAN_INFO_HYSTERESIS), 84 + .scan_index = CHANNEL_SCAN_INDEX_Z, 85 + } 86 + }; 87 + 88 + /* Adjust channel real bits based on report descriptor */ 89 + static void incl_3d_adjust_channel_bit_mask(struct iio_chan_spec *chan, 90 + int size) 91 + { 92 + chan->scan_type.sign = 's'; 93 + /* Real storage bits will change based on the report desc. */ 94 + chan->scan_type.realbits = size * 8; 95 + /* Maximum size of a sample to capture is u32 */ 96 + chan->scan_type.storagebits = sizeof(u32) * 8; 97 + } 98 + 99 + /* Channel read_raw handler */ 100 + static int incl_3d_read_raw(struct iio_dev *indio_dev, 101 + struct iio_chan_spec const *chan, 102 + int *val, int *val2, 103 + long mask) 104 + { 105 + struct incl_3d_state *incl_state = iio_priv(indio_dev); 106 + int report_id = -1; 107 + u32 address; 108 + int ret_type; 109 + 110 + *val = 0; 111 + *val2 = 0; 112 + switch (mask) { 113 + case IIO_CHAN_INFO_RAW: 114 + report_id = 115 + incl_state->incl[chan->scan_index].report_id; 116 + address = incl_3d_addresses[chan->scan_index]; 117 + if (report_id >= 0) 118 + *val = sensor_hub_input_attr_get_raw_value( 119 + incl_state->common_attributes.hsdev, 120 + HID_USAGE_SENSOR_INCLINOMETER_3D, address, 121 + report_id); 122 + else { 123 + return -EINVAL; 124 + } 125 + ret_type = IIO_VAL_INT; 126 + break; 127 + case IIO_CHAN_INFO_SCALE: 128 + *val = incl_state->incl[CHANNEL_SCAN_INDEX_X].units; 129 + ret_type = IIO_VAL_INT; 130 + break; 131 + case IIO_CHAN_INFO_OFFSET: 132 + *val = hid_sensor_convert_exponent( 133 + incl_state->incl[CHANNEL_SCAN_INDEX_X].unit_expo); 134 + ret_type = IIO_VAL_INT; 135 + break; 136 + case IIO_CHAN_INFO_SAMP_FREQ: 137 + ret_type = hid_sensor_read_samp_freq_value( 138 + &incl_state->common_attributes, val, val2); 139 + break; 140 + case IIO_CHAN_INFO_HYSTERESIS: 141 + ret_type = hid_sensor_read_raw_hyst_value( 142 + &incl_state->common_attributes, val, val2); 143 + break; 144 + default: 145 + ret_type = -EINVAL; 146 + break; 147 + } 148 + 149 + return ret_type; 150 + } 151 + 152 + /* Channel write_raw handler */ 153 + static int incl_3d_write_raw(struct iio_dev *indio_dev, 154 + struct iio_chan_spec const *chan, 155 + int val, 156 + int val2, 157 + long mask) 158 + { 159 + struct incl_3d_state *incl_state = iio_priv(indio_dev); 160 + int ret; 161 + 162 + switch (mask) { 163 + case IIO_CHAN_INFO_SAMP_FREQ: 164 + ret = hid_sensor_write_samp_freq_value( 165 + &incl_state->common_attributes, val, val2); 166 + break; 167 + case IIO_CHAN_INFO_HYSTERESIS: 168 + ret = hid_sensor_write_raw_hyst_value( 169 + &incl_state->common_attributes, val, val2); 170 + break; 171 + default: 172 + ret = -EINVAL; 173 + } 174 + 175 + return ret; 176 + } 177 + 178 + static const struct iio_info incl_3d_info = { 179 + .driver_module = THIS_MODULE, 180 + .read_raw = &incl_3d_read_raw, 181 + .write_raw = &incl_3d_write_raw, 182 + }; 183 + 184 + /* Function to push data to buffer */ 185 + static void hid_sensor_push_data(struct iio_dev *indio_dev, u8 *data, int len) 186 + { 187 + dev_dbg(&indio_dev->dev, "hid_sensor_push_data\n"); 188 + iio_push_to_buffers(indio_dev, (u8 *)data); 189 + } 190 + 191 + /* Callback handler to send event after all samples are received and captured */ 192 + static int incl_3d_proc_event(struct hid_sensor_hub_device *hsdev, 193 + unsigned usage_id, 194 + void *priv) 195 + { 196 + struct iio_dev *indio_dev = platform_get_drvdata(priv); 197 + struct incl_3d_state *incl_state = iio_priv(indio_dev); 198 + 199 + dev_dbg(&indio_dev->dev, "incl_3d_proc_event [%d]\n", 200 + incl_state->common_attributes.data_ready); 201 + if (incl_state->common_attributes.data_ready) 202 + hid_sensor_push_data(indio_dev, 203 + (u8 *)incl_state->incl_val, 204 + sizeof(incl_state->incl_val)); 205 + 206 + return 0; 207 + } 208 + 209 + /* Capture samples in local storage */ 210 + static int incl_3d_capture_sample(struct hid_sensor_hub_device *hsdev, 211 + unsigned usage_id, 212 + size_t raw_len, char *raw_data, 213 + void *priv) 214 + { 215 + struct iio_dev *indio_dev = platform_get_drvdata(priv); 216 + struct incl_3d_state *incl_state = iio_priv(indio_dev); 217 + int ret = 0; 218 + 219 + switch (usage_id) { 220 + case HID_USAGE_SENSOR_ORIENT_TILT_X: 221 + incl_state->incl_val[CHANNEL_SCAN_INDEX_X] = *(u32 *)raw_data; 222 + break; 223 + case HID_USAGE_SENSOR_ORIENT_TILT_Y: 224 + incl_state->incl_val[CHANNEL_SCAN_INDEX_Y] = *(u32 *)raw_data; 225 + break; 226 + case HID_USAGE_SENSOR_ORIENT_TILT_Z: 227 + incl_state->incl_val[CHANNEL_SCAN_INDEX_Z] = *(u32 *)raw_data; 228 + break; 229 + default: 230 + ret = -EINVAL; 231 + break; 232 + } 233 + 234 + return ret; 235 + } 236 + 237 + /* Parse report which is specific to an usage id*/ 238 + static int incl_3d_parse_report(struct platform_device *pdev, 239 + struct hid_sensor_hub_device *hsdev, 240 + struct iio_chan_spec *channels, 241 + unsigned usage_id, 242 + struct incl_3d_state *st) 243 + { 244 + int ret; 245 + 246 + ret = sensor_hub_input_get_attribute_info(hsdev, 247 + HID_INPUT_REPORT, 248 + usage_id, 249 + HID_USAGE_SENSOR_ORIENT_TILT_X, 250 + &st->incl[CHANNEL_SCAN_INDEX_X]); 251 + if (ret) 252 + return ret; 253 + incl_3d_adjust_channel_bit_mask(&channels[CHANNEL_SCAN_INDEX_X], 254 + st->incl[CHANNEL_SCAN_INDEX_X].size); 255 + 256 + ret = sensor_hub_input_get_attribute_info(hsdev, 257 + HID_INPUT_REPORT, 258 + usage_id, 259 + HID_USAGE_SENSOR_ORIENT_TILT_Y, 260 + &st->incl[CHANNEL_SCAN_INDEX_Y]); 261 + if (ret) 262 + return ret; 263 + incl_3d_adjust_channel_bit_mask(&channels[CHANNEL_SCAN_INDEX_Y], 264 + st->incl[CHANNEL_SCAN_INDEX_Y].size); 265 + 266 + ret = sensor_hub_input_get_attribute_info(hsdev, 267 + HID_INPUT_REPORT, 268 + usage_id, 269 + HID_USAGE_SENSOR_ORIENT_TILT_Z, 270 + &st->incl[CHANNEL_SCAN_INDEX_Z]); 271 + if (ret) 272 + return ret; 273 + incl_3d_adjust_channel_bit_mask(&channels[CHANNEL_SCAN_INDEX_Z], 274 + st->incl[CHANNEL_SCAN_INDEX_Z].size); 275 + 276 + dev_dbg(&pdev->dev, "incl_3d %x:%x, %x:%x, %x:%x\n", 277 + st->incl[0].index, 278 + st->incl[0].report_id, 279 + st->incl[1].index, st->incl[1].report_id, 280 + st->incl[2].index, st->incl[2].report_id); 281 + 282 + /* Set Sensitivity field ids, when there is no individual modifier */ 283 + if (st->common_attributes.sensitivity.index < 0) { 284 + sensor_hub_input_get_attribute_info(hsdev, 285 + HID_FEATURE_REPORT, usage_id, 286 + HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS | 287 + HID_USAGE_SENSOR_DATA_ORIENTATION, 288 + &st->common_attributes.sensitivity); 289 + dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n", 290 + st->common_attributes.sensitivity.index, 291 + st->common_attributes.sensitivity.report_id); 292 + } 293 + return ret; 294 + } 295 + 296 + /* Function to initialize the processing for usage id */ 297 + static int hid_incl_3d_probe(struct platform_device *pdev) 298 + { 299 + int ret; 300 + static char *name = "incli_3d"; 301 + struct iio_dev *indio_dev; 302 + struct incl_3d_state *incl_state; 303 + struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; 304 + struct iio_chan_spec *channels; 305 + 306 + indio_dev = devm_iio_device_alloc(&pdev->dev, 307 + sizeof(struct incl_3d_state)); 308 + if (indio_dev == NULL) 309 + return -ENOMEM; 310 + 311 + platform_set_drvdata(pdev, indio_dev); 312 + 313 + incl_state = iio_priv(indio_dev); 314 + incl_state->common_attributes.hsdev = hsdev; 315 + incl_state->common_attributes.pdev = pdev; 316 + 317 + ret = hid_sensor_parse_common_attributes(hsdev, 318 + HID_USAGE_SENSOR_INCLINOMETER_3D, 319 + &incl_state->common_attributes); 320 + if (ret) { 321 + dev_err(&pdev->dev, "failed to setup common attributes\n"); 322 + return ret; 323 + } 324 + 325 + channels = kmemdup(incl_3d_channels, sizeof(incl_3d_channels), 326 + GFP_KERNEL); 327 + if (!channels) { 328 + dev_err(&pdev->dev, "failed to duplicate channels\n"); 329 + return -ENOMEM; 330 + } 331 + 332 + ret = incl_3d_parse_report(pdev, hsdev, channels, 333 + HID_USAGE_SENSOR_INCLINOMETER_3D, incl_state); 334 + if (ret) { 335 + dev_err(&pdev->dev, "failed to setup attributes\n"); 336 + goto error_free_dev_mem; 337 + } 338 + 339 + indio_dev->channels = channels; 340 + indio_dev->num_channels = ARRAY_SIZE(incl_3d_channels); 341 + indio_dev->dev.parent = &pdev->dev; 342 + indio_dev->info = &incl_3d_info; 343 + indio_dev->name = name; 344 + indio_dev->modes = INDIO_DIRECT_MODE; 345 + 346 + ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, 347 + NULL, NULL); 348 + if (ret) { 349 + dev_err(&pdev->dev, "failed to initialize trigger buffer\n"); 350 + goto error_free_dev_mem; 351 + } 352 + incl_state->common_attributes.data_ready = false; 353 + ret = hid_sensor_setup_trigger(indio_dev, name, 354 + &incl_state->common_attributes); 355 + if (ret) { 356 + dev_err(&pdev->dev, "trigger setup failed\n"); 357 + goto error_unreg_buffer_funcs; 358 + } 359 + 360 + ret = iio_device_register(indio_dev); 361 + if (ret) { 362 + dev_err(&pdev->dev, "device register failed\n"); 363 + goto error_remove_trigger; 364 + } 365 + 366 + incl_state->callbacks.send_event = incl_3d_proc_event; 367 + incl_state->callbacks.capture_sample = incl_3d_capture_sample; 368 + incl_state->callbacks.pdev = pdev; 369 + ret = sensor_hub_register_callback(hsdev, 370 + HID_USAGE_SENSOR_INCLINOMETER_3D, 371 + &incl_state->callbacks); 372 + if (ret) { 373 + dev_err(&pdev->dev, "callback reg failed\n"); 374 + goto error_iio_unreg; 375 + } 376 + 377 + return 0; 378 + 379 + error_iio_unreg: 380 + iio_device_unregister(indio_dev); 381 + error_remove_trigger: 382 + hid_sensor_remove_trigger(&incl_state->common_attributes); 383 + error_unreg_buffer_funcs: 384 + iio_triggered_buffer_cleanup(indio_dev); 385 + error_free_dev_mem: 386 + kfree(indio_dev->channels); 387 + return ret; 388 + } 389 + 390 + /* Function to deinitialize the processing for usage id */ 391 + static int hid_incl_3d_remove(struct platform_device *pdev) 392 + { 393 + struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; 394 + struct iio_dev *indio_dev = platform_get_drvdata(pdev); 395 + struct incl_3d_state *incl_state = iio_priv(indio_dev); 396 + 397 + sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_INCLINOMETER_3D); 398 + iio_device_unregister(indio_dev); 399 + hid_sensor_remove_trigger(&incl_state->common_attributes); 400 + iio_triggered_buffer_cleanup(indio_dev); 401 + kfree(indio_dev->channels); 402 + 403 + return 0; 404 + } 405 + 406 + static struct platform_device_id hid_incl_3d_ids[] = { 407 + { 408 + /* Format: HID-SENSOR-usage_id_in_hex_lowercase */ 409 + .name = "HID-SENSOR-200086", 410 + }, 411 + { /* sentinel */ } 412 + }; 413 + MODULE_DEVICE_TABLE(platform, hid_incl_3d_ids); 414 + 415 + static struct platform_driver hid_incl_3d_platform_driver = { 416 + .id_table = hid_incl_3d_ids, 417 + .driver = { 418 + .name = KBUILD_MODNAME, 419 + .owner = THIS_MODULE, 420 + }, 421 + .probe = hid_incl_3d_probe, 422 + .remove = hid_incl_3d_remove, 423 + }; 424 + module_platform_driver(hid_incl_3d_platform_driver); 425 + 426 + MODULE_DESCRIPTION("HID Sensor Inclinometer 3D"); 427 + MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>"); 428 + MODULE_LICENSE("GPL");
+4 -4
drivers/staging/iio/accel/lis3l02dq_core.c
··· 676 676 static const struct iio_info lis3l02dq_info = { 677 677 .read_raw = &lis3l02dq_read_raw, 678 678 .write_raw = &lis3l02dq_write_raw, 679 - .read_event_value_new = &lis3l02dq_read_thresh, 680 - .write_event_value_new = &lis3l02dq_write_thresh, 681 - .write_event_config_new = &lis3l02dq_write_event_config, 682 - .read_event_config_new = &lis3l02dq_read_event_config, 679 + .read_event_value = &lis3l02dq_read_thresh, 680 + .write_event_value = &lis3l02dq_write_thresh, 681 + .write_event_config = &lis3l02dq_write_event_config, 682 + .read_event_config = &lis3l02dq_read_event_config, 683 683 .driver_module = THIS_MODULE, 684 684 .attrs = &lis3l02dq_attribute_group, 685 685 };
+8 -8
drivers/staging/iio/accel/sca3000_core.c
··· 1126 1126 .attrs = &sca3000_attribute_group, 1127 1127 .read_raw = &sca3000_read_raw, 1128 1128 .event_attrs = &sca3000_event_attribute_group, 1129 - .read_event_value_new = &sca3000_read_thresh, 1130 - .write_event_value_new = &sca3000_write_thresh, 1131 - .read_event_config_new = &sca3000_read_event_config, 1132 - .write_event_config_new = &sca3000_write_event_config, 1129 + .read_event_value = &sca3000_read_thresh, 1130 + .write_event_value = &sca3000_write_thresh, 1131 + .read_event_config = &sca3000_read_event_config, 1132 + .write_event_config = &sca3000_write_event_config, 1133 1133 .driver_module = THIS_MODULE, 1134 1134 }; 1135 1135 1136 1136 static const struct iio_info sca3000_info_with_temp = { 1137 1137 .attrs = &sca3000_attribute_group_with_temp, 1138 1138 .read_raw = &sca3000_read_raw, 1139 - .read_event_value_new = &sca3000_read_thresh, 1140 - .write_event_value_new = &sca3000_write_thresh, 1141 - .read_event_config_new = &sca3000_read_event_config, 1142 - .write_event_config_new = &sca3000_write_event_config, 1139 + .read_event_value = &sca3000_read_thresh, 1140 + .write_event_value = &sca3000_write_thresh, 1141 + .read_event_config = &sca3000_read_event_config, 1142 + .write_event_config = &sca3000_write_event_config, 1143 1143 .driver_module = THIS_MODULE, 1144 1144 }; 1145 1145
+15 -13
drivers/staging/iio/adc/ad7280a.c
··· 134 134 unsigned char aux_threshhigh; 135 135 unsigned char aux_threshlow; 136 136 unsigned char cb_mask[AD7280A_MAX_CHAIN]; 137 + 138 + __be32 buf[2] ____cacheline_aligned; 137 139 }; 138 140 139 141 static void ad7280_crc8_build_table(unsigned char *crc_tab) ··· 191 189 msleep(1); 192 190 } 193 191 194 - static int __ad7280_read32(struct spi_device *spi, unsigned *val) 192 + static int __ad7280_read32(struct ad7280_state *st, unsigned *val) 195 193 { 196 - unsigned rx_buf, tx_buf = cpu_to_be32(AD7280A_READ_TXVAL); 197 194 int ret; 198 - 199 195 struct spi_transfer t = { 200 - .tx_buf = &tx_buf, 201 - .rx_buf = &rx_buf, 196 + .tx_buf = &st->buf[0], 197 + .rx_buf = &st->buf[1], 202 198 .len = 4, 203 199 }; 204 200 205 - ret = spi_sync_transfer(spi, &t, 1); 201 + st->buf[0] = cpu_to_be32(AD7280A_READ_TXVAL); 202 + 203 + ret = spi_sync_transfer(st->spi, &t, 1); 206 204 if (ret) 207 205 return ret; 208 206 209 - *val = be32_to_cpu(rx_buf); 207 + *val = be32_to_cpu(st->buf[1]); 210 208 211 209 return 0; 212 210 } ··· 218 216 (val & 0xFF) << 13 | all << 12); 219 217 220 218 reg |= ad7280_calc_crc8(st->crc_tab, reg >> 11) << 3 | 0x2; 221 - reg = cpu_to_be32(reg); 219 + st->buf[0] = cpu_to_be32(reg); 222 220 223 - return spi_write(st->spi, &reg, 4); 221 + return spi_write(st->spi, &st->buf[0], 4); 224 222 } 225 223 226 224 static int ad7280_read(struct ad7280_state *st, unsigned devaddr, ··· 250 248 if (ret) 251 249 return ret; 252 250 253 - __ad7280_read32(st->spi, &tmp); 251 + __ad7280_read32(st, &tmp); 254 252 255 253 if (ad7280_check_crc(st, tmp)) 256 254 return -EIO; ··· 288 286 289 287 ad7280_delay(st); 290 288 291 - __ad7280_read32(st->spi, &tmp); 289 + __ad7280_read32(st, &tmp); 292 290 293 291 if (ad7280_check_crc(st, tmp)) 294 292 return -EIO; ··· 321 319 ad7280_delay(st); 322 320 323 321 for (i = 0; i < cnt; i++) { 324 - __ad7280_read32(st->spi, &tmp); 322 + __ad7280_read32(st, &tmp); 325 323 326 324 if (ad7280_check_crc(st, tmp)) 327 325 return -EIO; ··· 364 362 return ret; 365 363 366 364 for (n = 0; n <= AD7280A_MAX_CHAIN; n++) { 367 - __ad7280_read32(st->spi, &val); 365 + __ad7280_read32(st, &val); 368 366 if (val == 0) 369 367 return n - 1; 370 368
+4 -4
drivers/staging/iio/adc/ad7291.c
··· 452 452 453 453 static const struct iio_info ad7291_info = { 454 454 .read_raw = &ad7291_read_raw, 455 - .read_event_config_new = &ad7291_read_event_config, 456 - .write_event_config_new = &ad7291_write_event_config, 457 - .read_event_value_new = &ad7291_read_event_value, 458 - .write_event_value_new = &ad7291_write_event_value, 455 + .read_event_config = &ad7291_read_event_config, 456 + .write_event_config = &ad7291_write_event_config, 457 + .read_event_value = &ad7291_read_event_value, 458 + .write_event_value = &ad7291_write_event_value, 459 459 .driver_module = THIS_MODULE, 460 460 }; 461 461
+6 -1
drivers/staging/iio/adc/ad7606_core.c
··· 239 239 .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ 240 240 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE),\ 241 241 .scan_index = num, \ 242 - .scan_type = IIO_ST('s', 16, 16, 0), \ 242 + .scan_type = { \ 243 + .sign = 's', \ 244 + .realbits = 16, \ 245 + .storagebits = 16, \ 246 + .endianness = IIO_CPU, \ 247 + }, \ 243 248 } 244 249 245 250 static const struct iio_chan_spec ad7606_8_channels[] = {
+3 -3
drivers/staging/iio/adc/ad799x_core.c
··· 377 377 static const struct iio_info ad7993_4_7_8_info = { 378 378 .read_raw = &ad799x_read_raw, 379 379 .event_attrs = &ad799x_event_attrs_group, 380 - .read_event_config_new = &ad799x_read_event_config, 381 - .read_event_value_new = &ad799x_read_event_value, 382 - .write_event_value_new = &ad799x_write_event_value, 380 + .read_event_config = &ad799x_read_event_config, 381 + .read_event_value = &ad799x_read_event_value, 382 + .write_event_value = &ad799x_write_event_value, 383 383 .driver_module = THIS_MODULE, 384 384 .update_scan_mode = ad7997_8_update_scan_mode, 385 385 };
+78 -13
drivers/staging/iio/adc/mxs-lradc.c
··· 759 759 /* 760 760 * Raw I/O operations 761 761 */ 762 - static int mxs_lradc_read_raw(struct iio_dev *iio_dev, 763 - const struct iio_chan_spec *chan, 764 - int *val, int *val2, long m) 762 + static int mxs_lradc_read_single(struct iio_dev *iio_dev, int chan, int *val) 765 763 { 766 764 struct mxs_lradc *lradc = iio_priv(iio_dev); 767 765 int ret; 768 - 769 - if (m != IIO_CHAN_INFO_RAW) 770 - return -EINVAL; 771 - 772 - /* Check for invalid channel */ 773 - if (chan->channel > LRADC_MAX_TOTAL_CHANS) 774 - return -EINVAL; 775 766 776 767 /* 777 768 * See if there is no buffered operation in progess. If there is, simply ··· 788 797 789 798 /* Clean the slot's previous content, then set new one. */ 790 799 mxs_lradc_reg_clear(lradc, LRADC_CTRL4_LRADCSELECT_MASK(0), LRADC_CTRL4); 791 - mxs_lradc_reg_set(lradc, chan->channel, LRADC_CTRL4); 800 + mxs_lradc_reg_set(lradc, chan, LRADC_CTRL4); 792 801 793 802 mxs_lradc_reg_wrt(lradc, 0, LRADC_CH(0)); 794 803 ··· 813 822 mutex_unlock(&lradc->lock); 814 823 815 824 return ret; 825 + } 826 + 827 + static int mxs_lradc_read_temp(struct iio_dev *iio_dev, int *val) 828 + { 829 + int ret, min, max; 830 + 831 + ret = mxs_lradc_read_single(iio_dev, 8, &min); 832 + if (ret != IIO_VAL_INT) 833 + return ret; 834 + 835 + ret = mxs_lradc_read_single(iio_dev, 9, &max); 836 + if (ret != IIO_VAL_INT) 837 + return ret; 838 + 839 + *val = max - min; 840 + 841 + return IIO_VAL_INT; 842 + } 843 + 844 + static int mxs_lradc_read_raw(struct iio_dev *iio_dev, 845 + const struct iio_chan_spec *chan, 846 + int *val, int *val2, long m) 847 + { 848 + /* Check for invalid channel */ 849 + if (chan->channel > LRADC_MAX_TOTAL_CHANS) 850 + return -EINVAL; 851 + 852 + switch (m) { 853 + case IIO_CHAN_INFO_RAW: 854 + if (chan->type == IIO_TEMP) 855 + return mxs_lradc_read_temp(iio_dev, val); 856 + 857 + return mxs_lradc_read_single(iio_dev, chan->channel, val); 858 + 859 + case IIO_CHAN_INFO_SCALE: 860 + if (chan->type == IIO_TEMP) { 861 + /* From the datasheet, we have to multiply by 1.012 and 862 + * divide by 4 863 + */ 864 + *val = 0; 865 + *val2 = 253000; 866 + return IIO_VAL_INT_PLUS_MICRO; 867 + } 868 + 869 + return -EINVAL; 870 + 871 + case IIO_CHAN_INFO_OFFSET: 872 + if (chan->type == IIO_TEMP) { 873 + /* The calculated value from the ADC is in Kelvin, we 874 + * want Celsius for hwmon so the offset is 875 + * -272.15 * scale 876 + */ 877 + *val = -1075; 878 + *val2 = 691699; 879 + 880 + return IIO_VAL_INT_PLUS_MICRO; 881 + } 882 + 883 + return -EINVAL; 884 + 885 + default: 886 + break; 887 + } 888 + 889 + return -EINVAL; 816 890 } 817 891 818 892 static const struct iio_info mxs_lradc_iio_info = { ··· 1207 1151 MXS_ADC_CHAN(5, IIO_VOLTAGE), 1208 1152 MXS_ADC_CHAN(6, IIO_VOLTAGE), 1209 1153 MXS_ADC_CHAN(7, IIO_VOLTAGE), /* VBATT */ 1210 - MXS_ADC_CHAN(8, IIO_TEMP), /* Temp sense 0 */ 1211 - MXS_ADC_CHAN(9, IIO_TEMP), /* Temp sense 1 */ 1154 + /* Combined Temperature sensors */ 1155 + { 1156 + .type = IIO_TEMP, 1157 + .indexed = 1, 1158 + .scan_index = 8, 1159 + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | 1160 + BIT(IIO_CHAN_INFO_OFFSET) | 1161 + BIT(IIO_CHAN_INFO_SCALE), 1162 + .channel = 8, 1163 + .scan_type = {.sign = 'u', .realbits = 18, .storagebits = 32,}, 1164 + }, 1212 1165 MXS_ADC_CHAN(10, IIO_VOLTAGE), /* VDDIO */ 1213 1166 MXS_ADC_CHAN(11, IIO_VOLTAGE), /* VTH */ 1214 1167 MXS_ADC_CHAN(12, IIO_VOLTAGE), /* VDDA */
+4 -4
drivers/staging/iio/cdc/ad7150.c
··· 576 576 .event_attrs = &ad7150_event_attribute_group, 577 577 .driver_module = THIS_MODULE, 578 578 .read_raw = &ad7150_read_raw, 579 - .read_event_config_new = &ad7150_read_event_config, 580 - .write_event_config_new = &ad7150_write_event_config, 581 - .read_event_value_new = &ad7150_read_event_value, 582 - .write_event_value_new = &ad7150_write_event_value, 579 + .read_event_config = &ad7150_read_event_config, 580 + .write_event_config = &ad7150_write_event_config, 581 + .read_event_value = &ad7150_read_event_value, 582 + .write_event_value = &ad7150_write_event_value, 583 583 }; 584 584 585 585 /*
+7 -7
drivers/staging/iio/cdc/ad7746.c
··· 105 105 u8 vt_setup; 106 106 u8 capdac[2][2]; 107 107 s8 capdac_set; 108 + 109 + union { 110 + __be32 d32; 111 + u8 d8[4]; 112 + } data ____cacheline_aligned; 108 113 }; 109 114 110 115 enum ad7746_chan { ··· 571 566 int ret, delay; 572 567 u8 regval, reg; 573 568 574 - union { 575 - u32 d32; 576 - u8 d8[4]; 577 - } data; 578 - 579 569 mutex_lock(&indio_dev->mlock); 580 570 581 571 switch (mask) { ··· 591 591 /* Now read the actual register */ 592 592 593 593 ret = i2c_smbus_read_i2c_block_data(chip->client, 594 - chan->address >> 8, 3, &data.d8[1]); 594 + chan->address >> 8, 3, &chip->data.d8[1]); 595 595 596 596 if (ret < 0) 597 597 goto out; 598 598 599 - *val = (be32_to_cpu(data.d32) & 0xFFFFFF) - 0x800000; 599 + *val = (be32_to_cpu(chip->data.d32) & 0xFFFFFF) - 0x800000; 600 600 601 601 switch (chan->type) { 602 602 case IIO_TEMP:
+3 -3
drivers/staging/iio/frequency/ad9832.h
··· 92 92 * transfer buffers to live in their own cache lines. 93 93 */ 94 94 union { 95 - unsigned short freq_data[4]____cacheline_aligned; 96 - unsigned short phase_data[2]; 97 - unsigned short data; 95 + __be16 freq_data[4]____cacheline_aligned; 96 + __be16 phase_data[2]; 97 + __be16 data; 98 98 }; 99 99 }; 100 100
+2 -2
drivers/staging/iio/frequency/ad9834.h
··· 65 65 * DMA (thus cache coherency maintenance) requires the 66 66 * transfer buffers to live in their own cache lines. 67 67 */ 68 - unsigned short data ____cacheline_aligned; 69 - unsigned short freq_data[2] ; 68 + __be16 data ____cacheline_aligned; 69 + __be16 freq_data[2]; 70 70 }; 71 71 72 72
+4 -4
drivers/staging/iio/iio_simple_dummy.c
··· 370 370 .read_raw = &iio_dummy_read_raw, 371 371 .write_raw = &iio_dummy_write_raw, 372 372 #ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS 373 - .read_event_config_new = &iio_simple_dummy_read_event_config, 374 - .write_event_config_new = &iio_simple_dummy_write_event_config, 375 - .read_event_value_new = &iio_simple_dummy_read_event_value, 376 - .write_event_value_new = &iio_simple_dummy_write_event_value, 373 + .read_event_config = &iio_simple_dummy_read_event_config, 374 + .write_event_config = &iio_simple_dummy_write_event_config, 375 + .read_event_value = &iio_simple_dummy_read_event_value, 376 + .write_event_value = &iio_simple_dummy_write_event_value, 377 377 #endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */ 378 378 }; 379 379
+20 -20
drivers/staging/iio/light/tsl2x7x_core.c
··· 1672 1672 .driver_module = THIS_MODULE, 1673 1673 .read_raw = &tsl2x7x_read_raw, 1674 1674 .write_raw = &tsl2x7x_write_raw, 1675 - .read_event_value_new = &tsl2x7x_read_thresh, 1676 - .write_event_value_new = &tsl2x7x_write_thresh, 1677 - .read_event_config_new = &tsl2x7x_read_interrupt_config, 1678 - .write_event_config_new = &tsl2x7x_write_interrupt_config, 1675 + .read_event_value = &tsl2x7x_read_thresh, 1676 + .write_event_value = &tsl2x7x_write_thresh, 1677 + .read_event_config = &tsl2x7x_read_interrupt_config, 1678 + .write_event_config = &tsl2x7x_write_interrupt_config, 1679 1679 }, 1680 1680 [PRX] = { 1681 1681 .attrs = &tsl2X7X_device_attr_group_tbl[PRX], ··· 1683 1683 .driver_module = THIS_MODULE, 1684 1684 .read_raw = &tsl2x7x_read_raw, 1685 1685 .write_raw = &tsl2x7x_write_raw, 1686 - .read_event_value_new = &tsl2x7x_read_thresh, 1687 - .write_event_value_new = &tsl2x7x_write_thresh, 1688 - .read_event_config_new = &tsl2x7x_read_interrupt_config, 1689 - .write_event_config_new = &tsl2x7x_write_interrupt_config, 1686 + .read_event_value = &tsl2x7x_read_thresh, 1687 + .write_event_value = &tsl2x7x_write_thresh, 1688 + .read_event_config = &tsl2x7x_read_interrupt_config, 1689 + .write_event_config = &tsl2x7x_write_interrupt_config, 1690 1690 }, 1691 1691 [ALSPRX] = { 1692 1692 .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX], ··· 1694 1694 .driver_module = THIS_MODULE, 1695 1695 .read_raw = &tsl2x7x_read_raw, 1696 1696 .write_raw = &tsl2x7x_write_raw, 1697 - .read_event_value_new = &tsl2x7x_read_thresh, 1698 - .write_event_value_new = &tsl2x7x_write_thresh, 1699 - .read_event_config_new = &tsl2x7x_read_interrupt_config, 1700 - .write_event_config_new = &tsl2x7x_write_interrupt_config, 1697 + .read_event_value = &tsl2x7x_read_thresh, 1698 + .write_event_value = &tsl2x7x_write_thresh, 1699 + .read_event_config = &tsl2x7x_read_interrupt_config, 1700 + .write_event_config = &tsl2x7x_write_interrupt_config, 1701 1701 }, 1702 1702 [PRX2] = { 1703 1703 .attrs = &tsl2X7X_device_attr_group_tbl[PRX2], ··· 1705 1705 .driver_module = THIS_MODULE, 1706 1706 .read_raw = &tsl2x7x_read_raw, 1707 1707 .write_raw = &tsl2x7x_write_raw, 1708 - .read_event_value_new = &tsl2x7x_read_thresh, 1709 - .write_event_value_new = &tsl2x7x_write_thresh, 1710 - .read_event_config_new = &tsl2x7x_read_interrupt_config, 1711 - .write_event_config_new = &tsl2x7x_write_interrupt_config, 1708 + .read_event_value = &tsl2x7x_read_thresh, 1709 + .write_event_value = &tsl2x7x_write_thresh, 1710 + .read_event_config = &tsl2x7x_read_interrupt_config, 1711 + .write_event_config = &tsl2x7x_write_interrupt_config, 1712 1712 }, 1713 1713 [ALSPRX2] = { 1714 1714 .attrs = &tsl2X7X_device_attr_group_tbl[ALSPRX2], ··· 1716 1716 .driver_module = THIS_MODULE, 1717 1717 .read_raw = &tsl2x7x_read_raw, 1718 1718 .write_raw = &tsl2x7x_write_raw, 1719 - .read_event_value_new = &tsl2x7x_read_thresh, 1720 - .write_event_value_new = &tsl2x7x_write_thresh, 1721 - .read_event_config_new = &tsl2x7x_read_interrupt_config, 1722 - .write_event_config_new = &tsl2x7x_write_interrupt_config, 1719 + .read_event_value = &tsl2x7x_read_thresh, 1720 + .write_event_value = &tsl2x7x_write_thresh, 1721 + .read_event_config = &tsl2x7x_read_interrupt_config, 1722 + .write_event_config = &tsl2x7x_write_interrupt_config, 1723 1723 }, 1724 1724 }; 1725 1725
+1 -1
drivers/staging/iio/magnetometer/hmc5843.c
··· 639 639 .driver = { 640 640 .name = "hmc5843", 641 641 .pm = HMC5843_PM_OPS, 642 - .of_match_table = of_match_ptr(hmc5843_of_match), 642 + .of_match_table = hmc5843_of_match, 643 643 }, 644 644 .id_table = hmc5843_id, 645 645 .probe = hmc5843_probe,
+4
include/linux/hid-sensor-ids.h
··· 58 58 #define HID_USAGE_SENSOR_ORIENT_DISTANCE_Y 0x20047B 59 59 #define HID_USAGE_SENSOR_ORIENT_DISTANCE_Z 0x20047C 60 60 #define HID_USAGE_SENSOR_ORIENT_DISTANCE_OUT_OF_RANGE 0x20047D 61 + 62 + /* ORIENTATION: Inclinometer 3D: (200086) */ 63 + #define HID_USAGE_SENSOR_INCLINOMETER_3D 0x200086 61 64 #define HID_USAGE_SENSOR_ORIENT_TILT 0x20047E 62 65 #define HID_USAGE_SENSOR_ORIENT_TILT_X 0x20047F 63 66 #define HID_USAGE_SENSOR_ORIENT_TILT_Y 0x200480 64 67 #define HID_USAGE_SENSOR_ORIENT_TILT_Z 0x200481 68 + 65 69 #define HID_USAGE_SENSOR_ORIENT_ROTATION_MATRIX 0x200482 66 70 #define HID_USAGE_SENSOR_ORIENT_QUATERNION 0x200483 67 71 #define HID_USAGE_SENSOR_ORIENT_MAGN_FLUX 0x200484
+3
include/linux/iio/buffer.h
··· 21 21 * struct iio_buffer_access_funcs - access functions for buffers. 22 22 * @store_to: actually store stuff to the buffer 23 23 * @read_first_n: try to get a specified number of bytes (must exist) 24 + * @data_available: indicates whether data for reading from the buffer is 25 + * available. 24 26 * @request_update: if a parameter change has been marked, update underlying 25 27 * storage. 26 28 * @get_bytes_per_datum:get current bytes per datum ··· 45 43 int (*read_first_n)(struct iio_buffer *buffer, 46 44 size_t n, 47 45 char __user *buf); 46 + bool (*data_available)(struct iio_buffer *buffer); 48 47 49 48 int (*request_update)(struct iio_buffer *buffer); 50 49
-4
include/linux/iio/events.h
··· 46 46 ((u16)chan)) 47 47 48 48 49 - #define IIO_EV_DIR_MAX 4 50 - #define IIO_EV_BIT(type, direction) \ 51 - (1 << (type*IIO_EV_DIR_MAX + direction)) 52 - 53 49 /** 54 50 * IIO_MOD_EVENT_CODE() - create event identifier for modified channels 55 51 * @chan_type: Type of the channel. Should be one of enum iio_chan_type.
+5 -29
include/linux/iio/iio.h
··· 185 185 * by all channels of the same direction. 186 186 * @info_mask_shared_by_all: What information is to be exported that is shared 187 187 * by all channels. 188 - * @event_mask: What events can this channel produce. 189 188 * @event_spec: Array of events which should be registered for this 190 189 * channel. 191 190 * @num_event_specs: Size of the event_spec array. ··· 225 226 long info_mask_shared_by_type; 226 227 long info_mask_shared_by_dir; 227 228 long info_mask_shared_by_all; 228 - long event_mask; 229 229 const struct iio_event_spec *event_spec; 230 230 unsigned int num_event_specs; 231 231 const struct iio_chan_spec_ext_info *ext_info; ··· 305 307 * returns IIO_VAL_INT_PLUS_MICRO. 306 308 * @read_event_config: find out if the event is enabled. 307 309 * @write_event_config: set if the event is enabled. 308 - * @read_event_value: read a value associated with the event. Meaning 309 - * is event dependant. event_code specifies which event. 310 - * @write_event_value: write the value associated with the event. 311 - * Meaning is event dependent. 312 - * @read_event_config_new: find out if the event is enabled. New style interface. 313 - * @write_event_config_new: set if the event is enabled. New style interface. 314 - * @read_event_value_new: read a configuration value associated with the event. 315 - * New style interface. 316 - * @write_event_value_new: write a configuration value for the event. New style 317 - * interface. 310 + * @read_event_value: read a configuration value associated with the event. 311 + * @write_event_value: write a configuration value for the event. 318 312 * @validate_trigger: function to validate the trigger when the 319 313 * current trigger gets changed. 320 314 * @update_scan_mode: function to configure device and scan buffer when ··· 335 345 long mask); 336 346 337 347 int (*read_event_config)(struct iio_dev *indio_dev, 338 - u64 event_code); 339 - 340 - int (*write_event_config)(struct iio_dev *indio_dev, 341 - u64 event_code, 342 - int state); 343 - 344 - int (*read_event_value)(struct iio_dev *indio_dev, 345 - u64 event_code, 346 - int *val); 347 - int (*write_event_value)(struct iio_dev *indio_dev, 348 - u64 event_code, 349 - int val); 350 - 351 - int (*read_event_config_new)(struct iio_dev *indio_dev, 352 348 const struct iio_chan_spec *chan, 353 349 enum iio_event_type type, 354 350 enum iio_event_direction dir); 355 351 356 - int (*write_event_config_new)(struct iio_dev *indio_dev, 352 + int (*write_event_config)(struct iio_dev *indio_dev, 357 353 const struct iio_chan_spec *chan, 358 354 enum iio_event_type type, 359 355 enum iio_event_direction dir, 360 356 int state); 361 357 362 - int (*read_event_value_new)(struct iio_dev *indio_dev, 358 + int (*read_event_value)(struct iio_dev *indio_dev, 363 359 const struct iio_chan_spec *chan, 364 360 enum iio_event_type type, 365 361 enum iio_event_direction dir, 366 362 enum iio_event_info info, int *val, int *val2); 367 363 368 - int (*write_event_value_new)(struct iio_dev *indio_dev, 364 + int (*write_event_value)(struct iio_dev *indio_dev, 369 365 const struct iio_chan_spec *chan, 370 366 enum iio_event_type type, 371 367 enum iio_event_direction dir,
+1
include/linux/iio/types.h
··· 29 29 IIO_ALTVOLTAGE, 30 30 IIO_CCT, 31 31 IIO_PRESSURE, 32 + IIO_HUMIDITYRELATIVE, 32 33 }; 33 34 34 35 enum iio_modifier {