1、SENSOR_DEVICE_ATTR宏定义
#define SENSOR_DEVICE_ATTR(_name, _mode, _show, _store, _index) \
struct sensor_device_attribute sensor_dev_attr_##_name = SENSOR_ATTR(_name, _mode, _show, _store, _index)
该宏是用来定义一个struct sensor_device_attribute类型的变量,并初始化;
2、SENSOR_DEVICE_ATTR宏展开分析
SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1_input, NULL, 0);
struct sensor_device_attribute sensor_dev_attr_temp1_input = SENSOR_ATTR(temp1_input, S_IRUGO, show_temp1_input, NULL, 0)
struct sensor_device_attribute sensor_dev_attr_temp1_input = { \
.dev_attr = __ATTR(temp1_input, S_IRUGO, show_temp1_input, NULL), \
.index = _index }
struct sensor_device_attribute sensor_dev_attr_temp1_input = { \
.dev_attr = { \
.attr = {.name = temp1_input, .mode = S_IRUGO }, \
.show = _show, \
.store = _store, \
}\
.index = _index }
定义了一个struct sensor_device_attribute类型的变量,名字叫做sensor_dev_attr_temp1_input ,并初始化;