aboutsummaryrefslogtreecommitdiffstats
path: root/driver
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2006-03-22 15:11:54 -0800
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-22 15:11:54 -0800
commit126e1f3979f9316caba05c0ae9aa59c7a8e97363 (patch)
tree8297a57b6404d4652a36537b293f89247b91860e /driver
parentf2c2f130ddbab89249a6ebe2fee0bd6465834771 (diff)
downloadpatches-126e1f3979f9316caba05c0ae9aa59c7a8e97363.tar.gz
updated sysfs poll patch added
Diffstat (limited to 'driver')
-rw-r--r--driver/fix-up-the-sysfs-pollable-patch.patch122
-rw-r--r--driver/sysfs-allow-sysfs-attribute-files-to-be-pollable.patch (renamed from driver/allow-sysfs-attribute-files-to-be-pollable.patch)130
-rw-r--r--driver/sysfs-crash-debugging.patch15
3 files changed, 79 insertions, 188 deletions
diff --git a/driver/fix-up-the-sysfs-pollable-patch.patch b/driver/fix-up-the-sysfs-pollable-patch.patch
deleted file mode 100644
index deb664120d891..0000000000000
--- a/driver/fix-up-the-sysfs-pollable-patch.patch
+++ /dev/null
@@ -1,122 +0,0 @@
-From neilb@suse.de Mon Jan 16 13:57:41 2006
-From: Neil Brown <neilb@suse.de>
-To: maneesh@in.ibm.com
-Date: Thu, 12 Jan 2006 12:17:40 +1100
-Message-ID: <17349.44596.839590.753601@cse.unsw.edu.au>
-Cc: <gregkh@suse.de>, greg@kroah.com
-Subject: fix up the sysfs pollable patch
-
-On Friday December 23, maneesh@in.ibm.com wrote:
->
-> I donot agree with the sysfs_find() implementation and I think
-> Neil is trying to rework that. Also IMO, to allow proper poll semantics,
-> the read buffer should be flushed so as to see new contents on re-read.
-
-Does the patch below remove your concerns with sysfs_find?
-
-It also should allow you to reread the file (not requiring close and
-re-open). How I don't think this really classifies as "proper poll
-semantics". What we are doing is something quite different to what
-'poll' is normally used for. It is really a lot more like 'notify',
-but that interface isn't as mature yet.
-
-NeilBrown
-
-Signed-off-by: Neil Brown <neilb@suse.de>
-Acked-by: Maneesh Soni <maneesh@in.ibm.com>
-Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-
-
----
- fs/sysfs/file.c | 44 ++++++++++++++++++++++++++++++++++++--------
- fs/sysfs/inode.c | 21 ---------------------
- 2 files changed, 36 insertions(+), 29 deletions(-)
-
---- gregkh-2.6.orig/fs/sysfs/file.c
-+++ gregkh-2.6/fs/sysfs/file.c
-@@ -374,22 +374,50 @@ static unsigned int sysfs_poll(struct fi
-
- poll_wait(filp, &kobj->poll, wait);
-
-- if (buffer->event != atomic_read(&sd->s_event))
-+ if (buffer->event != atomic_read(&sd->s_event)) {
- res = POLLERR|POLLPRI;
-+ buffer->needs_read_fill = 1;
-+ }
-
- return res;
- }
-
-+
-+static struct dentry *step_down(struct dentry *dir, const char * name)
-+{
-+ struct dentry * de;
-+
-+ if (dir == NULL || dir->d_inode == NULL)
-+ return NULL;
-+
-+ mutex_lock(&dir->d_inode->i_mutex);
-+ de = lookup_one_len(name, dir, strlen(name));
-+ mutex_unlock(&dir->d_inode->i_mutex);
-+ dput(dir);
-+ if (IS_ERR(de))
-+ return NULL;
-+ if (de->d_inode == NULL) {
-+ dput(de);
-+ return NULL;
-+ }
-+ return de;
-+}
-+
- void sysfs_notify(struct kobject * k, char *dir, char *attr)
- {
-- struct sysfs_dirent * sd = k->dentry->d_fsdata;
-- if (sd && dir)
-- sd = sysfs_find(sd, dir);
-- if (sd && attr)
-- sd = sysfs_find(sd, attr);
-- if (sd) {
-- atomic_inc(&sd->s_event);
-+ struct dentry *de = k->dentry;
-+ if (de)
-+ dget(de);
-+ if (de && dir)
-+ de = step_down(de, dir);
-+ if (de && attr)
-+ de = step_down(de, attr);
-+ if (de) {
-+ struct sysfs_dirent * sd = de->d_fsdata;
-+ if (sd)
-+ atomic_inc(&sd->s_event);
- wake_up_interruptible(&k->poll);
-+ dput(de);
- }
- }
- EXPORT_SYMBOL_GPL(sysfs_notify);
---- gregkh-2.6.orig/fs/sysfs/inode.c
-+++ gregkh-2.6/fs/sysfs/inode.c
-@@ -249,24 +249,3 @@ void sysfs_hash_and_remove(struct dentry
- }
- mutex_unlock(&dir->d_inode->i_mutex);
- }
--
--struct sysfs_dirent *sysfs_find(struct sysfs_dirent *dir, const char * name)
--{
-- struct sysfs_dirent * sd, * rv = NULL;
--
-- if (dir->s_dentry == NULL ||
-- dir->s_dentry->d_inode == NULL)
-- return NULL;
--
-- mutex_lock(&dir->s_dentry->d_inode->i_mutex);
-- list_for_each_entry(sd, &dir->s_children, s_sibling) {
-- if (!sd->s_element)
-- continue;
-- if (!strcmp(sysfs_get_name(sd), name)) {
-- rv = sd;
-- break;
-- }
-- }
-- mutex_unlock(&dir->s_dentry->d_inode->i_mutex);
-- return rv;
--}
diff --git a/driver/allow-sysfs-attribute-files-to-be-pollable.patch b/driver/sysfs-allow-sysfs-attribute-files-to-be-pollable.patch
index a115dd781a556..1438663c30e1d 100644
--- a/driver/allow-sysfs-attribute-files-to-be-pollable.patch
+++ b/driver/sysfs-allow-sysfs-attribute-files-to-be-pollable.patch
@@ -1,17 +1,19 @@
-From neilb@suse.de Tue Dec 20 15:19:48 2005
-From: Neil Brown <neilb@suse.de>
-To: Greg KH <greg@kroah.com>, <maneesh@in.ibm.com>
-Date: Wed, 21 Dec 2005 10:14:29 +1100
-Message-ID: <17320.36949.269788.520946@cse.unsw.edu.au>
-Subject: [PATCH - 2.6.15-rc5-mm3] Allow sysfs attribute files to be pollable.
+From neilb@suse.de Wed Mar 22 15:03:35 2006
+From: NeilBrown <neilb@suse.de>
+To: Andrew Morton <akpm@osdl.org>, Greg KH <greg@kroah.com>
+Date: Mon, 20 Mar 2006 17:53:53 +1100
+Message-Id: <1060320065353.30933@suse.de>
+Cc: linux-kernel@vger.kernel.org
+Subject: sysfs: Allow sysfs attribute files to be pollable
-This allows an attribute file in sysfs to be polled for activity.
It works like this:
Open the file
Read all the contents.
Call poll requesting POLLERR or POLLPRI (so select/exceptfds works)
- When poll returns, close the file, and go to top of loop.
+ When poll returns,
+ close the file and go to top of loop.
+ or lseek to start of file and go back to the 'read'.
Events are signaled by an object manager calling
sysfs_notify(kobj, dir, attr);
@@ -32,16 +34,27 @@ to be pollable
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
---
- fs/sysfs/dir.c | 1 +
- fs/sysfs/file.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
- fs/sysfs/inode.c | 21 +++++++++++++++++++++
- fs/sysfs/sysfs.h | 1 +
- include/linux/kobject.h | 2 ++
- include/linux/sysfs.h | 7 +++++++
- lib/kobject.c | 1 +
- 7 files changed, 80 insertions(+)
+ drivers/md/md.c | 1
+ fs/sysfs/dir.c | 1
+ fs/sysfs/file.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++
+ fs/sysfs/sysfs.h | 1
+ include/linux/kobject.h | 2 +
+ include/linux/sysfs.h | 6 +++
+ lib/kobject.c | 1
+ 7 files changed, 88 insertions(+)
+--- gregkh-2.6.orig/drivers/md/md.c
++++ gregkh-2.6/drivers/md/md.c
+@@ -162,6 +162,7 @@ static void md_new_event(mddev_t *mddev)
+ {
+ atomic_inc(&md_event_count);
+ wake_up(&md_event_waiters);
++ sysfs_notify(&mddev->kobj, NULL, "sync_action");
+ }
+
+ /*
--- gregkh-2.6.orig/fs/sysfs/dir.c
+++ gregkh-2.6/fs/sysfs/dir.c
@@ -43,6 +43,7 @@ static struct sysfs_dirent * sysfs_new_d
@@ -86,7 +99,7 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
count = ops->show(kobj,attr,buffer->page);
buffer->needs_read_fill = 0;
BUG_ON(count > (ssize_t)PAGE_SIZE);
-@@ -348,12 +352,55 @@ static int sysfs_release(struct inode *
+@@ -348,12 +352,84 @@ static int sysfs_release(struct inode *
return 0;
}
@@ -101,7 +114,8 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+ * again will not get new data, or reset the state of 'poll'.
+ * Reminder: this only works for attributes which actively support
+ * it, and it is not possible to test an attribute from userspace
-+ * to see if it supports poll.
++ * to see if it supports poll (Nether 'poll' or 'select' return
++ * an appropriate error code). When in doubt, set a suitable timeout value.
+ */
+static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
+{
@@ -112,22 +126,50 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+ poll_wait(filp, &kobj->poll, wait);
+
-+ if (buffer->event != atomic_read(&sd->s_event))
++ if (buffer->event != atomic_read(&sd->s_event)) {
+ res = POLLERR|POLLPRI;
++ buffer->needs_read_fill = 1;
++ }
+
+ return res;
+}
+
++
++static struct dentry *step_down(struct dentry *dir, const char * name)
++{
++ struct dentry * de;
++
++ if (dir == NULL || dir->d_inode == NULL)
++ return NULL;
++
++ mutex_lock(&dir->d_inode->i_mutex);
++ de = lookup_one_len(name, dir, strlen(name));
++ mutex_unlock(&dir->d_inode->i_mutex);
++ dput(dir);
++ if (IS_ERR(de))
++ return NULL;
++ if (de->d_inode == NULL) {
++ dput(de);
++ return NULL;
++ }
++ return de;
++}
++
+void sysfs_notify(struct kobject * k, char *dir, char *attr)
+{
-+ struct sysfs_dirent * sd = k->dentry->d_fsdata;
-+ if (sd && dir)
-+ sd = sysfs_find(sd, dir);
-+ if (sd && attr)
-+ sd = sysfs_find(sd, attr);
-+ if (sd) {
-+ atomic_inc(&sd->s_event);
++ struct dentry *de = k->dentry;
++ if (de)
++ dget(de);
++ if (de && dir)
++ de = step_down(de, dir);
++ if (de && attr)
++ de = step_down(de, attr);
++ if (de) {
++ struct sysfs_dirent * sd = de->d_fsdata;
++ if (sd)
++ atomic_inc(&sd->s_event);
+ wake_up_interruptible(&k->poll);
++ dput(de);
+ }
+}
+EXPORT_SYMBOL_GPL(sysfs_notify);
@@ -142,33 +184,6 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
};
---- gregkh-2.6.orig/fs/sysfs/inode.c
-+++ gregkh-2.6/fs/sysfs/inode.c
-@@ -249,3 +249,24 @@ void sysfs_hash_and_remove(struct dentry
- }
- mutex_unlock(&dir->d_inode->i_mutex);
- }
-+
-+struct sysfs_dirent *sysfs_find(struct sysfs_dirent *dir, const char * name)
-+{
-+ struct sysfs_dirent * sd, * rv = NULL;
-+
-+ if (dir->s_dentry == NULL ||
-+ dir->s_dentry->d_inode == NULL)
-+ return NULL;
-+
-+ mutex_lock(&dir->s_dentry->d_inode->i_mutex);
-+ list_for_each_entry(sd, &dir->s_children, s_sibling) {
-+ if (!sd->s_element)
-+ continue;
-+ if (!strcmp(sysfs_get_name(sd), name)) {
-+ rv = sd;
-+ break;
-+ }
-+ }
-+ mutex_unlock(&dir->s_dentry->d_inode->i_mutex);
-+ return rv;
-+}
--- gregkh-2.6.orig/fs/sysfs/sysfs.h
+++ gregkh-2.6/fs/sysfs/sysfs.h
@@ -11,6 +11,7 @@ extern int sysfs_make_dirent(struct sysf
@@ -207,21 +222,20 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
};
#define SYSFS_ROOT 0x0001
-@@ -118,6 +119,7 @@ int sysfs_remove_bin_file(struct kobject
+@@ -117,6 +118,7 @@ int sysfs_remove_bin_file(struct kobject
+
int sysfs_create_group(struct kobject *, const struct attribute_group *);
void sysfs_remove_group(struct kobject *, const struct attribute_group *);
-
+void sysfs_notify(struct kobject * k, char *dir, char *attr);
+
#else /* CONFIG_SYSFS */
- static inline int sysfs_create_dir(struct kobject * k)
-@@ -185,6 +187,11 @@ static inline void sysfs_remove_group(st
+@@ -185,6 +187,10 @@ static inline void sysfs_remove_group(st
;
}
+static inline void sysfs_notify(struct kobject * k, char *dir, char *attr)
+{
-+ ;
+}
+
#endif /* CONFIG_SYSFS */
diff --git a/driver/sysfs-crash-debugging.patch b/driver/sysfs-crash-debugging.patch
index c659becb51413..989cf0683ad8e 100644
--- a/driver/sysfs-crash-debugging.patch
+++ b/driver/sysfs-crash-debugging.patch
@@ -20,8 +20,8 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/i386/kernel/traps.c | 3 ++-
arch/x86_64/kernel/traps.c | 1 +
fs/sysfs/file.c | 14 ++++++++++++++
- include/linux/sysfs.h | 7 +++++++
- 4 files changed, 24 insertions(+), 1 deletion(-)
+ include/linux/sysfs.h | 6 ++++++
+ 4 files changed, 23 insertions(+), 1 deletion(-)
--- gregkh-2.6.orig/arch/i386/kernel/traps.c
+++ gregkh-2.6/arch/i386/kernel/traps.c
@@ -87,17 +87,16 @@ Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
struct kobject * kobj = to_kobj(filp->f_dentry->d_parent);
--- gregkh-2.6.orig/include/linux/sysfs.h
+++ gregkh-2.6/include/linux/sysfs.h
-@@ -120,6 +120,8 @@ int sysfs_create_group(struct kobject *,
+@@ -119,6 +119,7 @@ int sysfs_remove_bin_file(struct kobject
+ int sysfs_create_group(struct kobject *, const struct attribute_group *);
void sysfs_remove_group(struct kobject *, const struct attribute_group *);
-
void sysfs_notify(struct kobject * k, char *dir, char *attr);
+void sysfs_printk_last_file(void);
-+
+
#else /* CONFIG_SYSFS */
- static inline int sysfs_create_dir(struct kobject * k)
-@@ -192,6 +194,11 @@ static inline void sysfs_notify(struct k
- ;
+@@ -191,6 +192,11 @@ static inline void sysfs_notify(struct k
+ {
}
+static inline void sysfs_printk_last_file(void)