Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-cor…
Browse files Browse the repository at this point in the history
…e-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.
  • Loading branch information
Linus Torvalds committed Oct 15, 2009
2 parents 59c0b58 + 83db93f commit e7957ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion fs/sysfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,8 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj)

mutex_lock(&sysfs_rename_mutex);
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;
if (sd->s_parent == new_parent_sd)
Expand Down
14 changes: 8 additions & 6 deletions fs/sysfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
struct sysfs_open_dirent *od, *new_od = NULL;

retry:
spin_lock(&sysfs_open_dirent_lock);
spin_lock_irq(&sysfs_open_dirent_lock);

if (!sd->s_attr.open && new_od) {
sd->s_attr.open = new_od;
Expand All @@ -281,7 +281,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
list_add_tail(&buffer->list, &od->buffers);
}

spin_unlock(&sysfs_open_dirent_lock);
spin_unlock_irq(&sysfs_open_dirent_lock);

if (od) {
kfree(new_od);
Expand Down Expand Up @@ -315,16 +315,17 @@ static void sysfs_put_open_dirent(struct sysfs_dirent *sd,
struct sysfs_buffer *buffer)
{
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);
if (atomic_dec_and_test(&od->refcnt))
sd->s_attr.open = NULL;
else
od = NULL;

spin_unlock(&sysfs_open_dirent_lock);
spin_unlock_irqrestore(&sysfs_open_dirent_lock, flags);

kfree(od);
}
Expand Down Expand Up @@ -456,16 +457,17 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
void sysfs_notify_dirent(struct sysfs_dirent *sd)
{
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;
if (od) {
atomic_inc(&od->event);
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);

Expand Down

0 comments on commit e7957ec

Please sign in to comment.