aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/kernfs.h8
-rw-r--r--include/linux/sysfs.h9
2 files changed, 17 insertions, 0 deletions
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/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, \