From 58aca23226a19983571bd3b65167521fc64f5869 Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Wed, 12 Mar 2008 00:57:22 +0100 Subject: PM: Handle device registrations during suspend/resume Modify the PM core to protect its data structures, specifically the dpm_active list, from being corrupted if a child of the currently suspending device is registered concurrently with its ->suspend() callback. In that case, since the new device (the child) is added to dpm_active after its parent, the PM core will attempt to suspend it after the parent, which is wrong. Introduce a new member of struct dev_pm_info, called 'sleeping', and use it to check if the parent of the device being added to dpm_active has been suspended, in which case the device registration fails. Also, use 'sleeping' for checking if the ordering of devices on dpm_active is correct. Introduce variable 'all_sleeping' that will be set to 'true' once all devices have been suspended and make new device registrations fail until 'all_sleeping' is reset to 'false', in order to avoid having unsuspended devices around while the system is going into a sleep state. Remove pm_sleep_rwsem which is not necessary any more. Special thanks to Alan Stern for discussions and suggestions that lead to the creation of this patch. Signed-off-by: Rafael J. Wysocki Acked-by: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/base/core.c') diff --git a/drivers/base/core.c b/drivers/base/core.c index 24198ad0197..79848e6c5db 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -820,7 +820,11 @@ int device_add(struct device *dev) error = dpm_sysfs_add(dev); if (error) goto PMError; - device_pm_add(dev); + error = device_pm_add(dev); + if (error) { + dpm_sysfs_remove(dev); + goto PMError; + } error = bus_add_device(dev); if (error) goto BusError; -- cgit v1.2.3-70-g09d2 From 57eee3d23e8833ca18708b374c648235691942ba Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Wed, 12 Mar 2008 00:59:38 +0100 Subject: Driver core: Call device_pm_add() after bus_add_device() in device_add() Include dpm_sysfs_add() into device_pm_add(), in analogy with device_pm_remove(), and modify device_add() to call the latter after bus_add_device(), to avoid situations in which the PM core may attempt to suspend a device the registration of which has not been successful. Signed-off-by: Rafael J. Wysocki Acked-by: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- drivers/base/core.c | 15 +++++---------- drivers/base/power/main.c | 4 +++- 2 files changed, 8 insertions(+), 11 deletions(-) (limited to 'drivers/base/core.c') diff --git a/drivers/base/core.c b/drivers/base/core.c index 79848e6c5db..adbc0178844 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -817,17 +817,12 @@ int device_add(struct device *dev) error = device_add_attrs(dev); if (error) goto AttrsError; - error = dpm_sysfs_add(dev); - if (error) - goto PMError; - error = device_pm_add(dev); - if (error) { - dpm_sysfs_remove(dev); - goto PMError; - } error = bus_add_device(dev); if (error) goto BusError; + error = device_pm_add(dev); + if (error) + goto PMError; kobject_uevent(&dev->kobj, KOBJ_ADD); bus_attach_device(dev); if (parent) @@ -847,9 +842,9 @@ int device_add(struct device *dev) Done: put_device(dev); return error; - BusError: - device_pm_remove(dev); PMError: + bus_remove_device(dev); + BusError: if (dev->bus) blocking_notifier_call_chain(&dev->bus->p->bus_notifier, BUS_NOTIFY_DEL_DEVICE, dev); diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 0e3991a437c..93a146940b9 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -81,7 +81,9 @@ int device_pm_add(struct device *dev) WARN_ON(true); error = -EBUSY; } else { - list_add_tail(&dev->power.entry, &dpm_active); + error = dpm_sysfs_add(dev); + if (!error) + list_add_tail(&dev->power.entry, &dpm_active); } mutex_unlock(&dpm_list_mtx); return error; -- cgit v1.2.3-70-g09d2 From b844eba292b477cda14582bfc6f535deed57a82d Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Sun, 23 Mar 2008 20:28:24 +0100 Subject: PM: Remove destroy_suspended_device() After 2.6.24 there was a plan to make the PM core acquire all device semaphores during a suspend/hibernation to protect itself from concurrent operations involving device objects. That proved to be too heavy-handed and we found a better way to achieve the goal, but before it happened, we had introduced the functions device_pm_schedule_removal() and destroy_suspended_device() to allow drivers to "safely" destroy a suspended device and we had adapted some drivers to use them. Now that these functions are no longer necessary, it seems reasonable to remove them and modify their users to use the normal device unregistration instead. Signed-off-by: Rafael J. Wysocki Acked-by: Pavel Machek Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpuid.c | 4 +--- arch/x86/kernel/msr.c | 4 +--- drivers/base/core.c | 29 ----------------------------- drivers/base/power/main.c | 40 ---------------------------------------- drivers/char/hw_random/core.c | 10 +++++----- drivers/char/misc.c | 13 ++++--------- drivers/leds/led-class.c | 11 +++-------- drivers/net/wireless/b43/leds.c | 5 +---- drivers/net/wireless/b43/main.c | 8 ++++---- include/linux/device.h | 14 -------------- include/linux/hw_random.h | 10 +--------- include/linux/leds.h | 10 +--------- include/linux/miscdevice.h | 10 +--------- 13 files changed, 22 insertions(+), 146 deletions(-) (limited to 'drivers/base/core.c') diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c index 288e7a6598a..daff52a6224 100644 --- a/arch/x86/kernel/cpuid.c +++ b/arch/x86/kernel/cpuid.c @@ -154,12 +154,10 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb, err = cpuid_device_create(cpu); break; case CPU_UP_CANCELED: + case CPU_UP_CANCELED_FROZEN: case CPU_DEAD: cpuid_device_destroy(cpu); break; - case CPU_UP_CANCELED_FROZEN: - destroy_suspended_device(cpuid_class, MKDEV(CPUID_MAJOR, cpu)); - break; } return err ? NOTIFY_BAD : NOTIFY_OK; } diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c index 4dfb4053005..1f3abe048e9 100644 --- a/arch/x86/kernel/msr.c +++ b/arch/x86/kernel/msr.c @@ -162,12 +162,10 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb, err = msr_device_create(cpu); break; case CPU_UP_CANCELED: + case CPU_UP_CANCELED_FROZEN: case CPU_DEAD: msr_device_destroy(cpu); break; - case CPU_UP_CANCELED_FROZEN: - destroy_suspended_device(msr_class, MKDEV(MSR_MAJOR, cpu)); - break; } return err ? NOTIFY_BAD : NOTIFY_OK; } diff --git a/drivers/base/core.c b/drivers/base/core.c index adbc0178844..0262fc7c45f 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1163,35 +1163,6 @@ void device_destroy(struct class *class, dev_t devt) } EXPORT_SYMBOL_GPL(device_destroy); -#ifdef CONFIG_PM_SLEEP -/** - * destroy_suspended_device - asks the PM core to remove a suspended device - * @class: pointer to the struct class that this device was registered with - * @devt: the dev_t of the device that was previously registered - * - * This call notifies the PM core of the necessity to unregister a suspended - * device created with a call to device_create() (devices cannot be - * unregistered directly while suspended, since the PM core holds their - * semaphores at that time). - * - * It can only be called within the scope of a system sleep transition. In - * practice this means it has to be directly or indirectly invoked either by - * a suspend or resume method, or by the PM core (e.g. via - * disable_nonboot_cpus() or enable_nonboot_cpus()). - */ -void destroy_suspended_device(struct class *class, dev_t devt) -{ - struct device *dev; - - dev = class_find_device(class, &devt, __match_devt); - if (dev) { - device_pm_schedule_removal(dev); - put_device(dev); - } -} -EXPORT_SYMBOL_GPL(destroy_suspended_device); -#endif /* CONFIG_PM_SLEEP */ - /** * device_rename - renames a device * @dev: the pointer to the struct device to be renamed diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 5630af302b2..c4568b82875 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -50,7 +50,6 @@ LIST_HEAD(dpm_active); static LIST_HEAD(dpm_off); static LIST_HEAD(dpm_off_irq); -static LIST_HEAD(dpm_destroy); static DEFINE_MUTEX(dpm_list_mtx); @@ -104,24 +103,6 @@ void device_pm_remove(struct device *dev) mutex_unlock(&dpm_list_mtx); } -/** - * device_pm_schedule_removal - schedule the removal of a suspended device - * @dev: Device to destroy - * - * Moves the device to the dpm_destroy list for further processing by - * unregister_dropped_devices(). - */ -void device_pm_schedule_removal(struct device *dev) -{ - pr_debug("PM: Preparing for removal: %s:%s\n", - dev->bus ? dev->bus->name : "No Bus", - kobject_name(&dev->kobj)); - mutex_lock(&dpm_list_mtx); - list_move_tail(&dev->power.entry, &dpm_destroy); - mutex_unlock(&dpm_list_mtx); -} -EXPORT_SYMBOL_GPL(device_pm_schedule_removal); - /*------------------------- Resume routines -------------------------*/ /** @@ -245,26 +226,6 @@ static void dpm_resume(void) mutex_unlock(&dpm_list_mtx); } -/** - * unregister_dropped_devices - Unregister devices scheduled for removal - * - * Unregister all devices on the dpm_destroy list. - */ -static void unregister_dropped_devices(void) -{ - mutex_lock(&dpm_list_mtx); - while (!list_empty(&dpm_destroy)) { - struct list_head *entry = dpm_destroy.next; - struct device *dev = to_device(entry); - - mutex_unlock(&dpm_list_mtx); - /* This also removes the device from the list */ - device_unregister(dev); - mutex_lock(&dpm_list_mtx); - } - mutex_unlock(&dpm_list_mtx); -} - /** * device_resume - Restore state of each device in system. * @@ -275,7 +236,6 @@ void device_resume(void) { might_sleep(); dpm_resume(); - unregister_dropped_devices(); } EXPORT_SYMBOL_GPL(device_resume); diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index 349b6edc579..662d60e44e9 100644 --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c @@ -238,11 +238,11 @@ static DEVICE_ATTR(rng_available, S_IRUGO, NULL); -static void unregister_miscdev(bool suspended) +static void unregister_miscdev(void) { device_remove_file(rng_miscdev.this_device, &dev_attr_rng_available); device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current); - __misc_deregister(&rng_miscdev, suspended); + misc_deregister(&rng_miscdev); } static int register_miscdev(void) @@ -317,7 +317,7 @@ out: } EXPORT_SYMBOL_GPL(hwrng_register); -void __hwrng_unregister(struct hwrng *rng, bool suspended) +void hwrng_unregister(struct hwrng *rng) { int err; @@ -336,11 +336,11 @@ void __hwrng_unregister(struct hwrng *rng, bool suspended) } } if (list_empty(&rng_list)) - unregister_miscdev(suspended); + unregister_miscdev(); mutex_unlock(&rng_mutex); } -EXPORT_SYMBOL_GPL(__hwrng_unregister); +EXPORT_SYMBOL_GPL(hwrng_unregister); MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver"); diff --git a/drivers/char/misc.c b/drivers/char/misc.c index a39101feb2e..4d058dadbfc 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c @@ -232,9 +232,8 @@ int misc_register(struct miscdevice * misc) } /** - * __misc_deregister - unregister a miscellaneous device + * misc_deregister - unregister a miscellaneous device * @misc: device to unregister - * @suspended: to be set if the function is used during suspend/resume * * Unregister a miscellaneous device that was previously * successfully registered with misc_register(). Success @@ -242,7 +241,7 @@ int misc_register(struct miscdevice * misc) * indicates an error. */ -int __misc_deregister(struct miscdevice *misc, bool suspended) +int misc_deregister(struct miscdevice *misc) { int i = misc->minor; @@ -251,11 +250,7 @@ int __misc_deregister(struct miscdevice *misc, bool suspended) mutex_lock(&misc_mtx); list_del(&misc->list); - if (suspended) - destroy_suspended_device(misc_class, - MKDEV(MISC_MAJOR, misc->minor)); - else - device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor)); + device_destroy(misc_class, MKDEV(MISC_MAJOR, misc->minor)); if (i < DYNAMIC_MINORS && i>0) { misc_minors[i>>3] &= ~(1 << (misc->minor & 7)); } @@ -264,7 +259,7 @@ int __misc_deregister(struct miscdevice *misc, bool suspended) } EXPORT_SYMBOL(misc_register); -EXPORT_SYMBOL(__misc_deregister); +EXPORT_SYMBOL(misc_deregister); static int __init misc_init(void) { diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 4a938780dfc..63aad90247c 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -139,12 +139,10 @@ EXPORT_SYMBOL_GPL(led_classdev_register); /** * __led_classdev_unregister - unregisters a object of led_properties class. * @led_cdev: the led device to unregister - * @suspended: indicates whether system-wide suspend or resume is in progress * * Unregisters a previously registered via led_classdev_register object. */ -void __led_classdev_unregister(struct led_classdev *led_cdev, - bool suspended) +void led_classdev_unregister(struct led_classdev *led_cdev) { device_remove_file(led_cdev->dev, &dev_attr_brightness); #ifdef CONFIG_LEDS_TRIGGERS @@ -155,16 +153,13 @@ void __led_classdev_unregister(struct led_classdev *led_cdev, up_write(&led_cdev->trigger_lock); #endif - if (suspended) - device_pm_schedule_removal(led_cdev->dev); - else - device_unregister(led_cdev->dev); + device_unregister(led_cdev->dev); down_write(&leds_list_lock); list_del(&led_cdev->node); up_write(&leds_list_lock); } -EXPORT_SYMBOL_GPL(__led_classdev_unregister); +EXPORT_SYMBOL_GPL(led_classdev_unregister); static int __init leds_init(void) { diff --git a/drivers/net/wireless/b43/leds.c b/drivers/net/wireless/b43/leds.c index 0aac1ff511d..36a9c42df83 100644 --- a/drivers/net/wireless/b43/leds.c +++ b/drivers/net/wireless/b43/leds.c @@ -116,10 +116,7 @@ static void b43_unregister_led(struct b43_led *led) { if (!led->dev) return; - if (led->dev->suspend_in_progress) - led_classdev_unregister_suspended(&led->led_dev); - else - led_classdev_unregister(&led->led_dev); + led_classdev_unregister(&led->led_dev); b43_led_turn_off(led->dev, led->index, led->activelow); led->dev = NULL; } diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index cf5c046c9fa..943cc851c50 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c @@ -2804,10 +2804,10 @@ static int b43_rng_read(struct hwrng *rng, u32 * data) return (sizeof(u16)); } -static void b43_rng_exit(struct b43_wl *wl, bool suspended) +static void b43_rng_exit(struct b43_wl *wl) { if (wl->rng_initialized) - __hwrng_unregister(&wl->rng, suspended); + hwrng_unregister(&wl->rng); } static int b43_rng_init(struct b43_wl *wl) @@ -3824,7 +3824,7 @@ static void b43_wireless_core_exit(struct b43_wldev *dev) if (!dev->suspend_in_progress) { b43_leds_exit(dev); - b43_rng_exit(dev->wl, false); + b43_rng_exit(dev->wl); } b43_dma_free(dev); b43_pio_free(dev); @@ -4589,7 +4589,7 @@ static int b43_resume(struct ssb_device *dev) err = b43_wireless_core_start(wldev); if (err) { b43_leds_exit(wldev); - b43_rng_exit(wldev->wl, true); + b43_rng_exit(wldev->wl); b43_wireless_core_exit(wldev); b43err(wl, "Resume failed at core start\n"); goto out; diff --git a/include/linux/device.h b/include/linux/device.h index 441461f5ee2..dc3429e2eb0 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -545,20 +545,6 @@ extern struct device *device_create(struct class *cls, struct device *parent, dev_t devt, const char *fmt, ...) __attribute__((format(printf, 4, 5))); extern void device_destroy(struct class *cls, dev_t devt); -#ifdef CONFIG_PM_SLEEP -extern void destroy_suspended_device(struct class *cls, dev_t devt); -extern void device_pm_schedule_removal(struct device *); -#else /* !CONFIG_PM_SLEEP */ -static inline void destroy_suspended_device(struct class *cls, dev_t devt) -{ - device_destroy(cls, devt); -} - -static inline void device_pm_schedule_removal(struct device *dev) -{ - device_unregister(dev); -} -#endif /* !CONFIG_PM_SLEEP */ /* * Platform "fixup" functions - allow the platform to have their say diff --git a/include/linux/hw_random.h b/include/linux/hw_random.h index 42131820bb8..85d11916e9e 100644 --- a/include/linux/hw_random.h +++ b/include/linux/hw_random.h @@ -44,15 +44,7 @@ struct hwrng { /** Register a new Hardware Random Number Generator driver. */ extern int hwrng_register(struct hwrng *rng); /** Unregister a Hardware Random Number Generator driver. */ -extern void __hwrng_unregister(struct hwrng *rng, bool suspended); -static inline void hwrng_unregister(struct hwrng *rng) -{ - __hwrng_unregister(rng, false); -} -static inline void hwrng_unregister_suspended(struct hwrng *rng) -{ - __hwrng_unregister(rng, true); -} +extern void hwrng_unregister(struct hwrng *rng); #endif /* __KERNEL__ */ #endif /* LINUX_HWRANDOM_H_ */ diff --git a/include/linux/leds.h b/include/linux/leds.h index 0201f6f51ce..b07e3d400bd 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -59,15 +59,7 @@ struct led_classdev { extern int led_classdev_register(struct device *parent, struct led_classdev *led_cdev); -extern void __led_classdev_unregister(struct led_classdev *led_cdev, bool sus); -static inline void led_classdev_unregister(struct led_classdev *lcd) -{ - __led_classdev_unregister(lcd, false); -} -static inline void led_classdev_unregister_suspended(struct led_classdev *lcd) -{ - __led_classdev_unregister(lcd, true); -} +extern void led_classdev_unregister(struct led_classdev *lcd); extern void led_classdev_suspend(struct led_classdev *led_cdev); extern void led_classdev_resume(struct led_classdev *led_cdev); diff --git a/include/linux/miscdevice.h b/include/linux/miscdevice.h index 24b30b9b4f8..26433ec520b 100644 --- a/include/linux/miscdevice.h +++ b/include/linux/miscdevice.h @@ -43,15 +43,7 @@ struct miscdevice { }; extern int misc_register(struct miscdevice * misc); -extern int __misc_deregister(struct miscdevice *misc, bool suspended); -static inline int misc_deregister(struct miscdevice *misc) -{ - return __misc_deregister(misc, false); -} -static inline int misc_deregister_suspended(struct miscdevice *misc) -{ - return __misc_deregister(misc, true); -} +extern int misc_deregister(struct miscdevice *misc); #define MODULE_ALIAS_MISCDEV(minor) \ MODULE_ALIAS("char-major-" __stringify(MISC_MAJOR) \ -- cgit v1.2.3-70-g09d2 From 2b3a302a09735276e13421db56c20045a48eb06d Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Tue, 4 Mar 2008 16:41:05 -0800 Subject: driver core: replace remaining __FUNCTION__ occurrences __FUNCTION__ is gcc-specific, use __func__ Signed-off-by: Harvey Harrison Signed-off-by: Greg Kroah-Hartman --- drivers/base/bus.c | 8 ++++---- drivers/base/class.c | 8 ++++---- drivers/base/core.c | 18 +++++++++--------- drivers/base/dd.c | 14 +++++++------- drivers/base/firmware_class.c | 18 +++++++++--------- drivers/base/memory.c | 4 ++-- drivers/base/sys.c | 2 +- 7 files changed, 36 insertions(+), 36 deletions(-) (limited to 'drivers/base/core.c') diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 450942acca1..be1cc514335 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -79,7 +79,7 @@ static void driver_release(struct kobject *kobj) { struct driver_private *drv_priv = to_driver(kobj); - pr_debug("driver: '%s': %s\n", kobject_name(kobj), __FUNCTION__); + pr_debug("driver: '%s': %s\n", kobject_name(kobj), __func__); kfree(drv_priv); } @@ -677,19 +677,19 @@ int bus_add_driver(struct device_driver *drv) error = driver_create_file(drv, &driver_attr_uevent); if (error) { printk(KERN_ERR "%s: uevent attr (%s) failed\n", - __FUNCTION__, drv->name); + __func__, drv->name); } error = driver_add_attrs(bus, drv); if (error) { /* How the hell do we get out of this pickle? Give up */ printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n", - __FUNCTION__, drv->name); + __func__, drv->name); } error = add_bind_files(drv); if (error) { /* Ditto */ printk(KERN_ERR "%s: add_bind_files(%s) failed\n", - __FUNCTION__, drv->name); + __func__, drv->name); } kobject_uevent(&priv->kobj, KOBJ_ADD); diff --git a/drivers/base/class.c b/drivers/base/class.c index 9d915376c31..b4901799308 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -175,13 +175,13 @@ void class_unregister(struct class *cls) static void class_create_release(struct class *cls) { - pr_debug("%s called for %s\n", __FUNCTION__, cls->name); + pr_debug("%s called for %s\n", __func__, cls->name); kfree(cls); } static void class_device_create_release(struct class_device *class_dev) { - pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id); + pr_debug("%s called for %s\n", __func__, class_dev->class_id); kfree(class_dev); } @@ -189,7 +189,7 @@ static void class_device_create_release(struct class_device *class_dev) static int class_device_create_uevent(struct class_device *class_dev, struct kobj_uevent_env *env) { - pr_debug("%s called for %s\n", __FUNCTION__, class_dev->class_id); + pr_debug("%s called for %s\n", __func__, class_dev->class_id); return 0; } @@ -415,7 +415,7 @@ static int class_uevent(struct kset *kset, struct kobject *kobj, struct device *dev = class_dev->dev; int retval = 0; - pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id); + pr_debug("%s - name = %s\n", __func__, class_dev->class_id); if (MAJOR(class_dev->devt)) { add_uevent_var(env, "MAJOR=%u", MAJOR(class_dev->devt)); diff --git a/drivers/base/core.c b/drivers/base/core.c index 0262fc7c45f..0737fe5392a 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -207,7 +207,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, retval = dev->bus->uevent(dev, env); if (retval) pr_debug("device: '%s': %s: bus uevent() returned %d\n", - dev->bus_id, __FUNCTION__, retval); + dev->bus_id, __func__, retval); } /* have the class specific function add its stuff */ @@ -216,7 +216,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, if (retval) pr_debug("device: '%s': %s: class uevent() " "returned %d\n", dev->bus_id, - __FUNCTION__, retval); + __func__, retval); } /* have the device type specific fuction add its stuff */ @@ -225,7 +225,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, if (retval) pr_debug("device: '%s': %s: dev_type uevent() " "returned %d\n", dev->bus_id, - __FUNCTION__, retval); + __func__, retval); } return retval; @@ -782,7 +782,7 @@ int device_add(struct device *dev) goto Done; } - pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); + pr_debug("device: '%s': %s\n", dev->bus_id, __func__); parent = get_device(dev->parent); setup_parent(dev, parent); @@ -980,7 +980,7 @@ void device_del(struct device *dev) */ void device_unregister(struct device *dev) { - pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); + pr_debug("device: '%s': %s\n", dev->bus_id, __func__); device_del(dev); put_device(dev); } @@ -1075,7 +1075,7 @@ EXPORT_SYMBOL_GPL(device_remove_file); static void device_create_release(struct device *dev) { - pr_debug("device: '%s': %s\n", dev->bus_id, __FUNCTION__); + pr_debug("device: '%s': %s\n", dev->bus_id, __func__); kfree(dev); } @@ -1180,7 +1180,7 @@ int device_rename(struct device *dev, char *new_name) return -EINVAL; pr_debug("device: '%s': %s: renaming to '%s'\n", dev->bus_id, - __FUNCTION__, new_name); + __func__, new_name); #ifdef CONFIG_SYSFS_DEPRECATED if ((dev->class) && (dev->parent)) @@ -1219,7 +1219,7 @@ int device_rename(struct device *dev, char *new_name) dev->bus_id); if (error) { dev_err(dev, "%s: sysfs_create_symlink failed (%d)\n", - __FUNCTION__, error); + __func__, error); } } #endif @@ -1295,7 +1295,7 @@ int device_move(struct device *dev, struct device *new_parent) new_parent_kobj = get_device_parent(dev, new_parent); pr_debug("device: '%s': %s: moving to '%s'\n", dev->bus_id, - __FUNCTION__, new_parent ? new_parent->bus_id : ""); + __func__, new_parent ? new_parent->bus_id : ""); error = kobject_move(&dev->kobj, new_parent_kobj); if (error) { cleanup_glue_dir(dev, new_parent_kobj); diff --git a/drivers/base/dd.c b/drivers/base/dd.c index a5cde94bb98..3ac443b2ac0 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -30,12 +30,12 @@ static void driver_bound(struct device *dev) { if (klist_node_attached(&dev->knode_driver)) { printk(KERN_WARNING "%s: device %s already bound\n", - __FUNCTION__, kobject_name(&dev->kobj)); + __func__, kobject_name(&dev->kobj)); return; } pr_debug("driver: '%s': %s: bound to device '%s'\n", dev->bus_id, - __FUNCTION__, dev->driver->name); + __func__, dev->driver->name); if (dev->bus) blocking_notifier_call_chain(&dev->bus->p->bus_notifier, @@ -104,13 +104,13 @@ static int really_probe(struct device *dev, struct device_driver *drv) atomic_inc(&probe_count); pr_debug("bus: '%s': %s: probing driver %s with device %s\n", - drv->bus->name, __FUNCTION__, drv->name, dev->bus_id); + drv->bus->name, __func__, drv->name, dev->bus_id); WARN_ON(!list_empty(&dev->devres_head)); dev->driver = drv; if (driver_sysfs_add(dev)) { printk(KERN_ERR "%s: driver_sysfs_add(%s) failed\n", - __FUNCTION__, dev->bus_id); + __func__, dev->bus_id); goto probe_failed; } @@ -127,7 +127,7 @@ static int really_probe(struct device *dev, struct device_driver *drv) driver_bound(dev); ret = 1; pr_debug("bus: '%s': %s: bound device %s to driver %s\n", - drv->bus->name, __FUNCTION__, dev->bus_id, drv->name); + drv->bus->name, __func__, dev->bus_id, drv->name); goto done; probe_failed: @@ -160,7 +160,7 @@ done: */ int driver_probe_done(void) { - pr_debug("%s: probe_count = %d\n", __FUNCTION__, + pr_debug("%s: probe_count = %d\n", __func__, atomic_read(&probe_count)); if (atomic_read(&probe_count)) return -EBUSY; @@ -194,7 +194,7 @@ int driver_probe_device(struct device_driver *drv, struct device *dev) goto done; pr_debug("bus: '%s': %s: matched device %s with driver %s\n", - drv->bus->name, __FUNCTION__, dev->bus_id, drv->name); + drv->bus->name, __func__, dev->bus_id, drv->name); ret = really_probe(dev, drv); diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 4a1b9bfc547..1fef7df8c9d 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -156,7 +156,7 @@ static ssize_t firmware_loading_store(struct device *dev, } /* fallthrough */ default: - printk(KERN_ERR "%s: unexpected value (%d)\n", __FUNCTION__, + printk(KERN_ERR "%s: unexpected value (%d)\n", __func__, loading); /* fallthrough */ case -1: @@ -209,7 +209,7 @@ fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) new_size = ALIGN(min_size, PAGE_SIZE); new_data = vmalloc(new_size); if (!new_data) { - printk(KERN_ERR "%s: unable to alloc buffer\n", __FUNCTION__); + printk(KERN_ERR "%s: unable to alloc buffer\n", __func__); /* Make sure that we don't keep incomplete data */ fw_load_abort(fw_priv); return -ENOMEM; @@ -307,7 +307,7 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, *dev_p = NULL; if (!fw_priv || !f_dev) { - printk(KERN_ERR "%s: kmalloc failed\n", __FUNCTION__); + printk(KERN_ERR "%s: kmalloc failed\n", __func__); retval = -ENOMEM; goto error_kfree; } @@ -328,7 +328,7 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, retval = device_register(f_dev); if (retval) { printk(KERN_ERR "%s: device_register failed\n", - __FUNCTION__); + __func__); goto error_kfree; } *dev_p = f_dev; @@ -362,14 +362,14 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p, retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); if (retval) { printk(KERN_ERR "%s: sysfs_create_bin_file failed\n", - __FUNCTION__); + __func__); goto error_unreg; } retval = device_create_file(f_dev, &dev_attr_loading); if (retval) { printk(KERN_ERR "%s: device_create_file failed\n", - __FUNCTION__); + __func__); goto error_unreg; } @@ -399,7 +399,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name, *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); if (!firmware) { printk(KERN_ERR "%s: kmalloc(struct firmware) failed\n", - __FUNCTION__); + __func__); retval = -ENOMEM; goto out; } @@ -570,13 +570,13 @@ firmware_class_init(void) int error; error = class_register(&firmware_class); if (error) { - printk(KERN_ERR "%s: class_register failed\n", __FUNCTION__); + printk(KERN_ERR "%s: class_register failed\n", __func__); return error; } error = class_create_file(&firmware_class, &class_attr_timeout); if (error) { printk(KERN_ERR "%s: class_create_file failed\n", - __FUNCTION__); + __func__); class_unregister(&firmware_class); } return error; diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 7891f7c9726..8ce6de5a7e2 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -186,7 +186,7 @@ memory_block_action(struct memory_block *mem, unsigned long action) break; default: printk(KERN_WARNING "%s(%p, %ld) unknown action: %ld\n", - __FUNCTION__, mem, action, action); + __func__, mem, action, action); WARN_ON(1); ret = -EINVAL; } @@ -444,6 +444,6 @@ int __init memory_dev_init(void) ret = err; out: if (ret) - printk(KERN_ERR "%s() failed: %d\n", __FUNCTION__, ret); + printk(KERN_ERR "%s() failed: %d\n", __func__, ret); return ret; } diff --git a/drivers/base/sys.c b/drivers/base/sys.c index 1a06c239371..4fbb56bcb1e 100644 --- a/drivers/base/sys.c +++ b/drivers/base/sys.c @@ -195,7 +195,7 @@ int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv) } } else { err = -EINVAL; - printk(KERN_ERR "%s: invalid device class\n", __FUNCTION__); + printk(KERN_ERR "%s: invalid device class\n", __func__); WARN_ON(1); } mutex_unlock(&sysdev_drivers_lock); -- cgit v1.2.3-70-g09d2