这个符号在内核源中定义/生成的位置在哪里?

时间:2016-03-17 00:56:28

标签: linux-kernel linux-device-driver sysfs

在drivers / base / firmware_class.c中,此结构中有dev_attr_loading的引用:

static struct attribute *fw_dev_attrs[] = {
        &dev_attr_loading.attr,
        NULL
};

该符号可以在哪里定义或生成?它似乎不在源树或生成的文件中的任何位置。我似乎无法找到构建它的宏。我试图想出更多地方或方式来寻找。

1 个答案:

答案 0 :(得分:1)

它实际上在同一个文件中。它是由宏创建的:

static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store);

宏在include / linux / device.h中定义:

#define DEVICE_ATTR(_name, _mode, _show, _store) \
        struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store)

" _name"是什么让我在我的搜索;我没有意识到下划线可以用在宏中。

相关问题