Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
sysfs.h
Go to the documentation of this file.
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 
15 struct iio_chan_spec;
16 
23 struct iio_dev_attr {
26  struct list_head l;
28 };
29 
30 #define to_iio_dev_attr(_dev_attr) \
31  container_of(_dev_attr, struct iio_dev_attr, dev_attr)
32 
34  struct device_attribute *attr,
35  char *len);
36 
44  const char *string;
46 };
47 
48 #define to_iio_const_attr(_dev_attr) \
49  container_of(_dev_attr, struct iio_const_attr, dev_attr)
50 
51 /* Some attributes will be hard coded (device dependent) and not require an
52  address, in these cases pass a negative */
53 #define IIO_ATTR(_name, _mode, _show, _store, _addr) \
54  { .dev_attr = __ATTR(_name, _mode, _show, _store), \
55  .address = _addr }
56 
57 #define IIO_DEVICE_ATTR(_name, _mode, _show, _store, _addr) \
58  struct iio_dev_attr iio_dev_attr_##_name \
59  = IIO_ATTR(_name, _mode, _show, _store, _addr)
60 
61 #define IIO_DEVICE_ATTR_NAMED(_vname, _name, _mode, _show, _store, _addr) \
62  struct iio_dev_attr iio_dev_attr_##_vname \
63  = IIO_ATTR(_name, _mode, _show, _store, _addr)
64 
65 #define IIO_CONST_ATTR(_name, _string) \
66  struct iio_const_attr iio_const_attr_##_name \
67  = { .string = _string, \
68  .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
69 
70 #define IIO_CONST_ATTR_NAMED(_vname, _name, _string) \
71  struct iio_const_attr iio_const_attr_##_vname \
72  = { .string = _string, \
73  .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)}
74 
75 /* Generic attributes of onetype or another */
79 #define IIO_DEV_ATTR_RESET(_store) \
80  IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, _store, 0)
81 
88 #define IIO_DEV_ATTR_SAMP_FREQ(_mode, _show, _store) \
89  IIO_DEVICE_ATTR(sampling_frequency, _mode, _show, _store, 0)
90 
97 #define IIO_DEV_ATTR_SAMP_FREQ_AVAIL(_show) \
98  IIO_DEVICE_ATTR(sampling_frequency_available, S_IRUGO, _show, NULL, 0)
99 
105 #define IIO_CONST_ATTR_SAMP_FREQ_AVAIL(_string) \
106  IIO_CONST_ATTR(sampling_frequency_available, _string)
107 
108 #define IIO_DEV_ATTR_TEMP_RAW(_show) \
109  IIO_DEVICE_ATTR(in_temp_raw, S_IRUGO, _show, NULL, 0)
110 
111 #define IIO_CONST_ATTR_TEMP_OFFSET(_string) \
112  IIO_CONST_ATTR(in_temp_offset, _string)
113 
114 #define IIO_CONST_ATTR_TEMP_SCALE(_string) \
115  IIO_CONST_ATTR(in_temp_scale, _string)
116 
117 #endif /* _INDUSTRIAL_IO_SYSFS_H_ */