aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/configfs.h
diff options
context:
space:
mode:
authorPantelis Antoniou <pantelis.antoniou@konsulko.com>2015-10-22 16:30:04 -0400
committerChristoph Hellwig <hch@lst.de>2016-01-04 06:31:46 -0500
commit03607ace807b414eab46323c794b6fb8fcc2d48c (patch)
treea192ae4376e5db9eb02e2563d3c12a7312e677ba /include/linux/configfs.h
parent4ef7675344d687a0ef5b0d7c0cee12da005870c0 (diff)
configfs: implement binary attributes
ConfigFS lacked binary attributes up until now. This patch introduces support for binary attributes in a somewhat similar manner of sysfs binary attributes albeit with changes that fit the configfs usage model. Problems that configfs binary attributes fix are everything that requires a binary blob as part of the configuration of a resource, such as bitstream loading for FPGAs, DTBs for dynamically created devices etc. Look at Documentation/filesystems/configfs/configfs.txt for internals and howto use them. This patch is against linux-next as of today that contains Christoph's configfs rework. Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com> [hch: folded a fix from Geert Uytterhoeven <geert+renesas@glider.be>] [hch: a few tiny updates based on review feedback] Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'include/linux/configfs.h')
-rw-r--r--include/linux/configfs.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 758a029011b1..f7300d023dbe 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -51,6 +51,7 @@ struct module;
51struct configfs_item_operations; 51struct configfs_item_operations;
52struct configfs_group_operations; 52struct configfs_group_operations;
53struct configfs_attribute; 53struct configfs_attribute;
54struct configfs_bin_attribute;
54struct configfs_subsystem; 55struct configfs_subsystem;
55 56
56struct config_item { 57struct config_item {
@@ -84,6 +85,7 @@ struct config_item_type {
84 struct configfs_item_operations *ct_item_ops; 85 struct configfs_item_operations *ct_item_ops;
85 struct configfs_group_operations *ct_group_ops; 86 struct configfs_group_operations *ct_group_ops;
86 struct configfs_attribute **ct_attrs; 87 struct configfs_attribute **ct_attrs;
88 struct configfs_bin_attribute **ct_bin_attrs;
87}; 89};
88 90
89/** 91/**
@@ -154,6 +156,54 @@ static struct configfs_attribute _pfx##attr_##_name = { \
154 .store = _pfx##_name##_store, \ 156 .store = _pfx##_name##_store, \
155} 157}
156 158
159struct file;
160struct vm_area_struct;
161
162struct configfs_bin_attribute {
163 struct configfs_attribute cb_attr; /* std. attribute */
164 void *cb_private; /* for user */
165 size_t cb_max_size; /* max core size */
166 ssize_t (*read)(struct config_item *, void *, size_t);
167 ssize_t (*write)(struct config_item *, const void *, size_t);
168};
169
170#define CONFIGFS_BIN_ATTR(_pfx, _name, _priv, _maxsz) \
171static struct configfs_bin_attribute _pfx##attr_##_name = { \
172 .cb_attr = { \
173 .ca_name = __stringify(_name), \
174 .ca_mode = S_IRUGO | S_IWUSR, \
175 .ca_owner = THIS_MODULE, \
176 }, \
177 .cb_private = _priv, \
178 .cb_max_size = _maxsz, \
179 .read = _pfx##_name##_read, \
180 .write = _pfx##_name##_write, \
181}
182
183#define CONFIGFS_BIN_ATTR_RO(_pfx, _name, _priv, _maxsz) \
184static struct configfs_attribute _pfx##attr_##_name = { \
185 .cb_attr = { \
186 .ca_name = __stringify(_name), \
187 .ca_mode = S_IRUGO, \
188 .ca_owner = THIS_MODULE, \
189 }, \
190 .cb_private = _priv, \
191 .cb_max_size = _maxsz, \
192 .read = _pfx##_name##_read, \
193}
194
195#define CONFIGFS_BIN_ATTR_WO(_pfx, _name, _priv, _maxsz) \
196static struct configfs_attribute _pfx##attr_##_name = { \
197 .cb_attr = { \
198 .ca_name = __stringify(_name), \
199 .ca_mode = S_IWUSR, \
200 .ca_owner = THIS_MODULE, \
201 }, \
202 .cb_private = _priv, \
203 .cb_max_size = _maxsz, \
204 .write = _pfx##_name##_write, \
205}
206
157/* 207/*
158 * If allow_link() exists, the item can symlink(2) out to other 208 * If allow_link() exists, the item can symlink(2) out to other
159 * items. If the item is a group, it may support mkdir(2). 209 * items. If the item is a group, it may support mkdir(2).