From: Daniel Baluta <daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
jlbec-aKy9MeLSZ9dg9hUCZPvPmw@public.gmane.org,
linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org,
knaack.h-Mmb7MZpHnFY@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
octavian.purdila-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
pebolle-IWqWACnzNjzz+pZb47iToQ@public.gmane.org,
patrick.porlan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
adriana.reus-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
constantin.musca-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
marten-4zOpVvZifTgX8gGd4fc/mEEOCMrvLtNR@public.gmane.org,
daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
cristina.opriceana-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org,
hch-jcswGhMUV9g@public.gmane.org,
viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org,
akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org
Subject: [PATCH v7 1/5] configfs: Allow dynamic group (un)registration
Date: Tue, 11 Aug 2015 01:42:38 +0300 [thread overview]
Message-ID: <1439246562-17515-2-git-send-email-daniel.baluta@intel.com> (raw)
In-Reply-To: <1439246562-17515-1-git-send-email-daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
We don't want to hardcode default groups at subsystem
creation time. Thus, we export:
* configfs_register_group
* configfs_unregister_group
that allows drivers to programatically create/destroy groups.
Signed-off-by: Daniel Baluta <daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
I am not sure about the locking scheme here, Joel can you help? :)
fs/configfs/dir.c | 39 +++++++++++++++++++++++++++++++++++++--
include/linux/configfs.h | 4 ++++
2 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index c81ce7f..dde3251 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -651,7 +651,8 @@ static void detach_groups(struct config_group *group)
* try using vfs_mkdir. Just a thought.
*/
static int create_default_group(struct config_group *parent_group,
- struct config_group *group)
+ struct config_group *group,
+ struct dentry **dentry)
{
int ret;
struct configfs_dirent *sd;
@@ -671,6 +672,8 @@ static int create_default_group(struct config_group *parent_group,
if (!ret) {
sd = child->d_fsdata;
sd->s_type |= CONFIGFS_USET_DEFAULT;
+ if (dentry)
+ *dentry = child;
} else {
BUG_ON(d_inode(child));
d_drop(child);
@@ -691,7 +694,7 @@ static int populate_groups(struct config_group *group)
for (i = 0; group->default_groups[i]; i++) {
new_group = group->default_groups[i];
- ret = create_default_group(group, new_group);
+ ret = create_default_group(group, new_group, NULL);
if (ret) {
detach_groups(group);
break;
@@ -1636,6 +1639,38 @@ const struct file_operations configfs_dir_operations = {
.iterate = configfs_readdir,
};
+int configfs_register_group(struct config_group *parent_group,
+ struct config_group *group)
+{
+ struct dentry *dentry;
+ int ret;
+
+ link_group(parent_group, group);
+
+ ret = create_default_group(parent_group, group, &dentry);
+ if (ret == 0)
+ configfs_dir_set_ready(dentry->d_fsdata);
+
+ return ret;
+}
+EXPORT_SYMBOL(configfs_register_group);
+
+void configfs_unregister_group(struct config_group *group)
+{
+ struct dentry *dentry = group->cg_item.ci_dentry;
+
+ mutex_lock(&d_inode(dentry)->i_mutex);
+ configfs_detach_group(&group->cg_item);
+ d_inode(dentry)->i_flags |= S_DEAD;
+ dont_mount(dentry);
+ mutex_unlock(&d_inode(dentry)->i_mutex);
+
+ d_delete(dentry);
+ dput(dentry);
+ unlink_group(group);
+}
+EXPORT_SYMBOL(configfs_unregister_group);
+
int configfs_register_subsystem(struct configfs_subsystem *subsys)
{
int err;
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index c9e5c57..726980e 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -251,6 +251,10 @@ static inline struct configfs_subsystem *to_configfs_subsystem(struct config_gro
int configfs_register_subsystem(struct configfs_subsystem *subsys);
void configfs_unregister_subsystem(struct configfs_subsystem *subsys);
+int configfs_register_group(struct config_group *parent_group,
+ struct config_group *group);
+void configfs_unregister_group(struct config_group *group);
+
/* These functions can sleep and can alloc with GFP_KERNEL */
/* WARNING: These cannot be called underneath configfs callbacks!! */
int configfs_depend_item(struct configfs_subsystem *subsys, struct config_item *target);
--
2.1.4
next prev parent reply other threads:[~2015-08-10 22:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-10 22:42 [PATCH v7 0/5] Add initial configfs support for IIO Daniel Baluta
[not found] ` <1439246562-17515-1-git-send-email-daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-08-10 22:42 ` Daniel Baluta [this message]
2015-08-31 16:02 ` [PATCH v7 1/5] configfs: Allow dynamic group (un)registration Lars-Peter Clausen
2015-08-10 22:42 ` [PATCH v7 2/5] iio: core: Introduce IIO configfs support Daniel Baluta
2015-08-10 22:42 ` [PATCH v7 3/5] iio: core: Introduce IIO software triggers Daniel Baluta
2015-08-17 11:31 ` Vladimir Barinov
[not found] ` <1439246562-17515-4-git-send-email-daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-08-31 14:41 ` Lars-Peter Clausen
2015-08-10 22:42 ` [PATCH v7 4/5] iio: trigger: Introduce IIO hrtimer based trigger Daniel Baluta
[not found] ` <1439246562-17515-5-git-send-email-daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-08-17 12:45 ` Vladimir Barinov
2015-08-17 12:49 ` Daniel Baluta
2015-08-31 14:57 ` Lars-Peter Clausen
[not found] ` <55E46B45.8040909-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2015-09-02 12:16 ` Vladimir Barinov
2015-08-31 15:13 ` Lars-Peter Clausen
2015-08-10 22:42 ` [PATCH v7 5/5] iio: Documentation: Add IIO configfs documentation Daniel Baluta
[not found] ` <1439246562-17515-6-git-send-email-daniel.baluta-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2015-08-17 12:01 ` Vladimir Barinov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1439246562-17515-2-git-send-email-daniel.baluta@intel.com \
--to=daniel.baluta-ral2jqcrhueavxtiumwx3w@public.gmane.org \
--cc=adriana.reus-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=constantin.musca-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=cristina.opriceana-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=hch-jcswGhMUV9g@public.gmane.org \
--cc=jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=jlbec-aKy9MeLSZ9dg9hUCZPvPmw@public.gmane.org \
--cc=knaack.h-Mmb7MZpHnFY@public.gmane.org \
--cc=lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=marten-4zOpVvZifTgX8gGd4fc/mEEOCMrvLtNR@public.gmane.org \
--cc=octavian.purdila-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=patrick.porlan-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=pebolle-IWqWACnzNjzz+pZb47iToQ@public.gmane.org \
--cc=pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org \
--cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).