Search code examples
linux-kernellinux-device-driversysfs

Where is this symbol defined/generated in the kernel source?


In drivers/base/firmware_class.c, there's a reference to dev_attr_loading in this struct:

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

Where could that symbol be defined or generated? It doesn't seem to be anywhere in the source tree or generated files. I can't seem to find a macro that builds it either. I'm trying to think of more places or ways to look.


Solution

  • It's actually in the same file. It's created by a macro:

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

    The macro is defined in include/linux/device.h:

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

    The "_name" is what threw me in my search; I didn't realize that the underscore could be used in a macro that way.