1 /* SPDX-License-Identifier: GPL-2.0 */ 2 3 #ifndef _INDUSTRIAL_IO_OPAQUE_H_ 4 #define _INDUSTRIAL_IO_OPAQUE_H_ 5 6 /** 7 * struct iio_dev_opaque - industrial I/O device opaque information 8 * @indio_dev: public industrial I/O device information 9 * @id: used to identify device internally 10 * @currentmode: operating mode currently in use, may be eventually 11 * checked by device drivers but should be considered 12 * read-only as this is a core internal bit 13 * @driver_module: used to make it harder to undercut users 14 * @mlock: lock used to prevent simultaneous device state changes 15 * @mlock_key: lockdep class for iio_dev lock 16 * @info_exist_lock: lock to prevent use during removal 17 * @info_exist_key: lockdep class for info_exist lock 18 * @trig_readonly: mark the current trigger immutable 19 * @event_interface: event chrdevs associated with interrupt lines 20 * @attached_buffers: array of buffers statically attached by the driver 21 * @attached_buffers_cnt: number of buffers in the array of statically attached buffers 22 * @buffer_ioctl_handler: ioctl() handler for this IIO device's buffer interface 23 * @buffer_list: list of all buffers currently attached 24 * @channel_attr_list: keep track of automatically created channel 25 * attributes 26 * @chan_attr_group: group for all attrs in base directory 27 * @ioctl_handlers: ioctl handlers registered with the core handler 28 * @groups: attribute groups 29 * @groupcounter: index of next attribute group 30 * @legacy_scan_el_group: attribute group for legacy scan elements attribute group 31 * @legacy_buffer_group: attribute group for legacy buffer attributes group 32 * @bounce_buffer: for devices that call iio_push_to_buffers_with_ts_unaligned() 33 * @bounce_buffer_size: size of currently allocate bounce buffer 34 * @scan_index_timestamp: cache of the index to the timestamp 35 * @clock_id: timestamping clock posix identifier 36 * @chrdev: associated character device 37 * @flags: file ops related flags including busy flag. 38 * @debugfs_dentry: device specific debugfs dentry 39 * @cached_reg_addr: cached register address for debugfs reads 40 * @read_buf: read buffer to be used for the initial reg read 41 * @read_buf_len: data length in @read_buf 42 */ 43 struct iio_dev_opaque { 44 struct iio_dev indio_dev; 45 int currentmode; 46 int id; 47 struct module *driver_module; 48 struct mutex mlock; 49 struct lock_class_key mlock_key; 50 struct mutex info_exist_lock; 51 struct lock_class_key info_exist_key; 52 bool trig_readonly; 53 struct iio_event_interface *event_interface; 54 struct iio_buffer **attached_buffers; 55 unsigned int attached_buffers_cnt; 56 struct iio_ioctl_handler *buffer_ioctl_handler; 57 struct list_head buffer_list; 58 struct list_head channel_attr_list; 59 struct attribute_group chan_attr_group; 60 struct list_head ioctl_handlers; 61 const struct attribute_group **groups; 62 int groupcounter; 63 struct attribute_group legacy_scan_el_group; 64 struct attribute_group legacy_buffer_group; 65 void *bounce_buffer; 66 size_t bounce_buffer_size; 67 68 unsigned int scan_index_timestamp; 69 clockid_t clock_id; 70 struct cdev chrdev; 71 unsigned long flags; 72 73 #if defined(CONFIG_DEBUG_FS) 74 struct dentry *debugfs_dentry; 75 unsigned int cached_reg_addr; 76 char read_buf[20]; 77 unsigned int read_buf_len; 78 #endif 79 }; 80 81 #define to_iio_dev_opaque(_indio_dev) \ 82 container_of((_indio_dev), struct iio_dev_opaque, indio_dev) 83 84 #endif 85