iio: introduce struct iio_scan_type
authorDavid Lechner <dlechner@baylibre.com>
Thu, 30 May 2024 15:14:08 +0000 (10:14 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 4 Jun 2024 18:53:08 +0000 (19:53 +0100)
This gives the channel scan_type a named type so that it can be used
to simplify code in later commits.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20240530-iio-add-support-for-multiple-scan-types-v3-1-cbc4acea2cfa@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
include/linux/iio/iio.h

index 55e2b22086a1aac4f975f6d0b8ffa16c7c8fc794..19de573a944a9a04a502797fa7a098ca4cf7272f 100644 (file)
@@ -173,6 +173,27 @@ struct iio_event_spec {
        unsigned long mask_shared_by_all;
 };
 
+/**
+ * struct iio_scan_type - specification for channel data format in buffer
+ * @sign:              's' or 'u' to specify signed or unsigned
+ * @realbits:          Number of valid bits of data
+ * @storagebits:       Realbits + padding
+ * @shift:             Shift right by this before masking out realbits.
+ * @repeat:            Number of times real/storage bits repeats. When the
+ *                     repeat element is more than 1, then the type element in
+ *                     sysfs will show a repeat value. Otherwise, the number
+ *                     of repetitions is omitted.
+ * @endianness:                little or big endian
+ */
+struct iio_scan_type {
+       char    sign;
+       u8      realbits;
+       u8      storagebits;
+       u8      shift;
+       u8      repeat;
+       enum iio_endian endianness;
+};
+
 /**
  * struct iio_chan_spec - specification of a single channel
  * @type:              What type of measurement is the channel making.
@@ -184,17 +205,6 @@ struct iio_event_spec {
  * @scan_index:                Monotonic index to give ordering in scans when read
  *                     from a buffer.
  * @scan_type:         struct describing the scan type
- * @scan_type.sign:            's' or 'u' to specify signed or unsigned
- * @scan_type.realbits:                Number of valid bits of data
- * @scan_type.storagebits:     Realbits + padding
- * @scan_type.shift:           Shift right by this before masking out
- *                             realbits.
- * @scan_type.repeat:          Number of times real/storage bits repeats.
- *                             When the repeat element is more than 1, then
- *                             the type element in sysfs will show a repeat
- *                             value. Otherwise, the number of repetitions
- *                             is omitted.
- * @scan_type.endianness:      little or big endian
  * @info_mask_separate: What information is to be exported that is specific to
  *                     this channel.
  * @info_mask_separate_available: What availability information is to be
@@ -245,14 +255,7 @@ struct iio_chan_spec {
        int                     channel2;
        unsigned long           address;
        int                     scan_index;
-       struct {
-               char    sign;
-               u8      realbits;
-               u8      storagebits;
-               u8      shift;
-               u8      repeat;
-               enum iio_endian endianness;
-       } scan_type;
+       struct iio_scan_type scan_type;
        long                    info_mask_separate;
        long                    info_mask_separate_available;
        long                    info_mask_shared_by_type;