diff options
Diffstat (limited to 'include/linux/device.h')
| -rw-r--r-- | include/linux/device.h | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 22b546a58591..2a9d6ed59579 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -66,6 +66,9 @@ extern void bus_remove_file(struct bus_type *, struct bus_attribute *); | |||
| 66 | * @bus_attrs: Default attributes of the bus. | 66 | * @bus_attrs: Default attributes of the bus. |
| 67 | * @dev_attrs: Default attributes of the devices on the bus. | 67 | * @dev_attrs: Default attributes of the devices on the bus. |
| 68 | * @drv_attrs: Default attributes of the device drivers on the bus. | 68 | * @drv_attrs: Default attributes of the device drivers on the bus. |
| 69 | * @bus_groups: Default attributes of the bus. | ||
| 70 | * @dev_groups: Default attributes of the devices on the bus. | ||
| 71 | * @drv_groups: Default attributes of the device drivers on the bus. | ||
| 69 | * @match: Called, perhaps multiple times, whenever a new device or driver | 72 | * @match: Called, perhaps multiple times, whenever a new device or driver |
| 70 | * is added for this bus. It should return a nonzero value if the | 73 | * is added for this bus. It should return a nonzero value if the |
| 71 | * given device can be handled by the given driver. | 74 | * given device can be handled by the given driver. |
| @@ -103,9 +106,12 @@ struct bus_type { | |||
| 103 | const char *name; | 106 | const char *name; |
| 104 | const char *dev_name; | 107 | const char *dev_name; |
| 105 | struct device *dev_root; | 108 | struct device *dev_root; |
| 106 | struct bus_attribute *bus_attrs; | 109 | struct bus_attribute *bus_attrs; /* use bus_groups instead */ |
| 107 | struct device_attribute *dev_attrs; | 110 | struct device_attribute *dev_attrs; /* use dev_groups instead */ |
| 108 | struct driver_attribute *drv_attrs; | 111 | struct driver_attribute *drv_attrs; /* use drv_groups instead */ |
| 112 | const struct attribute_group **bus_groups; | ||
| 113 | const struct attribute_group **dev_groups; | ||
| 114 | const struct attribute_group **drv_groups; | ||
| 109 | 115 | ||
| 110 | int (*match)(struct device *dev, struct device_driver *drv); | 116 | int (*match)(struct device *dev, struct device_driver *drv); |
| 111 | int (*uevent)(struct device *dev, struct kobj_uevent_env *env); | 117 | int (*uevent)(struct device *dev, struct kobj_uevent_env *env); |
| @@ -271,6 +277,8 @@ struct driver_attribute { | |||
| 271 | struct driver_attribute driver_attr_##_name = __ATTR_RW(_name) | 277 | struct driver_attribute driver_attr_##_name = __ATTR_RW(_name) |
| 272 | #define DRIVER_ATTR_RO(_name) \ | 278 | #define DRIVER_ATTR_RO(_name) \ |
| 273 | struct driver_attribute driver_attr_##_name = __ATTR_RO(_name) | 279 | struct driver_attribute driver_attr_##_name = __ATTR_RO(_name) |
| 280 | #define DRIVER_ATTR_WO(_name) \ | ||
| 281 | struct driver_attribute driver_attr_##_name = __ATTR_WO(_name) | ||
| 274 | 282 | ||
| 275 | extern int __must_check driver_create_file(struct device_driver *driver, | 283 | extern int __must_check driver_create_file(struct device_driver *driver, |
| 276 | const struct driver_attribute *attr); | 284 | const struct driver_attribute *attr); |
| @@ -528,6 +536,8 @@ ssize_t device_store_bool(struct device *dev, struct device_attribute *attr, | |||
| 528 | struct device_attribute dev_attr_##_name = __ATTR_RW(_name) | 536 | struct device_attribute dev_attr_##_name = __ATTR_RW(_name) |
| 529 | #define DEVICE_ATTR_RO(_name) \ | 537 | #define DEVICE_ATTR_RO(_name) \ |
| 530 | struct device_attribute dev_attr_##_name = __ATTR_RO(_name) | 538 | struct device_attribute dev_attr_##_name = __ATTR_RO(_name) |
| 539 | #define DEVICE_ATTR_WO(_name) \ | ||
| 540 | struct device_attribute dev_attr_##_name = __ATTR_WO(_name) | ||
| 531 | #define DEVICE_ULONG_ATTR(_name, _mode, _var) \ | 541 | #define DEVICE_ULONG_ATTR(_name, _mode, _var) \ |
| 532 | struct dev_ext_attribute dev_attr_##_name = \ | 542 | struct dev_ext_attribute dev_attr_##_name = \ |
| 533 | { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) } | 543 | { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) } |
| @@ -727,7 +737,7 @@ struct device { | |||
| 727 | 737 | ||
| 728 | struct dma_coherent_mem *dma_mem; /* internal for coherent mem | 738 | struct dma_coherent_mem *dma_mem; /* internal for coherent mem |
| 729 | override */ | 739 | override */ |
| 730 | #ifdef CONFIG_CMA | 740 | #ifdef CONFIG_DMA_CMA |
| 731 | struct cma *cma_area; /* contiguous memory area for dma | 741 | struct cma *cma_area; /* contiguous memory area for dma |
| 732 | allocations */ | 742 | allocations */ |
| 733 | #endif | 743 | #endif |
| @@ -895,6 +905,7 @@ static inline bool device_supports_offline(struct device *dev) | |||
| 895 | 905 | ||
| 896 | extern void lock_device_hotplug(void); | 906 | extern void lock_device_hotplug(void); |
| 897 | extern void unlock_device_hotplug(void); | 907 | extern void unlock_device_hotplug(void); |
| 908 | extern int lock_device_hotplug_sysfs(void); | ||
| 898 | extern int device_offline(struct device *dev); | 909 | extern int device_offline(struct device *dev); |
| 899 | extern int device_online(struct device *dev); | 910 | extern int device_online(struct device *dev); |
| 900 | /* | 911 | /* |
| @@ -1099,7 +1110,8 @@ do { \ | |||
| 1099 | dev_level_ratelimited(dev_notice, dev, fmt, ##__VA_ARGS__) | 1110 | dev_level_ratelimited(dev_notice, dev, fmt, ##__VA_ARGS__) |
| 1100 | #define dev_info_ratelimited(dev, fmt, ...) \ | 1111 | #define dev_info_ratelimited(dev, fmt, ...) \ |
| 1101 | dev_level_ratelimited(dev_info, dev, fmt, ##__VA_ARGS__) | 1112 | dev_level_ratelimited(dev_info, dev, fmt, ##__VA_ARGS__) |
| 1102 | #if defined(CONFIG_DYNAMIC_DEBUG) || defined(DEBUG) | 1113 | #if defined(CONFIG_DYNAMIC_DEBUG) |
| 1114 | /* descriptor check is first to prevent flooding with "callbacks suppressed" */ | ||
| 1103 | #define dev_dbg_ratelimited(dev, fmt, ...) \ | 1115 | #define dev_dbg_ratelimited(dev, fmt, ...) \ |
| 1104 | do { \ | 1116 | do { \ |
| 1105 | static DEFINE_RATELIMIT_STATE(_rs, \ | 1117 | static DEFINE_RATELIMIT_STATE(_rs, \ |
| @@ -1108,8 +1120,17 @@ do { \ | |||
| 1108 | DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ | 1120 | DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ |
| 1109 | if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \ | 1121 | if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \ |
| 1110 | __ratelimit(&_rs)) \ | 1122 | __ratelimit(&_rs)) \ |
| 1111 | __dynamic_pr_debug(&descriptor, pr_fmt(fmt), \ | 1123 | __dynamic_dev_dbg(&descriptor, dev, fmt, \ |
| 1112 | ##__VA_ARGS__); \ | 1124 | ##__VA_ARGS__); \ |
| 1125 | } while (0) | ||
| 1126 | #elif defined(DEBUG) | ||
| 1127 | #define dev_dbg_ratelimited(dev, fmt, ...) \ | ||
| 1128 | do { \ | ||
| 1129 | static DEFINE_RATELIMIT_STATE(_rs, \ | ||
| 1130 | DEFAULT_RATELIMIT_INTERVAL, \ | ||
| 1131 | DEFAULT_RATELIMIT_BURST); \ | ||
| 1132 | if (__ratelimit(&_rs)) \ | ||
| 1133 | dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__); \ | ||
| 1113 | } while (0) | 1134 | } while (0) |
| 1114 | #else | 1135 | #else |
| 1115 | #define dev_dbg_ratelimited(dev, fmt, ...) \ | 1136 | #define dev_dbg_ratelimited(dev, fmt, ...) \ |
