October 2017
Intermediate to advanced
586 pages
14h 8m
English
The structure used here is struct driver_attribute:
struct driver_attribute {
struct attribute attr;
ssize_t (*show)(struct device_driver *, char * buf);
ssize_t (*store)(struct device_driver *, const char * buf,
size_t count);
};
The declaration relies on the DRIVER_ATTR macro, which will prefix the attribute variable name with DRIVER_ATTR:
DRIVER_ATTR(_name, _mode, _show, _store)
The macro definition is as follows:
#define DRIVER_ATTR(_name, _mode, _show, _store) \ struct driver_attribute driver_attr_##_name = __ATTR(_name, _mode, _show, _store)
Creation/removal relies on the driver_{create|remove}_file functions:
int driver_create_file(struct device_driver *, const struct driver_attribute *); void driver_remove_file(struct ...