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

Configure Feed

Select the types of activity you want to include in your feed.

iio: backend: add API for interface get

Add backend support for obtaining the interface type used.

Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Link: https://patch.msgid.link/20250214131955.31973-2-antoniu.miclaus@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Antoniu Miclaus and committed by
Jonathan Cameron
4018ab42 ac856912

+35
+24
drivers/iio/industrialio-backend.c
··· 637 637 EXPORT_SYMBOL_NS_GPL(iio_backend_ext_info_set, "IIO_BACKEND"); 638 638 639 639 /** 640 + * iio_backend_interface_type_get - get the interface type used. 641 + * @back: Backend device 642 + * @type: Interface type 643 + * 644 + * RETURNS: 645 + * 0 on success, negative error number on failure. 646 + */ 647 + int iio_backend_interface_type_get(struct iio_backend *back, 648 + enum iio_backend_interface_type *type) 649 + { 650 + int ret; 651 + 652 + ret = iio_backend_op_call(back, interface_type_get, type); 653 + if (ret) 654 + return ret; 655 + 656 + if (*type >= IIO_BACKEND_INTERFACE_MAX) 657 + return -EINVAL; 658 + 659 + return 0; 660 + } 661 + EXPORT_SYMBOL_NS_GPL(iio_backend_interface_type_get, "IIO_BACKEND"); 662 + 663 + /** 640 664 * iio_backend_extend_chan_spec - Extend an IIO channel 641 665 * @back: Backend device 642 666 * @chan: IIO channel
+11
include/linux/iio/backend.h
··· 70 70 IIO_BACKEND_SAMPLE_TRIGGER_MAX 71 71 }; 72 72 73 + enum iio_backend_interface_type { 74 + IIO_BACKEND_INTERFACE_SERIAL_LVDS, 75 + IIO_BACKEND_INTERFACE_SERIAL_CMOS, 76 + IIO_BACKEND_INTERFACE_MAX 77 + }; 78 + 73 79 /** 74 80 * struct iio_backend_ops - operations structure for an iio_backend 75 81 * @enable: Enable backend. ··· 94 88 * @extend_chan_spec: Extend an IIO channel. 95 89 * @ext_info_set: Extended info setter. 96 90 * @ext_info_get: Extended info getter. 91 + * @interface_type_get: Interface type. 97 92 * @read_raw: Read a channel attribute from a backend device 98 93 * @debugfs_print_chan_status: Print channel status into a buffer. 99 94 * @debugfs_reg_access: Read or write register value of backend. ··· 135 128 const char *buf, size_t len); 136 129 int (*ext_info_get)(struct iio_backend *back, uintptr_t private, 137 130 const struct iio_chan_spec *chan, char *buf); 131 + int (*interface_type_get)(struct iio_backend *back, 132 + enum iio_backend_interface_type *type); 138 133 int (*read_raw)(struct iio_backend *back, 139 134 struct iio_chan_spec const *chan, int *val, int *val2, 140 135 long mask); ··· 195 186 const char *buf, size_t len); 196 187 ssize_t iio_backend_ext_info_get(struct iio_dev *indio_dev, uintptr_t private, 197 188 const struct iio_chan_spec *chan, char *buf); 189 + int iio_backend_interface_type_get(struct iio_backend *back, 190 + enum iio_backend_interface_type *type); 198 191 int iio_backend_read_raw(struct iio_backend *back, 199 192 struct iio_chan_spec const *chan, int *val, int *val2, 200 193 long mask);