From: Christian Gromm <christian.gromm@microchip.com>
To: <gregkh@linuxfoundation.org>
Cc: Christian Gromm <christian.gromm@microchip.com>,
driverdev-devel@linuxdriverproject.org
Subject: [PATCH 1/2] staging: most: configfs: move configfs subsystems to container struct
Date: Fri, 8 Nov 2019 17:21:07 +0100 [thread overview]
Message-ID: <1573230068-27658-2-git-send-email-christian.gromm@microchip.com> (raw)
In-Reply-To: <1573230068-27658-1-git-send-email-christian.gromm@microchip.com>
This patch moves the declarations of the configfs subsystems to
a superordinate container structure. This is done to get access
to private subsystem data.
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
---
drivers/staging/most/configfs.c | 80 +++++++++++++++++++++++------------------
1 file changed, 45 insertions(+), 35 deletions(-)
diff --git a/drivers/staging/most/configfs.c b/drivers/staging/most/configfs.c
index c06cf84..c292dd3 100644
--- a/drivers/staging/most/configfs.c
+++ b/drivers/staging/most/configfs.c
@@ -395,11 +395,12 @@ static const struct config_item_type mdev_link_type = {
struct most_common {
struct config_group group;
+ struct configfs_subsystem subsys;
};
-static struct most_common *to_most_common(struct config_item *item)
+static struct most_common *to_most_common(struct configfs_subsystem *subsys)
{
- return container_of(to_config_group(item), struct most_common, group);
+ return container_of(subsys, struct most_common, subsys);
}
static struct config_item *most_common_make_item(struct config_group *group,
@@ -426,7 +427,9 @@ static struct config_item *most_common_make_item(struct config_group *group,
static void most_common_release(struct config_item *item)
{
- kfree(to_most_common(item));
+ struct config_group *group = to_config_group(item);
+
+ kfree(to_most_common(group->cg_subsys));
}
static struct configfs_item_operations most_common_item_ops = {
@@ -443,29 +446,35 @@ static const struct config_item_type most_common_type = {
.ct_owner = THIS_MODULE,
};
-static struct configfs_subsystem most_cdev_subsys = {
- .su_group = {
- .cg_item = {
- .ci_namebuf = "most_cdev",
- .ci_type = &most_common_type,
+static struct most_common most_cdev = {
+ .subsys = {
+ .su_group = {
+ .cg_item = {
+ .ci_namebuf = "most_cdev",
+ .ci_type = &most_common_type,
+ },
},
},
};
-static struct configfs_subsystem most_net_subsys = {
- .su_group = {
- .cg_item = {
- .ci_namebuf = "most_net",
- .ci_type = &most_common_type,
+static struct most_common most_net = {
+ .subsys = {
+ .su_group = {
+ .cg_item = {
+ .ci_namebuf = "most_net",
+ .ci_type = &most_common_type,
+ },
},
},
};
-static struct configfs_subsystem most_video_subsys = {
- .su_group = {
- .cg_item = {
- .ci_namebuf = "most_video",
- .ci_type = &most_common_type,
+static struct most_common most_video = {
+ .subsys = {
+ .su_group = {
+ .cg_item = {
+ .ci_namebuf = "most_video",
+ .ci_type = &most_common_type,
+ },
},
},
};
@@ -597,16 +606,17 @@ int most_register_configfs_subsys(struct core_component *c)
{
int ret;
- if (!strcmp(c->name, "cdev"))
- ret = configfs_register_subsystem(&most_cdev_subsys);
- else if (!strcmp(c->name, "net"))
- ret = configfs_register_subsystem(&most_net_subsys);
- else if (!strcmp(c->name, "video"))
- ret = configfs_register_subsystem(&most_video_subsys);
- else if (!strcmp(c->name, "sound"))
+ if (!strcmp(c->name, "cdev")) {
+ ret = configfs_register_subsystem(&most_cdev.subsys);
+ } else if (!strcmp(c->name, "net")) {
+ ret = configfs_register_subsystem(&most_net.subsys);
+ } else if (!strcmp(c->name, "video")) {
+ ret = configfs_register_subsystem(&most_video.subsys);
+ } else if (!strcmp(c->name, "sound")) {
ret = configfs_register_subsystem(&most_sound_subsys.subsys);
- else
+ } else {
return -ENODEV;
+ }
if (ret) {
pr_err("Error %d while registering subsystem %s\n",
@@ -635,11 +645,11 @@ void most_interface_register_notify(const char *mdev)
void most_deregister_configfs_subsys(struct core_component *c)
{
if (!strcmp(c->name, "cdev"))
- configfs_unregister_subsystem(&most_cdev_subsys);
+ configfs_unregister_subsystem(&most_cdev.subsys);
else if (!strcmp(c->name, "net"))
- configfs_unregister_subsystem(&most_net_subsys);
+ configfs_unregister_subsystem(&most_net.subsys);
else if (!strcmp(c->name, "video"))
- configfs_unregister_subsystem(&most_video_subsys);
+ configfs_unregister_subsystem(&most_video.subsys);
else if (!strcmp(c->name, "sound"))
configfs_unregister_subsystem(&most_sound_subsys.subsys);
}
@@ -647,14 +657,14 @@ EXPORT_SYMBOL_GPL(most_deregister_configfs_subsys);
int __init configfs_init(void)
{
- config_group_init(&most_cdev_subsys.su_group);
- mutex_init(&most_cdev_subsys.su_mutex);
+ config_group_init(&most_cdev.subsys.su_group);
+ mutex_init(&most_cdev.subsys.su_mutex);
- config_group_init(&most_net_subsys.su_group);
- mutex_init(&most_net_subsys.su_mutex);
+ config_group_init(&most_net.subsys.su_group);
+ mutex_init(&most_net.subsys.su_mutex);
- config_group_init(&most_video_subsys.su_group);
- mutex_init(&most_video_subsys.su_mutex);
+ config_group_init(&most_video.subsys.su_group);
+ mutex_init(&most_video.subsys.su_mutex);
config_group_init(&most_sound_subsys.subsys.su_group);
mutex_init(&most_sound_subsys.subsys.su_mutex);
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next prev parent reply other threads:[~2019-11-08 16:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 16:21 [PATCH 0/2] staging: most: prevent module removal if configfs directory is populated Christian Gromm
2019-11-08 16:21 ` Christian Gromm [this message]
2019-11-08 16:21 ` [PATCH 2/2] staging: most: block module removal while having active configfs items Christian Gromm
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=1573230068-27658-2-git-send-email-christian.gromm@microchip.com \
--to=christian.gromm@microchip.com \
--cc=driverdev-devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.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).