diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/bitmap.h | 3 | ||||
| -rw-r--r-- | include/linux/cacheinfo.h | 100 | ||||
| -rw-r--r-- | include/linux/cpu.h | 4 | ||||
| -rw-r--r-- | include/linux/cpumask.h | 17 | ||||
| -rw-r--r-- | include/linux/debugfs.h | 17 | ||||
| -rw-r--r-- | include/linux/device.h | 35 | ||||
| -rw-r--r-- | include/linux/kernfs.h | 8 | ||||
| -rw-r--r-- | include/linux/platform_device.h | 12 | ||||
| -rw-r--r-- | include/linux/sysfs.h | 9 |
9 files changed, 200 insertions, 5 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 34e020c23644..202e4034fe26 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h | |||
| @@ -61,6 +61,7 @@ | |||
| 61 | * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region | 61 | * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region |
| 62 | * bitmap_release_region(bitmap, pos, order) Free specified bit region | 62 | * bitmap_release_region(bitmap, pos, order) Free specified bit region |
| 63 | * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region | 63 | * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region |
| 64 | * bitmap_print_to_pagebuf(list, buf, mask, nbits) Print bitmap src as list/hex | ||
| 64 | */ | 65 | */ |
| 65 | 66 | ||
| 66 | /* | 67 | /* |
| @@ -171,6 +172,8 @@ extern void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int o | |||
| 171 | extern int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order); | 172 | extern int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order); |
| 172 | extern void bitmap_copy_le(void *dst, const unsigned long *src, int nbits); | 173 | extern void bitmap_copy_le(void *dst, const unsigned long *src, int nbits); |
| 173 | extern int bitmap_ord_to_pos(const unsigned long *bitmap, int n, int bits); | 174 | extern int bitmap_ord_to_pos(const unsigned long *bitmap, int n, int bits); |
| 175 | extern int bitmap_print_to_pagebuf(bool list, char *buf, | ||
| 176 | const unsigned long *maskp, int nmaskbits); | ||
| 174 | 177 | ||
| 175 | #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG)) | 178 | #define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG)) |
| 176 | #define BITMAP_LAST_WORD_MASK(nbits) \ | 179 | #define BITMAP_LAST_WORD_MASK(nbits) \ |
diff --git a/include/linux/cacheinfo.h b/include/linux/cacheinfo.h new file mode 100644 index 000000000000..3daf5ed392c9 --- /dev/null +++ b/include/linux/cacheinfo.h | |||
| @@ -0,0 +1,100 @@ | |||
| 1 | #ifndef _LINUX_CACHEINFO_H | ||
| 2 | #define _LINUX_CACHEINFO_H | ||
| 3 | |||
| 4 | #include <linux/bitops.h> | ||
| 5 | #include <linux/cpumask.h> | ||
| 6 | #include <linux/smp.h> | ||
| 7 | |||
| 8 | struct device_node; | ||
| 9 | struct attribute; | ||
| 10 | |||
| 11 | enum cache_type { | ||
| 12 | CACHE_TYPE_NOCACHE = 0, | ||
| 13 | CACHE_TYPE_INST = BIT(0), | ||
| 14 | CACHE_TYPE_DATA = BIT(1), | ||
| 15 | CACHE_TYPE_SEPARATE = CACHE_TYPE_INST | CACHE_TYPE_DATA, | ||
| 16 | CACHE_TYPE_UNIFIED = BIT(2), | ||
| 17 | }; | ||
| 18 | |||
| 19 | /** | ||
| 20 | * struct cacheinfo - represent a cache leaf node | ||
| 21 | * @type: type of the cache - data, inst or unified | ||
| 22 | * @level: represents the hierarcy in the multi-level cache | ||
| 23 | * @coherency_line_size: size of each cache line usually representing | ||
| 24 | * the minimum amount of data that gets transferred from memory | ||
| 25 | * @number_of_sets: total number of sets, a set is a collection of cache | ||
| 26 | * lines sharing the same index | ||
| 27 | * @ways_of_associativity: number of ways in which a particular memory | ||
| 28 | * block can be placed in the cache | ||
| 29 | * @physical_line_partition: number of physical cache lines sharing the | ||
| 30 | * same cachetag | ||
| 31 | * @size: Total size of the cache | ||
| 32 | * @shared_cpu_map: logical cpumask representing all the cpus sharing | ||
| 33 | * this cache node | ||
| 34 | * @attributes: bitfield representing various cache attributes | ||
| 35 | * @of_node: if devicetree is used, this represents either the cpu node in | ||
| 36 | * case there's no explicit cache node or the cache node itself in the | ||
| 37 | * device tree | ||
| 38 | * @disable_sysfs: indicates whether this node is visible to the user via | ||
| 39 | * sysfs or not | ||
| 40 | * @priv: pointer to any private data structure specific to particular | ||
| 41 | * cache design | ||
| 42 | * | ||
| 43 | * While @of_node, @disable_sysfs and @priv are used for internal book | ||
| 44 | * keeping, the remaining members form the core properties of the cache | ||
| 45 | */ | ||
| 46 | struct cacheinfo { | ||
| 47 | enum cache_type type; | ||
| 48 | unsigned int level; | ||
| 49 | unsigned int coherency_line_size; | ||
| 50 | unsigned int number_of_sets; | ||
| 51 | unsigned int ways_of_associativity; | ||
| 52 | unsigned int physical_line_partition; | ||
| 53 | unsigned int size; | ||
| 54 | cpumask_t shared_cpu_map; | ||
| 55 | unsigned int attributes; | ||
| 56 | #define CACHE_WRITE_THROUGH BIT(0) | ||
| 57 | #define CACHE_WRITE_BACK BIT(1) | ||
| 58 | #define CACHE_WRITE_POLICY_MASK \ | ||
| 59 | (CACHE_WRITE_THROUGH | CACHE_WRITE_BACK) | ||
| 60 | #define CACHE_READ_ALLOCATE BIT(2) | ||
| 61 | #define CACHE_WRITE_ALLOCATE BIT(3) | ||
| 62 | #define CACHE_ALLOCATE_POLICY_MASK \ | ||
| 63 | (CACHE_READ_ALLOCATE | CACHE_WRITE_ALLOCATE) | ||
| 64 | |||
| 65 | struct device_node *of_node; | ||
| 66 | bool disable_sysfs; | ||
| 67 | void *priv; | ||
| 68 | }; | ||
| 69 | |||
| 70 | struct cpu_cacheinfo { | ||
| 71 | struct cacheinfo *info_list; | ||
| 72 | unsigned int num_levels; | ||
| 73 | unsigned int num_leaves; | ||
| 74 | }; | ||
| 75 | |||
| 76 | /* | ||
| 77 | * Helpers to make sure "func" is executed on the cpu whose cache | ||
| 78 | * attributes are being detected | ||
| 79 | */ | ||
| 80 | #define DEFINE_SMP_CALL_CACHE_FUNCTION(func) \ | ||
| 81 | static inline void _##func(void *ret) \ | ||
| 82 | { \ | ||
| 83 | int cpu = smp_processor_id(); \ | ||
| 84 | *(int *)ret = __##func(cpu); \ | ||
| 85 | } \ | ||
| 86 | \ | ||
| 87 | int func(unsigned int cpu) \ | ||
| 88 | { \ | ||
| 89 | int ret; \ | ||
| 90 | smp_call_function_single(cpu, _##func, &ret, true); \ | ||
| 91 | return ret; \ | ||
| 92 | } | ||
| 93 | |||
| 94 | struct cpu_cacheinfo *get_cpu_cacheinfo(unsigned int cpu); | ||
| 95 | int init_cache_level(unsigned int cpu); | ||
| 96 | int populate_cache_leaves(unsigned int cpu); | ||
| 97 | |||
| 98 | const struct attribute_group *cache_get_priv_group(struct cacheinfo *this_leaf); | ||
| 99 | |||
| 100 | #endif /* _LINUX_CACHEINFO_H */ | ||
diff --git a/include/linux/cpu.h b/include/linux/cpu.h index b2d9a43012b2..4260e8594bd7 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | 19 | ||
| 20 | struct device; | 20 | struct device; |
| 21 | struct device_node; | 21 | struct device_node; |
| 22 | struct attribute_group; | ||
| 22 | 23 | ||
| 23 | struct cpu { | 24 | struct cpu { |
| 24 | int node_id; /* The node which contains the CPU */ | 25 | int node_id; /* The node which contains the CPU */ |
| @@ -39,6 +40,9 @@ extern void cpu_remove_dev_attr(struct device_attribute *attr); | |||
| 39 | extern int cpu_add_dev_attr_group(struct attribute_group *attrs); | 40 | extern int cpu_add_dev_attr_group(struct attribute_group *attrs); |
| 40 | extern void cpu_remove_dev_attr_group(struct attribute_group *attrs); | 41 | extern void cpu_remove_dev_attr_group(struct attribute_group *attrs); |
| 41 | 42 | ||
| 43 | extern struct device *cpu_device_create(struct device *parent, void *drvdata, | ||
| 44 | const struct attribute_group **groups, | ||
| 45 | const char *fmt, ...); | ||
| 42 | #ifdef CONFIG_HOTPLUG_CPU | 46 | #ifdef CONFIG_HOTPLUG_CPU |
| 43 | extern void unregister_cpu(struct cpu *cpu); | 47 | extern void unregister_cpu(struct cpu *cpu); |
| 44 | extern ssize_t arch_cpu_probe(const char *, size_t); | 48 | extern ssize_t arch_cpu_probe(const char *, size_t); |
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index 0a9a6da21e74..b950e9d6008b 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h | |||
| @@ -803,6 +803,23 @@ static inline const struct cpumask *get_cpu_mask(unsigned int cpu) | |||
| 803 | } | 803 | } |
| 804 | #endif /* NR_CPUS > BITS_PER_LONG */ | 804 | #endif /* NR_CPUS > BITS_PER_LONG */ |
| 805 | 805 | ||
| 806 | /** | ||
| 807 | * cpumap_print_to_pagebuf - copies the cpumask into the buffer either | ||
| 808 | * as comma-separated list of cpus or hex values of cpumask | ||
| 809 | * @list: indicates whether the cpumap must be list | ||
| 810 | * @mask: the cpumask to copy | ||
| 811 | * @buf: the buffer to copy into | ||
| 812 | * | ||
| 813 | * Returns the length of the (null-terminated) @buf string, zero if | ||
| 814 | * nothing is copied. | ||
| 815 | */ | ||
| 816 | static inline ssize_t | ||
| 817 | cpumap_print_to_pagebuf(bool list, char *buf, const struct cpumask *mask) | ||
| 818 | { | ||
| 819 | return bitmap_print_to_pagebuf(list, buf, cpumask_bits(mask), | ||
| 820 | nr_cpumask_bits); | ||
| 821 | } | ||
| 822 | |||
| 806 | /* | 823 | /* |
| 807 | * | 824 | * |
| 808 | * From here down, all obsolete. Use cpumask_ variants! | 825 | * From here down, all obsolete. Use cpumask_ variants! |
diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index d84f8c254a87..da4c4983adbe 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | 20 | ||
| 21 | #include <linux/types.h> | 21 | #include <linux/types.h> |
| 22 | 22 | ||
| 23 | struct device; | ||
| 23 | struct file_operations; | 24 | struct file_operations; |
| 24 | 25 | ||
| 25 | struct debugfs_blob_wrapper { | 26 | struct debugfs_blob_wrapper { |
| @@ -99,13 +100,18 @@ struct dentry *debugfs_create_u32_array(const char *name, umode_t mode, | |||
| 99 | struct dentry *parent, | 100 | struct dentry *parent, |
| 100 | u32 *array, u32 elements); | 101 | u32 *array, u32 elements); |
| 101 | 102 | ||
| 103 | struct dentry *debugfs_create_devm_seqfile(struct device *dev, const char *name, | ||
| 104 | struct dentry *parent, | ||
| 105 | int (*read_fn)(struct seq_file *s, | ||
| 106 | void *data)); | ||
| 107 | |||
| 102 | bool debugfs_initialized(void); | 108 | bool debugfs_initialized(void); |
| 103 | 109 | ||
| 104 | #else | 110 | #else |
| 105 | 111 | ||
| 106 | #include <linux/err.h> | 112 | #include <linux/err.h> |
| 107 | 113 | ||
| 108 | /* | 114 | /* |
| 109 | * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled | 115 | * We do not return NULL from these functions if CONFIG_DEBUG_FS is not enabled |
| 110 | * so users have a chance to detect if there was a real error or not. We don't | 116 | * so users have a chance to detect if there was a real error or not. We don't |
| 111 | * want to duplicate the design decision mistakes of procfs and devfs again. | 117 | * want to duplicate the design decision mistakes of procfs and devfs again. |
| @@ -250,6 +256,15 @@ static inline struct dentry *debugfs_create_u32_array(const char *name, umode_t | |||
| 250 | return ERR_PTR(-ENODEV); | 256 | return ERR_PTR(-ENODEV); |
| 251 | } | 257 | } |
| 252 | 258 | ||
| 259 | static inline struct dentry *debugfs_create_devm_seqfile(struct device *dev, | ||
| 260 | const char *name, | ||
| 261 | struct dentry *parent, | ||
| 262 | int (*read_fn)(struct seq_file *s, | ||
| 263 | void *data)) | ||
| 264 | { | ||
| 265 | return ERR_PTR(-ENODEV); | ||
| 266 | } | ||
| 267 | |||
| 253 | #endif | 268 | #endif |
| 254 | 269 | ||
| 255 | #endif | 270 | #endif |
diff --git a/include/linux/device.h b/include/linux/device.h index 41d6a7555c6b..fb506738f7b7 100644 --- a/include/linux/device.h +++ b/include/linux/device.h | |||
| @@ -1123,6 +1123,41 @@ do { \ | |||
| 1123 | }) | 1123 | }) |
| 1124 | #endif | 1124 | #endif |
| 1125 | 1125 | ||
| 1126 | #ifdef CONFIG_PRINTK | ||
| 1127 | #define dev_level_once(dev_level, dev, fmt, ...) \ | ||
| 1128 | do { \ | ||
| 1129 | static bool __print_once __read_mostly; \ | ||
| 1130 | \ | ||
| 1131 | if (!__print_once) { \ | ||
| 1132 | __print_once = true; \ | ||
| 1133 | dev_level(dev, fmt, ##__VA_ARGS__); \ | ||
| 1134 | } \ | ||
| 1135 | } while (0) | ||
| 1136 | #else | ||
| 1137 | #define dev_level_once(dev_level, dev, fmt, ...) \ | ||
| 1138 | do { \ | ||
| 1139 | if (0) \ | ||
| 1140 | dev_level(dev, fmt, ##__VA_ARGS__); \ | ||
| 1141 | } while (0) | ||
| 1142 | #endif | ||
| 1143 | |||
| 1144 | #define dev_emerg_once(dev, fmt, ...) \ | ||
| 1145 | dev_level_once(dev_emerg, dev, fmt, ##__VA_ARGS__) | ||
| 1146 | #define dev_alert_once(dev, fmt, ...) \ | ||
| 1147 | dev_level_once(dev_alert, dev, fmt, ##__VA_ARGS__) | ||
| 1148 | #define dev_crit_once(dev, fmt, ...) \ | ||
| 1149 | dev_level_once(dev_crit, dev, fmt, ##__VA_ARGS__) | ||
| 1150 | #define dev_err_once(dev, fmt, ...) \ | ||
| 1151 | dev_level_once(dev_err, dev, fmt, ##__VA_ARGS__) | ||
| 1152 | #define dev_warn_once(dev, fmt, ...) \ | ||
| 1153 | dev_level_once(dev_warn, dev, fmt, ##__VA_ARGS__) | ||
| 1154 | #define dev_notice_once(dev, fmt, ...) \ | ||
| 1155 | dev_level_once(dev_notice, dev, fmt, ##__VA_ARGS__) | ||
| 1156 | #define dev_info_once(dev, fmt, ...) \ | ||
| 1157 | dev_level_once(dev_info, dev, fmt, ##__VA_ARGS__) | ||
| 1158 | #define dev_dbg_once(dev, fmt, ...) \ | ||
| 1159 | dev_level_once(dev_info, dev, fmt, ##__VA_ARGS__) | ||
| 1160 | |||
| 1126 | #define dev_level_ratelimited(dev_level, dev, fmt, ...) \ | 1161 | #define dev_level_ratelimited(dev_level, dev, fmt, ...) \ |
| 1127 | do { \ | 1162 | do { \ |
| 1128 | static DEFINE_RATELIMIT_STATE(_rs, \ | 1163 | static DEFINE_RATELIMIT_STATE(_rs, \ |
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h index 30faf797c2c3..d4e01b358341 100644 --- a/include/linux/kernfs.h +++ b/include/linux/kernfs.h | |||
| @@ -179,6 +179,7 @@ struct kernfs_open_file { | |||
| 179 | struct mutex mutex; | 179 | struct mutex mutex; |
| 180 | int event; | 180 | int event; |
| 181 | struct list_head list; | 181 | struct list_head list; |
| 182 | char *prealloc_buf; | ||
| 182 | 183 | ||
| 183 | size_t atomic_write_len; | 184 | size_t atomic_write_len; |
| 184 | bool mmapped; | 185 | bool mmapped; |
| @@ -214,6 +215,13 @@ struct kernfs_ops { | |||
| 214 | * larger ones are rejected with -E2BIG. | 215 | * larger ones are rejected with -E2BIG. |
| 215 | */ | 216 | */ |
| 216 | size_t atomic_write_len; | 217 | size_t atomic_write_len; |
| 218 | /* | ||
| 219 | * "prealloc" causes a buffer to be allocated at open for | ||
| 220 | * all read/write requests. As ->seq_show uses seq_read() | ||
| 221 | * which does its own allocation, it is incompatible with | ||
| 222 | * ->prealloc. Provide ->read and ->write with ->prealloc. | ||
| 223 | */ | ||
| 224 | bool prealloc; | ||
| 217 | ssize_t (*write)(struct kernfs_open_file *of, char *buf, size_t bytes, | 225 | ssize_t (*write)(struct kernfs_open_file *of, char *buf, size_t bytes, |
| 218 | loff_t off); | 226 | loff_t off); |
| 219 | 227 | ||
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h index 153d303af7eb..ae4882ca4a64 100644 --- a/include/linux/platform_device.h +++ b/include/linux/platform_device.h | |||
| @@ -197,8 +197,10 @@ extern void platform_driver_unregister(struct platform_driver *); | |||
| 197 | /* non-hotpluggable platform devices may use this so that probe() and | 197 | /* non-hotpluggable platform devices may use this so that probe() and |
| 198 | * its support may live in __init sections, conserving runtime memory. | 198 | * its support may live in __init sections, conserving runtime memory. |
| 199 | */ | 199 | */ |
| 200 | extern int platform_driver_probe(struct platform_driver *driver, | 200 | #define platform_driver_probe(drv, probe) \ |
| 201 | int (*probe)(struct platform_device *)); | 201 | __platform_driver_probe(drv, probe, THIS_MODULE) |
| 202 | extern int __platform_driver_probe(struct platform_driver *driver, | ||
| 203 | int (*probe)(struct platform_device *), struct module *module); | ||
| 202 | 204 | ||
| 203 | static inline void *platform_get_drvdata(const struct platform_device *pdev) | 205 | static inline void *platform_get_drvdata(const struct platform_device *pdev) |
| 204 | { | 206 | { |
| @@ -238,10 +240,12 @@ static void __exit __platform_driver##_exit(void) \ | |||
| 238 | } \ | 240 | } \ |
| 239 | module_exit(__platform_driver##_exit); | 241 | module_exit(__platform_driver##_exit); |
| 240 | 242 | ||
| 241 | extern struct platform_device *platform_create_bundle( | 243 | #define platform_create_bundle(driver, probe, res, n_res, data, size) \ |
| 244 | __platform_create_bundle(driver, probe, res, n_res, data, size, THIS_MODULE) | ||
| 245 | extern struct platform_device *__platform_create_bundle( | ||
| 242 | struct platform_driver *driver, int (*probe)(struct platform_device *), | 246 | struct platform_driver *driver, int (*probe)(struct platform_device *), |
| 243 | struct resource *res, unsigned int n_res, | 247 | struct resource *res, unsigned int n_res, |
| 244 | const void *data, size_t size); | 248 | const void *data, size_t size, struct module *module); |
| 245 | 249 | ||
| 246 | /* early platform driver interface */ | 250 | /* early platform driver interface */ |
| 247 | struct early_platform_driver { | 251 | struct early_platform_driver { |
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index f97d0dbb59fa..ddad16148bd6 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h | |||
| @@ -70,6 +70,8 @@ struct attribute_group { | |||
| 70 | * for examples.. | 70 | * for examples.. |
| 71 | */ | 71 | */ |
| 72 | 72 | ||
| 73 | #define SYSFS_PREALLOC 010000 | ||
| 74 | |||
| 73 | #define __ATTR(_name, _mode, _show, _store) { \ | 75 | #define __ATTR(_name, _mode, _show, _store) { \ |
| 74 | .attr = {.name = __stringify(_name), \ | 76 | .attr = {.name = __stringify(_name), \ |
| 75 | .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \ | 77 | .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \ |
| @@ -77,6 +79,13 @@ struct attribute_group { | |||
| 77 | .store = _store, \ | 79 | .store = _store, \ |
| 78 | } | 80 | } |
| 79 | 81 | ||
| 82 | #define __ATTR_PREALLOC(_name, _mode, _show, _store) { \ | ||
| 83 | .attr = {.name = __stringify(_name), \ | ||
| 84 | .mode = SYSFS_PREALLOC | VERIFY_OCTAL_PERMISSIONS(_mode) },\ | ||
| 85 | .show = _show, \ | ||
| 86 | .store = _store, \ | ||
| 87 | } | ||
| 88 | |||
| 80 | #define __ATTR_RO(_name) { \ | 89 | #define __ATTR_RO(_name) { \ |
| 81 | .attr = { .name = __stringify(_name), .mode = S_IRUGO }, \ | 90 | .attr = { .name = __stringify(_name), .mode = S_IRUGO }, \ |
| 82 | .show = _name##_show, \ | 91 | .show = _name##_show, \ |
