Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6:
  sysfs: Allow sysfs_notify_dirent to be called from interrupt context.
  sysfs: Allow sysfs_move_dir(..., NULL) again.
This commit is contained in:
Linus Torvalds 2009-10-15 15:05:46 -07:00
commit e7957ec6b6
2 changed files with 10 additions and 7 deletions

View File

@ -894,7 +894,8 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj)
mutex_lock(&sysfs_rename_mutex); mutex_lock(&sysfs_rename_mutex);
BUG_ON(!sd->s_parent); BUG_ON(!sd->s_parent);
new_parent_sd = new_parent_kobj->sd ? new_parent_kobj->sd : &sysfs_root; new_parent_sd = (new_parent_kobj && new_parent_kobj->sd) ?
new_parent_kobj->sd : &sysfs_root;
error = 0; error = 0;
if (sd->s_parent == new_parent_sd) if (sd->s_parent == new_parent_sd)

View File

@ -268,7 +268,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
struct sysfs_open_dirent *od, *new_od = NULL; struct sysfs_open_dirent *od, *new_od = NULL;
retry: retry:
spin_lock(&sysfs_open_dirent_lock); spin_lock_irq(&sysfs_open_dirent_lock);
if (!sd->s_attr.open && new_od) { if (!sd->s_attr.open && new_od) {
sd->s_attr.open = new_od; sd->s_attr.open = new_od;
@ -281,7 +281,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
list_add_tail(&buffer->list, &od->buffers); list_add_tail(&buffer->list, &od->buffers);
} }
spin_unlock(&sysfs_open_dirent_lock); spin_unlock_irq(&sysfs_open_dirent_lock);
if (od) { if (od) {
kfree(new_od); kfree(new_od);
@ -315,8 +315,9 @@ static void sysfs_put_open_dirent(struct sysfs_dirent *sd,
struct sysfs_buffer *buffer) struct sysfs_buffer *buffer)
{ {
struct sysfs_open_dirent *od = sd->s_attr.open; struct sysfs_open_dirent *od = sd->s_attr.open;
unsigned long flags;
spin_lock(&sysfs_open_dirent_lock); spin_lock_irqsave(&sysfs_open_dirent_lock, flags);
list_del(&buffer->list); list_del(&buffer->list);
if (atomic_dec_and_test(&od->refcnt)) if (atomic_dec_and_test(&od->refcnt))
@ -324,7 +325,7 @@ static void sysfs_put_open_dirent(struct sysfs_dirent *sd,
else else
od = NULL; od = NULL;
spin_unlock(&sysfs_open_dirent_lock); spin_unlock_irqrestore(&sysfs_open_dirent_lock, flags);
kfree(od); kfree(od);
} }
@ -456,8 +457,9 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
void sysfs_notify_dirent(struct sysfs_dirent *sd) void sysfs_notify_dirent(struct sysfs_dirent *sd)
{ {
struct sysfs_open_dirent *od; struct sysfs_open_dirent *od;
unsigned long flags;
spin_lock(&sysfs_open_dirent_lock); spin_lock_irqsave(&sysfs_open_dirent_lock, flags);
od = sd->s_attr.open; od = sd->s_attr.open;
if (od) { if (od) {
@ -465,7 +467,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
wake_up_interruptible(&od->poll); wake_up_interruptible(&od->poll);
} }
spin_unlock(&sysfs_open_dirent_lock); spin_unlock_irqrestore(&sysfs_open_dirent_lock, flags);
} }
EXPORT_SYMBOL_GPL(sysfs_notify_dirent); EXPORT_SYMBOL_GPL(sysfs_notify_dirent);