1
2
3
4
5
6
7
8
9#ifndef _INDUSTRIAL_IO_SYSFS_H_
10#define _INDUSTRIAL_IO_SYSFS_H_
11
12struct iio_chan_spec;
13
14
15
16
17
18
19
20
21struct iio_dev_attr {
22 struct device_attribute dev_attr;
23 u64 address;
24 struct list_head l;
25 struct iio_chan_spec const *c;
26};
27
28#define to_iio_dev_attr(_dev_attr) \
29 container_of(_dev_attr, struct iio_dev_attr, dev_attr)
30
31ssize_t iio_read_const_attr(struct device *dev,
32 struct device_attribute *attr,
33 char *len);
34
35
36
37
38
39
40
41struct iio_const_attr {
42 const char *string;
43 struct device_attribute dev_attr;
44};
45
46#define to_iio_const_attr(_dev_attr) \
47 container_of(_dev_attr, struct iio_const_attr, dev_attr)
48
49
50
51#define IIO_ATTR(_name, _mode, _show, _store, _addr) \
52 { .dev_attr = __ATTR(_name, _mode, _show, _store), \
53 .address = _addr }
54
55#define IIO_ATTR_RO(_name, _addr) \
56 { .dev_attr = __ATTR_RO(_name), \
57 .address = _addr }
58
59#define IIO_ATTR_WO(_name, _addr) \
60 { .dev_attr = __ATTR_WO(_name), \
61 .address = _addr }
62
63#define IIO_ATTR_RW(_name, _addr) \
64 { .dev_attr = __ATTR_RW(_name), \
65 .address = _addr }
66
67#define IIO_DEVICE_ATTR(_name, _mode, _show, _store, _addr) \
68 struct iio_dev_attr iio_dev_attr_##_name \
69 = IIO_ATTR(_name, _mode, _show, _store, _addr)
70
71#define IIO_DEVICE_ATTR_RO(_name, _addr) \
72 struct iio_dev_attr iio_dev_attr_##_name \
73 = IIO_ATTR_RO(_name, _addr)
74
75#define IIO_DEVICE_ATTR_WO(_name, _addr) \
76 struct iio_dev_attr iio_dev_attr_##_name \
77 = IIO_ATTR_WO(_name, _addr)
78
79#define IIO_DEVICE_ATTR_RW(_name, _addr) \
80 struct iio_dev_attr iio_dev_attr_##_name \
81 = IIO_ATTR_RW(_name, _addr)
82
83#define IIO_DEVICE_ATTR_NAMED(_vname, _name, _mode, _show, _store, _addr) \
84 struct iio_dev_attr iio_dev_attr_##_vname \
85 = IIO_ATTR(_name, _mode, _show, _store, _addr)
86
87#define IIO_CONST_ATTR(_name, _string) \
88 struct iio_const_attr iio_const_attr_##_name \
89 = { .string = _string, \
90 .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
91
92#define IIO_CONST_ATTR_NAMED(_vname, _name, _string) \
93 struct iio_const_attr iio_const_attr_##_vname \
94 = { .string = _string, \
95 .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
96
97
98
99
100
101
102
103
104
105#define IIO_DEV_ATTR_SAMP_FREQ(_mode, _show, _store) \
106 IIO_DEVICE_ATTR(sampling_frequency, _mode, _show, _store, 0)
107
108
109
110
111
112
113
114#define IIO_DEV_ATTR_SAMP_FREQ_AVAIL(_show) \
115 IIO_DEVICE_ATTR(sampling_frequency_available, S_IRUGO, _show, NULL, 0)
116
117
118
119
120
121
122#define IIO_CONST_ATTR_SAMP_FREQ_AVAIL(_string) \
123 IIO_CONST_ATTR(sampling_frequency_available, _string)
124
125
126
127
128
129#define IIO_DEV_ATTR_INT_TIME_AVAIL(_show) \
130 IIO_DEVICE_ATTR(integration_time_available, S_IRUGO, _show, NULL, 0)
131
132
133
134
135
136
137#define IIO_CONST_ATTR_INT_TIME_AVAIL(_string) \
138 IIO_CONST_ATTR(integration_time_available, _string)
139
140#define IIO_DEV_ATTR_TEMP_RAW(_show) \
141 IIO_DEVICE_ATTR(in_temp_raw, S_IRUGO, _show, NULL, 0)
142
143#define IIO_CONST_ATTR_TEMP_OFFSET(_string) \
144 IIO_CONST_ATTR(in_temp_offset, _string)
145
146#define IIO_CONST_ATTR_TEMP_SCALE(_string) \
147 IIO_CONST_ATTR(in_temp_scale, _string)
148
149#endif
150