From: ebiederm@xmission.com (Eric W. Biederman)
To: Greg KH <gregkh@suse.de>
Cc: "Américo Wang" <xiyou.wangcong@gmail.com>,
"Tejun Heo <tj@kernel.org> Neil Brown" <neilb@suse.de>,
linux-kernel@vger.kernel.org
Subject: [PATCH] sysfs: Document sysfs_attr_init and sysfs_bin_attr_init
Date: Fri, 12 Feb 2010 04:47:10 -0800 [thread overview]
Message-ID: <m1vde2vcxd.fsf_-_@fess.ebiederm.org> (raw)
In-Reply-To: <20100211234221.GA10498@suse.de> (Greg KH's message of "Thu\, 11 Feb 2010 15\:42\:21 -0800")
Greg KH <gregkh@suse.de> writes:
> On Thu, Feb 11, 2010 at 03:23:05PM -0800, Eric W. Biederman wrote:
>>
>> These are the non-static sysfs attributes that exist on
>> my test machine. Fix them to use sysfs_attr_init or
>> sysfs_bin_attr_init as appropriate. It simply requires
>> making a sysfs attribute present to see this. So this
>> is a little bit tedious but otherwise not too bad.
>
> Can we document this in the sysfs_attr_init kerneldoc documentation that
> you add for this new function?
Here you go.
>From 646c76c0b20b30923a652bbf8cefec5e335359a9 Mon Sep 17 00:00:00 2001
From: Eric W. Biederman <ebiederm@xmission.com>
Date: Fri, 12 Feb 2010 04:35:32 -0800
Subject: [PATCH] sysfs: Document sysfs_attr_init and sysfs_bin_attr_init
I have added a new requirement to the external sysfs interface
that dynamically allocated sysfs attributes must call sysfs_attr_init
if lockdep is enabled. For the time being callying sysfs_attr_init
is only mandatory if lockdep is enabled, so we can live with a few
unconverted instances until we find them all. As this is part of
the public interface of sysfs it is a good idea to document these
pseudo functions so someone inspeciting the code can find out
what has happened.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
include/linux/sysfs.h | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index c3048de..2b24ae5 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -36,6 +36,16 @@ struct attribute {
#endif
};
+/**
+ * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
+ * @attr: struct attribute to initialize
+ *
+ * Initialize a dynamically allocated struct attribute so we can
+ * make lockdep happy. This is a new requirement for attributes
+ * and initially this is only needed when lockdep is enabled.
+ * Lockdep gives a nice error when your attribute is added to
+ * sysfs if you don't have this.
+ */
#ifdef CONFIG_DEBUG_LOCK_ALLOC
#define sysfs_attr_init(attr) \
do { \
@@ -90,6 +100,16 @@ struct bin_attribute {
struct vm_area_struct *vma);
};
+/**
+ * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
+ * @attr: struct bin_attribute to initialize
+ *
+ * Initialize a dynamically allocated struct bin_attribute so we
+ * can make lockdep happy. This is a new requirement for
+ * attributes and initially this is only needed when lockdep is
+ * enabled. Lockdep gives a nice error when your attribute is
+ * added to sysfs if you don't have this.
+ */
#define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&bin_attr->attr)
struct sysfs_ops {
--
1.6.5.2.143.g8cc62
next prev parent reply other threads:[~2010-02-12 12:47 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-10 1:09 [PATCH] sysfs: differentiate between locking links and non-links Neil Brown
2010-02-10 1:21 ` David Rientjes
2010-02-10 1:56 ` Américo Wang
2010-02-10 3:05 ` David Rientjes
2010-02-10 3:14 ` Américo Wang
2010-02-10 3:19 ` David Rientjes
2010-02-10 3:33 ` Américo Wang
2010-02-10 2:08 ` Américo Wang
2010-02-10 2:19 ` Tejun Heo
2010-02-10 3:12 ` Américo Wang
2010-02-10 8:03 ` Eric W. Biederman
2010-02-10 10:39 ` Tejun Heo
2010-02-10 18:25 ` Eric W. Biederman
2010-02-10 23:05 ` Greg KH
2010-02-11 1:31 ` Eric W. Biederman
2010-02-11 2:10 ` Tejun Heo
2010-02-11 18:08 ` Eric W. Biederman
2010-02-12 0:59 ` Tejun Heo
2010-02-12 1:20 ` Eric W. Biederman
2010-02-12 1:20 ` Eric W. Biederman
2010-02-12 2:16 ` Tejun Heo
2010-02-11 23:13 ` [PATCH 0/4] Better sysfs lockdep Eric W. Biederman
2010-02-11 23:14 ` [PATCH 1/4] sysfs: Remove sysfs_get/put_active_two Eric W. Biederman
2010-02-11 23:20 ` [PATCH 2/4] sysfs: Only take active references on attributes Eric W. Biederman
2010-02-11 23:21 ` [PATCH 3/4] sysfs: Use one lockdep class per sysfs attribute Eric W. Biederman
2010-02-11 23:23 ` [PATCH 4/4] sysfs: Use sysfs_attr_init and sysfs_bin_attr_init on dynamic attributes Eric W. Biederman
2010-02-11 23:42 ` Greg KH
2010-02-12 12:47 ` Eric W. Biederman [this message]
2010-02-12 21:41 ` [PATCH] sysfs: Use sysfs_attr_init and sysfs_bin_attr_init on module " Eric W. Biederman
2010-02-15 10:38 ` [PATCH 4/4] sysfs: Use sysfs_attr_init and sysfs_bin_attr_init on " Américo Wang
2010-02-15 12:53 ` Eric W. Biederman
2010-02-15 10:35 ` [PATCH 3/4] sysfs: Use one lockdep class per sysfs attribute Américo Wang
2010-02-15 7:27 ` [PATCH 2/4] sysfs: Only take active references on attributes Américo Wang
2010-02-15 8:15 ` Américo Wang
2010-02-15 8:31 ` Américo Wang
2010-02-15 10:11 ` Eric W. Biederman
2010-02-15 7:03 ` [PATCH 1/4] sysfs: Remove sysfs_get/put_active_two Américo Wang
2010-02-11 23:18 ` Eric W. Biederman
2010-02-11 23:17 ` [PATCH 0/4] Better sysfs lockdep Eric W. Biederman
2010-02-11 23:43 ` Greg KH
2010-02-10 23:54 ` [PATCH] sysfs: differentiate between locking links and non-links Tejun Heo
2010-02-11 0:38 ` Eric W. Biederman
2010-02-10 17:36 ` Eric W. Biederman
2010-02-10 17:55 ` Dmitry Torokhov
2010-02-10 23:06 ` Greg KH
2010-02-11 21:42 ` Eric W. Biederman
2010-02-11 22:32 ` Greg KH
2010-02-11 22:47 ` Eric W. Biederman
2010-02-17 22:38 ` Greg KH
2010-02-18 0:39 ` Neil Brown
2010-02-18 1:01 ` Eric W. Biederman
2010-02-18 1:12 ` Greg KH
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=m1vde2vcxd.fsf_-_@fess.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=neilb@suse.de \
--cc=xiyou.wangcong@gmail.com \
/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