From: Guenter Roeck <linux@roeck-us.net>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Guenter Roeck <linux@roeck-us.net>
Subject: [RFC PATCH 0/2] fs: sysfs: Add devres support
Date: Thu, 14 Mar 2013 20:24:45 -0700 [thread overview]
Message-ID: <1363317887-24009-1-git-send-email-linux@roeck-us.net> (raw)
Provide devres functions for device_create_file, sysfs_create_file,
and sysfs_create_group plus the respective remove functions.
Idea is to be able to drop calls to the remove functions from the various
drivers using those calls.
Potential savings are substantial. There are more than 700 calls to
device_remove_file in the kernel, more than 500 calls to sysfs_remove_group,
and some 50 calls to sysfs_remove_file (though not all of those use dev->kobj
as parameter). Expanding the API to sysfs_create_bin_file would add another 80+
opportunities, and adding sysfs_create_link would create another 100 or so.
The approach used in this patch set is one possible solution.
Another possibility would be to not bother with sysfs and provide
devm_device_create_file, devm_device_create_group, and its remove functions
in drivers/base/core.c instead.
I am not sure which approach is better. The solution presented here is more
aligned with other devm_ functions (I think) and does not require changing
function parameters besides the first one. Providing functions in the driver
core code would mean parameter changes [sysfs_create_file(dev, attr) ->
devm_device_create_file(dev, device_attr)] and thus be more invasive and thus a
bit more risky. It would also create devres data entries even if sysfs
is not configured (if that is even possible nowadays).
One question with the presented API is how the API should look like.
Should it be
int devm_sysfs_create_file(struct device *dev, const struct attribute *attr)
or
int devm_sysfs_create_file(struct device *dev,
struct kobject *kobj,
const struct attribute *attr)
The latter would be more consistent with other devm_ functions, but the
additional parameter seems like a waste, as the kobj would presumably
always be &dev->kobj anyway.
Before I go much further with this, I would like to get some feedback from the
community if this all makes sense or not.
Note that the code is compile tested only at this time - I don't want to spend
too much time on it if turns out to be a bad idea.
next reply other threads:[~2013-03-15 3:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-15 3:24 Guenter Roeck [this message]
2013-03-15 3:24 ` [RFC PATCH 1/2] fs: sysfs: Add support for devm_ functions Guenter Roeck
2013-03-15 3:24 ` [RFC PATCH 2/2] drivers/core: " Guenter Roeck
2013-03-16 16:21 ` [RFC PATCH 0/2] fs: sysfs: Add devres support Greg Kroah-Hartman
2013-03-16 18:12 ` Guenter Roeck
2013-03-16 19:50 ` Greg Kroah-Hartman
2013-03-16 21:25 ` Guenter Roeck
2013-03-17 6:30 ` [lm-sensors] " Guenter Roeck
2013-03-17 12:39 ` Jean Delvare
2013-03-17 13:19 ` Guenter Roeck
2013-03-17 14:54 ` Guenter Roeck
2013-03-18 8:02 ` Jean Delvare
2013-03-18 13:29 ` Guenter Roeck
2013-11-22 22:47 ` Dmitry Torokhov
2013-11-22 22:53 ` Greg Kroah-Hartman
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=1363317887-24009-1-git-send-email-linux@roeck-us.net \
--to=linux@roeck-us.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.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