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:
driver core: numa: fix BUILD_BUG_ON for node_read_distance
driver-core: document ERR_PTR() return values
kobject: documentation: Update to refer to kset-example.c.
sysdev: the cpu probe/release attributes should be sysdev_class_attributes
kobject: documentation: Fix erroneous example in kobject doc.
driver-core: fix missing kernel-doc in firmware_class
Driver core: Early platform kernel-doc update
sysfs: fix sysfs lockdep warning in mlx4 code
sysfs: fix sysfs lockdep warning in infiniband code
sysfs: fix sysfs lockdep warning in ipmi code
sysfs: Initialised pci bus legacy_mem field before use
sysfs: use sysfs_bin_attr_init in firmware class driver

+102 -38
+40 -20
Documentation/kobject.txt
··· 59 59 direct expression of inheritance, so other techniques - such as structure 60 60 embedding - must be used. 61 61 62 - So, for example, the UIO code has a structure that defines the memory 63 - region associated with a uio device: 62 + (As an aside, for those familiar with the kernel linked list implementation, 63 + this is analogous as to how "list_head" structs are rarely useful on 64 + their own, but are invariably found embedded in the larger objects of 65 + interest.) 64 66 65 - struct uio_mem { 67 + So, for example, the UIO code in drivers/uio/uio.c has a structure that 68 + defines the memory region associated with a uio device: 69 + 70 + struct uio_map { 66 71 struct kobject kobj; 67 - unsigned long addr; 68 - unsigned long size; 69 - int memtype; 70 - void __iomem *internal_addr; 71 - }; 72 + struct uio_mem *mem; 73 + }; 72 74 73 - If you have a struct uio_mem structure, finding its embedded kobject is 75 + If you have a struct uio_map structure, finding its embedded kobject is 74 76 just a matter of using the kobj member. Code that works with kobjects will 75 77 often have the opposite problem, however: given a struct kobject pointer, 76 78 what is the pointer to the containing structure? You must avoid tricks 77 79 (such as assuming that the kobject is at the beginning of the structure) 78 80 and, instead, use the container_of() macro, found in <linux/kernel.h>: 79 81 80 - container_of(pointer, type, member) 82 + container_of(pointer, type, member) 81 83 82 - where pointer is the pointer to the embedded kobject, type is the type of 83 - the containing structure, and member is the name of the structure field to 84 - which pointer points. The return value from container_of() is a pointer to 85 - the given type. So, for example, a pointer "kp" to a struct kobject 86 - embedded within a struct uio_mem could be converted to a pointer to the 87 - containing uio_mem structure with: 84 + where: 88 85 89 - struct uio_mem *u_mem = container_of(kp, struct uio_mem, kobj); 86 + * "pointer" is the pointer to the embedded kobject, 87 + * "type" is the type of the containing structure, and 88 + * "member" is the name of the structure field to which "pointer" points. 90 89 91 - Programmers often define a simple macro for "back-casting" kobject pointers 92 - to the containing type. 90 + The return value from container_of() is a pointer to the corresponding 91 + container type. So, for example, a pointer "kp" to a struct kobject 92 + embedded *within* a struct uio_map could be converted to a pointer to the 93 + *containing* uio_map structure with: 94 + 95 + struct uio_map *u_map = container_of(kp, struct uio_map, kobj); 96 + 97 + For convenience, programmers often define a simple macro for "back-casting" 98 + kobject pointers to the containing type. Exactly this happens in the 99 + earlier drivers/uio/uio.c, as you can see here: 100 + 101 + struct uio_map { 102 + struct kobject kobj; 103 + struct uio_mem *mem; 104 + }; 105 + 106 + #define to_map(map) container_of(map, struct uio_map, kobj) 107 + 108 + where the macro argument "map" is a pointer to the struct kobject in 109 + question. That macro is subsequently invoked with: 110 + 111 + struct uio_map *map = to_map(kobj); 93 112 94 113 95 114 Initialization of kobjects ··· 406 387 Example code to copy from 407 388 408 389 For a more complete example of using ksets and kobjects properly, see the 409 - sample/kobject/kset-example.c code. 390 + example programs samples/kobject/{kobject-example.c,kset-example.c}, 391 + which will be built as loadable modules if you select CONFIG_SAMPLE_KOBJECT.
+2
drivers/base/class.c
··· 219 219 * This is used to create a struct class pointer that can then be used 220 220 * in calls to device_create(). 221 221 * 222 + * Returns &struct class pointer on success, or ERR_PTR() on error. 223 + * 222 224 * Note, the pointer created here is to be destroyed when finished by 223 225 * making a call to class_destroy(). 224 226 */
+6
drivers/base/core.c
··· 1345 1345 * 'module' symlink which points to the @owner directory 1346 1346 * in sysfs. 1347 1347 * 1348 + * Returns &struct device pointer on success, or ERR_PTR() on error. 1349 + * 1348 1350 * Note: You probably want to use root_device_register(). 1349 1351 */ 1350 1352 struct device *__root_device_register(const char *name, struct module *owner) ··· 1434 1432 * Any further sysfs files that might be required can be created using this 1435 1433 * pointer. 1436 1434 * 1435 + * Returns &struct device pointer on success, or ERR_PTR() on error. 1436 + * 1437 1437 * Note: the struct class passed to this function must have previously 1438 1438 * been created with a call to class_create(). 1439 1439 */ ··· 1495 1491 * The pointer to the struct device will be returned from the call. 1496 1492 * Any further sysfs files that might be required can be created using this 1497 1493 * pointer. 1494 + * 1495 + * Returns &struct device pointer on success, or ERR_PTR() on error. 1498 1496 * 1499 1497 * Note: the struct class passed to this function must have previously 1500 1498 * been created with a call to class_create().
+8 -8
drivers/base/cpu.c
··· 79 79 } 80 80 81 81 #ifdef CONFIG_ARCH_CPU_PROBE_RELEASE 82 - static ssize_t cpu_probe_store(struct sys_device *dev, 83 - struct sysdev_attribute *attr, 84 - const char *buf, 82 + static ssize_t cpu_probe_store(struct sysdev_class *class, 83 + struct sysdev_class_attribute *attr, 84 + const char *buf, 85 85 size_t count) 86 86 { 87 87 return arch_cpu_probe(buf, count); 88 88 } 89 89 90 - static ssize_t cpu_release_store(struct sys_device *dev, 91 - struct sysdev_attribute *attr, 92 - const char *buf, 90 + static ssize_t cpu_release_store(struct sysdev_class *class, 91 + struct sysdev_class_attribute *attr, 92 + const char *buf, 93 93 size_t count) 94 94 { 95 95 return arch_cpu_release(buf, count); 96 96 } 97 97 98 - static SYSDEV_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); 99 - static SYSDEV_ATTR(release, S_IWUSR, NULL, cpu_release_store); 98 + static SYSDEV_CLASS_ATTR(probe, S_IWUSR, NULL, cpu_probe_store); 99 + static SYSDEV_CLASS_ATTR(release, S_IWUSR, NULL, cpu_release_store); 100 100 #endif /* CONFIG_ARCH_CPU_PROBE_RELEASE */ 101 101 102 102 #else /* ... !CONFIG_HOTPLUG_CPU */
+2
drivers/base/firmware_class.c
··· 78 78 /** 79 79 * firmware_timeout_store - set number of seconds to wait for firmware 80 80 * @class: device class pointer 81 + * @attr: device attribute pointer 81 82 * @buf: buffer to scan for timeout value 82 83 * @count: number of bytes in @buf 83 84 * ··· 443 442 fw_priv = dev_get_drvdata(f_dev); 444 443 445 444 fw_priv->fw = fw; 445 + sysfs_bin_attr_init(&fw_priv->attr_data); 446 446 retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); 447 447 if (retval) { 448 448 dev_err(device, "%s: sysfs_create_bin_file failed\n", __func__);
+5 -2
drivers/base/node.c
··· 165 165 int len = 0; 166 166 int i; 167 167 168 - /* buf currently PAGE_SIZE, need ~4 chars per node */ 169 - BUILD_BUG_ON(MAX_NUMNODES*4 > PAGE_SIZE/2); 168 + /* 169 + * buf is currently PAGE_SIZE in length and each node needs 4 chars 170 + * at the most (distance + space or newline). 171 + */ 172 + BUILD_BUG_ON(MAX_NUMNODES * 4 > PAGE_SIZE); 170 173 171 174 for_each_online_node(i) 172 175 len += sprintf(buf + len, "%s%d", i ? " " : "", node_distance(nid, i));
+26 -7
drivers/base/platform.c
··· 362 362 * enumeration tasks, they don't fully conform to the Linux driver model. 363 363 * In particular, when such drivers are built as modules, they can't be 364 364 * "hotplugged". 365 + * 366 + * Returns &struct platform_device pointer on success, or ERR_PTR() on error. 365 367 */ 366 368 struct platform_device *platform_device_register_simple(const char *name, 367 369 int id, ··· 410 408 * allocated for the device allows drivers using such devices to be 411 409 * unloaded without waiting for the last reference to the device to be 412 410 * dropped. 411 + * 412 + * Returns &struct platform_device pointer on success, or ERR_PTR() on error. 413 413 */ 414 414 struct platform_device *platform_device_register_data( 415 415 struct device *parent, ··· 563 559 * 564 560 * Use this in legacy-style modules that probe hardware directly and 565 561 * register a single platform device and corresponding platform driver. 562 + * 563 + * Returns &struct platform_device pointer on success, or ERR_PTR() on error. 566 564 */ 567 565 struct platform_device * __init_or_module platform_create_bundle( 568 566 struct platform_driver *driver, ··· 1058 1052 static __initdata LIST_HEAD(early_platform_device_list); 1059 1053 1060 1054 /** 1061 - * early_platform_driver_register 1055 + * early_platform_driver_register - register early platform driver 1062 1056 * @epdrv: early_platform driver structure 1063 1057 * @buf: string passed from early_param() 1058 + * 1059 + * Helper function for early_platform_init() / early_platform_init_buffer() 1064 1060 */ 1065 1061 int __init early_platform_driver_register(struct early_platform_driver *epdrv, 1066 1062 char *buf) ··· 1114 1106 } 1115 1107 1116 1108 /** 1117 - * early_platform_add_devices - add a numbers of early platform devices 1109 + * early_platform_add_devices - adds a number of early platform devices 1118 1110 * @devs: array of early platform devices to add 1119 1111 * @num: number of early platform devices in array 1112 + * 1113 + * Used by early architecture code to register early platform devices and 1114 + * their platform data. 1120 1115 */ 1121 1116 void __init early_platform_add_devices(struct platform_device **devs, int num) 1122 1117 { ··· 1139 1128 } 1140 1129 1141 1130 /** 1142 - * early_platform_driver_register_all 1131 + * early_platform_driver_register_all - register early platform drivers 1143 1132 * @class_str: string to identify early platform driver class 1133 + * 1134 + * Used by architecture code to register all early platform drivers 1135 + * for a certain class. If omitted then only early platform drivers 1136 + * with matching kernel command line class parameters will be registered. 1144 1137 */ 1145 1138 void __init early_platform_driver_register_all(char *class_str) 1146 1139 { ··· 1166 1151 } 1167 1152 1168 1153 /** 1169 - * early_platform_match 1154 + * early_platform_match - find early platform device matching driver 1170 1155 * @epdrv: early platform driver structure 1171 1156 * @id: id to match against 1172 1157 */ ··· 1184 1169 } 1185 1170 1186 1171 /** 1187 - * early_platform_left 1172 + * early_platform_left - check if early platform driver has matching devices 1188 1173 * @epdrv: early platform driver structure 1189 1174 * @id: return true if id or above exists 1190 1175 */ ··· 1202 1187 } 1203 1188 1204 1189 /** 1205 - * early_platform_driver_probe_id 1190 + * early_platform_driver_probe_id - probe drivers matching class_str and id 1206 1191 * @class_str: string to identify early platform driver class 1207 1192 * @id: id to match against 1208 1193 * @nr_probe: number of platform devices to successfully probe before exiting ··· 1272 1257 } 1273 1258 1274 1259 /** 1275 - * early_platform_driver_probe 1260 + * early_platform_driver_probe - probe a class of registered drivers 1276 1261 * @class_str: string to identify early platform driver class 1277 1262 * @nr_probe: number of platform devices to successfully probe before exiting 1278 1263 * @user_only: only probe user specified early platform devices 1264 + * 1265 + * Used by architecture code to probe registered early platform drivers 1266 + * within a certain class. For probe to happen a registered early platform 1267 + * device matching a registered early platform driver is needed. 1279 1268 */ 1280 1269 int __init early_platform_driver_probe(char *class_str, 1281 1270 int nr_probe,
+10
drivers/char/ipmi/ipmi_msghandler.c
··· 2272 2272 bmc->device_id_attr.attr.name = "device_id"; 2273 2273 bmc->device_id_attr.attr.mode = S_IRUGO; 2274 2274 bmc->device_id_attr.show = device_id_show; 2275 + sysfs_attr_init(&bmc->device_id_attr.attr); 2275 2276 2276 2277 bmc->provides_dev_sdrs_attr.attr.name = "provides_device_sdrs"; 2277 2278 bmc->provides_dev_sdrs_attr.attr.mode = S_IRUGO; 2278 2279 bmc->provides_dev_sdrs_attr.show = provides_dev_sdrs_show; 2280 + sysfs_attr_init(&bmc->provides_dev_sdrs_attr.attr); 2279 2281 2280 2282 bmc->revision_attr.attr.name = "revision"; 2281 2283 bmc->revision_attr.attr.mode = S_IRUGO; 2282 2284 bmc->revision_attr.show = revision_show; 2285 + sysfs_attr_init(&bmc->revision_attr.attr); 2283 2286 2284 2287 bmc->firmware_rev_attr.attr.name = "firmware_revision"; 2285 2288 bmc->firmware_rev_attr.attr.mode = S_IRUGO; 2286 2289 bmc->firmware_rev_attr.show = firmware_rev_show; 2290 + sysfs_attr_init(&bmc->firmware_rev_attr.attr); 2287 2291 2288 2292 bmc->version_attr.attr.name = "ipmi_version"; 2289 2293 bmc->version_attr.attr.mode = S_IRUGO; 2290 2294 bmc->version_attr.show = ipmi_version_show; 2295 + sysfs_attr_init(&bmc->version_attr.attr); 2291 2296 2292 2297 bmc->add_dev_support_attr.attr.name = "additional_device_support"; 2293 2298 bmc->add_dev_support_attr.attr.mode = S_IRUGO; 2294 2299 bmc->add_dev_support_attr.show = add_dev_support_show; 2300 + sysfs_attr_init(&bmc->add_dev_support_attr.attr); 2295 2301 2296 2302 bmc->manufacturer_id_attr.attr.name = "manufacturer_id"; 2297 2303 bmc->manufacturer_id_attr.attr.mode = S_IRUGO; 2298 2304 bmc->manufacturer_id_attr.show = manufacturer_id_show; 2305 + sysfs_attr_init(&bmc->manufacturer_id_attr.attr); 2299 2306 2300 2307 bmc->product_id_attr.attr.name = "product_id"; 2301 2308 bmc->product_id_attr.attr.mode = S_IRUGO; 2302 2309 bmc->product_id_attr.show = product_id_show; 2310 + sysfs_attr_init(&bmc->product_id_attr.attr); 2303 2311 2304 2312 bmc->guid_attr.attr.name = "guid"; 2305 2313 bmc->guid_attr.attr.mode = S_IRUGO; 2306 2314 bmc->guid_attr.show = guid_show; 2315 + sysfs_attr_init(&bmc->guid_attr.attr); 2307 2316 2308 2317 bmc->aux_firmware_rev_attr.attr.name = "aux_firmware_revision"; 2309 2318 bmc->aux_firmware_rev_attr.attr.mode = S_IRUGO; 2310 2319 bmc->aux_firmware_rev_attr.show = aux_firmware_rev_show; 2320 + sysfs_attr_init(&bmc->aux_firmware_rev_attr.attr); 2311 2321 2312 2322 err = device_create_file(&bmc->dev->dev, 2313 2323 &bmc->device_id_attr);
+1
drivers/infiniband/core/sysfs.c
··· 461 461 element->attr.attr.mode = S_IRUGO; 462 462 element->attr.show = show; 463 463 element->index = i; 464 + sysfs_attr_init(&element->attr.attr); 464 465 465 466 tab_attr[i] = &element->attr.attr; 466 467 }
+1
drivers/net/mlx4/main.c
··· 1023 1023 info->port_attr.attr.mode = S_IRUGO | S_IWUSR; 1024 1024 info->port_attr.show = show_port_type; 1025 1025 info->port_attr.store = set_port_type; 1026 + sysfs_attr_init(&info->port_attr.attr); 1026 1027 1027 1028 err = device_create_file(&dev->pdev->dev, &info->port_attr); 1028 1029 if (err) {
+1 -1
drivers/pci/pci-sysfs.c
··· 655 655 goto legacy_io_err; 656 656 657 657 /* Allocated above after the legacy_io struct */ 658 - sysfs_bin_attr_init(b->legacy_mem); 659 658 b->legacy_mem = b->legacy_io + 1; 659 + sysfs_bin_attr_init(b->legacy_mem); 660 660 b->legacy_mem->attr.name = "legacy_mem"; 661 661 b->legacy_mem->size = 1024*1024; 662 662 b->legacy_mem->attr.mode = S_IRUSR | S_IWUSR;