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