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: Add IIO_STATIC_CONST_DEVICE_ATTR

Add IIO_STATIC_CONST_DEVICE_ATTR macro for creating an read-only
iio_dev_attr which returns constant value. This macro is intended to be
used when replacing the IIO_CONST_ATTR - attributes for triggered
buffers because the triggered buffer attributes must be of type
iio_dev_attr.

Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/8dd853dd0ef8eb40cb980cc6f6e7a43166de3afb.1664782676.git.mazziesaccount@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Matti Vaittinen and committed by
Jonathan Cameron
2cc64a23 6abcb19e

+11
+11
include/linux/iio/sysfs.h
··· 97 97 = { .string = _string, \ 98 98 .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)} 99 99 100 + #define IIO_STATIC_CONST_DEVICE_ATTR(_name, _string) \ 101 + static ssize_t iio_const_dev_attr_show_##_name( \ 102 + struct device *dev, \ 103 + struct device_attribute *attr, \ 104 + char *buf) \ 105 + { \ 106 + return sysfs_emit(buf, "%s\n", _string); \ 107 + } \ 108 + static IIO_DEVICE_ATTR(_name, 0444, \ 109 + iio_const_dev_attr_show_##_name, NULL, 0) 110 + 100 111 /* Generic attributes of onetype or another */ 101 112 102 113 /**