Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *  hwmon-sysfs.h - hardware monitoring chip driver sysfs defines
0004  *
0005  *  Copyright (C) 2005 Yani Ioannou <yani.ioannou@gmail.com>
0006  */
0007 #ifndef _LINUX_HWMON_SYSFS_H
0008 #define _LINUX_HWMON_SYSFS_H
0009 
0010 #include <linux/device.h>
0011 
0012 struct sensor_device_attribute{
0013     struct device_attribute dev_attr;
0014     int index;
0015 };
0016 #define to_sensor_dev_attr(_dev_attr) \
0017     container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
0018 
0019 #define SENSOR_ATTR(_name, _mode, _show, _store, _index)    \
0020     { .dev_attr = __ATTR(_name, _mode, _show, _store),  \
0021       .index = _index }
0022 
0023 #define SENSOR_ATTR_RO(_name, _func, _index)            \
0024     SENSOR_ATTR(_name, 0444, _func##_show, NULL, _index)
0025 
0026 #define SENSOR_ATTR_RW(_name, _func, _index)            \
0027     SENSOR_ATTR(_name, 0644, _func##_show, _func##_store, _index)
0028 
0029 #define SENSOR_ATTR_WO(_name, _func, _index)            \
0030     SENSOR_ATTR(_name, 0200, NULL, _func##_store, _index)
0031 
0032 #define SENSOR_DEVICE_ATTR(_name, _mode, _show, _store, _index) \
0033 struct sensor_device_attribute sensor_dev_attr_##_name      \
0034     = SENSOR_ATTR(_name, _mode, _show, _store, _index)
0035 
0036 #define SENSOR_DEVICE_ATTR_RO(_name, _func, _index)     \
0037     SENSOR_DEVICE_ATTR(_name, 0444, _func##_show, NULL, _index)
0038 
0039 #define SENSOR_DEVICE_ATTR_RW(_name, _func, _index)     \
0040     SENSOR_DEVICE_ATTR(_name, 0644, _func##_show, _func##_store, _index)
0041 
0042 #define SENSOR_DEVICE_ATTR_WO(_name, _func, _index)     \
0043     SENSOR_DEVICE_ATTR(_name, 0200, NULL, _func##_store, _index)
0044 
0045 struct sensor_device_attribute_2 {
0046     struct device_attribute dev_attr;
0047     u8 index;
0048     u8 nr;
0049 };
0050 #define to_sensor_dev_attr_2(_dev_attr) \
0051     container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
0052 
0053 #define SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index) \
0054     { .dev_attr = __ATTR(_name, _mode, _show, _store),  \
0055       .index = _index,                  \
0056       .nr = _nr }
0057 
0058 #define SENSOR_ATTR_2_RO(_name, _func, _nr, _index)     \
0059     SENSOR_ATTR_2(_name, 0444, _func##_show, NULL, _nr, _index)
0060 
0061 #define SENSOR_ATTR_2_RW(_name, _func, _nr, _index)     \
0062     SENSOR_ATTR_2(_name, 0644, _func##_show, _func##_store, _nr, _index)
0063 
0064 #define SENSOR_ATTR_2_WO(_name, _func, _nr, _index)     \
0065     SENSOR_ATTR_2(_name, 0200, NULL, _func##_store, _nr, _index)
0066 
0067 #define SENSOR_DEVICE_ATTR_2(_name,_mode,_show,_store,_nr,_index)   \
0068 struct sensor_device_attribute_2 sensor_dev_attr_##_name        \
0069     = SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index)
0070 
0071 #define SENSOR_DEVICE_ATTR_2_RO(_name, _func, _nr, _index)      \
0072     SENSOR_DEVICE_ATTR_2(_name, 0444, _func##_show, NULL,       \
0073                  _nr, _index)
0074 
0075 #define SENSOR_DEVICE_ATTR_2_RW(_name, _func, _nr, _index)      \
0076     SENSOR_DEVICE_ATTR_2(_name, 0644, _func##_show, _func##_store,  \
0077                  _nr, _index)
0078 
0079 #define SENSOR_DEVICE_ATTR_2_WO(_name, _func, _nr, _index)      \
0080     SENSOR_DEVICE_ATTR_2(_name, 0200, NULL, _func##_store,      \
0081                  _nr, _index)
0082 
0083 #endif /* _LINUX_HWMON_SYSFS_H */