Blame view

include/linux/hwmon-sysfs.h 2.77 KB
74ba9207e   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-or-later */
0a3e7eeab   Yani Ioannou   [PATCH] I2C: add ...
2
  /*
10c08f810   Jean Delvare   [PATCH] I2C: rena...
3
   *  hwmon-sysfs.h - hardware monitoring chip driver sysfs defines
0a3e7eeab   Yani Ioannou   [PATCH] I2C: add ...
4
5
   *
   *  Copyright (C) 2005 Yani Ioannou <yani.ioannou@gmail.com>
0a3e7eeab   Yani Ioannou   [PATCH] I2C: add ...
6
   */
10c08f810   Jean Delvare   [PATCH] I2C: rena...
7
8
  #ifndef _LINUX_HWMON_SYSFS_H
  #define _LINUX_HWMON_SYSFS_H
0a3e7eeab   Yani Ioannou   [PATCH] I2C: add ...
9

313162d0b   Paul Gortmaker   device.h: audit a...
10
  #include <linux/device.h>
0a3e7eeab   Yani Ioannou   [PATCH] I2C: add ...
11
12
13
14
15
16
  struct sensor_device_attribute{
  	struct device_attribute dev_attr;
  	int index;
  };
  #define to_sensor_dev_attr(_dev_attr) \
  	container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
42d3b83fe   Jim Cromie   [PATCH] hwmon: Al...
17
18
19
  #define SENSOR_ATTR(_name, _mode, _show, _store, _index)	\
  	{ .dev_attr = __ATTR(_name, _mode, _show, _store),	\
  	  .index = _index }
a5c47c0d3   Guenter Roeck   hwmon: Introduce ...
20
21
22
23
24
25
26
27
  #define SENSOR_ATTR_RO(_name, _func, _index)			\
  	SENSOR_ATTR(_name, 0444, _func##_show, NULL, _index)
  
  #define SENSOR_ATTR_RW(_name, _func, _index)			\
  	SENSOR_ATTR(_name, 0644, _func##_show, _func##_store, _index)
  
  #define SENSOR_ATTR_WO(_name, _func, _index)			\
  	SENSOR_ATTR(_name, 0200, NULL, _func##_store, _index)
42d3b83fe   Jim Cromie   [PATCH] hwmon: Al...
28
29
30
  #define SENSOR_DEVICE_ATTR(_name, _mode, _show, _store, _index)	\
  struct sensor_device_attribute sensor_dev_attr_##_name		\
  	= SENSOR_ATTR(_name, _mode, _show, _store, _index)
0a3e7eeab   Yani Ioannou   [PATCH] I2C: add ...
31

a5c47c0d3   Guenter Roeck   hwmon: Introduce ...
32
33
34
35
36
37
38
39
  #define SENSOR_DEVICE_ATTR_RO(_name, _func, _index)		\
  	SENSOR_DEVICE_ATTR(_name, 0444, _func##_show, NULL, _index)
  
  #define SENSOR_DEVICE_ATTR_RW(_name, _func, _index)		\
  	SENSOR_DEVICE_ATTR(_name, 0644, _func##_show, _func##_store, _index)
  
  #define SENSOR_DEVICE_ATTR_WO(_name, _func, _index)		\
  	SENSOR_DEVICE_ATTR(_name, 0200, NULL, _func##_store, _index)
5563e27d3   Rudolf Marek   [PATCH] I2C: W837...
40
41
42
43
44
45
46
  struct sensor_device_attribute_2 {
  	struct device_attribute dev_attr;
  	u8 index;
  	u8 nr;
  };
  #define to_sensor_dev_attr_2(_dev_attr) \
  	container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
70adca5a9   Jim Cromie   [PATCH] hwmon: Re...
47
48
49
50
  #define SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index)	\
  	{ .dev_attr = __ATTR(_name, _mode, _show, _store),	\
  	  .index = _index,					\
  	  .nr = _nr }
a5c47c0d3   Guenter Roeck   hwmon: Introduce ...
51
52
53
54
55
56
57
58
  #define SENSOR_ATTR_2_RO(_name, _func, _nr, _index)		\
  	SENSOR_ATTR_2(_name, 0444, _func##_show, NULL, _nr, _index)
  
  #define SENSOR_ATTR_2_RW(_name, _func, _nr, _index)		\
  	SENSOR_ATTR_2(_name, 0644, _func##_show, _func##_store, _nr, _index)
  
  #define SENSOR_ATTR_2_WO(_name, _func, _nr, _index)		\
  	SENSOR_ATTR_2(_name, 0200, NULL, _func##_store, _nr, _index)
5563e27d3   Rudolf Marek   [PATCH] I2C: W837...
59
  #define SENSOR_DEVICE_ATTR_2(_name,_mode,_show,_store,_nr,_index)	\
70adca5a9   Jim Cromie   [PATCH] hwmon: Re...
60
61
  struct sensor_device_attribute_2 sensor_dev_attr_##_name		\
  	= SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index)
5563e27d3   Rudolf Marek   [PATCH] I2C: W837...
62

a5c47c0d3   Guenter Roeck   hwmon: Introduce ...
63
64
65
66
67
68
69
70
71
72
73
  #define SENSOR_DEVICE_ATTR_2_RO(_name, _func, _nr, _index)		\
  	SENSOR_DEVICE_ATTR_2(_name, 0444, _func##_show, NULL,		\
  			     _nr, _index)
  
  #define SENSOR_DEVICE_ATTR_2_RW(_name, _func, _nr, _index)		\
  	SENSOR_DEVICE_ATTR_2(_name, 0644, _func##_show, _func##_store,	\
  			     _nr, _index)
  
  #define SENSOR_DEVICE_ATTR_2_WO(_name, _func, _nr, _index)		\
  	SENSOR_DEVICE_ATTR_2(_name, 0200, NULL, _func##_store,		\
  			     _nr, _index)
10c08f810   Jean Delvare   [PATCH] I2C: rena...
74
  #endif /* _LINUX_HWMON_SYSFS_H */