From e1955ca0ee55286cbc65a8ed7471d540ae83dac8 Mon Sep 17 00:00:00 2001 From: Jiri Kosina Date: Tue, 9 Mar 2010 19:30:28 +0100 Subject: sysfs: use sysfs_bin_attr_init in firmware class driver Annotate dynamic sysfs attribute in fw_setup_device(). This gets rid of the following lockdep warning: bnx2 0000:08:00.0: firmware: requesting bnx2/bnx2-mips-06-5.0.0.j6.fw BUG: key ffff880008293470 not in .data! ------------[ cut here ]------------ WARNING: at kernel/lockdep.c:2706 lockdep_init_map+0x562/0x620() Modules linked in: bnx2(+) sg tpm_bios floppy rtc_lib usb_storage i2c_piix4 joydev button container shpchp i2c_core sr_mod cdrom pci_hotplug usbhid hid ohci_hcd ehci_hcd sd_mod usbcore edd ext3 mbcache jbd fan ata_generic sata_svw pata_serverworks libata scsi_mod thermal processor Pid: 1915, comm: work_for_cpu Not tainted 2.6.34-rc1-default #81 Call Trace: [] ? lockdep_init_map+0x562/0x620 [] warn_slowpath_common+0x78/0xd0 [] warn_slowpath_null+0xf/0x20 [] lockdep_init_map+0x562/0x620 [] ? sysfs_new_dirent+0x76/0x120 [] ? put_device+0x12/0x20 [] sysfs_add_file_mode+0x6c/0xd0 [] sysfs_add_file+0xc/0x10 [] sysfs_create_bin_file+0x21/0x30 [] _request_firmware+0x2f1/0x650 [] request_firmware+0xe/0x10 [] bnx2_init_one+0x8f5/0x177e [bnx2] [] ? _raw_spin_unlock_irq+0x2b/0x40 [] ? finish_task_switch+0x69/0x100 [] ? finish_task_switch+0x0/0x100 [] ? do_work_for_cpu+0x0/0x30 [] local_pci_probe+0x12/0x20 [] do_work_for_cpu+0x13/0x30 [] ? do_work_for_cpu+0x0/0x30 [] kthread+0x96/0xa0 [] kernel_thread_helper+0x4/0x10 [] ? restore_args+0x0/0x30 [] ? kthread+0x0/0xa0 [] ? kernel_thread_helper+0x0/0x10 ---[ end trace a2ecee9c9602d195 ]--- Cc: Eric W. Biederman Cc: Greg Kroah-Hartman Signed-off-by: Jiri Kosina Signed-off-by: Greg Kroah-Hartman --- drivers/base/firmware_class.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/base') diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index d0dc26ad5387..fc7565ce7e86 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -442,6 +442,7 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p, fw_priv = dev_get_drvdata(f_dev); fw_priv->fw = fw; + sysfs_bin_attr_init(&fw_priv->attr_data); retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); if (retval) { dev_err(device, "%s: sysfs_create_bin_file failed\n", __func__); -- cgit v1.2.3 From 4d26e139f0b7d4c0700d6993506f1f60e2f2caa5 Mon Sep 17 00:00:00 2001 From: Magnus Damm Date: Wed, 10 Mar 2010 20:50:38 +0900 Subject: Driver core: Early platform kernel-doc update This patch updates the kernel-doc notation for early platform functions. Signed-off-by: Magnus Damm Acked-by: Randy Dunlap Signed-off-by: Greg Kroah-Hartman --- drivers/base/platform.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'drivers/base') diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 1ba9d617d241..f6bcf22e6bd1 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -1052,9 +1052,11 @@ static __initdata LIST_HEAD(early_platform_driver_list); static __initdata LIST_HEAD(early_platform_device_list); /** - * early_platform_driver_register + * early_platform_driver_register - register early platform driver * @epdrv: early_platform driver structure * @buf: string passed from early_param() + * + * Helper function for early_platform_init() / early_platform_init_buffer() */ int __init early_platform_driver_register(struct early_platform_driver *epdrv, char *buf) @@ -1106,9 +1108,12 @@ int __init early_platform_driver_register(struct early_platform_driver *epdrv, } /** - * early_platform_add_devices - add a numbers of early platform devices + * early_platform_add_devices - adds a number of early platform devices * @devs: array of early platform devices to add * @num: number of early platform devices in array + * + * Used by early architecture code to register early platform devices and + * their platform data. */ void __init early_platform_add_devices(struct platform_device **devs, int num) { @@ -1128,8 +1133,12 @@ void __init early_platform_add_devices(struct platform_device **devs, int num) } /** - * early_platform_driver_register_all + * early_platform_driver_register_all - register early platform drivers * @class_str: string to identify early platform driver class + * + * Used by architecture code to register all early platform drivers + * for a certain class. If omitted then only early platform drivers + * with matching kernel command line class parameters will be registered. */ void __init early_platform_driver_register_all(char *class_str) { @@ -1151,7 +1160,7 @@ void __init early_platform_driver_register_all(char *class_str) } /** - * early_platform_match + * early_platform_match - find early platform device matching driver * @epdrv: early platform driver structure * @id: id to match against */ @@ -1169,7 +1178,7 @@ early_platform_match(struct early_platform_driver *epdrv, int id) } /** - * early_platform_left + * early_platform_left - check if early platform driver has matching devices * @epdrv: early platform driver structure * @id: return true if id or above exists */ @@ -1187,7 +1196,7 @@ static __init int early_platform_left(struct early_platform_driver *epdrv, } /** - * early_platform_driver_probe_id + * early_platform_driver_probe_id - probe drivers matching class_str and id * @class_str: string to identify early platform driver class * @id: id to match against * @nr_probe: number of platform devices to successfully probe before exiting @@ -1257,10 +1266,14 @@ static int __init early_platform_driver_probe_id(char *class_str, } /** - * early_platform_driver_probe + * early_platform_driver_probe - probe a class of registered drivers * @class_str: string to identify early platform driver class * @nr_probe: number of platform devices to successfully probe before exiting * @user_only: only probe user specified early platform devices + * + * Used by architecture code to probe registered early platform drivers + * within a certain class. For probe to happen a registered early platform + * device matching a registered early platform driver is needed. */ int __init early_platform_driver_probe(char *class_str, int nr_probe, -- cgit v1.2.3 From e59817bf089a3893e05a059026c668fb65f8c748 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Wed, 10 Mar 2010 11:47:58 -0800 Subject: driver-core: fix missing kernel-doc in firmware_class Fix kernel-doc warning in firmware_class.c: Warning(drivers/base/firmware_class.c:94): No description found for parameter 'attr' Signed-off-by: Randy Dunlap Signed-off-by: Greg Kroah-Hartman --- drivers/base/firmware_class.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/base') diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index fc7565ce7e86..18518ba13c81 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -78,6 +78,7 @@ firmware_timeout_show(struct class *class, /** * firmware_timeout_store - set number of seconds to wait for firmware * @class: device class pointer + * @attr: device attribute pointer * @buf: buffer to scan for timeout value * @count: number of bytes in @buf * -- cgit v1.2.3 From 67fc233f4fb67907861b4077cea5294035f80dc7 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 16 Mar 2010 10:33:32 +1100 Subject: sysdev: the cpu probe/release attributes should be sysdev_class_attributes This fixes these warnings: drivers/base/cpu.c:264: warning: initialization from incompatible pointer type drivers/base/cpu.c:265: warning: initialization from incompatible pointer type Cc: Andi Kleen Signed-off-by: Stephen Rothwell Signed-off-by: Greg Kroah-Hartman --- drivers/base/cpu.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/base') diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 7036e8e96ab8..b5242e1e8bc4 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -79,24 +79,24 @@ void unregister_cpu(struct cpu *cpu) } #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE -static ssize_t cpu_probe_store(struct sys_device *dev, - struct sysdev_attribute *attr, - const char *buf, +static ssize_t cpu_probe_store(struct sysdev_class *class, + struct sysdev_class_attribute *attr, + const char *buf, size_t count) { return arch_cpu_probe(buf, count); } -static ssize_t cpu_release_store(struct sys_device *dev, - struct sysdev_attribute *attr, - const char *buf, +static ssize_t cpu_release_store(struct sysdev_class *class, + struct sysdev_class_attribute *attr, + const char *buf, size_t count) { return arch_cpu_release(buf, count); } -static SYSDEV_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); -static SYSDEV_ATTR(release, S_IWUSR, NULL, cpu_release_store); +static SYSDEV_CLASS_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); +static SYSDEV_CLASS_ATTR(release, S_IWUSR, NULL, cpu_release_store); #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ #else /* ... !CONFIG_HOTPLUG_CPU */ -- cgit v1.2.3 From f0eae0ed3b7d4182a6b4dd03540a738518ea3163 Mon Sep 17 00:00:00 2001 From: Jani Nikula Date: Thu, 11 Mar 2010 18:11:45 +0200 Subject: driver-core: document ERR_PTR() return values A number of functions in the driver core return ERR_PTR() values on error. Document this in the kernel-doc of the functions. Signed-off-by: Jani Nikula Signed-off-by: Greg Kroah-Hartman --- drivers/base/class.c | 2 ++ drivers/base/core.c | 6 ++++++ drivers/base/platform.c | 6 ++++++ 3 files changed, 14 insertions(+) (limited to 'drivers/base') diff --git a/drivers/base/class.c b/drivers/base/class.c index 0147f476b8a9..9c6a0d6408e7 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -219,6 +219,8 @@ static void class_create_release(struct class *cls) * This is used to create a struct class pointer that can then be used * in calls to device_create(). * + * Returns &struct class pointer on success, or ERR_PTR() on error. + * * Note, the pointer created here is to be destroyed when finished by * making a call to class_destroy(). */ diff --git a/drivers/base/core.c b/drivers/base/core.c index ef55df34ddd0..b56a0ba31d4a 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1345,6 +1345,8 @@ static void root_device_release(struct device *dev) * 'module' symlink which points to the @owner directory * in sysfs. * + * Returns &struct device pointer on success, or ERR_PTR() on error. + * * Note: You probably want to use root_device_register(). */ struct device *__root_device_register(const char *name, struct module *owner) @@ -1432,6 +1434,8 @@ static void device_create_release(struct device *dev) * Any further sysfs files that might be required can be created using this * pointer. * + * Returns &struct device pointer on success, or ERR_PTR() on error. + * * Note: the struct class passed to this function must have previously * been created with a call to class_create(). */ @@ -1492,6 +1496,8 @@ EXPORT_SYMBOL_GPL(device_create_vargs); * Any further sysfs files that might be required can be created using this * pointer. * + * Returns &struct device pointer on success, or ERR_PTR() on error. + * * Note: the struct class passed to this function must have previously * been created with a call to class_create(). */ diff --git a/drivers/base/platform.c b/drivers/base/platform.c index f6bcf22e6bd1..4b4b565c835f 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -362,6 +362,8 @@ EXPORT_SYMBOL_GPL(platform_device_unregister); * enumeration tasks, they don't fully conform to the Linux driver model. * In particular, when such drivers are built as modules, they can't be * "hotplugged". + * + * Returns &struct platform_device pointer on success, or ERR_PTR() on error. */ struct platform_device *platform_device_register_simple(const char *name, int id, @@ -408,6 +410,8 @@ EXPORT_SYMBOL_GPL(platform_device_register_simple); * allocated for the device allows drivers using such devices to be * unloaded without waiting for the last reference to the device to be * dropped. + * + * Returns &struct platform_device pointer on success, or ERR_PTR() on error. */ struct platform_device *platform_device_register_data( struct device *parent, @@ -559,6 +563,8 @@ EXPORT_SYMBOL_GPL(platform_driver_probe); * * Use this in legacy-style modules that probe hardware directly and * register a single platform device and corresponding platform driver. + * + * Returns &struct platform_device pointer on success, or ERR_PTR() on error. */ struct platform_device * __init_or_module platform_create_bundle( struct platform_driver *driver, -- cgit v1.2.3 From 12ee3c0a0ac42bed0939420468fd35f5cdceae4f Mon Sep 17 00:00:00 2001 From: David Rientjes Date: Wed, 10 Mar 2010 14:50:21 -0800 Subject: driver core: numa: fix BUILD_BUG_ON for node_read_distance node_read_distance() has a BUILD_BUG_ON() to prevent buffer overruns when the number of nodes printed will exceed the buffer length. Each node only needs four chars: three for distance (maximum distance is 255) and one for a seperating space or a trailing newline. Signed-off-by: David Rientjes Cc: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- drivers/base/node.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers/base') diff --git a/drivers/base/node.c b/drivers/base/node.c index ad43185ec15a..93b3ac65c2d4 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -165,8 +165,11 @@ static ssize_t node_read_distance(struct sys_device * dev, int len = 0; int i; - /* buf currently PAGE_SIZE, need ~4 chars per node */ - BUILD_BUG_ON(MAX_NUMNODES*4 > PAGE_SIZE/2); + /* + * buf is currently PAGE_SIZE in length and each node needs 4 chars + * at the most (distance + space or newline). + */ + BUILD_BUG_ON(MAX_NUMNODES * 4 > PAGE_SIZE); for_each_online_node(i) len += sprintf(buf + len, "%s%d", i ? " " : "", node_distance(nid, i)); -- cgit v1.2.3