Merge remote-tracking branch 'asoc/topic/sti' into asoc-next
[deliverable/linux.git] / include / linux / iio / sysfs.h
CommitLineData
847ec80b
JC
1/* The industrial I/O core
2 *
3 *Copyright (c) 2008 Jonathan Cameron
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * General attributes
10 */
11
12#ifndef _INDUSTRIAL_IO_SYSFS_H_
13#define _INDUSTRIAL_IO_SYSFS_H_
14
4bfd5421 15struct iio_chan_spec;
847ec80b 16
847ec80b
JC
17/**
18 * struct iio_dev_attr - iio specific device attribute
19 * @dev_attr: underlying device attribute
20 * @address: associated register address
2854c098
CO
21 * @l: list head for maintaining list of dynamically created attrs
22 * @c: specification for the underlying channel
847ec80b
JC
23 */
24struct iio_dev_attr {
25 struct device_attribute dev_attr;
e614a54b 26 u64 address;
1d892719
JC
27 struct list_head l;
28 struct iio_chan_spec const *c;
847ec80b
JC
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 * struct iio_const_attr - constant device specific attribute
40 * often used for things like available modes
4c572605
RD
41 * @string: attribute string
42 * @dev_attr: underlying device attribute
847ec80b
JC
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
4c572605 52/* Some attributes will be hard coded (device dependent) and not require an
847ec80b
JC
53 address, in these cases pass a negative */
54#define IIO_ATTR(_name, _mode, _show, _store, _addr) \
55 { .dev_attr = __ATTR(_name, _mode, _show, _store), \
56 .address = _addr }
57
847ec80b
JC
58#define IIO_DEVICE_ATTR(_name, _mode, _show, _store, _addr) \
59 struct iio_dev_attr iio_dev_attr_##_name \
60 = IIO_ATTR(_name, _mode, _show, _store, _addr)
61
ad313b10
JC
62#define IIO_DEVICE_ATTR_NAMED(_vname, _name, _mode, _show, _store, _addr) \
63 struct iio_dev_attr iio_dev_attr_##_vname \
64 = IIO_ATTR(_name, _mode, _show, _store, _addr)
847ec80b 65
847ec80b
JC
66#define IIO_CONST_ATTR(_name, _string) \
67 struct iio_const_attr iio_const_attr_##_name \
68 = { .string = _string, \
69 .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
70
fc5d0e42
JC
71#define IIO_CONST_ATTR_NAMED(_vname, _name, _string) \
72 struct iio_const_attr iio_const_attr_##_vname \
73 = { .string = _string, \
74 .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
4c572605 75
355e25c1 76/* Generic attributes of onetype or another */
4f0cd86d 77
847ec80b 78/**
4c572605
RD
79 * IIO_DEV_ATTR_SAMP_FREQ - sets any internal clock frequency
80 * @_mode: sysfs file mode/permissions
81 * @_show: output method for the attribute
82 * @_store: input method for the attribute
847ec80b
JC
83 **/
84#define IIO_DEV_ATTR_SAMP_FREQ(_mode, _show, _store) \
85 IIO_DEVICE_ATTR(sampling_frequency, _mode, _show, _store, 0)
86
87/**
355e25c1 88 * IIO_DEV_ATTR_SAMP_FREQ_AVAIL - list available sampling frequencies
4c572605 89 * @_show: output method for the attribute
847ec80b 90 *
4c572605 91 * May be mode dependent on some devices
847ec80b 92 **/
ff7723e2
JC
93#define IIO_DEV_ATTR_SAMP_FREQ_AVAIL(_show) \
94 IIO_DEVICE_ATTR(sampling_frequency_available, S_IRUGO, _show, NULL, 0)
847ec80b 95/**
b90406f1 96 * IIO_CONST_ATTR_SAMP_FREQ_AVAIL - list available sampling frequencies
4c572605 97 * @_string: frequency string for the attribute
847ec80b
JC
98 *
99 * Constant version
100 **/
ff7723e2
JC
101#define IIO_CONST_ATTR_SAMP_FREQ_AVAIL(_string) \
102 IIO_CONST_ATTR(sampling_frequency_available, _string)
103
899d90bd
PM
104/**
105 * IIO_DEV_ATTR_INT_TIME_AVAIL - list available integration times
106 * @_show: output method for the attribute
107 **/
108#define IIO_DEV_ATTR_INT_TIME_AVAIL(_show) \
109 IIO_DEVICE_ATTR(integration_time_available, S_IRUGO, _show, NULL, 0)
110/**
111 * IIO_CONST_ATTR_INT_TIME_AVAIL - list available integration times
112 * @_string: frequency string for the attribute
113 *
114 * Constant version
115 **/
116#define IIO_CONST_ATTR_INT_TIME_AVAIL(_string) \
117 IIO_CONST_ATTR(integration_time_available, _string)
118
ff7723e2 119#define IIO_DEV_ATTR_TEMP_RAW(_show) \
322c9563 120 IIO_DEVICE_ATTR(in_temp_raw, S_IRUGO, _show, NULL, 0)
ff7723e2 121
51a0a5b0 122#define IIO_CONST_ATTR_TEMP_OFFSET(_string) \
322c9563 123 IIO_CONST_ATTR(in_temp_offset, _string)
51a0a5b0
MS
124
125#define IIO_CONST_ATTR_TEMP_SCALE(_string) \
322c9563 126 IIO_CONST_ATTR(in_temp_scale, _string)
51a0a5b0 127
847ec80b 128#endif /* _INDUSTRIAL_IO_SYSFS_H_ */
This page took 0.572254 seconds and 5 git commands to generate.