0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _INDUSTRIAL_IO_SYSFS_H_
0010 #define _INDUSTRIAL_IO_SYSFS_H_
0011
0012 struct iio_buffer;
0013 struct iio_chan_spec;
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 struct iio_dev_attr {
0024 struct device_attribute dev_attr;
0025 u64 address;
0026 struct list_head l;
0027 struct iio_chan_spec const *c;
0028 struct iio_buffer *buffer;
0029 };
0030
0031 #define to_iio_dev_attr(_dev_attr) \
0032 container_of(_dev_attr, struct iio_dev_attr, dev_attr)
0033
0034 ssize_t iio_read_const_attr(struct device *dev,
0035 struct device_attribute *attr,
0036 char *len);
0037
0038
0039
0040
0041
0042
0043
0044 struct iio_const_attr {
0045 const char *string;
0046 struct device_attribute dev_attr;
0047 };
0048
0049 #define to_iio_const_attr(_dev_attr) \
0050 container_of(_dev_attr, struct iio_const_attr, dev_attr)
0051
0052
0053
0054 #define IIO_ATTR(_name, _mode, _show, _store, _addr) \
0055 { .dev_attr = __ATTR(_name, _mode, _show, _store), \
0056 .address = _addr }
0057
0058 #define IIO_ATTR_RO(_name, _addr) \
0059 { .dev_attr = __ATTR_RO(_name), \
0060 .address = _addr }
0061
0062 #define IIO_ATTR_WO(_name, _addr) \
0063 { .dev_attr = __ATTR_WO(_name), \
0064 .address = _addr }
0065
0066 #define IIO_ATTR_RW(_name, _addr) \
0067 { .dev_attr = __ATTR_RW(_name), \
0068 .address = _addr }
0069
0070 #define IIO_DEVICE_ATTR(_name, _mode, _show, _store, _addr) \
0071 struct iio_dev_attr iio_dev_attr_##_name \
0072 = IIO_ATTR(_name, _mode, _show, _store, _addr)
0073
0074 #define IIO_DEVICE_ATTR_RO(_name, _addr) \
0075 struct iio_dev_attr iio_dev_attr_##_name \
0076 = IIO_ATTR_RO(_name, _addr)
0077
0078 #define IIO_DEVICE_ATTR_WO(_name, _addr) \
0079 struct iio_dev_attr iio_dev_attr_##_name \
0080 = IIO_ATTR_WO(_name, _addr)
0081
0082 #define IIO_DEVICE_ATTR_RW(_name, _addr) \
0083 struct iio_dev_attr iio_dev_attr_##_name \
0084 = IIO_ATTR_RW(_name, _addr)
0085
0086 #define IIO_DEVICE_ATTR_NAMED(_vname, _name, _mode, _show, _store, _addr) \
0087 struct iio_dev_attr iio_dev_attr_##_vname \
0088 = IIO_ATTR(_name, _mode, _show, _store, _addr)
0089
0090 #define IIO_CONST_ATTR(_name, _string) \
0091 struct iio_const_attr iio_const_attr_##_name \
0092 = { .string = _string, \
0093 .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
0094
0095 #define IIO_CONST_ATTR_NAMED(_vname, _name, _string) \
0096 struct iio_const_attr iio_const_attr_##_vname \
0097 = { .string = _string, \
0098 .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108 #define IIO_DEV_ATTR_SAMP_FREQ(_mode, _show, _store) \
0109 IIO_DEVICE_ATTR(sampling_frequency, _mode, _show, _store, 0)
0110
0111
0112
0113
0114
0115
0116
0117 #define IIO_DEV_ATTR_SAMP_FREQ_AVAIL(_show) \
0118 IIO_DEVICE_ATTR(sampling_frequency_available, S_IRUGO, _show, NULL, 0)
0119
0120
0121
0122
0123
0124
0125 #define IIO_CONST_ATTR_SAMP_FREQ_AVAIL(_string) \
0126 IIO_CONST_ATTR(sampling_frequency_available, _string)
0127
0128
0129
0130
0131
0132 #define IIO_DEV_ATTR_INT_TIME_AVAIL(_show) \
0133 IIO_DEVICE_ATTR(integration_time_available, S_IRUGO, _show, NULL, 0)
0134
0135
0136
0137
0138
0139
0140 #define IIO_CONST_ATTR_INT_TIME_AVAIL(_string) \
0141 IIO_CONST_ATTR(integration_time_available, _string)
0142
0143 #define IIO_DEV_ATTR_TEMP_RAW(_show) \
0144 IIO_DEVICE_ATTR(in_temp_raw, S_IRUGO, _show, NULL, 0)
0145
0146 #define IIO_CONST_ATTR_TEMP_OFFSET(_string) \
0147 IIO_CONST_ATTR(in_temp_offset, _string)
0148
0149 #define IIO_CONST_ATTR_TEMP_SCALE(_string) \
0150 IIO_CONST_ATTR(in_temp_scale, _string)
0151
0152 #endif