History

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

Jonathan writes: Second set of new device support, cleanups and features for IIO in the 5.8 cycle Usual mixed back but with a few subsystem wide or device type wide cleanups. New device support * adis16475 - New driver supporting adis16470, adis16475, adis16477, adis16465, adis16467, adis16500, adis16505 and adis16507. Includes some rework of the adis library to simplify using it for this new driver. * ak8974 - Add support for Alps hscdt008a. ID only. Related patches add support for scale. * atlas-sensor - Add support for RTD-SM OEM temperature sensor. * cm32181 - Add support for CM3218 including support for SMBUS alert via ACPI resources. * ltc2632 - Add support for ltc2634-12/10/8 DACS including handling per device type numbers of channels. Major Features * cm32181 - ACPI bindings including parsing CPM0 and CPM1 custom ACPI tables. Includes minor tidy ups and fixes. * vcnl4000 - Add event support - Add buffered data capture support - Add control of sampling frequency Cleanups and minor fixes. * core - Trivial rework of iio_device_alloc to use an early return and improve readability. - Precursors to addition of multiple buffer support. So far minor refactoring. * subsystem wide - Use get_unaligned_be24 slightly improve readability over open coding it. * adis drivers - Use iio_get_debugfs_dentry access function. * bh1780, cm32181, cm3232, gp2ap02a00f, opt3001, st_uvis25, vl6180, dmard06, kxsd9 - Drop use of of_match_ptr to allow ACPI based probing via PRP0001. Part of clear out of this to avoid cut and paste into new drivers. * ad5592r, ad5593r - Fix typos * ad5933 - Use managed interfaces to automate error handling and remove. * ak8974 - Fix wrong number of 'real bits' for buffered data. - Refactor to pull measurement code out as separate function. bmp280 - Fix lack of clamp on range during data capture. * at91-sama5d2_adc - Handle unfinished conversions correctly. - Allow use of triggers other than it's own. - Reorganize buffer setup and tear down as part of long running subsystem wide rework. * ccs811 - Add DT binding docs and match table. - Support external reset and wakeup pins. * hid-sensors - Reorganize buffer setup and tear down as part of long running subsystem wide rework. * ltr501 - Constify some structs. * vcnl4000 - Fix an endian issue by using explicit byte swapped i2c accessors. * tag 'iio-for-5.8b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (74 commits) iio: light: ltr501: Constify structs staging: iio: ad5933: attach life-cycle of kfifo buffer to parent device and use managed calls throughout iio: bmp280: fix compensation of humidity iio: light: cm32181: Fix integartion time typo iio: light: cm32181: Add support for parsing CPM0 and CPM1 ACPI tables iio: light: cm32181: Make lux_per_bit and lux_per_bit_base_it runtime settings iio: light: cm32181: Use units of 1/100000th for calibscale and lux_per_bit iio: light: cm32181: Change reg_init to use a bitmap of which registers to init iio: light: cm32181: Handle CM3218 ACPI devices with 2 I2C resources iio: light: cm32181: Clean up the probe function a bit iio: light: cm32181: Add support for the CM3218 iio: light: cm32181: Add some extra register defines iio: light: cm32181: Add support for ACPI enumeration iio: light: cm32181: Switch to new style i2c-driver probe function iio: hid-sensors: move triggered buffer setup into hid_sensor_setup_trigger iio: vcnl4000: Add buffer support for VCNL4010/20. iio: vcnl4000: Add sampling frequency support for VCNL4010/20. iio: vcnl4000: Add event support for VCNL4010/20. iio: vcnl4000: Factorize data reading and writing. iio: vcnl4000: Fix i2c swapped word reading. ...

Greg Kroah-Hartman committed 6 years ago

Commit cef077e2 parents c336c02 6b46ddb72 files · +3459 −650Browse files

Showing the changes to include/linux (1 of 72 files). Show all

Unified · Split

include/linux/iio/imu/adis.h+85−2
@@ -83,10 +83,13 @@ struct adis_data { · 82 unmodified lines
8383 * @trig: IIO trigger object data
8484 * @data: ADIS chip variant specific data
8585 * @burst: ADIS burst transfer information
86+ * @burst_extra_len: Burst extra length. Should only be used by devices that can
87+ * dynamically change their burst mode length.
8688 * @state_lock: Lock used by the device to protect state
8789 * @msg: SPI message object
8890 * @xfer: SPI transfer objects to be used for a @msg
8991 * @current_page: Some ADIS devices have registers, this selects current page
92+ * @irq_flag: IRQ handling flags as passed to request_irq()
9093 * @buffer: Data buffer for information read from the device
9194 * @tx: DMA safe TX buffer for SPI transfers
9295 * @rx: DMA safe RX buffer for SPI transfers
@@ -97,7 +100,7 @@ struct adis { · 4 unmodified lines
97100
98101 const struct adis_data *data;
99102 struct adis_burst *burst;
100−
103+ unsigned int burst_extra_len;
101104 /**
102105 * The state_lock is meant to be used during operations that require
103106 * a sequence of SPI R/W in order to protect the SPI transfer
@@ -113,6 +116,7 @@ struct adis { · 9 unmodified lines
113116 struct spi_message msg;
114117 struct spi_transfer *xfer;
115118 unsigned int current_page;
119+ unsigned long irq_flag;
116120 void *buffer;
117121
118122 uint8_t tx[10] ____cacheline_aligned;
@@ -331,6 +335,65 @@ static inline int adis_read_reg_32(struct adis *adis, unsigned int reg, · 212 unmodified lines
331335 return ret;
332336 }
333337
338+int __adis_update_bits_base(struct adis *adis, unsigned int reg, const u32 mask,
339+ const u32 val, u8 size);
340+/**
341+ * adis_update_bits_base() - ADIS Update bits function - Locked version
342+ * @adis: The adis device
343+ * @reg: The address of the lower of the two registers
344+ * @mask: Bitmask to change
345+ * @val: Value to be written
346+ * @size: Size of the register to update
347+ *
348+ * Updates the desired bits of @reg in accordance with @mask and @val.
349+ */
350+static inline int adis_update_bits_base(struct adis *adis, unsigned int reg,
351+ const u32 mask, const u32 val, u8 size)
352+{
353+ int ret;
354+
355+ mutex_lock(&adis->state_lock);
356+ ret = __adis_update_bits_base(adis, reg, mask, val, size);
357+ mutex_unlock(&adis->state_lock);
358+ return ret;
359+}
360+
361+/**
362+ * adis_update_bits() - Wrapper macro for adis_update_bits_base - Locked version
363+ * @adis: The adis device
364+ * @reg: The address of the lower of the two registers
365+ * @mask: Bitmask to change
366+ * @val: Value to be written
367+ *
368+ * This macro evaluates the sizeof of @val at compile time and calls
369+ * adis_update_bits_base() accordingly. Be aware that using MACROS/DEFINES for
370+ * @val can lead to undesired behavior if the register to update is 16bit.
371+ */
372+#define adis_update_bits(adis, reg, mask, val) ({ \
373+ BUILD_BUG_ON(sizeof(val) == 1 || sizeof(val) == 8); \
374+ __builtin_choose_expr(sizeof(val) == 4, \
375+ adis_update_bits_base(adis, reg, mask, val, 4), \
376+ adis_update_bits_base(adis, reg, mask, val, 2)); \
377+})
378+
379+/**
380+ * adis_update_bits() - Wrapper macro for adis_update_bits_base
381+ * @adis: The adis device
382+ * @reg: The address of the lower of the two registers
383+ * @mask: Bitmask to change
384+ * @val: Value to be written
385+ *
386+ * This macro evaluates the sizeof of @val at compile time and calls
387+ * adis_update_bits_base() accordingly. Be aware that using MACROS/DEFINES for
388+ * @val can lead to undesired behavior if the register to update is 16bit.
389+ */
390+#define __adis_update_bits(adis, reg, mask, val) ({ \
391+ BUILD_BUG_ON(sizeof(val) == 1 || sizeof(val) == 8); \
392+ __builtin_choose_expr(sizeof(val) == 4, \
393+ __adis_update_bits_base(adis, reg, mask, val, 4), \
394+ __adis_update_bits_base(adis, reg, mask, val, 2)); \
395+})
396+
334397 int adis_enable_irq(struct adis *adis, bool enable);
335398 int __adis_check_status(struct adis *adis);
336399 int __adis_initial_startup(struct adis *adis);
@@ -441,18 +504,25 @@ int adis_single_conversion(struct iio_dev *indio_dev, · 104 unmodified lines
441504 * @en burst mode enabled
442505 * @reg_cmd register command that triggers burst
443506 * @extra_len extra length to account in the SPI RX buffer
507+ * @burst_max_len holds the maximum burst size when the device supports
508+ * more than one burst mode with different sizes
444509 */
445510 struct adis_burst {
446511 bool en;
447512 unsigned int reg_cmd;
448− unsigned int extra_len;
513+ const u32 extra_len;
514+ const u32 burst_max_len;
449515 };
450516
517+int
518+devm_adis_setup_buffer_and_trigger(struct adis *adis, struct iio_dev *indio_dev,
519+ irq_handler_t trigger_handler);
451520 int adis_setup_buffer_and_trigger(struct adis *adis,
452521 struct iio_dev *indio_dev, irqreturn_t (*trigger_handler)(int, void *));
453522 void adis_cleanup_buffer_and_trigger(struct adis *adis,
454523 struct iio_dev *indio_dev);
455524
525+int devm_adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev);
456526 int adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev);
457527 void adis_remove_trigger(struct adis *adis);
458528
@@ -461,6 +531,13 @@ int adis_update_scan_mode(struct iio_dev *indio_dev, · 2 unmodified lines
461531
462532 #else /* CONFIG_IIO_BUFFER */
463533
534+static inline int
535+devm_adis_setup_buffer_and_trigger(struct adis *adis, struct iio_dev *indio_dev,
536+ irq_handler_t trigger_handler)
537+{
538+ return 0;
539+}
540+
464541 static inline int adis_setup_buffer_and_trigger(struct adis *adis,
465542 struct iio_dev *indio_dev, irqreturn_t (*trigger_handler)(int, void *))
466543 {
@@ -472,6 +549,12 @@ static inline void adis_cleanup_buffer_and_trigger(struct adis *adis, · 5 unmodified lines
472549 {
473550 }
474551
552+static inline int devm_adis_probe_trigger(struct adis *adis,
553+ struct iio_dev *indio_dev)
554+{
555+ return 0;
556+}
557+
475558 static inline int adis_probe_trigger(struct adis *adis,
476559 struct iio_dev *indio_dev)
477560 {