diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-04-27 15:58:54 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-04-27 15:58:54 -0400 |
commit | d868772fff6c4b881d66af8640251714e1aefa98 (patch) | |
tree | c95a68d358d5c875d25763ffe9a44fe9f2081f34 /fs/sysfs/file.c | |
parent | a205752d1ad2d37d6597aaae5a56fc396a770868 (diff) | |
parent | 404d5b185b4eb56d6fa2f7bd27833f8df1c38ce4 (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6: (46 commits)
dev_dbg: check dev_dbg() arguments
drivers/base/attribute_container.c: use mutex instead of binary semaphore
mod_sysfs_setup() doesn't return errno when kobject_add_dir() failure occurs
s2ram: add arch irq disable/enable hooks
define platform wakeup hook, use in pci_enable_wake()
security: prevent permission checking of file removal via sysfs_remove_group()
device_schedule_callback() needs a module reference
s390: cio: Delay uevents for subchannels
sysfs: bin.c printk fix
Driver core: use mutex instead of semaphore in DMA pool handler
driver core: bus_add_driver should return an error if no bus
debugfs: Add debugfs_create_u64()
the overdue removal of the mount/umount uevents
kobject: Comment and warning fixes to kobject.c
Driver core: warn when userspace writes to the uevent file in a non-supported way
Driver core: make uevent-environment available in uevent-file
kobject core: remove rwsem from struct subsystem
qeth: Remove usage of subsys.rwsem
PHY: remove rwsem use from phy core
IEEE1394: remove rwsem use from ieee1394 core
...
Diffstat (limited to 'fs/sysfs/file.c')
-rw-r--r-- | fs/sysfs/file.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index fc4633378dc0..db0413a411d6 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -633,6 +633,7 @@ struct sysfs_schedule_callback_struct { | |||
633 | struct kobject *kobj; | 633 | struct kobject *kobj; |
634 | void (*func)(void *); | 634 | void (*func)(void *); |
635 | void *data; | 635 | void *data; |
636 | struct module *owner; | ||
636 | struct work_struct work; | 637 | struct work_struct work; |
637 | }; | 638 | }; |
638 | 639 | ||
@@ -643,6 +644,7 @@ static void sysfs_schedule_callback_work(struct work_struct *work) | |||
643 | 644 | ||
644 | (ss->func)(ss->data); | 645 | (ss->func)(ss->data); |
645 | kobject_put(ss->kobj); | 646 | kobject_put(ss->kobj); |
647 | module_put(ss->owner); | ||
646 | kfree(ss); | 648 | kfree(ss); |
647 | } | 649 | } |
648 | 650 | ||
@@ -651,6 +653,7 @@ static void sysfs_schedule_callback_work(struct work_struct *work) | |||
651 | * @kobj: object we're acting for. | 653 | * @kobj: object we're acting for. |
652 | * @func: callback function to invoke later. | 654 | * @func: callback function to invoke later. |
653 | * @data: argument to pass to @func. | 655 | * @data: argument to pass to @func. |
656 | * @owner: module owning the callback code | ||
654 | * | 657 | * |
655 | * sysfs attribute methods must not unregister themselves or their parent | 658 | * sysfs attribute methods must not unregister themselves or their parent |
656 | * kobject (which would amount to the same thing). Attempts to do so will | 659 | * kobject (which would amount to the same thing). Attempts to do so will |
@@ -663,20 +666,25 @@ static void sysfs_schedule_callback_work(struct work_struct *work) | |||
663 | * until @func returns. | 666 | * until @func returns. |
664 | * | 667 | * |
665 | * Returns 0 if the request was submitted, -ENOMEM if storage could not | 668 | * Returns 0 if the request was submitted, -ENOMEM if storage could not |
666 | * be allocated. | 669 | * be allocated, -ENODEV if a reference to @owner isn't available. |
667 | */ | 670 | */ |
668 | int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *), | 671 | int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *), |
669 | void *data) | 672 | void *data, struct module *owner) |
670 | { | 673 | { |
671 | struct sysfs_schedule_callback_struct *ss; | 674 | struct sysfs_schedule_callback_struct *ss; |
672 | 675 | ||
676 | if (!try_module_get(owner)) | ||
677 | return -ENODEV; | ||
673 | ss = kmalloc(sizeof(*ss), GFP_KERNEL); | 678 | ss = kmalloc(sizeof(*ss), GFP_KERNEL); |
674 | if (!ss) | 679 | if (!ss) { |
680 | module_put(owner); | ||
675 | return -ENOMEM; | 681 | return -ENOMEM; |
682 | } | ||
676 | kobject_get(kobj); | 683 | kobject_get(kobj); |
677 | ss->kobj = kobj; | 684 | ss->kobj = kobj; |
678 | ss->func = func; | 685 | ss->func = func; |
679 | ss->data = data; | 686 | ss->data = data; |
687 | ss->owner = owner; | ||
680 | INIT_WORK(&ss->work, sysfs_schedule_callback_work); | 688 | INIT_WORK(&ss->work, sysfs_schedule_callback_work); |
681 | schedule_work(&ss->work); | 689 | schedule_work(&ss->work); |
682 | return 0; | 690 | return 0; |