diff options
Diffstat (limited to 'include/linux/device.h')
-rw-r--r-- | include/linux/device.h | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/include/linux/device.h b/include/linux/device.h index 5ad17cccdd71..e04f5776f6d0 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
24 | #include <linux/pm.h> | 24 | #include <linux/pm.h> |
25 | #include <linux/atomic.h> | 25 | #include <linux/atomic.h> |
26 | #include <linux/ratelimit.h> | ||
26 | #include <asm/device.h> | 27 | #include <asm/device.h> |
27 | 28 | ||
28 | struct device; | 29 | struct device; |
@@ -502,7 +503,10 @@ ssize_t device_store_int(struct device *dev, struct device_attribute *attr, | |||
502 | { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) } | 503 | { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) } |
503 | #define DEVICE_INT_ATTR(_name, _mode, _var) \ | 504 | #define DEVICE_INT_ATTR(_name, _mode, _var) \ |
504 | struct dev_ext_attribute dev_attr_##_name = \ | 505 | struct dev_ext_attribute dev_attr_##_name = \ |
505 | { __ATTR(_name, _mode, device_show_ulong, device_store_ulong), &(_var) } | 506 | { __ATTR(_name, _mode, device_show_int, device_store_int), &(_var) } |
507 | #define DEVICE_ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) \ | ||
508 | struct device_attribute dev_attr_##_name = \ | ||
509 | __ATTR_IGNORE_LOCKDEP(_name, _mode, _show, _store) | ||
506 | 510 | ||
507 | extern int device_create_file(struct device *device, | 511 | extern int device_create_file(struct device *device, |
508 | const struct device_attribute *entry); | 512 | const struct device_attribute *entry); |
@@ -541,6 +545,8 @@ extern void *devres_remove(struct device *dev, dr_release_t release, | |||
541 | dr_match_t match, void *match_data); | 545 | dr_match_t match, void *match_data); |
542 | extern int devres_destroy(struct device *dev, dr_release_t release, | 546 | extern int devres_destroy(struct device *dev, dr_release_t release, |
543 | dr_match_t match, void *match_data); | 547 | dr_match_t match, void *match_data); |
548 | extern int devres_release(struct device *dev, dr_release_t release, | ||
549 | dr_match_t match, void *match_data); | ||
544 | 550 | ||
545 | /* devres group */ | 551 | /* devres group */ |
546 | extern void * __must_check devres_open_group(struct device *dev, void *id, | 552 | extern void * __must_check devres_open_group(struct device *dev, void *id, |
@@ -931,6 +937,32 @@ int _dev_info(const struct device *dev, const char *fmt, ...) | |||
931 | 937 | ||
932 | #endif | 938 | #endif |
933 | 939 | ||
940 | #define dev_level_ratelimited(dev_level, dev, fmt, ...) \ | ||
941 | do { \ | ||
942 | static DEFINE_RATELIMIT_STATE(_rs, \ | ||
943 | DEFAULT_RATELIMIT_INTERVAL, \ | ||
944 | DEFAULT_RATELIMIT_BURST); \ | ||
945 | if (__ratelimit(&_rs)) \ | ||
946 | dev_level(dev, fmt, ##__VA_ARGS__); \ | ||
947 | } while (0) | ||
948 | |||
949 | #define dev_emerg_ratelimited(dev, fmt, ...) \ | ||
950 | dev_level_ratelimited(dev_emerg, dev, fmt, ##__VA_ARGS__) | ||
951 | #define dev_alert_ratelimited(dev, fmt, ...) \ | ||
952 | dev_level_ratelimited(dev_alert, dev, fmt, ##__VA_ARGS__) | ||
953 | #define dev_crit_ratelimited(dev, fmt, ...) \ | ||
954 | dev_level_ratelimited(dev_crit, dev, fmt, ##__VA_ARGS__) | ||
955 | #define dev_err_ratelimited(dev, fmt, ...) \ | ||
956 | dev_level_ratelimited(dev_err, dev, fmt, ##__VA_ARGS__) | ||
957 | #define dev_warn_ratelimited(dev, fmt, ...) \ | ||
958 | dev_level_ratelimited(dev_warn, dev, fmt, ##__VA_ARGS__) | ||
959 | #define dev_notice_ratelimited(dev, fmt, ...) \ | ||
960 | dev_level_ratelimited(dev_notice, dev, fmt, ##__VA_ARGS__) | ||
961 | #define dev_info_ratelimited(dev, fmt, ...) \ | ||
962 | dev_level_ratelimited(dev_info, dev, fmt, ##__VA_ARGS__) | ||
963 | #define dev_dbg_ratelimited(dev, fmt, ...) \ | ||
964 | dev_level_ratelimited(dev_dbg, dev, fmt, ##__VA_ARGS__) | ||
965 | |||
934 | /* | 966 | /* |
935 | * Stupid hackaround for existing uses of non-printk uses dev_info | 967 | * Stupid hackaround for existing uses of non-printk uses dev_info |
936 | * | 968 | * |