Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: (61 commits)
Dynamic debug: fix pr_fmt() build error
Dynamic debug: allow simple quoting of words
dynamic debug: update docs
dynamic debug: combine dprintk and dynamic printk
sysfs: fix some bin_vm_ops errors
kobject: don't block for each kobject_uevent
sysfs: only allow one scheduled removal callback per kobj
Driver core: Fix device_move() vs. dpm list ordering, v2
Driver core: some cleanup on drivers/base/sys.c
Driver core: implement uevent suppress in kobject
vcs: hook sysfs devices into object lifetime instead of "binding"
driver core: fix passing platform_data
driver core: move platform_data into platform_device
sysfs: don't block indefinitely for unmapped files.
driver core: move knode_bus into private structure
driver core: move knode_driver into private structure
driver core: move klist_children into private structure
driver core: create a private portion of struct device
driver core: remove polling for driver_probe_done(v5)
sysfs: reference sysfs_dirent from sysfs inodes
...

Fixed conflicts in drivers/sh/maple/maple.c manually

+2664 -1170
+25 -4
Documentation/DocBook/uio-howto.tmpl
··· 42 42 43 43 <revhistory> 44 44 <revision> 45 + <revnumber>0.8</revnumber> 46 + <date>2008-12-24</date> 47 + <authorinitials>hjk</authorinitials> 48 + <revremark>Added name attributes in mem and portio sysfs directories. 49 + </revremark> 50 + </revision> 51 + <revision> 45 52 <revnumber>0.7</revnumber> 46 53 <date>2008-12-23</date> 47 54 <authorinitials>hjk</authorinitials> ··· 310 303 appear if the size of the mapping is not 0. 311 304 </para> 312 305 <para> 313 - Each <filename>mapX/</filename> directory contains two read-only files 314 - that show start address and size of the memory: 306 + Each <filename>mapX/</filename> directory contains four read-only files 307 + that show attributes of the memory: 315 308 </para> 316 309 <itemizedlist> 310 + <listitem> 311 + <para> 312 + <filename>name</filename>: A string identifier for this mapping. This 313 + is optional, the string can be empty. Drivers can set this to make it 314 + easier for userspace to find the correct mapping. 315 + </para> 316 + </listitem> 317 317 <listitem> 318 318 <para> 319 319 <filename>addr</filename>: The address of memory that can be mapped. ··· 380 366 <filename>/sys/class/uio/uioX/portio/</filename>. 381 367 </para> 382 368 <para> 383 - Each <filename>portX/</filename> directory contains three read-only 384 - files that show start, size, and type of the port region: 369 + Each <filename>portX/</filename> directory contains four read-only 370 + files that show name, start, size, and type of the port region: 385 371 </para> 386 372 <itemizedlist> 373 + <listitem> 374 + <para> 375 + <filename>name</filename>: A string identifier for this port region. 376 + The string is optional and can be empty. Drivers can set it to make it 377 + easier for userspace to find a certain port region. 378 + </para> 379 + </listitem> 387 380 <listitem> 388 381 <para> 389 382 <filename>start</filename>: The first port of this region.
+240
Documentation/dynamic-debug-howto.txt
··· 1 + 2 + Introduction 3 + ============ 4 + 5 + This document describes how to use the dynamic debug (ddebug) feature. 6 + 7 + Dynamic debug is designed to allow you to dynamically enable/disable kernel 8 + code to obtain additional kernel information. Currently, if 9 + CONFIG_DYNAMIC_DEBUG is set, then all pr_debug()/dev_debug() calls can be 10 + dynamically enabled per-callsite. 11 + 12 + Dynamic debug has even more useful features: 13 + 14 + * Simple query language allows turning on and off debugging statements by 15 + matching any combination of: 16 + 17 + - source filename 18 + - function name 19 + - line number (including ranges of line numbers) 20 + - module name 21 + - format string 22 + 23 + * Provides a debugfs control file: <debugfs>/dynamic_debug/control which can be 24 + read to display the complete list of known debug statements, to help guide you 25 + 26 + Controlling dynamic debug Behaviour 27 + =============================== 28 + 29 + The behaviour of pr_debug()/dev_debug()s are controlled via writing to a 30 + control file in the 'debugfs' filesystem. Thus, you must first mount the debugfs 31 + filesystem, in order to make use of this feature. Subsequently, we refer to the 32 + control file as: <debugfs>/dynamic_debug/control. For example, if you want to 33 + enable printing from source file 'svcsock.c', line 1603 you simply do: 34 + 35 + nullarbor:~ # echo 'file svcsock.c line 1603 +p' > 36 + <debugfs>/dynamic_debug/control 37 + 38 + If you make a mistake with the syntax, the write will fail thus: 39 + 40 + nullarbor:~ # echo 'file svcsock.c wtf 1 +p' > 41 + <debugfs>/dynamic_debug/control 42 + -bash: echo: write error: Invalid argument 43 + 44 + Viewing Dynamic Debug Behaviour 45 + =========================== 46 + 47 + You can view the currently configured behaviour of all the debug statements 48 + via: 49 + 50 + nullarbor:~ # cat <debugfs>/dynamic_debug/control 51 + # filename:lineno [module]function flags format 52 + /usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:323 [svcxprt_rdma]svc_rdma_cleanup - "SVCRDMA Module Removed, deregister RPC RDMA transport\012" 53 + /usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:341 [svcxprt_rdma]svc_rdma_init - "\011max_inline : %d\012" 54 + /usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:340 [svcxprt_rdma]svc_rdma_init - "\011sq_depth : %d\012" 55 + /usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svc_rdma.c:338 [svcxprt_rdma]svc_rdma_init - "\011max_requests : %d\012" 56 + ... 57 + 58 + 59 + You can also apply standard Unix text manipulation filters to this 60 + data, e.g. 61 + 62 + nullarbor:~ # grep -i rdma <debugfs>/dynamic_debug/control | wc -l 63 + 62 64 + 65 + nullarbor:~ # grep -i tcp <debugfs>/dynamic_debug/control | wc -l 66 + 42 67 + 68 + Note in particular that the third column shows the enabled behaviour 69 + flags for each debug statement callsite (see below for definitions of the 70 + flags). The default value, no extra behaviour enabled, is "-". So 71 + you can view all the debug statement callsites with any non-default flags: 72 + 73 + nullarbor:~ # awk '$3 != "-"' <debugfs>/dynamic_debug/control 74 + # filename:lineno [module]function flags format 75 + /usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svcsock.c:1603 [sunrpc]svc_send p "svc_process: st_sendto returned %d\012" 76 + 77 + 78 + Command Language Reference 79 + ========================== 80 + 81 + At the lexical level, a command comprises a sequence of words separated 82 + by whitespace characters. Note that newlines are treated as word 83 + separators and do *not* end a command or allow multiple commands to 84 + be done together. So these are all equivalent: 85 + 86 + nullarbor:~ # echo -c 'file svcsock.c line 1603 +p' > 87 + <debugfs>/dynamic_debug/control 88 + nullarbor:~ # echo -c ' file svcsock.c line 1603 +p ' > 89 + <debugfs>/dynamic_debug/control 90 + nullarbor:~ # echo -c 'file svcsock.c\nline 1603 +p' > 91 + <debugfs>/dynamic_debug/control 92 + nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > 93 + <debugfs>/dynamic_debug/control 94 + 95 + Commands are bounded by a write() system call. If you want to do 96 + multiple commands you need to do a separate "echo" for each, like: 97 + 98 + nullarbor:~ # echo 'file svcsock.c line 1603 +p' > /proc/dprintk ;\ 99 + > echo 'file svcsock.c line 1563 +p' > /proc/dprintk 100 + 101 + or even like: 102 + 103 + nullarbor:~ # ( 104 + > echo 'file svcsock.c line 1603 +p' ;\ 105 + > echo 'file svcsock.c line 1563 +p' ;\ 106 + > ) > /proc/dprintk 107 + 108 + At the syntactical level, a command comprises a sequence of match 109 + specifications, followed by a flags change specification. 110 + 111 + command ::= match-spec* flags-spec 112 + 113 + The match-spec's are used to choose a subset of the known dprintk() 114 + callsites to which to apply the flags-spec. Think of them as a query 115 + with implicit ANDs between each pair. Note that an empty list of 116 + match-specs is possible, but is not very useful because it will not 117 + match any debug statement callsites. 118 + 119 + A match specification comprises a keyword, which controls the attribute 120 + of the callsite to be compared, and a value to compare against. Possible 121 + keywords are: 122 + 123 + match-spec ::= 'func' string | 124 + 'file' string | 125 + 'module' string | 126 + 'format' string | 127 + 'line' line-range 128 + 129 + line-range ::= lineno | 130 + '-'lineno | 131 + lineno'-' | 132 + lineno'-'lineno 133 + // Note: line-range cannot contain space, e.g. 134 + // "1-30" is valid range but "1 - 30" is not. 135 + 136 + lineno ::= unsigned-int 137 + 138 + The meanings of each keyword are: 139 + 140 + func 141 + The given string is compared against the function name 142 + of each callsite. Example: 143 + 144 + func svc_tcp_accept 145 + 146 + file 147 + The given string is compared against either the full 148 + pathname or the basename of the source file of each 149 + callsite. Examples: 150 + 151 + file svcsock.c 152 + file /usr/src/packages/BUILD/sgi-enhancednfs-1.4/default/net/sunrpc/svcsock.c 153 + 154 + module 155 + The given string is compared against the module name 156 + of each callsite. The module name is the string as 157 + seen in "lsmod", i.e. without the directory or the .ko 158 + suffix and with '-' changed to '_'. Examples: 159 + 160 + module sunrpc 161 + module nfsd 162 + 163 + format 164 + The given string is searched for in the dynamic debug format 165 + string. Note that the string does not need to match the 166 + entire format, only some part. Whitespace and other 167 + special characters can be escaped using C octal character 168 + escape \ooo notation, e.g. the space character is \040. 169 + Alternatively, the string can be enclosed in double quote 170 + characters (") or single quote characters ('). 171 + Examples: 172 + 173 + format svcrdma: // many of the NFS/RDMA server dprintks 174 + format readahead // some dprintks in the readahead cache 175 + format nfsd:\040SETATTR // one way to match a format with whitespace 176 + format "nfsd: SETATTR" // a neater way to match a format with whitespace 177 + format 'nfsd: SETATTR' // yet another way to match a format with whitespace 178 + 179 + line 180 + The given line number or range of line numbers is compared 181 + against the line number of each dprintk() callsite. A single 182 + line number matches the callsite line number exactly. A 183 + range of line numbers matches any callsite between the first 184 + and last line number inclusive. An empty first number means 185 + the first line in the file, an empty line number means the 186 + last number in the file. Examples: 187 + 188 + line 1603 // exactly line 1603 189 + line 1600-1605 // the six lines from line 1600 to line 1605 190 + line -1605 // the 1605 lines from line 1 to line 1605 191 + line 1600- // all lines from line 1600 to the end of the file 192 + 193 + The flags specification comprises a change operation followed 194 + by one or more flag characters. The change operation is one 195 + of the characters: 196 + 197 + - 198 + remove the given flags 199 + 200 + + 201 + add the given flags 202 + 203 + = 204 + set the flags to the given flags 205 + 206 + The flags are: 207 + 208 + p 209 + Causes a printk() message to be emitted to dmesg 210 + 211 + Note the regexp ^[-+=][scp]+$ matches a flags specification. 212 + Note also that there is no convenient syntax to remove all 213 + the flags at once, you need to use "-psc". 214 + 215 + Examples 216 + ======== 217 + 218 + // enable the message at line 1603 of file svcsock.c 219 + nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > 220 + <debugfs>/dynamic_debug/control 221 + 222 + // enable all the messages in file svcsock.c 223 + nullarbor:~ # echo -n 'file svcsock.c +p' > 224 + <debugfs>/dynamic_debug/control 225 + 226 + // enable all the messages in the NFS server module 227 + nullarbor:~ # echo -n 'module nfsd +p' > 228 + <debugfs>/dynamic_debug/control 229 + 230 + // enable all 12 messages in the function svc_process() 231 + nullarbor:~ # echo -n 'func svc_process +p' > 232 + <debugfs>/dynamic_debug/control 233 + 234 + // disable all 12 messages in the function svc_process() 235 + nullarbor:~ # echo -n 'func svc_process -p' > 236 + <debugfs>/dynamic_debug/control 237 + 238 + // enable messages for NFS calls READ, READLINK, READDIR and READDIR+. 239 + nullarbor:~ # echo -n 'format "nfsd: READ" +p' > 240 + <debugfs>/dynamic_debug/control
-5
Documentation/kernel-parameters.txt
··· 1826 1826 autoconfiguration. 1827 1827 Ranges are in pairs (memory base and size). 1828 1828 1829 - dynamic_printk Enables pr_debug()/dev_dbg() calls if 1830 - CONFIG_DYNAMIC_PRINTK_DEBUG has been enabled. 1831 - These can also be switched on/off via 1832 - <debugfs>/dynamic_printk/modules 1833 - 1834 1829 print-fatal-signals= 1835 1830 [KNL] debug: print fatal signals 1836 1831 print-fatal-signals=1: print segfault info to
+13 -14
arch/mips/basler/excite/excite_iodev.c
··· 33 33 34 34 35 35 static const struct resource *iodev_get_resource(struct platform_device *, const char *, unsigned int); 36 - static int __init iodev_probe(struct device *); 37 - static int __exit iodev_remove(struct device *); 36 + static int __init iodev_probe(struct platform_device *); 37 + static int __exit iodev_remove(struct platform_device *); 38 38 static int iodev_open(struct inode *, struct file *); 39 39 static int iodev_release(struct inode *, struct file *); 40 40 static ssize_t iodev_read(struct file *, char __user *, size_t s, loff_t *); ··· 65 65 .fops = &fops 66 66 }; 67 67 68 - static struct device_driver iodev_driver = 69 - { 70 - .name = (char *) iodev_name, 71 - .bus = &platform_bus_type, 72 - .owner = THIS_MODULE, 68 + static struct platform_driver iodev_driver = { 69 + .driver = { 70 + .name = iodev_name, 71 + .owner = THIS_MODULE, 72 + }, 73 73 .probe = iodev_probe, 74 - .remove = __exit_p(iodev_remove) 74 + .remove = __devexit_p(iodev_remove), 75 75 }; 76 76 77 77 ··· 89 89 90 90 91 91 /* No hotplugging on the platform bus - use __init */ 92 - static int __init iodev_probe(struct device *dev) 92 + static int __init iodev_probe(struct platform_device *dev) 93 93 { 94 - struct platform_device * const pdv = to_platform_device(dev); 95 94 const struct resource * const ri = 96 - iodev_get_resource(pdv, IODEV_RESOURCE_IRQ, IORESOURCE_IRQ); 95 + iodev_get_resource(dev, IODEV_RESOURCE_IRQ, IORESOURCE_IRQ); 97 96 98 97 if (unlikely(!ri)) 99 98 return -ENXIO; ··· 103 104 104 105 105 106 106 - static int __exit iodev_remove(struct device *dev) 107 + static int __exit iodev_remove(struct platform_device *dev) 107 108 { 108 109 return misc_deregister(&miscdev); 109 110 } ··· 159 160 160 161 static int __init iodev_init_module(void) 161 162 { 162 - return driver_register(&iodev_driver); 163 + return platform_driver_register(&iodev_driver); 163 164 } 164 165 165 166 166 167 167 168 static void __exit iodev_cleanup_module(void) 168 169 { 169 - driver_unregister(&iodev_driver); 170 + platform_driver_unregister(&iodev_driver); 170 171 } 171 172 172 173 module_init(iodev_init_module);
+2 -2
arch/powerpc/platforms/ps3/system-bus.c
··· 376 376 struct ps3_system_bus_driver *drv; 377 377 378 378 BUG_ON(!dev); 379 - pr_debug(" -> %s:%d: %s\n", __func__, __LINE__, _dev->bus_id); 379 + dev_dbg(_dev, "%s:%d\n", __func__, __LINE__); 380 380 381 381 drv = ps3_system_bus_dev_to_system_bus_drv(dev); 382 382 BUG_ON(!drv); ··· 398 398 struct ps3_system_bus_driver *drv; 399 399 400 400 BUG_ON(!dev); 401 - pr_debug(" -> %s:%d: %s\n", __func__, __LINE__, _dev->bus_id); 401 + dev_dbg(_dev, "%s:%d\n", __func__, __LINE__); 402 402 403 403 drv = ps3_system_bus_dev_to_system_bus_drv(dev); 404 404 BUG_ON(!drv);
+1 -1
drivers/acpi/dock.c
··· 977 977 sizeof(struct dock_station *)); 978 978 979 979 /* we want the dock device to send uevents */ 980 - dock_device->dev.uevent_suppress = 0; 980 + dev_set_uevent_suppress(&dock_device->dev, 0); 981 981 982 982 if (is_dock(handle)) 983 983 dock_station->flags |= DOCK_IS_DOCK;
+2 -2
drivers/amba/bus.c
··· 210 210 dev->dev.release = amba_device_release; 211 211 dev->dev.bus = &amba_bustype; 212 212 dev->dev.dma_mask = &dev->dma_mask; 213 - dev->res.name = dev->dev.bus_id; 213 + dev->res.name = dev_name(&dev->dev); 214 214 215 215 if (!dev->dev.coherent_dma_mask && dev->dma_mask) 216 216 dev_warn(&dev->dev, "coherent dma mask is unset\n"); ··· 294 294 if (d->parent) 295 295 r &= d->parent == dev->parent; 296 296 if (d->busid) 297 - r &= strcmp(dev->bus_id, d->busid) == 0; 297 + r &= strcmp(dev_name(dev), d->busid) == 0; 298 298 299 299 if (r) { 300 300 get_device(dev);
+31
drivers/base/base.h
··· 63 63 #define to_class(obj) \ 64 64 container_of(obj, struct class_private, class_subsys.kobj) 65 65 66 + /** 67 + * struct device_private - structure to hold the private to the driver core portions of the device structure. 68 + * 69 + * @klist_children - klist containing all children of this device 70 + * @knode_parent - node in sibling list 71 + * @knode_driver - node in driver list 72 + * @knode_bus - node in bus list 73 + * @device - pointer back to the struct class that this structure is 74 + * associated with. 75 + * 76 + * Nothing outside of the driver core should ever touch these fields. 77 + */ 78 + struct device_private { 79 + struct klist klist_children; 80 + struct klist_node knode_parent; 81 + struct klist_node knode_driver; 82 + struct klist_node knode_bus; 83 + struct device *device; 84 + }; 85 + #define to_device_private_parent(obj) \ 86 + container_of(obj, struct device_private, knode_parent) 87 + #define to_device_private_driver(obj) \ 88 + container_of(obj, struct device_private, knode_driver) 89 + #define to_device_private_bus(obj) \ 90 + container_of(obj, struct device_private, knode_bus) 91 + 66 92 /* initialisation functions */ 67 93 extern int devices_init(void); 68 94 extern int buses_init(void); ··· 112 86 113 87 extern void driver_detach(struct device_driver *drv); 114 88 extern int driver_probe_device(struct device_driver *drv, struct device *dev); 89 + static inline int driver_match_device(struct device_driver *drv, 90 + struct device *dev) 91 + { 92 + return drv->bus->match && drv->bus->match(dev, drv); 93 + } 115 94 116 95 extern void sysdev_shutdown(void); 117 96
+30 -14
drivers/base/bus.c
··· 198 198 int err = -ENODEV; 199 199 200 200 dev = bus_find_device_by_name(bus, NULL, buf); 201 - if (dev && dev->driver == NULL) { 201 + if (dev && dev->driver == NULL && driver_match_device(drv, dev)) { 202 202 if (dev->parent) /* Needed for USB */ 203 203 down(&dev->parent->sem); 204 204 down(&dev->sem); ··· 253 253 static struct device *next_device(struct klist_iter *i) 254 254 { 255 255 struct klist_node *n = klist_next(i); 256 - return n ? container_of(n, struct device, knode_bus) : NULL; 256 + struct device *dev = NULL; 257 + struct device_private *dev_prv; 258 + 259 + if (n) { 260 + dev_prv = to_device_private_bus(n); 261 + dev = dev_prv->device; 262 + } 263 + return dev; 257 264 } 258 265 259 266 /** ··· 293 286 return -EINVAL; 294 287 295 288 klist_iter_init_node(&bus->p->klist_devices, &i, 296 - (start ? &start->knode_bus : NULL)); 289 + (start ? &start->p->knode_bus : NULL)); 297 290 while ((dev = next_device(&i)) && !error) 298 291 error = fn(dev, data); 299 292 klist_iter_exit(&i); ··· 327 320 return NULL; 328 321 329 322 klist_iter_init_node(&bus->p->klist_devices, &i, 330 - (start ? &start->knode_bus : NULL)); 323 + (start ? &start->p->knode_bus : NULL)); 331 324 while ((dev = next_device(&i))) 332 325 if (match(dev, data) && get_device(dev)) 333 326 break; ··· 514 507 ret = device_attach(dev); 515 508 WARN_ON(ret < 0); 516 509 if (ret >= 0) 517 - klist_add_tail(&dev->knode_bus, &bus->p->klist_devices); 510 + klist_add_tail(&dev->p->knode_bus, 511 + &bus->p->klist_devices); 518 512 } 519 513 } 520 514 ··· 536 528 sysfs_remove_link(&dev->bus->p->devices_kset->kobj, 537 529 dev_name(dev)); 538 530 device_remove_attrs(dev->bus, dev); 539 - if (klist_node_attached(&dev->knode_bus)) 540 - klist_del(&dev->knode_bus); 531 + if (klist_node_attached(&dev->p->knode_bus)) 532 + klist_del(&dev->p->knode_bus); 541 533 542 534 pr_debug("bus: '%s': remove device %s\n", 543 535 dev->bus->name, dev_name(dev)); ··· 839 831 840 832 static void klist_devices_get(struct klist_node *n) 841 833 { 842 - struct device *dev = container_of(n, struct device, knode_bus); 834 + struct device_private *dev_prv = to_device_private_bus(n); 835 + struct device *dev = dev_prv->device; 843 836 844 837 get_device(dev); 845 838 } 846 839 847 840 static void klist_devices_put(struct klist_node *n) 848 841 { 849 - struct device *dev = container_of(n, struct device, knode_bus); 842 + struct device_private *dev_prv = to_device_private_bus(n); 843 + struct device *dev = dev_prv->device; 850 844 851 845 put_device(dev); 852 846 } ··· 942 932 kset_unregister(&bus->p->subsys); 943 933 kfree(bus->p); 944 934 out: 935 + bus->p = NULL; 945 936 return retval; 946 937 } 947 938 EXPORT_SYMBOL_GPL(bus_register); ··· 964 953 bus_remove_file(bus, &bus_attr_uevent); 965 954 kset_unregister(&bus->p->subsys); 966 955 kfree(bus->p); 956 + bus->p = NULL; 967 957 } 968 958 EXPORT_SYMBOL_GPL(bus_unregister); 969 959 ··· 1005 993 { 1006 994 struct list_head *pos; 1007 995 struct klist_node *n; 996 + struct device_private *dev_prv; 1008 997 struct device *b; 1009 998 1010 999 list_for_each(pos, list) { 1011 1000 n = container_of(pos, struct klist_node, n_node); 1012 - b = container_of(n, struct device, knode_bus); 1001 + dev_prv = to_device_private_bus(n); 1002 + b = dev_prv->device; 1013 1003 if (compare(a, b) <= 0) { 1014 - list_move_tail(&a->knode_bus.n_node, 1015 - &b->knode_bus.n_node); 1004 + list_move_tail(&a->p->knode_bus.n_node, 1005 + &b->p->knode_bus.n_node); 1016 1006 return; 1017 1007 } 1018 1008 } 1019 - list_move_tail(&a->knode_bus.n_node, list); 1009 + list_move_tail(&a->p->knode_bus.n_node, list); 1020 1010 } 1021 1011 1022 1012 void bus_sort_breadthfirst(struct bus_type *bus, ··· 1028 1014 LIST_HEAD(sorted_devices); 1029 1015 struct list_head *pos, *tmp; 1030 1016 struct klist_node *n; 1017 + struct device_private *dev_prv; 1031 1018 struct device *dev; 1032 1019 struct klist *device_klist; 1033 1020 ··· 1037 1022 spin_lock(&device_klist->k_lock); 1038 1023 list_for_each_safe(pos, tmp, &device_klist->k_list) { 1039 1024 n = container_of(pos, struct klist_node, n_node); 1040 - dev = container_of(n, struct device, knode_bus); 1025 + dev_prv = to_device_private_bus(n); 1026 + dev = dev_prv->device; 1041 1027 device_insertion_sort_klist(dev, &sorted_devices, compare); 1042 1028 } 1043 1029 list_splice(&sorted_devices, &device_klist->k_list);
+71 -37
drivers/base/core.c
··· 109 109 static void device_release(struct kobject *kobj) 110 110 { 111 111 struct device *dev = to_dev(kobj); 112 + struct device_private *p = dev->p; 112 113 113 114 if (dev->release) 114 115 dev->release(dev); ··· 121 120 WARN(1, KERN_ERR "Device '%s' does not have a release() " 122 121 "function, it is broken and must be fixed.\n", 123 122 dev_name(dev)); 123 + kfree(p); 124 124 } 125 125 126 126 static struct kobj_type device_ktype = { ··· 136 134 137 135 if (ktype == &device_ktype) { 138 136 struct device *dev = to_dev(kobj); 139 - if (dev->uevent_suppress) 140 - return 0; 141 137 if (dev->bus) 142 138 return 1; 143 139 if (dev->class) ··· 507 507 508 508 static void klist_children_get(struct klist_node *n) 509 509 { 510 - struct device *dev = container_of(n, struct device, knode_parent); 510 + struct device_private *p = to_device_private_parent(n); 511 + struct device *dev = p->device; 511 512 512 513 get_device(dev); 513 514 } 514 515 515 516 static void klist_children_put(struct klist_node *n) 516 517 { 517 - struct device *dev = container_of(n, struct device, knode_parent); 518 + struct device_private *p = to_device_private_parent(n); 519 + struct device *dev = p->device; 518 520 519 521 put_device(dev); 520 522 } ··· 540 538 { 541 539 dev->kobj.kset = devices_kset; 542 540 kobject_init(&dev->kobj, &device_ktype); 543 - klist_init(&dev->klist_children, klist_children_get, 544 - klist_children_put); 545 541 INIT_LIST_HEAD(&dev->dma_pools); 546 542 init_MUTEX(&dev->sem); 547 543 spin_lock_init(&dev->devres_lock); ··· 777 777 int dev_set_name(struct device *dev, const char *fmt, ...) 778 778 { 779 779 va_list vargs; 780 - char *s; 780 + int err; 781 781 782 782 va_start(vargs, fmt); 783 - vsnprintf(dev->bus_id, sizeof(dev->bus_id), fmt, vargs); 783 + err = kobject_set_name_vargs(&dev->kobj, fmt, vargs); 784 784 va_end(vargs); 785 - 786 - /* ewww... some of these buggers have / in the name... */ 787 - while ((s = strchr(dev->bus_id, '/'))) 788 - *s = '!'; 789 - 790 - return 0; 785 + return err; 791 786 } 792 787 EXPORT_SYMBOL_GPL(dev_set_name); 793 788 ··· 859 864 if (!dev) 860 865 goto done; 861 866 862 - /* Temporarily support init_name if it is set. 863 - * It will override bus_id for now */ 864 - if (dev->init_name) 865 - dev_set_name(dev, "%s", dev->init_name); 867 + dev->p = kzalloc(sizeof(*dev->p), GFP_KERNEL); 868 + if (!dev->p) { 869 + error = -ENOMEM; 870 + goto done; 871 + } 872 + dev->p->device = dev; 873 + klist_init(&dev->p->klist_children, klist_children_get, 874 + klist_children_put); 866 875 867 - if (!strlen(dev->bus_id)) 876 + /* 877 + * for statically allocated devices, which should all be converted 878 + * some day, we need to initialize the name. We prevent reading back 879 + * the name, and force the use of dev_name() 880 + */ 881 + if (dev->init_name) { 882 + dev_set_name(dev, dev->init_name); 883 + dev->init_name = NULL; 884 + } 885 + 886 + if (!dev_name(dev)) 868 887 goto done; 869 888 870 889 pr_debug("device: '%s': %s\n", dev_name(dev), __func__); ··· 937 928 kobject_uevent(&dev->kobj, KOBJ_ADD); 938 929 bus_attach_device(dev); 939 930 if (parent) 940 - klist_add_tail(&dev->knode_parent, &parent->klist_children); 931 + klist_add_tail(&dev->p->knode_parent, 932 + &parent->p->klist_children); 941 933 942 934 if (dev->class) { 943 935 mutex_lock(&dev->class->p->class_mutex); ··· 1052 1042 device_pm_remove(dev); 1053 1043 dpm_sysfs_remove(dev); 1054 1044 if (parent) 1055 - klist_del(&dev->knode_parent); 1045 + klist_del(&dev->p->knode_parent); 1056 1046 if (MAJOR(dev->devt)) { 1057 1047 device_remove_sys_dev_entry(dev); 1058 1048 device_remove_file(dev, &devt_attr); ··· 1113 1103 static struct device *next_device(struct klist_iter *i) 1114 1104 { 1115 1105 struct klist_node *n = klist_next(i); 1116 - return n ? container_of(n, struct device, knode_parent) : NULL; 1106 + struct device *dev = NULL; 1107 + struct device_private *p; 1108 + 1109 + if (n) { 1110 + p = to_device_private_parent(n); 1111 + dev = p->device; 1112 + } 1113 + return dev; 1117 1114 } 1118 1115 1119 1116 /** ··· 1142 1125 struct device *child; 1143 1126 int error = 0; 1144 1127 1145 - klist_iter_init(&parent->klist_children, &i); 1128 + klist_iter_init(&parent->p->klist_children, &i); 1146 1129 while ((child = next_device(&i)) && !error) 1147 1130 error = fn(child, data); 1148 1131 klist_iter_exit(&i); ··· 1173 1156 if (!parent) 1174 1157 return NULL; 1175 1158 1176 - klist_iter_init(&parent->klist_children, &i); 1159 + klist_iter_init(&parent->p->klist_children, &i); 1177 1160 while ((child = next_device(&i))) 1178 1161 if (match(child, data) && get_device(child)) 1179 1162 break; ··· 1365 1348 dev->release = device_create_release; 1366 1349 dev_set_drvdata(dev, drvdata); 1367 1350 1368 - vsnprintf(dev->bus_id, BUS_ID_SIZE, fmt, args); 1351 + retval = kobject_set_name_vargs(&dev->kobj, fmt, args); 1352 + if (retval) 1353 + goto error; 1354 + 1369 1355 retval = device_register(dev); 1370 1356 if (retval) 1371 1357 goto error; ··· 1472 1452 old_class_name = make_class_name(dev->class->name, &dev->kobj); 1473 1453 #endif 1474 1454 1475 - old_device_name = kmalloc(BUS_ID_SIZE, GFP_KERNEL); 1455 + old_device_name = kstrdup(dev_name(dev), GFP_KERNEL); 1476 1456 if (!old_device_name) { 1477 1457 error = -ENOMEM; 1478 1458 goto out; 1479 1459 } 1480 - strlcpy(old_device_name, dev->bus_id, BUS_ID_SIZE); 1481 - strlcpy(dev->bus_id, new_name, BUS_ID_SIZE); 1482 1460 1483 1461 error = kobject_rename(&dev->kobj, new_name); 1484 - if (error) { 1485 - strlcpy(dev->bus_id, old_device_name, BUS_ID_SIZE); 1462 + if (error) 1486 1463 goto out; 1487 - } 1488 1464 1489 1465 #ifdef CONFIG_SYSFS_DEPRECATED 1490 1466 if (old_class_name) { ··· 1561 1545 * device_move - moves a device to a new parent 1562 1546 * @dev: the pointer to the struct device to be moved 1563 1547 * @new_parent: the new parent of the device (can by NULL) 1548 + * @dpm_order: how to reorder the dpm_list 1564 1549 */ 1565 - int device_move(struct device *dev, struct device *new_parent) 1550 + int device_move(struct device *dev, struct device *new_parent, 1551 + enum dpm_order dpm_order) 1566 1552 { 1567 1553 int error; 1568 1554 struct device *old_parent; ··· 1574 1556 if (!dev) 1575 1557 return -EINVAL; 1576 1558 1559 + device_pm_lock(); 1577 1560 new_parent = get_device(new_parent); 1578 1561 new_parent_kobj = get_device_parent(dev, new_parent); 1579 1562 ··· 1589 1570 old_parent = dev->parent; 1590 1571 dev->parent = new_parent; 1591 1572 if (old_parent) 1592 - klist_remove(&dev->knode_parent); 1573 + klist_remove(&dev->p->knode_parent); 1593 1574 if (new_parent) { 1594 - klist_add_tail(&dev->knode_parent, &new_parent->klist_children); 1575 + klist_add_tail(&dev->p->knode_parent, 1576 + &new_parent->p->klist_children); 1595 1577 set_dev_node(dev, dev_to_node(new_parent)); 1596 1578 } 1597 1579 ··· 1604 1584 device_move_class_links(dev, new_parent, old_parent); 1605 1585 if (!kobject_move(&dev->kobj, &old_parent->kobj)) { 1606 1586 if (new_parent) 1607 - klist_remove(&dev->knode_parent); 1587 + klist_remove(&dev->p->knode_parent); 1608 1588 dev->parent = old_parent; 1609 1589 if (old_parent) { 1610 - klist_add_tail(&dev->knode_parent, 1611 - &old_parent->klist_children); 1590 + klist_add_tail(&dev->p->knode_parent, 1591 + &old_parent->p->klist_children); 1612 1592 set_dev_node(dev, dev_to_node(old_parent)); 1613 1593 } 1614 1594 } ··· 1616 1596 put_device(new_parent); 1617 1597 goto out; 1618 1598 } 1599 + switch (dpm_order) { 1600 + case DPM_ORDER_NONE: 1601 + break; 1602 + case DPM_ORDER_DEV_AFTER_PARENT: 1603 + device_pm_move_after(dev, new_parent); 1604 + break; 1605 + case DPM_ORDER_PARENT_BEFORE_DEV: 1606 + device_pm_move_before(new_parent, dev); 1607 + break; 1608 + case DPM_ORDER_DEV_LAST: 1609 + device_pm_move_last(dev); 1610 + break; 1611 + } 1619 1612 out_put: 1620 1613 put_device(old_parent); 1621 1614 out: 1615 + device_pm_unlock(); 1622 1616 put_device(dev); 1623 1617 return error; 1624 1618 }
+17 -23
drivers/base/dd.c
··· 30 30 31 31 static void driver_bound(struct device *dev) 32 32 { 33 - if (klist_node_attached(&dev->knode_driver)) { 33 + if (klist_node_attached(&dev->p->knode_driver)) { 34 34 printk(KERN_WARNING "%s: device %s already bound\n", 35 35 __func__, kobject_name(&dev->kobj)); 36 36 return; ··· 43 43 blocking_notifier_call_chain(&dev->bus->p->bus_notifier, 44 44 BUS_NOTIFY_BOUND_DRIVER, dev); 45 45 46 - klist_add_tail(&dev->knode_driver, &dev->driver->p->klist_devices); 46 + klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices); 47 47 } 48 48 49 49 static int driver_sysfs_add(struct device *dev) ··· 172 172 /** 173 173 * wait_for_device_probe 174 174 * Wait for device probing to be completed. 175 - * 176 - * Note: this function polls at 100 msec intervals. 177 175 */ 178 - int wait_for_device_probe(void) 176 + void wait_for_device_probe(void) 179 177 { 180 178 /* wait for the known devices to complete their probing */ 181 - while (driver_probe_done() != 0) 182 - msleep(100); 179 + wait_event(probe_waitqueue, atomic_read(&probe_count) == 0); 183 180 async_synchronize_full(); 184 - return 0; 185 181 } 186 182 187 183 /** ··· 185 189 * @drv: driver to bind a device to 186 190 * @dev: device to try to bind to the driver 187 191 * 188 - * First, we call the bus's match function, if one present, which should 189 - * compare the device IDs the driver supports with the device IDs of the 190 - * device. Note we don't do this ourselves because we don't know the 191 - * format of the ID structures, nor what is to be considered a match and 192 - * what is not. 193 - * 194 - * This function returns 1 if a match is found, -ENODEV if the device is 195 - * not registered, and 0 otherwise. 192 + * This function returns -ENODEV if the device is not registered, 193 + * 1 if the device is bound sucessfully and 0 otherwise. 196 194 * 197 195 * This function must be called with @dev->sem held. When called for a 198 196 * USB interface, @dev->parent->sem must be held as well. ··· 197 207 198 208 if (!device_is_registered(dev)) 199 209 return -ENODEV; 200 - if (drv->bus->match && !drv->bus->match(dev, drv)) 201 - goto done; 202 210 203 211 pr_debug("bus: '%s': %s: matched device %s with driver %s\n", 204 212 drv->bus->name, __func__, dev_name(dev), drv->name); 205 213 206 214 ret = really_probe(dev, drv); 207 215 208 - done: 209 216 return ret; 210 217 } 211 218 212 219 static int __device_attach(struct device_driver *drv, void *data) 213 220 { 214 221 struct device *dev = data; 222 + 223 + if (!driver_match_device(drv, dev)) 224 + return 0; 225 + 215 226 return driver_probe_device(drv, dev); 216 227 } 217 228 ··· 265 274 * is an error. 266 275 */ 267 276 268 - if (drv->bus->match && !drv->bus->match(dev, drv)) 277 + if (!driver_match_device(drv, dev)) 269 278 return 0; 270 279 271 280 if (dev->parent) /* Needed for USB */ ··· 318 327 drv->remove(dev); 319 328 devres_release_all(dev); 320 329 dev->driver = NULL; 321 - klist_remove(&dev->knode_driver); 330 + klist_remove(&dev->p->knode_driver); 322 331 } 323 332 } 324 333 ··· 348 357 */ 349 358 void driver_detach(struct device_driver *drv) 350 359 { 360 + struct device_private *dev_prv; 351 361 struct device *dev; 352 362 353 363 for (;;) { ··· 357 365 spin_unlock(&drv->p->klist_devices.k_lock); 358 366 break; 359 367 } 360 - dev = list_entry(drv->p->klist_devices.k_list.prev, 361 - struct device, knode_driver.n_node); 368 + dev_prv = list_entry(drv->p->klist_devices.k_list.prev, 369 + struct device_private, 370 + knode_driver.n_node); 371 + dev = dev_prv->device; 362 372 get_device(dev); 363 373 spin_unlock(&drv->p->klist_devices.k_lock); 364 374
+12 -3
drivers/base/driver.c
··· 19 19 static struct device *next_device(struct klist_iter *i) 20 20 { 21 21 struct klist_node *n = klist_next(i); 22 - return n ? container_of(n, struct device, knode_driver) : NULL; 22 + struct device *dev = NULL; 23 + struct device_private *dev_prv; 24 + 25 + if (n) { 26 + dev_prv = to_device_private_driver(n); 27 + dev = dev_prv->device; 28 + } 29 + return dev; 23 30 } 24 31 25 32 /** ··· 49 42 return -EINVAL; 50 43 51 44 klist_iter_init_node(&drv->p->klist_devices, &i, 52 - start ? &start->knode_driver : NULL); 45 + start ? &start->p->knode_driver : NULL); 53 46 while ((dev = next_device(&i)) && !error) 54 47 error = fn(dev, data); 55 48 klist_iter_exit(&i); ··· 83 76 return NULL; 84 77 85 78 klist_iter_init_node(&drv->p->klist_devices, &i, 86 - (start ? &start->knode_driver : NULL)); 79 + (start ? &start->p->knode_driver : NULL)); 87 80 while ((dev = next_device(&i))) 88 81 if (match(dev, data) && get_device(dev)) 89 82 break; ··· 222 215 { 223 216 int ret; 224 217 struct device_driver *other; 218 + 219 + BUG_ON(!drv->bus->p); 225 220 226 221 if ((drv->bus->probe && drv->probe) || 227 222 (drv->bus->remove && drv->remove) ||
+2 -2
drivers/base/firmware_class.c
··· 319 319 f_dev->parent = device; 320 320 f_dev->class = &firmware_class; 321 321 dev_set_drvdata(f_dev, fw_priv); 322 - f_dev->uevent_suppress = 1; 322 + dev_set_uevent_suppress(f_dev, 1); 323 323 retval = device_register(f_dev); 324 324 if (retval) { 325 325 dev_err(device, "%s: device_register failed\n", __func__); ··· 366 366 } 367 367 368 368 if (uevent) 369 - f_dev->uevent_suppress = 0; 369 + dev_set_uevent_suppress(f_dev, 0); 370 370 *dev_p = f_dev; 371 371 goto out; 372 372
+47 -13
drivers/base/platform.c
··· 217 217 if (d) { 218 218 memcpy(d, data, size); 219 219 pdev->dev.platform_data = d; 220 + pdev->platform_data = d; 220 221 } 221 222 return d ? 0 : -ENOMEM; 222 223 } ··· 246 245 dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id); 247 246 else 248 247 dev_set_name(&pdev->dev, pdev->name); 248 + 249 + /* We will remove platform_data field from struct device 250 + * if all platform devices pass its platform specific data 251 + * from platform_device. The conversion is going to be a 252 + * long time, so we allow the two cases coexist to make 253 + * this kind of fix more easily*/ 254 + if (pdev->platform_data && pdev->dev.platform_data) { 255 + printk(KERN_ERR 256 + "%s: use which platform_data?\n", 257 + dev_name(&pdev->dev)); 258 + } else if (pdev->platform_data) { 259 + pdev->dev.platform_data = pdev->platform_data; 260 + } else if (pdev->dev.platform_data) { 261 + pdev->platform_data = pdev->dev.platform_data; 262 + } 249 263 250 264 for (i = 0; i < pdev->num_resources; i++) { 251 265 struct resource *p, *r = &pdev->resource[i]; ··· 600 584 { 601 585 struct platform_device *pdev = to_platform_device(dev); 602 586 603 - add_uevent_var(env, "MODALIAS=platform:%s", pdev->name); 587 + add_uevent_var(env, "MODALIAS=%s%s", PLATFORM_MODULE_PREFIX, 588 + (pdev->id_entry) ? pdev->id_entry->name : pdev->name); 604 589 return 0; 590 + } 591 + 592 + static const struct platform_device_id *platform_match_id( 593 + struct platform_device_id *id, 594 + struct platform_device *pdev) 595 + { 596 + while (id->name[0]) { 597 + if (strcmp(pdev->name, id->name) == 0) { 598 + pdev->id_entry = id; 599 + return id; 600 + } 601 + id++; 602 + } 603 + return NULL; 605 604 } 606 605 607 606 /** ··· 634 603 */ 635 604 static int platform_match(struct device *dev, struct device_driver *drv) 636 605 { 637 - struct platform_device *pdev; 606 + struct platform_device *pdev = to_platform_device(dev); 607 + struct platform_driver *pdrv = to_platform_driver(drv); 638 608 639 - pdev = container_of(dev, struct platform_device, dev); 609 + /* match against the id table first */ 610 + if (pdrv->id_table) 611 + return platform_match_id(pdrv->id_table, pdev) != NULL; 612 + 613 + /* fall-back to driver name match */ 640 614 return (strcmp(pdev->name, drv->name) == 0); 641 615 } 642 616 ··· 659 623 660 624 static int platform_legacy_suspend_late(struct device *dev, pm_message_t mesg) 661 625 { 662 - struct platform_driver *drv = to_platform_driver(dev->driver); 663 - struct platform_device *pdev; 626 + struct platform_driver *pdrv = to_platform_driver(dev->driver); 627 + struct platform_device *pdev = to_platform_device(dev); 664 628 int ret = 0; 665 629 666 - pdev = container_of(dev, struct platform_device, dev); 667 - if (dev->driver && drv->suspend_late) 668 - ret = drv->suspend_late(pdev, mesg); 630 + if (dev->driver && pdrv->suspend_late) 631 + ret = pdrv->suspend_late(pdev, mesg); 669 632 670 633 return ret; 671 634 } 672 635 673 636 static int platform_legacy_resume_early(struct device *dev) 674 637 { 675 - struct platform_driver *drv = to_platform_driver(dev->driver); 676 - struct platform_device *pdev; 638 + struct platform_driver *pdrv = to_platform_driver(dev->driver); 639 + struct platform_device *pdev = to_platform_device(dev); 677 640 int ret = 0; 678 641 679 - pdev = container_of(dev, struct platform_device, dev); 680 - if (dev->driver && drv->resume_early) 681 - ret = drv->resume_early(pdev); 642 + if (dev->driver && pdrv->resume_early) 643 + ret = pdrv->resume_early(pdev); 682 644 683 645 return ret; 684 646 }
+44
drivers/base/power/main.c
··· 107 107 } 108 108 109 109 /** 110 + * device_pm_move_before - move device in dpm_list 111 + * @deva: Device to move in dpm_list 112 + * @devb: Device @deva should come before 113 + */ 114 + void device_pm_move_before(struct device *deva, struct device *devb) 115 + { 116 + pr_debug("PM: Moving %s:%s before %s:%s\n", 117 + deva->bus ? deva->bus->name : "No Bus", 118 + kobject_name(&deva->kobj), 119 + devb->bus ? devb->bus->name : "No Bus", 120 + kobject_name(&devb->kobj)); 121 + /* Delete deva from dpm_list and reinsert before devb. */ 122 + list_move_tail(&deva->power.entry, &devb->power.entry); 123 + } 124 + 125 + /** 126 + * device_pm_move_after - move device in dpm_list 127 + * @deva: Device to move in dpm_list 128 + * @devb: Device @deva should come after 129 + */ 130 + void device_pm_move_after(struct device *deva, struct device *devb) 131 + { 132 + pr_debug("PM: Moving %s:%s after %s:%s\n", 133 + deva->bus ? deva->bus->name : "No Bus", 134 + kobject_name(&deva->kobj), 135 + devb->bus ? devb->bus->name : "No Bus", 136 + kobject_name(&devb->kobj)); 137 + /* Delete deva from dpm_list and reinsert after devb. */ 138 + list_move(&deva->power.entry, &devb->power.entry); 139 + } 140 + 141 + /** 142 + * device_pm_move_last - move device to end of dpm_list 143 + * @dev: Device to move in dpm_list 144 + */ 145 + void device_pm_move_last(struct device *dev) 146 + { 147 + pr_debug("PM: Moving %s:%s to end of list\n", 148 + dev->bus ? dev->bus->name : "No Bus", 149 + kobject_name(&dev->kobj)); 150 + list_move_tail(&dev->power.entry, &dpm_list); 151 + } 152 + 153 + /** 110 154 * pm_op - execute the PM operation appropiate for given PM event 111 155 * @dev: Device. 112 156 * @ops: PM operations to choose from.
+8
drivers/base/power/power.h
··· 18 18 19 19 extern void device_pm_add(struct device *); 20 20 extern void device_pm_remove(struct device *); 21 + extern void device_pm_move_before(struct device *, struct device *); 22 + extern void device_pm_move_after(struct device *, struct device *); 23 + extern void device_pm_move_last(struct device *); 21 24 22 25 #else /* CONFIG_PM_SLEEP */ 23 26 24 27 static inline void device_pm_add(struct device *dev) {} 25 28 static inline void device_pm_remove(struct device *dev) {} 29 + static inline void device_pm_move_before(struct device *deva, 30 + struct device *devb) {} 31 + static inline void device_pm_move_after(struct device *deva, 32 + struct device *devb) {} 33 + static inline void device_pm_move_last(struct device *dev) {} 26 34 27 35 #endif 28 36
+27 -27
drivers/base/sys.c
··· 30 30 31 31 32 32 static ssize_t 33 - sysdev_show(struct kobject * kobj, struct attribute * attr, char * buffer) 33 + sysdev_show(struct kobject *kobj, struct attribute *attr, char *buffer) 34 34 { 35 - struct sys_device * sysdev = to_sysdev(kobj); 36 - struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr); 35 + struct sys_device *sysdev = to_sysdev(kobj); 36 + struct sysdev_attribute *sysdev_attr = to_sysdev_attr(attr); 37 37 38 38 if (sysdev_attr->show) 39 39 return sysdev_attr->show(sysdev, sysdev_attr, buffer); ··· 42 42 43 43 44 44 static ssize_t 45 - sysdev_store(struct kobject * kobj, struct attribute * attr, 46 - const char * buffer, size_t count) 45 + sysdev_store(struct kobject *kobj, struct attribute *attr, 46 + const char *buffer, size_t count) 47 47 { 48 - struct sys_device * sysdev = to_sysdev(kobj); 49 - struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr); 48 + struct sys_device *sysdev = to_sysdev(kobj); 49 + struct sysdev_attribute *sysdev_attr = to_sysdev_attr(attr); 50 50 51 51 if (sysdev_attr->store) 52 52 return sysdev_attr->store(sysdev, sysdev_attr, buffer, count); ··· 63 63 }; 64 64 65 65 66 - int sysdev_create_file(struct sys_device * s, struct sysdev_attribute * a) 66 + int sysdev_create_file(struct sys_device *s, struct sysdev_attribute *a) 67 67 { 68 68 return sysfs_create_file(&s->kobj, &a->attr); 69 69 } 70 70 71 71 72 - void sysdev_remove_file(struct sys_device * s, struct sysdev_attribute * a) 72 + void sysdev_remove_file(struct sys_device *s, struct sysdev_attribute *a) 73 73 { 74 74 sysfs_remove_file(&s->kobj, &a->attr); 75 75 } ··· 84 84 static ssize_t sysdev_class_show(struct kobject *kobj, struct attribute *attr, 85 85 char *buffer) 86 86 { 87 - struct sysdev_class * class = to_sysdev_class(kobj); 87 + struct sysdev_class *class = to_sysdev_class(kobj); 88 88 struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); 89 89 90 90 if (class_attr->show) ··· 95 95 static ssize_t sysdev_class_store(struct kobject *kobj, struct attribute *attr, 96 96 const char *buffer, size_t count) 97 97 { 98 - struct sysdev_class * class = to_sysdev_class(kobj); 99 - struct sysdev_class_attribute * class_attr = to_sysdev_class_attr(attr); 98 + struct sysdev_class *class = to_sysdev_class(kobj); 99 + struct sysdev_class_attribute *class_attr = to_sysdev_class_attr(attr); 100 100 101 101 if (class_attr->store) 102 102 return class_attr->store(class, buffer, count); ··· 128 128 129 129 static struct kset *system_kset; 130 130 131 - int sysdev_class_register(struct sysdev_class * cls) 131 + int sysdev_class_register(struct sysdev_class *cls) 132 132 { 133 133 pr_debug("Registering sysdev class '%s'\n", cls->name); 134 134 ··· 141 141 return kset_register(&cls->kset); 142 142 } 143 143 144 - void sysdev_class_unregister(struct sysdev_class * cls) 144 + void sysdev_class_unregister(struct sysdev_class *cls) 145 145 { 146 146 pr_debug("Unregistering sysdev class '%s'\n", 147 147 kobject_name(&cls->kset.kobj)); ··· 203 203 * @cls: Class driver belongs to. 204 204 * @drv: Driver. 205 205 */ 206 - void sysdev_driver_unregister(struct sysdev_class * cls, 207 - struct sysdev_driver * drv) 206 + void sysdev_driver_unregister(struct sysdev_class *cls, 207 + struct sysdev_driver *drv) 208 208 { 209 209 mutex_lock(&sysdev_drivers_lock); 210 210 list_del_init(&drv->entry); ··· 229 229 * @sysdev: device in question 230 230 * 231 231 */ 232 - int sysdev_register(struct sys_device * sysdev) 232 + int sysdev_register(struct sys_device *sysdev) 233 233 { 234 234 int error; 235 - struct sysdev_class * cls = sysdev->cls; 235 + struct sysdev_class *cls = sysdev->cls; 236 236 237 237 if (!cls) 238 238 return -EINVAL; ··· 252 252 sysdev->id); 253 253 254 254 if (!error) { 255 - struct sysdev_driver * drv; 255 + struct sysdev_driver *drv; 256 256 257 257 pr_debug("Registering sys device '%s'\n", 258 258 kobject_name(&sysdev->kobj)); ··· 274 274 return error; 275 275 } 276 276 277 - void sysdev_unregister(struct sys_device * sysdev) 277 + void sysdev_unregister(struct sys_device *sysdev) 278 278 { 279 - struct sysdev_driver * drv; 279 + struct sysdev_driver *drv; 280 280 281 281 mutex_lock(&sysdev_drivers_lock); 282 282 list_for_each_entry(drv, &sysdev->cls->drivers, entry) { ··· 305 305 */ 306 306 void sysdev_shutdown(void) 307 307 { 308 - struct sysdev_class * cls; 308 + struct sysdev_class *cls; 309 309 310 310 pr_debug("Shutting Down System Devices\n"); 311 311 312 312 mutex_lock(&sysdev_drivers_lock); 313 313 list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) { 314 - struct sys_device * sysdev; 314 + struct sys_device *sysdev; 315 315 316 316 pr_debug("Shutting down type '%s':\n", 317 317 kobject_name(&cls->kset.kobj)); 318 318 319 319 list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) { 320 - struct sysdev_driver * drv; 320 + struct sysdev_driver *drv; 321 321 pr_debug(" %s\n", kobject_name(&sysdev->kobj)); 322 322 323 323 /* Call auxillary drivers first */ ··· 364 364 */ 365 365 int sysdev_suspend(pm_message_t state) 366 366 { 367 - struct sysdev_class * cls; 367 + struct sysdev_class *cls; 368 368 struct sys_device *sysdev, *err_dev; 369 369 struct sysdev_driver *drv, *err_drv; 370 370 int ret; ··· 442 442 */ 443 443 int sysdev_resume(void) 444 444 { 445 - struct sysdev_class * cls; 445 + struct sysdev_class *cls; 446 446 447 447 pr_debug("Resuming System Devices\n"); 448 448 449 449 list_for_each_entry(cls, &system_kset->list, kset.kobj.entry) { 450 - struct sys_device * sysdev; 450 + struct sys_device *sysdev; 451 451 452 452 pr_debug("Resuming type '%s':\n", 453 453 kobject_name(&cls->kset.kobj));
+1 -2
drivers/block/floppy.c
··· 4135 4135 static ssize_t floppy_cmos_show(struct device *dev, 4136 4136 struct device_attribute *attr, char *buf) 4137 4137 { 4138 - struct platform_device *p; 4138 + struct platform_device *p = to_platform_device(dev); 4139 4139 int drive; 4140 4140 4141 - p = container_of(dev, struct platform_device,dev); 4142 4141 drive = p->id; 4143 4142 return sprintf(buf, "%X\n", UDP->cmos); 4144 4143 }
+19 -9
drivers/char/tpm/tpm_atmel.c
··· 168 168 } 169 169 } 170 170 171 - static struct device_driver atml_drv = { 172 - .name = "tpm_atmel", 173 - .bus = &platform_bus_type, 174 - .owner = THIS_MODULE, 175 - .suspend = tpm_pm_suspend, 176 - .resume = tpm_pm_resume, 171 + static int tpm_atml_suspend(struct platform_device *dev, pm_message_t msg) 172 + { 173 + return tpm_pm_suspend(&dev->dev, msg); 174 + } 175 + 176 + static int tpm_atml_resume(struct platform_device *dev) 177 + { 178 + return tpm_pm_resume(&dev->dev); 179 + } 180 + static struct platform_driver atml_drv = { 181 + .driver = { 182 + .name = "tpm_atmel", 183 + .owner = THIS_MODULE, 184 + }, 185 + .suspend = tpm_atml_suspend, 186 + .resume = tpm_atml_resume, 177 187 }; 178 188 179 189 static int __init init_atmel(void) ··· 194 184 unsigned long base; 195 185 struct tpm_chip *chip; 196 186 197 - rc = driver_register(&atml_drv); 187 + rc = platform_driver_register(&atml_drv); 198 188 if (rc) 199 189 return rc; 200 190 ··· 233 223 atmel_release_region(base, 234 224 region_size); 235 225 err_unreg_drv: 236 - driver_unregister(&atml_drv); 226 + platform_driver_unregister(&atml_drv); 237 227 return rc; 238 228 } 239 229 240 230 static void __exit cleanup_atmel(void) 241 231 { 242 - driver_unregister(&atml_drv); 232 + platform_driver_unregister(&atml_drv); 243 233 atml_plat_remove(); 244 234 } 245 235
+19 -9
drivers/char/tpm/tpm_tis.c
··· 654 654 sizeof(tpm_pnp_tbl[TIS_HID_USR_IDX].id), 0444); 655 655 MODULE_PARM_DESC(hid, "Set additional specific HID for this driver to probe"); 656 656 657 - static struct device_driver tis_drv = { 658 - .name = "tpm_tis", 659 - .bus = &platform_bus_type, 660 - .owner = THIS_MODULE, 661 - .suspend = tpm_pm_suspend, 662 - .resume = tpm_pm_resume, 657 + static int tpm_tis_suspend(struct platform_device *dev, pm_message_t msg) 658 + { 659 + return tpm_pm_suspend(&dev->dev, msg); 660 + } 661 + 662 + static int tpm_tis_resume(struct platform_device *dev) 663 + { 664 + return tpm_pm_resume(&dev->dev); 665 + } 666 + static struct platform_driver tis_drv = { 667 + .driver = { 668 + .name = "tpm_tis", 669 + .owner = THIS_MODULE, 670 + }, 671 + .suspend = tpm_tis_suspend, 672 + .resume = tpm_tis_resume, 663 673 }; 664 674 665 675 static struct platform_device *pdev; ··· 682 672 int rc; 683 673 684 674 if (force) { 685 - rc = driver_register(&tis_drv); 675 + rc = platform_driver_register(&tis_drv); 686 676 if (rc < 0) 687 677 return rc; 688 678 if (IS_ERR(pdev=platform_device_register_simple("tpm_tis", -1, NULL, 0))) 689 679 return PTR_ERR(pdev); 690 680 if((rc=tpm_tis_init(&pdev->dev, TIS_MEM_BASE, TIS_MEM_LEN, 0)) != 0) { 691 681 platform_device_unregister(pdev); 692 - driver_unregister(&tis_drv); 682 + platform_driver_unregister(&tis_drv); 693 683 } 694 684 return rc; 695 685 } ··· 721 711 722 712 if (force) { 723 713 platform_device_unregister(pdev); 724 - driver_unregister(&tis_drv); 714 + platform_driver_unregister(&tis_drv); 725 715 } else 726 716 pnp_unregister_driver(&tis_pnp_driver); 727 717 }
+8 -8
drivers/char/vc_screen.c
··· 479 479 480 480 static struct class *vc_class; 481 481 482 - void vcs_make_sysfs(struct tty_struct *tty) 482 + void vcs_make_sysfs(int index) 483 483 { 484 - device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), NULL, 485 - "vcs%u", tty->index + 1); 486 - device_create(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), NULL, 487 - "vcsa%u", tty->index + 1); 484 + device_create(vc_class, NULL, MKDEV(VCS_MAJOR, index + 1), NULL, 485 + "vcs%u", index + 1); 486 + device_create(vc_class, NULL, MKDEV(VCS_MAJOR, index + 129), NULL, 487 + "vcsa%u", index + 1); 488 488 } 489 489 490 - void vcs_remove_sysfs(struct tty_struct *tty) 490 + void vcs_remove_sysfs(int index) 491 491 { 492 - device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 1)); 493 - device_destroy(vc_class, MKDEV(VCS_MAJOR, tty->index + 129)); 492 + device_destroy(vc_class, MKDEV(VCS_MAJOR, index + 1)); 493 + device_destroy(vc_class, MKDEV(VCS_MAJOR, index + 129)); 494 494 } 495 495 496 496 int __init vcs_init(void)
+3 -2
drivers/char/vt.c
··· 778 778 } 779 779 vc->vc_kmalloced = 1; 780 780 vc_init(vc, vc->vc_rows, vc->vc_cols, 1); 781 + vcs_make_sysfs(currcons); 781 782 atomic_notifier_call_chain(&vt_notifier_list, VT_ALLOCATE, &param); 782 783 } 783 784 return 0; ··· 988 987 if (vc_cons_allocated(currcons)) { 989 988 struct vc_data *vc = vc_cons[currcons].d; 990 989 struct vt_notifier_param param = { .vc = vc }; 990 + 991 991 atomic_notifier_call_chain(&vt_notifier_list, VT_DEALLOCATE, &param); 992 + vcs_remove_sysfs(currcons); 992 993 vc->vc_sw->con_deinit(vc); 993 994 put_pid(vc->vt_pid); 994 995 module_put(vc->vc_sw->owner); ··· 2778 2775 tty->termios->c_iflag |= IUTF8; 2779 2776 else 2780 2777 tty->termios->c_iflag &= ~IUTF8; 2781 - vcs_make_sysfs(tty); 2782 2778 release_console_sem(); 2783 2779 return ret; 2784 2780 } ··· 2797 2795 BUG_ON(vc == NULL); 2798 2796 acquire_console_sem(); 2799 2797 vc->vc_tty = NULL; 2800 - vcs_remove_sysfs(tty); 2801 2798 release_console_sem(); 2802 2799 tty_shutdown(tty); 2803 2800 }
+2 -2
drivers/dio/dio.c
··· 182 182 183 183 /* Initialize the DIO bus */ 184 184 INIT_LIST_HEAD(&dio_bus.devices); 185 - strcpy(dio_bus.dev.bus_id, "dio"); 185 + dev_set_name(&dio_bus.dev, "dio"); 186 186 error = device_register(&dio_bus.dev); 187 187 if (error) { 188 188 pr_err("DIO: Error registering dio_bus\n"); ··· 237 237 dev->scode = scode; 238 238 dev->resource.start = pa; 239 239 dev->resource.end = pa + DIO_SIZE(scode, va); 240 - sprintf(dev->dev.bus_id,"%02x", scode); 240 + dev_set_name(&dev->dev, "%02x", scode); 241 241 242 242 /* read the ID byte(s) and encode if necessary. */ 243 243 prid = DIO_ID(va);
+1 -1
drivers/dma/dw_dmac.c
··· 1011 1011 dma_writel(dw, CFG, DW_CFG_DMA_EN); 1012 1012 1013 1013 printk(KERN_INFO "%s: DesignWare DMA Controller, %d channels\n", 1014 - pdev->dev.bus_id, dw->dma.chancnt); 1014 + dev_name(&pdev->dev), dw->dma.chancnt); 1015 1015 1016 1016 dma_async_device_register(&dw->dma); 1017 1017
+1 -1
drivers/edac/cell_edac.c
··· 198 198 mci->edac_cap = EDAC_FLAG_EC | EDAC_FLAG_SECDED; 199 199 mci->mod_name = "cell_edac"; 200 200 mci->ctl_name = "MIC"; 201 - mci->dev_name = pdev->dev.bus_id; 201 + mci->dev_name = dev_name(&pdev->dev); 202 202 mci->edac_check = cell_edac_check; 203 203 cell_edac_init_csrows(mci); 204 204
+1 -1
drivers/edac/mpc85xx_edac.c
··· 218 218 pci->dev = &op->dev; 219 219 pci->mod_name = EDAC_MOD_STR; 220 220 pci->ctl_name = pdata->name; 221 - pci->dev_name = op->dev.bus_id; 221 + pci->dev_name = dev_name(&op->dev); 222 222 223 223 if (edac_op_state == EDAC_OPSTATE_POLL) 224 224 pci->edac_check = mpc85xx_pci_check;
+4 -4
drivers/edac/mv64x60_edac.c
··· 121 121 pdata->irq = NO_IRQ; 122 122 platform_set_drvdata(pdev, pci); 123 123 pci->dev = &pdev->dev; 124 - pci->dev_name = pdev->dev.bus_id; 124 + pci->dev_name = dev_name(&pdev->dev); 125 125 pci->mod_name = EDAC_MOD_STR; 126 126 pci->ctl_name = pdata->name; 127 127 ··· 294 294 pdata->irq = NO_IRQ; 295 295 edac_dev->dev = &pdev->dev; 296 296 platform_set_drvdata(pdev, edac_dev); 297 - edac_dev->dev_name = pdev->dev.bus_id; 297 + edac_dev->dev_name = dev_name(&pdev->dev); 298 298 299 299 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 300 300 if (!r) { ··· 462 462 pdata->irq = NO_IRQ; 463 463 edac_dev->dev = &pdev->dev; 464 464 platform_set_drvdata(pdev, edac_dev); 465 - edac_dev->dev_name = pdev->dev.bus_id; 465 + edac_dev->dev_name = dev_name(&pdev->dev); 466 466 467 467 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 468 468 if (!r) { ··· 713 713 platform_set_drvdata(pdev, mci); 714 714 pdata->name = "mv64x60_mc_err"; 715 715 pdata->irq = NO_IRQ; 716 - mci->dev_name = pdev->dev.bus_id; 716 + mci->dev_name = dev_name(&pdev->dev); 717 717 pdata->edac_idx = edac_mc_idx++; 718 718 719 719 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+2 -2
drivers/eisa/eisa-bus.c
··· 200 200 edev->dev.bus = &eisa_bus_type; 201 201 edev->dev.dma_mask = &edev->dma_mask; 202 202 edev->dev.coherent_dma_mask = edev->dma_mask; 203 - sprintf (edev->dev.bus_id, "%02X:%02X", root->bus_nr, slot); 203 + dev_set_name(&edev->dev, "%02X:%02X", root->bus_nr, slot); 204 204 205 205 for (i = 0; i < EISA_MAX_RESOURCES; i++) { 206 206 #ifdef CONFIG_EISA_NAMES ··· 301 301 struct eisa_device *edev; 302 302 303 303 printk (KERN_INFO "EISA: Probing bus %d at %s\n", 304 - root->bus_nr, root->dev->bus_id); 304 + root->bus_nr, dev_name(root->dev)); 305 305 306 306 /* First try to get hold of slot 0. If there is no device 307 307 * here, simply fail, unless root->force_probe is set. */
+1 -1
drivers/gpio/bt8xxgpio.c
··· 160 160 { 161 161 struct gpio_chip *c = &bg->gpio; 162 162 163 - c->label = bg->pdev->dev.bus_id; 163 + c->label = dev_name(&bg->pdev->dev); 164 164 c->owner = THIS_MODULE; 165 165 c->direction_input = bt8xxgpio_gpio_direction_input; 166 166 c->get = bt8xxgpio_gpio_get;
+2 -2
drivers/gpu/drm/drm_sysfs.c
··· 359 359 DRM_DEBUG("adding \"%s\" to sysfs\n", 360 360 drm_get_connector_name(connector)); 361 361 362 - snprintf(connector->kdev.bus_id, BUS_ID_SIZE, "card%d-%s", 363 - dev->primary->index, drm_get_connector_name(connector)); 362 + dev_set_name(&connector->kdev, "card%d-%s", 363 + dev->primary->index, drm_get_connector_name(connector)); 364 364 ret = device_register(&connector->kdev); 365 365 366 366 if (ret) {
+1 -1
drivers/i2c/i2c-core.c
··· 841 841 842 842 if (client->driver && !is_newstyle_driver(client->driver)) { 843 843 client->dev.release = i2c_client_release; 844 - client->dev.uevent_suppress = 1; 844 + dev_set_uevent_suppress(&client->dev, 1); 845 845 } else 846 846 client->dev.release = i2c_client_dev_release; 847 847
+18 -18
drivers/ide/au1xxx-ide.c
··· 536 536 #endif 537 537 }; 538 538 539 - static int au_ide_probe(struct device *dev) 539 + static int au_ide_probe(struct platform_device *dev) 540 540 { 541 - struct platform_device *pdev = to_platform_device(dev); 542 541 _auide_hwif *ahwif = &auide_hwif; 543 542 struct resource *res; 544 543 struct ide_host *host; ··· 551 552 #endif 552 553 553 554 memset(&auide_hwif, 0, sizeof(_auide_hwif)); 554 - ahwif->irq = platform_get_irq(pdev, 0); 555 + ahwif->irq = platform_get_irq(dev, 0); 555 556 556 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 557 + res = platform_get_resource(dev, IORESOURCE_MEM, 0); 557 558 558 559 if (res == NULL) { 559 - pr_debug("%s %d: no base address\n", DRV_NAME, pdev->id); 560 + pr_debug("%s %d: no base address\n", DRV_NAME, dev->id); 560 561 ret = -ENODEV; 561 562 goto out; 562 563 } 563 564 if (ahwif->irq < 0) { 564 - pr_debug("%s %d: no IRQ\n", DRV_NAME, pdev->id); 565 + pr_debug("%s %d: no IRQ\n", DRV_NAME, dev->id); 565 566 ret = -ENODEV; 566 567 goto out; 567 568 } 568 569 569 570 if (!request_mem_region(res->start, res->end - res->start + 1, 570 - pdev->name)) { 571 + dev->name)) { 571 572 pr_debug("%s: request_mem_region failed\n", DRV_NAME); 572 573 ret = -EBUSY; 573 574 goto out; ··· 582 583 memset(&hw, 0, sizeof(hw)); 583 584 auide_setup_ports(&hw, ahwif); 584 585 hw.irq = ahwif->irq; 585 - hw.dev = dev; 586 + hw.dev = &dev->dev; 586 587 hw.chipset = ide_au1xxx; 587 588 588 589 ret = ide_host_add(&au1xxx_port_info, hws, &host); ··· 591 592 592 593 auide_hwif.hwif = host->ports[0]; 593 594 594 - dev_set_drvdata(dev, host); 595 + platform_set_drvdata(dev, host); 595 596 596 597 printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode ); 597 598 ··· 599 600 return ret; 600 601 } 601 602 602 - static int au_ide_remove(struct device *dev) 603 + static int au_ide_remove(struct platform_device *dev) 603 604 { 604 - struct platform_device *pdev = to_platform_device(dev); 605 605 struct resource *res; 606 - struct ide_host *host = dev_get_drvdata(dev); 606 + struct ide_host *host = platform_get_drvdata(dev); 607 607 _auide_hwif *ahwif = &auide_hwif; 608 608 609 609 ide_host_remove(host); 610 610 611 611 iounmap((void *)ahwif->regbase); 612 612 613 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 613 + res = platform_get_resource(dev, IORESOURCE_MEM, 0); 614 614 release_mem_region(res->start, res->end - res->start + 1); 615 615 616 616 return 0; 617 617 } 618 618 619 - static struct device_driver au1200_ide_driver = { 620 - .name = "au1200-ide", 621 - .bus = &platform_bus_type, 619 + static struct platform_driver au1200_ide_driver = { 620 + .driver = { 621 + .name = "au1200-ide", 622 + .owner = THIS_MODULE, 623 + }, 622 624 .probe = au_ide_probe, 623 625 .remove = au_ide_remove, 624 626 }; 625 627 626 628 static int __init au_ide_init(void) 627 629 { 628 - return driver_register(&au1200_ide_driver); 630 + return platform_driver_register(&au1200_ide_driver); 629 631 } 630 632 631 633 static void __exit au_ide_exit(void) 632 634 { 633 - driver_unregister(&au1200_ide_driver); 635 + platform_driver_unregister(&au1200_ide_driver); 634 636 } 635 637 636 638 MODULE_LICENSE("GPL");
+1 -2
drivers/isdn/gigaset/ser-gigaset.c
··· 389 389 390 390 static void gigaset_device_release(struct device *dev) 391 391 { 392 - struct platform_device *pdev = 393 - container_of(dev, struct platform_device, dev); 392 + struct platform_device *pdev = to_platform_device(dev); 394 393 395 394 /* adapted from platform_device_release() in drivers/base/platform.c */ 396 395 //FIXME is this actually necessary?
+2 -2
drivers/mca/mca-bus.c
··· 110 110 111 111 mca_dev->dev.parent = &mca_bus->dev; 112 112 mca_dev->dev.bus = &mca_bus_type; 113 - sprintf (mca_dev->dev.bus_id, "%02d:%02X", bus, mca_dev->slot); 113 + dev_set_name(&mca_dev->dev, "%02d:%02X", bus, mca_dev->slot); 114 114 mca_dev->dma_mask = mca_bus->default_dma_mask; 115 115 mca_dev->dev.dma_mask = &mca_dev->dma_mask; 116 116 mca_dev->dev.coherent_dma_mask = mca_dev->dma_mask; ··· 151 151 if (!mca_bus) 152 152 return NULL; 153 153 154 - sprintf(mca_bus->dev.bus_id,"mca%d",bus); 154 + dev_set_name(&mca_bus->dev, "mca%d", bus); 155 155 sprintf(mca_bus->name,"Host %s MCA Bridge", bus ? "Secondary" : "Primary"); 156 156 if (device_register(&mca_bus->dev)) { 157 157 kfree(mca_bus);
+2 -1
drivers/media/radio/radio-tea5764.c
··· 298 298 299 299 strlcpy(v->driver, dev->dev.driver->name, sizeof(v->driver)); 300 300 strlcpy(v->card, dev->name, sizeof(v->card)); 301 - snprintf(v->bus_info, sizeof(v->bus_info), "I2C:%s", dev->dev.bus_id); 301 + snprintf(v->bus_info, sizeof(v->bus_info), 302 + "I2C:%s", dev_name(&dev->dev)); 302 303 v->version = RADIO_VERSION; 303 304 v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO; 304 305 return 0;
+1 -1
drivers/media/video/v4l2-device.c
··· 34 34 spin_lock_init(&v4l2_dev->lock); 35 35 v4l2_dev->dev = dev; 36 36 snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), "%s %s", 37 - dev->driver->name, dev->bus_id); 37 + dev->driver->name, dev_name(dev)); 38 38 dev_set_drvdata(dev, v4l2_dev); 39 39 return 0; 40 40 }
+1 -1
drivers/mfd/mcp-core.c
··· 214 214 215 215 int mcp_host_register(struct mcp *mcp) 216 216 { 217 - strcpy(mcp->attached_device.bus_id, "mcp0"); 217 + dev_set_name(&mcp->attached_device, "mcp0"); 218 218 return device_register(&mcp->attached_device); 219 219 } 220 220 EXPORT_SYMBOL(mcp_host_register);
+1 -1
drivers/mfd/ucb1x00-core.c
··· 492 492 493 493 ucb->dev.class = &ucb1x00_class; 494 494 ucb->dev.parent = &mcp->attached_device; 495 - strlcpy(ucb->dev.bus_id, "ucb1x00", sizeof(ucb->dev.bus_id)); 495 + dev_set_name(&ucb->dev, "ucb1x00"); 496 496 497 497 spin_lock_init(&ucb->lock); 498 498 spin_lock_init(&ucb->io_lock);
+1 -1
drivers/mmc/host/atmel-mci.c
··· 1603 1603 1604 1604 tasklet_init(&host->tasklet, atmci_tasklet_func, (unsigned long)host); 1605 1605 1606 - ret = request_irq(irq, atmci_interrupt, 0, pdev->dev.bus_id, host); 1606 + ret = request_irq(irq, atmci_interrupt, 0, dev_name(&pdev->dev), host); 1607 1607 if (ret) 1608 1608 goto err_request_irq; 1609 1609
+1 -1
drivers/mmc/host/of_mmc_spi.c
··· 103 103 if (!gpio_is_valid(oms->gpios[i])) 104 104 continue; 105 105 106 - ret = gpio_request(oms->gpios[i], dev->bus_id); 106 + ret = gpio_request(oms->gpios[i], dev_name(dev)); 107 107 if (ret < 0) { 108 108 oms->gpios[i] = -EINVAL; 109 109 continue;
+19 -18
drivers/mtd/maps/pxa2xx-flash.c
··· 41 41 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; 42 42 43 43 44 - static int __init pxa2xx_flash_probe(struct device *dev) 44 + static int __init pxa2xx_flash_probe(struct platform_device *pdev) 45 45 { 46 - struct platform_device *pdev = to_platform_device(dev); 47 46 struct flash_platform_data *flash = pdev->dev.platform_data; 48 47 struct pxa2xx_flash_info *info; 49 48 struct mtd_partition *parts; ··· 113 114 add_mtd_device(info->mtd); 114 115 } 115 116 116 - dev_set_drvdata(dev, info); 117 + platform_set_drvdata(pdev, info); 117 118 return 0; 118 119 } 119 120 120 - static int __exit pxa2xx_flash_remove(struct device *dev) 121 + static int __exit pxa2xx_flash_remove(struct platform_device *dev) 121 122 { 122 - struct pxa2xx_flash_info *info = dev_get_drvdata(dev); 123 + struct pxa2xx_flash_info *info = platform_get_drvdata(dev); 123 124 124 - dev_set_drvdata(dev, NULL); 125 + platform_set_drvdata(dev, NULL); 125 126 126 127 #ifdef CONFIG_MTD_PARTITIONS 127 128 if (info->nr_parts) ··· 140 141 } 141 142 142 143 #ifdef CONFIG_PM 143 - static int pxa2xx_flash_suspend(struct device *dev, pm_message_t state) 144 + static int pxa2xx_flash_suspend(struct platform_device *dev, pm_message_t state) 144 145 { 145 - struct pxa2xx_flash_info *info = dev_get_drvdata(dev); 146 + struct pxa2xx_flash_info *info = platform_get_drvdata(dev); 146 147 int ret = 0; 147 148 148 149 if (info->mtd && info->mtd->suspend) ··· 150 151 return ret; 151 152 } 152 153 153 - static int pxa2xx_flash_resume(struct device *dev) 154 + static int pxa2xx_flash_resume(struct platform_device *dev) 154 155 { 155 - struct pxa2xx_flash_info *info = dev_get_drvdata(dev); 156 + struct pxa2xx_flash_info *info = platform_get_drvdata(dev); 156 157 157 158 if (info->mtd && info->mtd->resume) 158 159 info->mtd->resume(info->mtd); 159 160 return 0; 160 161 } 161 - static void pxa2xx_flash_shutdown(struct device *dev) 162 + static void pxa2xx_flash_shutdown(struct platform_device *dev) 162 163 { 163 - struct pxa2xx_flash_info *info = dev_get_drvdata(dev); 164 + struct pxa2xx_flash_info *info = platform_get_drvdata(dev); 164 165 165 166 if (info && info->mtd->suspend(info->mtd) == 0) 166 167 info->mtd->resume(info->mtd); ··· 171 172 #define pxa2xx_flash_shutdown NULL 172 173 #endif 173 174 174 - static struct device_driver pxa2xx_flash_driver = { 175 - .name = "pxa2xx-flash", 176 - .bus = &platform_bus_type, 175 + static struct platform_driver pxa2xx_flash_driver = { 176 + .driver = { 177 + .name = "pxa2xx-flash", 178 + .owner = THIS_MODULE, 179 + }, 177 180 .probe = pxa2xx_flash_probe, 178 - .remove = __exit_p(pxa2xx_flash_remove), 181 + .remove = __devexit_p(pxa2xx_flash_remove), 179 182 .suspend = pxa2xx_flash_suspend, 180 183 .resume = pxa2xx_flash_resume, 181 184 .shutdown = pxa2xx_flash_shutdown, ··· 185 184 186 185 static int __init init_pxa2xx_flash(void) 187 186 { 188 - return driver_register(&pxa2xx_flash_driver); 187 + return platform_driver_register(&pxa2xx_flash_driver); 189 188 } 190 189 191 190 static void __exit cleanup_pxa2xx_flash(void) 192 191 { 193 - driver_unregister(&pxa2xx_flash_driver); 192 + platform_driver_unregister(&pxa2xx_flash_driver); 194 193 } 195 194 196 195 module_init(init_pxa2xx_flash);
+13 -12
drivers/mtd/nand/excite_nandflash.c
··· 128 128 * The binding to the mtd and all allocated 129 129 * resources are released. 130 130 */ 131 - static int __exit excite_nand_remove(struct device *dev) 131 + static int __exit excite_nand_remove(struct platform_device *dev) 132 132 { 133 - struct excite_nand_drvdata * const this = dev_get_drvdata(dev); 133 + struct excite_nand_drvdata * const this = platform_get_drvdata(dev); 134 134 135 - dev_set_drvdata(dev, NULL); 135 + platform_set_drvdata(dev, NULL); 136 136 137 137 if (unlikely(!this)) { 138 138 printk(KERN_ERR "%s: called %s without private data!!", ··· 159 159 * it can allocate all necessary resources then calls the 160 160 * nand layer to look for devices. 161 161 */ 162 - static int __init excite_nand_probe(struct device *dev) 162 + static int __init excite_nand_probe(struct platform_device *pdev) 163 163 { 164 - struct platform_device * const pdev = to_platform_device(dev); 165 164 struct excite_nand_drvdata *drvdata; /* private driver data */ 166 165 struct nand_chip *board_chip; /* private flash chip data */ 167 166 struct mtd_info *board_mtd; /* mtd info for this board */ ··· 174 175 } 175 176 176 177 /* bind private data into driver */ 177 - dev_set_drvdata(dev, drvdata); 178 + platform_set_drvdata(pdev, drvdata); 178 179 179 180 /* allocate and map the resource */ 180 181 drvdata->regs = ··· 218 219 return 0; 219 220 } 220 221 221 - static struct device_driver excite_nand_driver = { 222 - .name = "excite_nand", 223 - .bus = &platform_bus_type, 222 + static struct platform_driver excite_nand_driver = { 223 + .driver = { 224 + .name = "excite_nand", 225 + .owner = THIS_MODULE, 226 + }, 224 227 .probe = excite_nand_probe, 225 - .remove = __exit_p(excite_nand_remove) 228 + .remove = __devexit_p(excite_nand_remove) 226 229 }; 227 230 228 231 static int __init excite_nand_init(void) 229 232 { 230 233 pr_info("Basler eXcite nand flash driver Version " 231 234 EXCITE_NANDFLASH_VERSION "\n"); 232 - return driver_register(&excite_nand_driver); 235 + return platform_driver_register(&excite_nand_driver); 233 236 } 234 237 235 238 static void __exit excite_nand_exit(void) 236 239 { 237 - driver_unregister(&excite_nand_driver); 240 + platform_driver_unregister(&excite_nand_driver); 238 241 } 239 242 240 243 module_init(excite_nand_init);
+1 -1
drivers/mtd/nand/ndfc.c
··· 187 187 return -ENODEV; 188 188 189 189 ndfc->mtd.name = kasprintf(GFP_KERNEL, "%s.%s", 190 - ndfc->ofdev->dev.bus_id, flash_np->name); 190 + dev_name(&ndfc->ofdev->dev), flash_np->name); 191 191 if (!ndfc->mtd.name) { 192 192 ret = -ENOMEM; 193 193 goto err;
+13 -13
drivers/mtd/onenand/generic.c
··· 36 36 struct onenand_chip onenand; 37 37 }; 38 38 39 - static int __devinit generic_onenand_probe(struct device *dev) 39 + static int __devinit generic_onenand_probe(struct platform_device *pdev) 40 40 { 41 41 struct onenand_info *info; 42 - struct platform_device *pdev = to_platform_device(dev); 43 42 struct flash_platform_data *pdata = pdev->dev.platform_data; 44 43 struct resource *res = pdev->resource; 45 44 unsigned long size = res->end - res->start + 1; ··· 48 49 if (!info) 49 50 return -ENOMEM; 50 51 51 - if (!request_mem_region(res->start, size, dev->driver->name)) { 52 + if (!request_mem_region(res->start, size, pdev->dev.driver->name)) { 52 53 err = -EBUSY; 53 54 goto out_free_info; 54 55 } ··· 81 82 #endif 82 83 err = add_mtd_device(&info->mtd); 83 84 84 - dev_set_drvdata(&pdev->dev, info); 85 + platform_set_drvdata(pdev, info); 85 86 86 87 return 0; 87 88 ··· 95 96 return err; 96 97 } 97 98 98 - static int __devexit generic_onenand_remove(struct device *dev) 99 + static int __devexit generic_onenand_remove(struct platform_device *pdev) 99 100 { 100 - struct platform_device *pdev = to_platform_device(dev); 101 - struct onenand_info *info = dev_get_drvdata(&pdev->dev); 101 + struct onenand_info *info = platform_get_drvdata(pdev); 102 102 struct resource *res = pdev->resource; 103 103 unsigned long size = res->end - res->start + 1; 104 104 105 - dev_set_drvdata(&pdev->dev, NULL); 105 + platform_set_drvdata(pdev, NULL); 106 106 107 107 if (info) { 108 108 if (info->parts) ··· 118 120 return 0; 119 121 } 120 122 121 - static struct device_driver generic_onenand_driver = { 122 - .name = DRIVER_NAME, 123 - .bus = &platform_bus_type, 123 + static struct platform_driver generic_onenand_driver = { 124 + .driver = { 125 + .name = DRIVER_NAME, 126 + .owner = THIS_MODULE, 127 + }, 124 128 .probe = generic_onenand_probe, 125 129 .remove = __devexit_p(generic_onenand_remove), 126 130 }; ··· 131 131 132 132 static int __init generic_onenand_init(void) 133 133 { 134 - return driver_register(&generic_onenand_driver); 134 + return platform_driver_register(&generic_onenand_driver); 135 135 } 136 136 137 137 static void __exit generic_onenand_exit(void) 138 138 { 139 - driver_unregister(&generic_onenand_driver); 139 + platform_driver_unregister(&generic_onenand_driver); 140 140 } 141 141 142 142 module_init(generic_onenand_init);
+1 -1
drivers/net/arm/ks8695net.c
··· 1059 1059 { 1060 1060 strlcpy(info->driver, MODULENAME, sizeof(info->driver)); 1061 1061 strlcpy(info->version, MODULEVERSION, sizeof(info->version)); 1062 - strlcpy(info->bus_info, ndev->dev.parent->bus_id, 1062 + strlcpy(info->bus_info, dev_name(ndev->dev.parent), 1063 1063 sizeof(info->bus_info)); 1064 1064 } 1065 1065
+4 -4
drivers/net/au1000_eth.c
··· 355 355 /* now we are supposed to have a proper phydev, to attach to... */ 356 356 BUG_ON(phydev->attached_dev); 357 357 358 - phydev = phy_connect(dev, phydev->dev.bus_id, &au1000_adjust_link, 0, 359 - PHY_INTERFACE_MODE_MII); 358 + phydev = phy_connect(dev, dev_name(&phydev->dev), &au1000_adjust_link, 359 + 0, PHY_INTERFACE_MODE_MII); 360 360 361 361 if (IS_ERR(phydev)) { 362 362 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); ··· 381 381 aup->phy_dev = phydev; 382 382 383 383 printk(KERN_INFO "%s: attached PHY driver [%s] " 384 - "(mii_bus:phy_addr=%s, irq=%d)\n", 385 - dev->name, phydev->drv->name, phydev->dev.bus_id, phydev->irq); 384 + "(mii_bus:phy_addr=%s, irq=%d)\n", dev->name, 385 + phydev->drv->name, dev_name(&phydev->dev), phydev->irq); 386 386 387 387 return 0; 388 388 }
+6 -6
drivers/net/bfin_mac.c
··· 415 415 } 416 416 417 417 #if defined(CONFIG_BFIN_MAC_RMII) 418 - phydev = phy_connect(dev, phydev->dev.bus_id, &bfin_mac_adjust_link, 0, 419 - PHY_INTERFACE_MODE_RMII); 418 + phydev = phy_connect(dev, dev_name(&phydev->dev), &bfin_mac_adjust_link, 419 + 0, PHY_INTERFACE_MODE_RMII); 420 420 #else 421 - phydev = phy_connect(dev, phydev->dev.bus_id, &bfin_mac_adjust_link, 0, 422 - PHY_INTERFACE_MODE_MII); 421 + phydev = phy_connect(dev, dev_name(&phydev->dev), &bfin_mac_adjust_link, 422 + 0, PHY_INTERFACE_MODE_MII); 423 423 #endif 424 424 425 425 if (IS_ERR(phydev)) { ··· 447 447 printk(KERN_INFO "%s: attached PHY driver [%s] " 448 448 "(mii_bus:phy_addr=%s, irq=%d, mdc_clk=%dHz(mdc_div=%d)" 449 449 "@sclk=%dMHz)\n", 450 - DRV_NAME, phydev->drv->name, phydev->dev.bus_id, phydev->irq, 450 + DRV_NAME, phydev->drv->name, dev_name(&phydev->dev), phydev->irq, 451 451 MDC_CLK, mdc_div, sclk/1000000); 452 452 453 453 return 0; ··· 488 488 strcpy(info->driver, DRV_NAME); 489 489 strcpy(info->version, DRV_VERSION); 490 490 strcpy(info->fw_version, "N/A"); 491 - strcpy(info->bus_info, dev->dev.bus_id); 491 + strcpy(info->bus_info, dev_name(&dev->dev)); 492 492 } 493 493 494 494 static struct ethtool_ops bfin_mac_ethtool_ops = {
+1 -1
drivers/net/bmac.c
··· 1240 1240 { 1241 1241 struct bmac_data *bp = netdev_priv(dev); 1242 1242 strcpy(info->driver, "bmac"); 1243 - strcpy(info->bus_info, bp->mdev->ofdev.dev.bus_id); 1243 + strcpy(info->bus_info, dev_name(&bp->mdev->ofdev.dev)); 1244 1244 } 1245 1245 1246 1246 static const struct ethtool_ops bmac_ethtool_ops = {
+1 -1
drivers/net/cpmac.c
··· 1161 1161 priv->msg_enable = netif_msg_init(debug_level, 0xff); 1162 1162 memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); 1163 1163 1164 - priv->phy = phy_connect(dev, cpmac_mii->phy_map[phy_id]->dev.bus_id, 1164 + priv->phy = phy_connect(dev, dev_name(&cpmac_mii->phy_map[phy_id]->dev), 1165 1165 &cpmac_adjust_link, 0, PHY_INTERFACE_MODE_MII); 1166 1166 if (IS_ERR(priv->phy)) { 1167 1167 if (netif_msg_drv(priv))
+3 -3
drivers/net/declance.c
··· 1027 1027 printk(version); 1028 1028 1029 1029 if (bdev) 1030 - snprintf(name, sizeof(name), "%s", bdev->bus_id); 1030 + snprintf(name, sizeof(name), "%s", dev_name(bdev)); 1031 1031 else { 1032 1032 i = 0; 1033 1033 dev = root_lance_dev; ··· 1105 1105 1106 1106 start = to_tc_dev(bdev)->resource.start; 1107 1107 len = to_tc_dev(bdev)->resource.end - start + 1; 1108 - if (!request_mem_region(start, len, bdev->bus_id)) { 1108 + if (!request_mem_region(start, len, dev_name(bdev))) { 1109 1109 printk(KERN_ERR 1110 1110 "%s: Unable to reserve MMIO resource\n", 1111 - bdev->bus_id); 1111 + dev_name(bdev)); 1112 1112 ret = -EBUSY; 1113 1113 goto err_out_dev; 1114 1114 }
+3 -3
drivers/net/depca.c
··· 606 606 if (!mem_start || lp->adapter < DEPCA || lp->adapter >=unknown) 607 607 return -ENXIO; 608 608 609 - printk ("%s: %s at 0x%04lx", 610 - device->bus_id, depca_signature[lp->adapter], ioaddr); 609 + printk("%s: %s at 0x%04lx", 610 + dev_name(device), depca_signature[lp->adapter], ioaddr); 611 611 612 612 switch (lp->depca_bus) { 613 613 #ifdef CONFIG_MCA ··· 669 669 670 670 spin_lock_init(&lp->lock); 671 671 sprintf(lp->adapter_name, "%s (%s)", 672 - depca_signature[lp->adapter], device->bus_id); 672 + depca_signature[lp->adapter], dev_name(device)); 673 673 status = -EBUSY; 674 674 675 675 /* Initialisation Block */
+1 -1
drivers/net/ehea/ehea_main.c
··· 3040 3040 port->ofdev.dev.parent = &port->adapter->ofdev->dev; 3041 3041 port->ofdev.dev.bus = &ibmebus_bus_type; 3042 3042 3043 - sprintf(port->ofdev.dev.bus_id, "port%d", port_name_cnt++); 3043 + dev_set_name(&port->ofdev.dev, "port%d", port_name_cnt++); 3044 3044 port->ofdev.dev.release = logical_port_release; 3045 3045 3046 3046 ret = of_device_register(&port->ofdev);
+4 -2
drivers/net/jazzsonic.c
··· 131 131 if (sonic_debug && version_printed++ == 0) 132 132 printk(version); 133 133 134 - printk(KERN_INFO "%s: Sonic ethernet found at 0x%08lx, ", lp->device->bus_id, dev->base_addr); 134 + printk(KERN_INFO "%s: Sonic ethernet found at 0x%08lx, ", 135 + dev_name(lp->device), dev->base_addr); 135 136 136 137 /* 137 138 * Put the sonic into software reset, then ··· 157 156 if ((lp->descriptors = dma_alloc_coherent(lp->device, 158 157 SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode), 159 158 &lp->descriptors_laddr, GFP_KERNEL)) == NULL) { 160 - printk(KERN_ERR "%s: couldn't alloc DMA memory for descriptors.\n", lp->device->bus_id); 159 + printk(KERN_ERR "%s: couldn't alloc DMA memory for descriptors.\n", 160 + dev_name(lp->device)); 161 161 goto out; 162 162 } 163 163
+5 -5
drivers/net/macb.c
··· 211 211 212 212 /* attach the mac to the phy */ 213 213 if (pdata && pdata->is_rmii) { 214 - phydev = phy_connect(dev, phydev->dev.bus_id, 214 + phydev = phy_connect(dev, dev_name(&phydev->dev), 215 215 &macb_handle_link_change, 0, PHY_INTERFACE_MODE_RMII); 216 216 } else { 217 - phydev = phy_connect(dev, phydev->dev.bus_id, 217 + phydev = phy_connect(dev, dev_name(&phydev->dev), 218 218 &macb_handle_link_change, 0, PHY_INTERFACE_MODE_MII); 219 219 } 220 220 ··· 1077 1077 1078 1078 strcpy(info->driver, bp->pdev->dev.driver->name); 1079 1079 strcpy(info->version, "$Revision: 1.14 $"); 1080 - strcpy(info->bus_info, bp->pdev->dev.bus_id); 1080 + strcpy(info->bus_info, dev_name(&bp->pdev->dev)); 1081 1081 } 1082 1082 1083 1083 static struct ethtool_ops macb_ethtool_ops = { ··· 1234 1234 1235 1235 phydev = bp->phy_dev; 1236 1236 printk(KERN_INFO "%s: attached PHY driver [%s] " 1237 - "(mii_bus:phy_addr=%s, irq=%d)\n", 1238 - dev->name, phydev->drv->name, phydev->dev.bus_id, phydev->irq); 1237 + "(mii_bus:phy_addr=%s, irq=%d)\n", dev->name, 1238 + phydev->drv->name, dev_name(&phydev->dev), phydev->irq); 1239 1239 1240 1240 return 0; 1241 1241
+8 -7
drivers/net/macsonic.c
··· 176 176 if ((lp->descriptors = dma_alloc_coherent(lp->device, 177 177 SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode), 178 178 &lp->descriptors_laddr, GFP_KERNEL)) == NULL) { 179 - printk(KERN_ERR "%s: couldn't alloc DMA memory for descriptors.\n", lp->device->bus_id); 179 + printk(KERN_ERR "%s: couldn't alloc DMA memory for descriptors.\n", 180 + dev_name(lp->device)); 180 181 return -ENOMEM; 181 182 } 182 183 ··· 338 337 sonic_version_printed = 1; 339 338 } 340 339 printk(KERN_INFO "%s: onboard / comm-slot SONIC at 0x%08lx\n", 341 - lp->device->bus_id, dev->base_addr); 340 + dev_name(lp->device), dev->base_addr); 342 341 343 342 /* The PowerBook's SONIC is 16 bit always. */ 344 343 if (macintosh_config->ident == MAC_MODEL_PB520) { ··· 371 370 } 372 371 printk(KERN_INFO 373 372 "%s: revision 0x%04x, using %d bit DMA and register offset %d\n", 374 - lp->device->bus_id, sr, lp->dma_bitmode?32:16, lp->reg_offset); 373 + dev_name(lp->device), sr, lp->dma_bitmode?32:16, lp->reg_offset); 375 374 376 375 #if 0 /* This is sometimes useful to find out how MacOS configured the card. */ 377 - printk(KERN_INFO "%s: DCR: 0x%04x, DCR2: 0x%04x\n", lp->device->bus_id, 376 + printk(KERN_INFO "%s: DCR: 0x%04x, DCR2: 0x%04x\n", dev_name(lp->device), 378 377 SONIC_READ(SONIC_DCR) & 0xffff, SONIC_READ(SONIC_DCR2) & 0xffff); 379 378 #endif 380 379 ··· 526 525 sonic_version_printed = 1; 527 526 } 528 527 printk(KERN_INFO "%s: %s in slot %X\n", 529 - lp->device->bus_id, ndev->board->name, ndev->board->slot); 528 + dev_name(lp->device), ndev->board->name, ndev->board->slot); 530 529 printk(KERN_INFO "%s: revision 0x%04x, using %d bit DMA and register offset %d\n", 531 - lp->device->bus_id, SONIC_READ(SONIC_SR), dma_bitmode?32:16, reg_offset); 530 + dev_name(lp->device), SONIC_READ(SONIC_SR), dma_bitmode?32:16, reg_offset); 532 531 533 532 #if 0 /* This is sometimes useful to find out how MacOS configured the card. */ 534 - printk(KERN_INFO "%s: DCR: 0x%04x, DCR2: 0x%04x\n", lp->device->bus_id, 533 + printk(KERN_INFO "%s: DCR: 0x%04x, DCR2: 0x%04x\n", dev_name(lp->device), 535 534 SONIC_READ(SONIC_DCR) & 0xffff, SONIC_READ(SONIC_DCR2) & 0xffff); 536 535 #endif 537 536
+14 -12
drivers/net/mipsnet.c
··· 237 237 { 238 238 } 239 239 240 - static int __init mipsnet_probe(struct device *dev) 240 + static int __init mipsnet_probe(struct platform_device *dev) 241 241 { 242 242 struct net_device *netdev; 243 243 int err; ··· 248 248 goto out; 249 249 } 250 250 251 - dev_set_drvdata(dev, netdev); 251 + platform_set_drvdata(dev, netdev); 252 252 253 253 netdev->open = mipsnet_open; 254 254 netdev->stop = mipsnet_close; ··· 293 293 return err; 294 294 } 295 295 296 - static int __devexit mipsnet_device_remove(struct device *device) 296 + static int __devexit mipsnet_device_remove(struct platform_device *device) 297 297 { 298 - struct net_device *dev = dev_get_drvdata(device); 298 + struct net_device *dev = platform_get_drvdata(device); 299 299 300 300 unregister_netdev(dev); 301 301 release_region(dev->base_addr, sizeof(struct mipsnet_regs)); 302 302 free_netdev(dev); 303 - dev_set_drvdata(device, NULL); 303 + platform_set_drvdata(device, NULL); 304 304 305 305 return 0; 306 306 } 307 307 308 - static struct device_driver mipsnet_driver = { 309 - .name = mipsnet_string, 310 - .bus = &platform_bus_type, 311 - .probe = mipsnet_probe, 312 - .remove = __devexit_p(mipsnet_device_remove), 308 + static struct platform_driver mipsnet_driver = { 309 + .driver = { 310 + .name = mipsnet_string, 311 + .owner = THIS_MODULE, 312 + }, 313 + .probe = mipsnet_probe, 314 + .remove = __devexit_p(mipsnet_device_remove), 313 315 }; 314 316 315 317 static int __init mipsnet_init_module(void) ··· 321 319 printk(KERN_INFO "MIPSNet Ethernet driver. Version: %s. " 322 320 "(c)2005 MIPS Technologies, Inc.\n", MIPSNET_VERSION); 323 321 324 - err = driver_register(&mipsnet_driver); 322 + err = platform_driver_register(&mipsnet_driver); 325 323 if (err) 326 324 printk(KERN_ERR "Driver registration failed\n"); 327 325 ··· 330 328 331 329 static void __exit mipsnet_exit_module(void) 332 330 { 333 - driver_unregister(&mipsnet_driver); 331 + platform_driver_unregister(&mipsnet_driver); 334 332 } 335 333 336 334 module_init(mipsnet_init_module);
+1 -1
drivers/net/mv643xx_eth.c
··· 2588 2588 2589 2589 phy_reset(mp); 2590 2590 2591 - phy_attach(mp->dev, phy->dev.bus_id, 0, PHY_INTERFACE_MODE_GMII); 2591 + phy_attach(mp->dev, dev_name(&phy->dev), 0, PHY_INTERFACE_MODE_GMII); 2592 2592 2593 2593 if (speed == 0) { 2594 2594 phy->autoneg = AUTONEG_ENABLE;
+5 -5
drivers/net/sb1250-mac.c
··· 2478 2478 return -ENXIO; 2479 2479 } 2480 2480 2481 - phy_dev = phy_connect(dev, phy_dev->dev.bus_id, &sbmac_mii_poll, 0, 2481 + phy_dev = phy_connect(dev, dev_name(&phy_dev->dev), &sbmac_mii_poll, 0, 2482 2482 PHY_INTERFACE_MODE_GMII); 2483 2483 if (IS_ERR(phy_dev)) { 2484 2484 printk(KERN_ERR "%s: could not attach to PHY\n", dev->name); ··· 2500 2500 2501 2501 pr_info("%s: attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n", 2502 2502 dev->name, phy_dev->drv->name, 2503 - phy_dev->dev.bus_id, phy_dev->irq); 2503 + dev_name(&phy_dev->dev), phy_dev->irq); 2504 2504 2505 2505 sc->phy_dev = phy_dev; 2506 2506 ··· 2697 2697 sbm_base = ioremap_nocache(res->start, res->end - res->start + 1); 2698 2698 if (!sbm_base) { 2699 2699 printk(KERN_ERR "%s: unable to map device registers\n", 2700 - pldev->dev.bus_id); 2700 + dev_name(&pldev->dev)); 2701 2701 err = -ENOMEM; 2702 2702 goto out_out; 2703 2703 } ··· 2708 2708 * If we find a zero, skip this MAC. 2709 2709 */ 2710 2710 sbmac_orig_hwaddr = __raw_readq(sbm_base + R_MAC_ETHERNET_ADDR); 2711 - pr_debug("%s: %sconfiguring MAC at 0x%08Lx\n", pldev->dev.bus_id, 2711 + pr_debug("%s: %sconfiguring MAC at 0x%08Lx\n", dev_name(&pldev->dev), 2712 2712 sbmac_orig_hwaddr ? "" : "not ", (long long)res->start); 2713 2713 if (sbmac_orig_hwaddr == 0) { 2714 2714 err = 0; ··· 2721 2721 dev = alloc_etherdev(sizeof(struct sbmac_softc)); 2722 2722 if (!dev) { 2723 2723 printk(KERN_ERR "%s: unable to allocate etherdev\n", 2724 - pldev->dev.bus_id); 2724 + dev_name(&pldev->dev)); 2725 2725 err = -ENOMEM; 2726 2726 goto out_unmap; 2727 2727 }
+1 -1
drivers/net/smc911x.c
··· 1545 1545 { 1546 1546 strncpy(info->driver, CARDNAME, sizeof(info->driver)); 1547 1547 strncpy(info->version, version, sizeof(info->version)); 1548 - strncpy(info->bus_info, dev->dev.parent->bus_id, sizeof(info->bus_info)); 1548 + strncpy(info->bus_info, dev_name(dev->dev.parent), sizeof(info->bus_info)); 1549 1549 } 1550 1550 1551 1551 static int smc911x_ethtool_nwayreset(struct net_device *dev)
+1 -1
drivers/net/smc91x.c
··· 1614 1614 { 1615 1615 strncpy(info->driver, CARDNAME, sizeof(info->driver)); 1616 1616 strncpy(info->version, version, sizeof(info->version)); 1617 - strncpy(info->bus_info, dev->dev.parent->bus_id, sizeof(info->bus_info)); 1617 + strncpy(info->bus_info, dev_name(dev->dev.parent), sizeof(info->bus_info)); 1618 1618 } 1619 1619 1620 1620 static int smc_ethtool_nwayreset(struct net_device *dev)
+4 -3
drivers/net/smsc911x.c
··· 769 769 return -ENODEV; 770 770 } 771 771 772 - phydev = phy_connect(dev, phydev->dev.bus_id, 772 + phydev = phy_connect(dev, dev_name(&phydev->dev), 773 773 &smsc911x_phy_adjust_link, 0, pdata->config.phy_interface); 774 774 775 775 if (IS_ERR(phydev)) { ··· 778 778 } 779 779 780 780 pr_info("%s: attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n", 781 - dev->name, phydev->drv->name, phydev->dev.bus_id, phydev->irq); 781 + dev->name, phydev->drv->name, 782 + dev_name(&phydev->dev), phydev->irq); 782 783 783 784 /* mask with MAC supported features */ 784 785 phydev->supported &= (PHY_BASIC_FEATURES | SUPPORTED_Pause | ··· 1550 1549 { 1551 1550 strlcpy(info->driver, SMSC_CHIPNAME, sizeof(info->driver)); 1552 1551 strlcpy(info->version, SMSC_DRV_VERSION, sizeof(info->version)); 1553 - strlcpy(info->bus_info, dev->dev.parent->bus_id, 1552 + strlcpy(info->bus_info, dev_name(dev->dev.parent), 1554 1553 sizeof(info->bus_info)); 1555 1554 } 1556 1555
+2 -2
drivers/net/smsc9420.c
··· 1160 1160 smsc_info(PROBE, "PHY addr %d, phy_id 0x%08X", phydev->addr, 1161 1161 phydev->phy_id); 1162 1162 1163 - phydev = phy_connect(dev, phydev->dev.bus_id, 1163 + phydev = phy_connect(dev, dev_name(&phydev->dev), 1164 1164 &smsc9420_phy_adjust_link, 0, PHY_INTERFACE_MODE_MII); 1165 1165 1166 1166 if (IS_ERR(phydev)) { ··· 1169 1169 } 1170 1170 1171 1171 pr_info("%s: attached PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n", 1172 - dev->name, phydev->drv->name, phydev->dev.bus_id, phydev->irq); 1172 + dev->name, phydev->drv->name, dev_name(&phydev->dev), phydev->irq); 1173 1173 1174 1174 /* mask with MAC supported features */ 1175 1175 phydev->supported &= (PHY_BASIC_FEATURES | SUPPORTED_Pause |
+2 -2
drivers/net/tc35815.c
··· 725 725 } 726 726 727 727 /* attach the mac to the phy */ 728 - phydev = phy_connect(dev, phydev->dev.bus_id, 728 + phydev = phy_connect(dev, dev_name(&phydev->dev), 729 729 &tc_handle_link_change, 0, 730 730 lp->chiptype == TC35815_TX4939 ? 731 731 PHY_INTERFACE_MODE_RMII : PHY_INTERFACE_MODE_MII); ··· 735 735 } 736 736 printk(KERN_INFO "%s: attached PHY driver [%s] " 737 737 "(mii_bus:phy_addr=%s, id=%x)\n", 738 - dev->name, phydev->drv->name, phydev->dev.bus_id, 738 + dev->name, phydev->drv->name, dev_name(&phydev->dev), 739 739 phydev->phy_id); 740 740 741 741 /* mask with MAC supported features */
+1 -1
drivers/net/wimax/i2400m/driver.c
··· 613 613 d_fnstart(3, dev, "(i2400m %p)\n", i2400m); 614 614 615 615 snprintf(wimax_dev->name, sizeof(wimax_dev->name), 616 - "i2400m-%s:%s", dev->bus->name, dev->bus_id); 616 + "i2400m-%s:%s", dev->bus->name, dev_name(dev)); 617 617 618 618 i2400m->bm_cmd_buf = kzalloc(I2400M_BM_CMD_BUF_SIZE, GFP_KERNEL); 619 619 if (i2400m->bm_cmd_buf == NULL) {
+1 -1
drivers/net/wimax/i2400m/usb-notif.c
··· 102 102 dev_err(dev, "HW BUG? Unknown/unexpected data in notification " 103 103 "message (%zu bytes)\n", buf_len); 104 104 snprintf(prefix, sizeof(prefix), "%s %s: ", 105 - dev_driver_string(dev) , dev->bus_id); 105 + dev_driver_string(dev) , dev_name(dev)); 106 106 if (buf_len > 64) { 107 107 print_hex_dump(KERN_ERR, prefix, DUMP_PREFIX_OFFSET, 108 108 8, 4, buf, 64, 0);
+1 -1
drivers/net/xtsonic.c
··· 183 183 184 184 if (lp->descriptors == NULL) { 185 185 printk(KERN_ERR "%s: couldn't alloc DMA memory for " 186 - " descriptors.\n", lp->device->bus_id); 186 + " descriptors.\n", dev_name(lp->device)); 187 187 goto out; 188 188 } 189 189
+2 -1
drivers/pci/hotplug/cpqphp_sysfs.c
··· 225 225 226 226 void cpqhp_create_debugfs_files(struct controller *ctrl) 227 227 { 228 - ctrl->dentry = debugfs_create_file(ctrl->pci_dev->dev.bus_id, S_IRUGO, root, ctrl, &debug_ops); 228 + ctrl->dentry = debugfs_create_file(dev_name(&ctrl->pci_dev->dev), 229 + S_IRUGO, root, ctrl, &debug_ops); 229 230 } 230 231 231 232 void cpqhp_remove_debugfs_files(struct controller *ctrl)
+24 -13
drivers/pcmcia/au1000_generic.c
··· 468 468 return ret; 469 469 } 470 470 471 - int au1x00_drv_pcmcia_remove(struct device *dev) 471 + int au1x00_drv_pcmcia_remove(struct platform_device *dev) 472 472 { 473 - struct skt_dev_info *sinfo = dev_get_drvdata(dev); 473 + struct skt_dev_info *sinfo = platform_get_drvdata(dev); 474 474 int i; 475 475 476 476 mutex_lock(&pcmcia_sockets_lock); 477 - dev_set_drvdata(dev, NULL); 477 + platform_set_drvdata(dev, NULL); 478 478 479 479 for (i = 0; i < sinfo->nskt; i++) { 480 480 struct au1000_pcmcia_socket *skt = PCMCIA_SOCKET(i); ··· 498 498 * PCMCIA "Driver" API 499 499 */ 500 500 501 - static int au1x00_drv_pcmcia_probe(struct device *dev) 501 + static int au1x00_drv_pcmcia_probe(struct platform_device *dev) 502 502 { 503 503 int i, ret = -ENODEV; 504 504 505 505 mutex_lock(&pcmcia_sockets_lock); 506 506 for (i=0; i < ARRAY_SIZE(au1x00_pcmcia_hw_init); i++) { 507 - ret = au1x00_pcmcia_hw_init[i](dev); 507 + ret = au1x00_pcmcia_hw_init[i](&dev->dev); 508 508 if (ret == 0) 509 509 break; 510 510 } ··· 512 512 return ret; 513 513 } 514 514 515 + static int au1x00_drv_pcmcia_suspend(struct platform_device *dev, 516 + pm_message_t state) 517 + { 518 + return pcmcia_socket_dev_suspend(&dev->dev, state); 519 + } 515 520 516 - static struct device_driver au1x00_pcmcia_driver = { 521 + static int au1x00_drv_pcmcia_resume(struct platform_device *dev) 522 + { 523 + return pcmcia_socket_dev_resume(&dev->dev); 524 + } 525 + 526 + static struct platform_driver au1x00_pcmcia_driver = { 527 + .driver = { 528 + .name = "au1x00-pcmcia", 529 + .owner = THIS_MODULE, 530 + }, 517 531 .probe = au1x00_drv_pcmcia_probe, 518 532 .remove = au1x00_drv_pcmcia_remove, 519 - .name = "au1x00-pcmcia", 520 - .bus = &platform_bus_type, 521 - .suspend = pcmcia_socket_dev_suspend, 522 - .resume = pcmcia_socket_dev_resume, 533 + .suspend = au1x00_drv_pcmcia_suspend, 534 + .resume = au1x00_drv_pcmcia_resume, 523 535 }; 524 536 525 537 ··· 545 533 static int __init au1x00_pcmcia_init(void) 546 534 { 547 535 int error = 0; 548 - if ((error = driver_register(&au1x00_pcmcia_driver))) 549 - return error; 536 + error = platform_driver_register(&au1x00_pcmcia_driver); 550 537 return error; 551 538 } 552 539 ··· 555 544 */ 556 545 static void __exit au1x00_pcmcia_exit(void) 557 546 { 558 - driver_unregister(&au1x00_pcmcia_driver); 547 + platform_driver_unregister(&au1x00_pcmcia_driver); 559 548 } 560 549 561 550 module_init(au1x00_pcmcia_init);
+20 -8
drivers/pcmcia/i82365.c
··· 1238 1238 return 0; 1239 1239 } 1240 1240 1241 + static int i82365_drv_pcmcia_suspend(struct platform_device *dev, 1242 + pm_message_t state) 1243 + { 1244 + return pcmcia_socket_dev_suspend(&dev->dev, state); 1245 + } 1246 + 1247 + static int i82365_drv_pcmcia_resume(struct platform_device *dev) 1248 + { 1249 + return pcmcia_socket_dev_resume(&dev->dev); 1250 + } 1241 1251 static struct pccard_operations pcic_operations = { 1242 1252 .init = pcic_init, 1243 1253 .get_status = pcic_get_status, ··· 1258 1248 1259 1249 /*====================================================================*/ 1260 1250 1261 - static struct device_driver i82365_driver = { 1262 - .name = "i82365", 1263 - .bus = &platform_bus_type, 1264 - .suspend = pcmcia_socket_dev_suspend, 1265 - .resume = pcmcia_socket_dev_resume, 1251 + static struct platform_driver i82365_driver = { 1252 + .driver = { 1253 + .name = "i82365", 1254 + .owner = THIS_MODULE, 1255 + }, 1256 + .suspend = i82365_drv_pcmcia_suspend, 1257 + .resume = i82365_drv_pcmcia_resume, 1266 1258 }; 1267 1259 1268 1260 static struct platform_device *i82365_device; ··· 1273 1261 { 1274 1262 int i, ret; 1275 1263 1276 - ret = driver_register(&i82365_driver); 1264 + ret = platform_driver_register(&i82365_driver); 1277 1265 if (ret) 1278 1266 goto err_out; 1279 1267 ··· 1349 1337 pnp_disable_dev(i82365_pnpdev); 1350 1338 #endif 1351 1339 err_driver_unregister: 1352 - driver_unregister(&i82365_driver); 1340 + platform_driver_unregister(&i82365_driver); 1353 1341 err_out: 1354 1342 return ret; 1355 1343 } /* init_i82365 */ ··· 1377 1365 if (i82365_pnpdev) 1378 1366 pnp_disable_dev(i82365_pnpdev); 1379 1367 #endif 1380 - driver_unregister(&i82365_driver); 1368 + platform_driver_unregister(&i82365_driver); 1381 1369 } /* exit_i82365 */ 1382 1370 1383 1371 module_init(init_i82365);
+21 -9
drivers/pcmcia/m32r_cfc.c
··· 696 696 .set_mem_map = pcc_set_mem_map, 697 697 }; 698 698 699 + static int cfc_drv_pcmcia_suspend(struct platform_device *dev, 700 + pm_message_t state) 701 + { 702 + return pcmcia_socket_dev_suspend(&dev->dev, state); 703 + } 704 + 705 + static int cfc_drv_pcmcia_resume(struct platform_device *dev) 706 + { 707 + return pcmcia_socket_dev_resume(&dev->dev); 708 + } 699 709 /*====================================================================*/ 700 710 701 - static struct device_driver pcc_driver = { 702 - .name = "cfc", 703 - .bus = &platform_bus_type, 704 - .suspend = pcmcia_socket_dev_suspend, 705 - .resume = pcmcia_socket_dev_resume, 711 + static struct platform_driver pcc_driver = { 712 + .driver = { 713 + .name = "cfc", 714 + .owner = THIS_MODULE, 715 + }, 716 + .suspend = cfc_drv_pcmcia_suspend, 717 + .resume = cfc_drv_pcmcia_resume, 706 718 }; 707 719 708 720 static struct platform_device pcc_device = { ··· 728 716 { 729 717 int i, ret; 730 718 731 - ret = driver_register(&pcc_driver); 719 + ret = platform_driver_register(&pcc_driver); 732 720 if (ret) 733 721 return ret; 734 722 735 723 ret = platform_device_register(&pcc_device); 736 724 if (ret){ 737 - driver_unregister(&pcc_driver); 725 + platform_driver_unregister(&pcc_driver); 738 726 return ret; 739 727 } 740 728 ··· 766 754 if (pcc_sockets == 0) { 767 755 printk("socket is not found.\n"); 768 756 platform_device_unregister(&pcc_device); 769 - driver_unregister(&pcc_driver); 757 + platform_driver_unregister(&pcc_driver); 770 758 return -ENODEV; 771 759 } 772 760 ··· 814 802 if (poll_interval != 0) 815 803 del_timer_sync(&poll_timer); 816 804 817 - driver_unregister(&pcc_driver); 805 + platform_driver_unregister(&pcc_driver); 818 806 } /* exit_m32r_pcc */ 819 807 820 808 module_init(init_m32r_pcc);
+21 -9
drivers/pcmcia/m32r_pcc.c
··· 672 672 .set_mem_map = pcc_set_mem_map, 673 673 }; 674 674 675 + static int pcc_drv_pcmcia_suspend(struct platform_device *dev, 676 + pm_message_t state) 677 + { 678 + return pcmcia_socket_dev_suspend(&dev->dev, state); 679 + } 680 + 681 + static int pcc_drv_pcmcia_resume(struct platform_device *dev) 682 + { 683 + return pcmcia_socket_dev_resume(&dev->dev); 684 + } 675 685 /*====================================================================*/ 676 686 677 - static struct device_driver pcc_driver = { 678 - .name = "pcc", 679 - .bus = &platform_bus_type, 680 - .suspend = pcmcia_socket_dev_suspend, 681 - .resume = pcmcia_socket_dev_resume, 687 + static struct platform_driver pcc_driver = { 688 + .driver = { 689 + .name = "pcc", 690 + .owner = THIS_MODULE, 691 + }, 692 + .suspend = pcc_drv_pcmcia_suspend, 693 + .resume = pcc_drv_pcmcia_resume, 682 694 }; 683 695 684 696 static struct platform_device pcc_device = { ··· 704 692 { 705 693 int i, ret; 706 694 707 - ret = driver_register(&pcc_driver); 695 + ret = platform_driver_register(&pcc_driver); 708 696 if (ret) 709 697 return ret; 710 698 711 699 ret = platform_device_register(&pcc_device); 712 700 if (ret){ 713 - driver_unregister(&pcc_driver); 701 + platform_driver_unregister(&pcc_driver); 714 702 return ret; 715 703 } 716 704 ··· 727 715 if (pcc_sockets == 0) { 728 716 printk("socket is not found.\n"); 729 717 platform_device_unregister(&pcc_device); 730 - driver_unregister(&pcc_driver); 718 + platform_driver_unregister(&pcc_driver); 731 719 return -ENODEV; 732 720 } 733 721 ··· 775 763 if (poll_interval != 0) 776 764 del_timer_sync(&poll_timer); 777 765 778 - driver_unregister(&pcc_driver); 766 + platform_driver_unregister(&pcc_driver); 779 767 } /* exit_m32r_pcc */ 780 768 781 769 module_init(init_m32r_pcc);
+1 -1
drivers/pcmcia/rsrc_mgr.c
··· 153 153 unsigned long align, struct pcmcia_socket *s) 154 154 { 155 155 struct resource *res = make_resource(0, num, IORESOURCE_IO, 156 - s->dev.bus_id); 156 + dev_name(&s->dev)); 157 157 struct pcmcia_align_data data; 158 158 unsigned long min = base; 159 159 int ret;
+28 -10
drivers/pcmcia/sa1100_generic.c
··· 65 65 #endif 66 66 }; 67 67 68 - static int sa11x0_drv_pcmcia_probe(struct device *dev) 68 + static int sa11x0_drv_pcmcia_probe(struct platform_device *dev) 69 69 { 70 70 int i, ret = -ENODEV; 71 71 ··· 73 73 * Initialise any "on-board" PCMCIA sockets. 74 74 */ 75 75 for (i = 0; i < ARRAY_SIZE(sa11x0_pcmcia_hw_init); i++) { 76 - ret = sa11x0_pcmcia_hw_init[i](dev); 76 + ret = sa11x0_pcmcia_hw_init[i](&dev->dev); 77 77 if (ret == 0) 78 78 break; 79 79 } ··· 81 81 return ret; 82 82 } 83 83 84 - static struct device_driver sa11x0_pcmcia_driver = { 84 + static int sa11x0_drv_pcmcia_remove(struct platform_device *dev) 85 + { 86 + return soc_common_drv_pcmcia_remove(&dev->dev); 87 + } 88 + 89 + static int sa11x0_drv_pcmcia_suspend(struct platform_device *dev, 90 + pm_message_t state) 91 + { 92 + return pcmcia_socket_dev_suspend(&dev->dev, state); 93 + } 94 + 95 + static int sa11x0_drv_pcmcia_resume(struct platform_device *dev) 96 + { 97 + return pcmcia_socket_dev_resume(&dev->dev); 98 + } 99 + 100 + static struct platform_driver sa11x0_pcmcia_driver = { 101 + .driver = { 102 + .name = "sa11x0-pcmcia", 103 + .owner = THIS_MODULE, 104 + }, 85 105 .probe = sa11x0_drv_pcmcia_probe, 86 - .remove = soc_common_drv_pcmcia_remove, 87 - .name = "sa11x0-pcmcia", 88 - .bus = &platform_bus_type, 89 - .suspend = pcmcia_socket_dev_suspend, 90 - .resume = pcmcia_socket_dev_resume, 106 + .remove = sa11x0_drv_pcmcia_remove, 107 + .suspend = sa11x0_drv_pcmcia_suspend, 108 + .resume = sa11x0_drv_pcmcia_resume, 91 109 }; 92 110 93 111 /* sa11x0_pcmcia_init() ··· 118 100 */ 119 101 static int __init sa11x0_pcmcia_init(void) 120 102 { 121 - return driver_register(&sa11x0_pcmcia_driver); 103 + return platform_driver_register(&sa11x0_pcmcia_driver); 122 104 } 123 105 124 106 /* sa11x0_pcmcia_exit() ··· 128 110 */ 129 111 static void __exit sa11x0_pcmcia_exit(void) 130 112 { 131 - driver_unregister(&sa11x0_pcmcia_driver); 113 + platform_driver_unregister(&sa11x0_pcmcia_driver); 132 114 } 133 115 134 116 MODULE_AUTHOR("John Dorsey <john+@cs.cmu.edu>");
+21 -9
drivers/pcmcia/tcic.c
··· 363 363 return id; 364 364 } 365 365 366 + static int tcic_drv_pcmcia_suspend(struct platform_device *dev, 367 + pm_message_t state) 368 + { 369 + return pcmcia_socket_dev_suspend(&dev->dev, state); 370 + } 371 + 372 + static int tcic_drv_pcmcia_resume(struct platform_device *dev) 373 + { 374 + return pcmcia_socket_dev_resume(&dev->dev); 375 + } 366 376 /*====================================================================*/ 367 377 368 - static struct device_driver tcic_driver = { 369 - .name = "tcic-pcmcia", 370 - .bus = &platform_bus_type, 371 - .suspend = pcmcia_socket_dev_suspend, 372 - .resume = pcmcia_socket_dev_resume, 378 + static struct platform_driver tcic_driver = { 379 + .driver = { 380 + .name = "tcic-pcmcia", 381 + .owner = THIS_MODULE, 382 + }, 383 + .suspend = tcic_drv_pcmcia_suspend, 384 + .resume = tcic_drv_pcmcia_resume, 373 385 }; 374 386 375 387 static struct platform_device tcic_device = { ··· 395 383 int i, sock, ret = 0; 396 384 u_int mask, scan; 397 385 398 - if (driver_register(&tcic_driver)) 386 + if (platform_driver_register(&tcic_driver)) 399 387 return -1; 400 388 401 389 printk(KERN_INFO "Databook TCIC-2 PCMCIA probe: "); ··· 403 391 404 392 if (!request_region(tcic_base, 16, "tcic-2")) { 405 393 printk("could not allocate ports,\n "); 406 - driver_unregister(&tcic_driver); 394 + platform_driver_unregister(&tcic_driver); 407 395 return -ENODEV; 408 396 } 409 397 else { ··· 426 414 if (sock == 0) { 427 415 printk("not found.\n"); 428 416 release_region(tcic_base, 16); 429 - driver_unregister(&tcic_driver); 417 + platform_driver_unregister(&tcic_driver); 430 418 return -ENODEV; 431 419 } 432 420 ··· 554 542 } 555 543 556 544 platform_device_unregister(&tcic_device); 557 - driver_unregister(&tcic_driver); 545 + platform_driver_unregister(&tcic_driver); 558 546 } /* exit_tcic */ 559 547 560 548 /*====================================================================*/
+24 -10
drivers/pcmcia/vrc4171_card.c
··· 704 704 705 705 __setup("vrc4171_card=", vrc4171_card_setup); 706 706 707 - static struct device_driver vrc4171_card_driver = { 708 - .name = vrc4171_card_name, 709 - .bus = &platform_bus_type, 710 - .suspend = pcmcia_socket_dev_suspend, 711 - .resume = pcmcia_socket_dev_resume, 707 + static int vrc4171_card_suspend(struct platform_device *dev, 708 + pm_message_t state) 709 + { 710 + return pcmcia_socket_dev_suspend(&dev->dev, state); 711 + } 712 + 713 + static int vrc4171_card_resume(struct platform_device *dev) 714 + { 715 + return pcmcia_socket_dev_resume(&dev->dev); 716 + } 717 + 718 + static struct platform_driver vrc4171_card_driver = { 719 + .driver = { 720 + .name = vrc4171_card_name, 721 + .owner = THIS_MODULE, 722 + }, 723 + .suspend = vrc4171_card_suspend, 724 + .resume = vrc4171_card_resume, 712 725 }; 713 726 714 727 static int __devinit vrc4171_card_init(void) 715 728 { 716 729 int retval; 717 730 718 - retval = driver_register(&vrc4171_card_driver); 731 + retval = platform_driver_register(&vrc4171_card_driver); 719 732 if (retval < 0) 720 733 return retval; 721 734 722 735 retval = platform_device_register(&vrc4171_card_device); 723 736 if (retval < 0) { 724 - driver_unregister(&vrc4171_card_driver); 737 + platform_driver_unregister(&vrc4171_card_driver); 725 738 return retval; 726 739 } 727 740 ··· 748 735 if (retval < 0) { 749 736 vrc4171_remove_sockets(); 750 737 platform_device_unregister(&vrc4171_card_device); 751 - driver_unregister(&vrc4171_card_driver); 738 + platform_driver_unregister(&vrc4171_card_driver); 752 739 return retval; 753 740 } 754 741 755 - printk(KERN_INFO "%s, connected to IRQ %d\n", vrc4171_card_driver.name, vrc4171_irq); 742 + printk(KERN_INFO "%s, connected to IRQ %d\n", 743 + vrc4171_card_driver.driver.name, vrc4171_irq); 756 744 757 745 return 0; 758 746 } ··· 763 749 free_irq(vrc4171_irq, vrc4171_sockets); 764 750 vrc4171_remove_sockets(); 765 751 platform_device_unregister(&vrc4171_card_device); 766 - driver_unregister(&vrc4171_card_driver); 752 + platform_driver_unregister(&vrc4171_card_driver); 767 753 } 768 754 769 755 module_init(vrc4171_card_init);
+1 -1
drivers/rapidio/rio-driver.c
··· 193 193 } 194 194 195 195 static struct device rio_bus = { 196 - .bus_id = "rapidio", 196 + .init_name = "rapidio", 197 197 }; 198 198 199 199 struct bus_type rio_bus_type = {
+2 -2
drivers/rtc/rtc-at91sam9.c
··· 351 351 /* register irq handler after we know what name we'll use */ 352 352 ret = request_irq(AT91_ID_SYS, at91_rtc_interrupt, 353 353 IRQF_DISABLED | IRQF_SHARED, 354 - rtc->rtcdev->dev.bus_id, rtc); 354 + dev_name(&rtc->rtcdev->dev), rtc); 355 355 if (ret) { 356 356 dev_dbg(&pdev->dev, "can't share IRQ %d?\n", AT91_ID_SYS); 357 357 rtc_device_unregister(rtc->rtcdev); ··· 366 366 367 367 if (gpbr_readl(rtc) == 0) 368 368 dev_warn(&pdev->dev, "%s: SET TIME!\n", 369 - rtc->rtcdev->dev.bus_id); 369 + dev_name(&rtc->rtcdev->dev)); 370 370 371 371 return 0; 372 372
+2 -2
drivers/rtc/rtc-omap.c
··· 377 377 378 378 /* handle periodic and alarm irqs */ 379 379 if (request_irq(omap_rtc_timer, rtc_irq, IRQF_DISABLED, 380 - rtc->dev.bus_id, rtc)) { 380 + dev_name(&rtc->dev), rtc)) { 381 381 pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n", 382 382 pdev->name, omap_rtc_timer); 383 383 goto fail0; 384 384 } 385 385 if (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED, 386 - rtc->dev.bus_id, rtc)) { 386 + dev_name(&rtc->dev), rtc)) { 387 387 pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n", 388 388 pdev->name, omap_rtc_alarm); 389 389 goto fail1;
+1 -1
drivers/rtc/rtc-twl4030.c
··· 426 426 427 427 ret = request_irq(irq, twl4030_rtc_interrupt, 428 428 IRQF_TRIGGER_RISING, 429 - rtc->dev.bus_id, rtc); 429 + dev_name(&rtc->dev), rtc); 430 430 if (ret < 0) { 431 431 dev_err(&pdev->dev, "IRQ is not free.\n"); 432 432 goto out1;
+3 -2
drivers/s390/cio/ccwgroup.c
··· 104 104 rc = device_schedule_callback(dev, ccwgroup_ungroup_callback); 105 105 out: 106 106 if (rc) { 107 - /* Release onoff "lock" when ungrouping failed. */ 108 - atomic_set(&gdev->onoff, 0); 107 + if (rc != -EAGAIN) 108 + /* Release onoff "lock" when ungrouping failed. */ 109 + atomic_set(&gdev->onoff, 0); 109 110 return rc; 110 111 } 111 112 return count;
+2 -2
drivers/s390/cio/chsc_sch.c
··· 84 84 kfree(private); 85 85 } else { 86 86 sch->private = private; 87 - if (sch->dev.uevent_suppress) { 88 - sch->dev.uevent_suppress = 0; 87 + if (dev_get_uevent_suppress(&sch->dev)) { 88 + dev_set_uevent_suppress(&sch->dev, 0); 89 89 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 90 90 } 91 91 }
+2 -2
drivers/s390/cio/css.c
··· 272 272 * the subchannel driver can decide itself when it wants to inform 273 273 * userspace of its existence. 274 274 */ 275 - sch->dev.uevent_suppress = 1; 275 + dev_set_uevent_suppress(&sch->dev, 1); 276 276 css_update_ssd_info(sch); 277 277 /* make it known to the system */ 278 278 ret = css_sch_device_register(sch); ··· 287 287 * a fitting driver module may be loaded based on the 288 288 * modalias. 289 289 */ 290 - sch->dev.uevent_suppress = 0; 290 + dev_set_uevent_suppress(&sch->dev, 0); 291 291 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 292 292 } 293 293 return ret;
+7 -6
drivers/s390/cio/device.c
··· 799 799 return; 800 800 other_sch = to_subchannel(cdev->dev.parent); 801 801 /* Note: device_move() changes cdev->dev.parent */ 802 - ret = device_move(&cdev->dev, &sch->dev); 802 + ret = device_move(&cdev->dev, &sch->dev, DPM_ORDER_PARENT_BEFORE_DEV); 803 803 if (ret) { 804 804 CIO_MSG_EVENT(0, "Moving disconnected device 0.%x.%04x failed " 805 805 "(ret=%d)!\n", cdev->private->dev_id.ssid, ··· 830 830 * Try to move the ccw device to its new subchannel. 831 831 * Note: device_move() changes cdev->dev.parent 832 832 */ 833 - ret = device_move(&cdev->dev, &sch->dev); 833 + ret = device_move(&cdev->dev, &sch->dev, DPM_ORDER_PARENT_BEFORE_DEV); 834 834 if (ret) { 835 835 CIO_MSG_EVENT(0, "Moving device 0.%x.%04x from orphanage " 836 836 "failed (ret=%d)!\n", ··· 897 897 * ccw device can take its place on the subchannel. 898 898 * Note: device_move() changes cdev->dev.parent 899 899 */ 900 - ret = device_move(&cdev->dev, &css->pseudo_subchannel->dev); 900 + ret = device_move(&cdev->dev, &css->pseudo_subchannel->dev, 901 + DPM_ORDER_NONE); 901 902 if (ret) { 902 903 CIO_MSG_EVENT(0, "Moving device 0.%x.%04x to orphanage failed " 903 904 "(ret=%d)!\n", cdev->private->dev_id.ssid, ··· 982 981 * Now we know this subchannel will stay, we can throw 983 982 * our delayed uevent. 984 983 */ 985 - sch->dev.uevent_suppress = 0; 984 + dev_set_uevent_suppress(&sch->dev, 0); 986 985 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 987 986 /* make it known to the system */ 988 987 ret = ccw_device_register(cdev); ··· 1130 1129 * Try to move the ccw device to its new subchannel. 1131 1130 * Note: device_move() changes cdev->dev.parent 1132 1131 */ 1133 - rc = device_move(&cdev->dev, &sch->dev); 1132 + rc = device_move(&cdev->dev, &sch->dev, DPM_ORDER_PARENT_BEFORE_DEV); 1134 1133 mutex_unlock(&sch->reg_mutex); 1135 1134 if (rc) { 1136 1135 CIO_MSG_EVENT(0, "Moving device 0.%x.%04x to subchannel " ··· 1244 1243 * the ccw_device and exit. This happens for all early 1245 1244 * devices, e.g. the console. 1246 1245 */ 1247 - sch->dev.uevent_suppress = 0; 1246 + dev_set_uevent_suppress(&sch->dev, 0); 1248 1247 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 1249 1248 cdev->dev.groups = ccwdev_attr_groups; 1250 1249 device_initialize(&cdev->dev);
+1 -1
drivers/s390/net/qeth_l3_main.c
··· 1038 1038 rc = qeth_query_setadapterparms(card); 1039 1039 if (rc) { 1040 1040 QETH_DBF_MESSAGE(2, "%s couldn't set adapter parameters: " 1041 - "0x%x\n", card->gdev->dev.bus_id, rc); 1041 + "0x%x\n", dev_name(&card->gdev->dev), rc); 1042 1042 return rc; 1043 1043 } 1044 1044 if (qeth_adp_supported(card, IPA_SETADP_ALTER_MAC_ADDRESS)) {
+16 -13
drivers/scsi/a4000t.c
··· 35 35 36 36 #define A4000T_SCSI_ADDR 0xdd0040 37 37 38 - static int __devinit a4000t_probe(struct device *dev) 38 + static int __devinit a4000t_probe(struct platform_device *dev) 39 39 { 40 40 struct Scsi_Host *host; 41 41 struct NCR_700_Host_Parameters *hostdata; ··· 61 61 hostdata->dcntl_extra = EA_710; 62 62 63 63 /* and register the chip */ 64 - host = NCR_700_detect(&a4000t_scsi_driver_template, hostdata, dev); 64 + host = NCR_700_detect(&a4000t_scsi_driver_template, hostdata, 65 + &dev->dev); 65 66 if (!host) { 66 67 printk(KERN_ERR "a4000t-scsi: No host detected; " 67 68 "board configuration problem?\n"); ··· 79 78 goto out_put_host; 80 79 } 81 80 82 - dev_set_drvdata(dev, host); 81 + platform_set_drvdata(dev, host); 83 82 scsi_scan_host(host); 84 83 85 84 return 0; ··· 94 93 return -ENODEV; 95 94 } 96 95 97 - static __devexit int a4000t_device_remove(struct device *dev) 96 + static __devexit int a4000t_device_remove(struct platform_device *dev) 98 97 { 99 - struct Scsi_Host *host = dev_get_drvdata(dev); 98 + struct Scsi_Host *host = platform_get_drvdata(dev); 100 99 struct NCR_700_Host_Parameters *hostdata = shost_priv(host); 101 100 102 101 scsi_remove_host(host); ··· 109 108 return 0; 110 109 } 111 110 112 - static struct device_driver a4000t_scsi_driver = { 113 - .name = "a4000t-scsi", 114 - .bus = &platform_bus_type, 115 - .probe = a4000t_probe, 116 - .remove = __devexit_p(a4000t_device_remove), 111 + static struct platform_driver a4000t_scsi_driver = { 112 + .driver = { 113 + .name = "a4000t-scsi", 114 + .owner = THIS_MODULE, 115 + }, 116 + .probe = a4000t_probe, 117 + .remove = __devexit_p(a4000t_device_remove), 117 118 }; 118 119 119 120 static int __init a4000t_scsi_init(void) 120 121 { 121 122 int err; 122 123 123 - err = driver_register(&a4000t_scsi_driver); 124 + err = platform_driver_register(&a4000t_scsi_driver); 124 125 if (err) 125 126 return err; 126 127 127 128 a4000t_scsi_device = platform_device_register_simple("a4000t-scsi", 128 129 -1, NULL, 0); 129 130 if (IS_ERR(a4000t_scsi_device)) { 130 - driver_unregister(&a4000t_scsi_driver); 131 + platform_driver_register(&a4000t_scsi_driver); 131 132 return PTR_ERR(a4000t_scsi_device); 132 133 } 133 134 ··· 139 136 static void __exit a4000t_scsi_exit(void) 140 137 { 141 138 platform_device_unregister(a4000t_scsi_device); 142 - driver_unregister(&a4000t_scsi_driver); 139 + platform_driver_unregister(&a4000t_scsi_driver); 143 140 } 144 141 145 142 module_init(a4000t_scsi_init);
+16 -13
drivers/scsi/bvme6000_scsi.c
··· 34 34 static struct platform_device *bvme6000_scsi_device; 35 35 36 36 static __devinit int 37 - bvme6000_probe(struct device *dev) 37 + bvme6000_probe(struct platform_device *dev) 38 38 { 39 39 struct Scsi_Host *host; 40 40 struct NCR_700_Host_Parameters *hostdata; ··· 58 58 hostdata->ctest7_extra = CTEST7_TT1; 59 59 60 60 /* and register the chip */ 61 - host = NCR_700_detect(&bvme6000_scsi_driver_template, hostdata, dev); 61 + host = NCR_700_detect(&bvme6000_scsi_driver_template, hostdata, 62 + &dev->dev); 62 63 if (!host) { 63 64 printk(KERN_ERR "bvme6000-scsi: No host detected; " 64 65 "board configuration problem?\n"); ··· 74 73 goto out_put_host; 75 74 } 76 75 77 - dev_set_drvdata(dev, host); 76 + platform_set_drvdata(dev, host); 78 77 scsi_scan_host(host); 79 78 80 79 return 0; ··· 88 87 } 89 88 90 89 static __devexit int 91 - bvme6000_device_remove(struct device *dev) 90 + bvme6000_device_remove(struct platform_device *dev) 92 91 { 93 - struct Scsi_Host *host = dev_get_drvdata(dev); 92 + struct Scsi_Host *host = platform_get_drvdata(dev); 94 93 struct NCR_700_Host_Parameters *hostdata = shost_priv(host); 95 94 96 95 scsi_remove_host(host); ··· 101 100 return 0; 102 101 } 103 102 104 - static struct device_driver bvme6000_scsi_driver = { 105 - .name = "bvme6000-scsi", 106 - .bus = &platform_bus_type, 107 - .probe = bvme6000_probe, 108 - .remove = __devexit_p(bvme6000_device_remove), 103 + static struct platform_driver bvme6000_scsi_driver = { 104 + .driver = { 105 + .name = "bvme6000-scsi", 106 + .owner = THIS_MODULE, 107 + }, 108 + .probe = bvme6000_probe, 109 + .remove = __devexit_p(bvme6000_device_remove), 109 110 }; 110 111 111 112 static int __init bvme6000_scsi_init(void) 112 113 { 113 114 int err; 114 115 115 - err = driver_register(&bvme6000_scsi_driver); 116 + err = platform_driver_register(&bvme6000_scsi_driver); 116 117 if (err) 117 118 return err; 118 119 119 120 bvme6000_scsi_device = platform_device_register_simple("bvme6000-scsi", 120 121 -1, NULL, 0); 121 122 if (IS_ERR(bvme6000_scsi_device)) { 122 - driver_unregister(&bvme6000_scsi_driver); 123 + platform_driver_unregister(&bvme6000_scsi_driver); 123 124 return PTR_ERR(bvme6000_scsi_device); 124 125 } 125 126 ··· 131 128 static void __exit bvme6000_scsi_exit(void) 132 129 { 133 130 platform_device_unregister(bvme6000_scsi_device); 134 - driver_unregister(&bvme6000_scsi_driver); 131 + platform_driver_unregister(&bvme6000_scsi_driver); 135 132 } 136 133 137 134 module_init(bvme6000_scsi_init);
+16 -13
drivers/scsi/mvme16x_scsi.c
··· 34 34 static struct platform_device *mvme16x_scsi_device; 35 35 36 36 static __devinit int 37 - mvme16x_probe(struct device *dev) 37 + mvme16x_probe(struct platform_device *dev) 38 38 { 39 39 struct Scsi_Host * host = NULL; 40 40 struct NCR_700_Host_Parameters *hostdata; ··· 64 64 hostdata->ctest7_extra = CTEST7_TT1; 65 65 66 66 /* and register the chip */ 67 - host = NCR_700_detect(&mvme16x_scsi_driver_template, hostdata, dev); 67 + host = NCR_700_detect(&mvme16x_scsi_driver_template, hostdata, 68 + &dev->dev); 68 69 if (!host) { 69 70 printk(KERN_ERR "mvme16x-scsi: No host detected; " 70 71 "board configuration problem?\n"); ··· 89 88 out_be32(0xfff4202c, v); 90 89 } 91 90 92 - dev_set_drvdata(dev, host); 91 + platform_set_drvdata(dev, host); 93 92 scsi_scan_host(host); 94 93 95 94 return 0; ··· 103 102 } 104 103 105 104 static __devexit int 106 - mvme16x_device_remove(struct device *dev) 105 + mvme16x_device_remove(struct platform_device *dev) 107 106 { 108 - struct Scsi_Host *host = dev_get_drvdata(dev); 107 + struct Scsi_Host *host = platform_get_drvdata(dev); 109 108 struct NCR_700_Host_Parameters *hostdata = shost_priv(host); 110 109 111 110 /* Disable scsi chip ints */ ··· 124 123 return 0; 125 124 } 126 125 127 - static struct device_driver mvme16x_scsi_driver = { 128 - .name = "mvme16x-scsi", 129 - .bus = &platform_bus_type, 130 - .probe = mvme16x_probe, 131 - .remove = __devexit_p(mvme16x_device_remove), 126 + static struct platform_driver mvme16x_scsi_driver = { 127 + .driver = { 128 + .name = "mvme16x-scsi", 129 + .owner = THIS_MODULE, 130 + }, 131 + .probe = mvme16x_probe, 132 + .remove = __devexit_p(mvme16x_device_remove), 132 133 }; 133 134 134 135 static int __init mvme16x_scsi_init(void) 135 136 { 136 137 int err; 137 138 138 - err = driver_register(&mvme16x_scsi_driver); 139 + err = platform_driver_register(&mvme16x_scsi_driver); 139 140 if (err) 140 141 return err; 141 142 142 143 mvme16x_scsi_device = platform_device_register_simple("mvme16x-scsi", 143 144 -1, NULL, 0); 144 145 if (IS_ERR(mvme16x_scsi_device)) { 145 - driver_unregister(&mvme16x_scsi_driver); 146 + platform_driver_unregister(&mvme16x_scsi_driver); 146 147 return PTR_ERR(mvme16x_scsi_device); 147 148 } 148 149 ··· 154 151 static void __exit mvme16x_scsi_exit(void) 155 152 { 156 153 platform_device_unregister(mvme16x_scsi_device); 157 - driver_unregister(&mvme16x_scsi_driver); 154 + platform_driver_unregister(&mvme16x_scsi_driver); 158 155 } 159 156 160 157 module_init(mvme16x_scsi_init);
+2 -2
drivers/serial/sunzilog.c
··· 1438 1438 } else { 1439 1439 printk(KERN_INFO "%s: Keyboard at MMIO 0x%llx (irq = %d) " 1440 1440 "is a %s\n", 1441 - op->dev.bus_id, 1441 + dev_name(&op->dev), 1442 1442 (unsigned long long) up[0].port.mapbase, 1443 1443 op->irqs[0], sunzilog_type(&up[0].port)); 1444 1444 printk(KERN_INFO "%s: Mouse at MMIO 0x%llx (irq = %d) " 1445 1445 "is a %s\n", 1446 - op->dev.bus_id, 1446 + dev_name(&op->dev), 1447 1447 (unsigned long long) up[1].port.mapbase, 1448 1448 op->irqs[0], sunzilog_type(&up[1].port)); 1449 1449 kbm_inst++;
-1
drivers/sh/maple/maple.c
··· 379 379 dev_info(&mdev->dev, "no driver found\n"); 380 380 mdev->driver = &maple_unsupported_device; 381 381 } 382 - 383 382 dev_set_name(&mdev->dev, "%d:0%d.%lX", mdev->port, 384 383 mdev->unit, function); 385 384 }
+4 -4
drivers/spi/atmel_spi.c
··· 322 322 spi = msg->spi; 323 323 324 324 dev_dbg(master->dev.parent, "start message %p for %s\n", 325 - msg, spi->dev.bus_id); 325 + msg, dev_name(&spi->dev)); 326 326 327 327 /* select chip if it's not still active */ 328 328 if (as->stay) { ··· 627 627 if (!asd) 628 628 return -ENOMEM; 629 629 630 - ret = gpio_request(npcs_pin, spi->dev.bus_id); 630 + ret = gpio_request(npcs_pin, dev_name(&spi->dev)); 631 631 if (ret) { 632 632 kfree(asd); 633 633 return ret; ··· 668 668 as = spi_master_get_devdata(spi->master); 669 669 670 670 dev_dbg(controller, "new message %p submitted for %s\n", 671 - msg, spi->dev.bus_id); 671 + msg, dev_name(&spi->dev)); 672 672 673 673 if (unlikely(list_empty(&msg->transfers))) 674 674 return -EINVAL; ··· 803 803 as->clk = clk; 804 804 805 805 ret = request_irq(irq, atmel_spi_interrupt, 0, 806 - pdev->dev.bus_id, master); 806 + dev_name(&pdev->dev), master); 807 807 if (ret) 808 808 goto out_unmap_regs; 809 809
+1 -1
drivers/spi/mpc52xx_psc_spi.c
··· 429 429 INIT_LIST_HEAD(&mps->queue); 430 430 431 431 mps->workqueue = create_singlethread_workqueue( 432 - master->dev.parent->bus_id); 432 + dev_name(master->dev.parent)); 433 433 if (mps->workqueue == NULL) { 434 434 ret = -EBUSY; 435 435 goto free_irq;
+1 -1
drivers/spi/omap2_mcspi.c
··· 1003 1003 goto err1; 1004 1004 } 1005 1005 if (!request_mem_region(r->start, (r->end - r->start) + 1, 1006 - pdev->dev.bus_id)) { 1006 + dev_name(&pdev->dev))) { 1007 1007 status = -EBUSY; 1008 1008 goto err1; 1009 1009 }
+6 -6
drivers/spi/omap_uwire.c
··· 245 245 246 246 #ifdef VERBOSE 247 247 pr_debug("%s: write-%d =%04x\n", 248 - spi->dev.bus_id, bits, val); 248 + dev_name(&spi->dev), bits, val); 249 249 #endif 250 250 if (wait_uwire_csr_flag(CSRB, 0, 0)) 251 251 goto eio; ··· 305 305 status += bytes; 306 306 #ifdef VERBOSE 307 307 pr_debug("%s: read-%d =%04x\n", 308 - spi->dev.bus_id, bits, val); 308 + dev_name(&spi->dev), bits, val); 309 309 #endif 310 310 311 311 } ··· 331 331 uwire = spi_master_get_devdata(spi->master); 332 332 333 333 if (spi->chip_select > 3) { 334 - pr_debug("%s: cs%d?\n", spi->dev.bus_id, spi->chip_select); 334 + pr_debug("%s: cs%d?\n", dev_name(&spi->dev), spi->chip_select); 335 335 status = -ENODEV; 336 336 goto done; 337 337 } ··· 343 343 bits = 8; 344 344 345 345 if (bits > 16) { 346 - pr_debug("%s: wordsize %d?\n", spi->dev.bus_id, bits); 346 + pr_debug("%s: wordsize %d?\n", dev_name(&spi->dev), bits); 347 347 status = -ENODEV; 348 348 goto done; 349 349 } ··· 378 378 hz = t->speed_hz; 379 379 380 380 if (!hz) { 381 - pr_debug("%s: zero speed?\n", spi->dev.bus_id); 381 + pr_debug("%s: zero speed?\n", dev_name(&spi->dev)); 382 382 status = -EINVAL; 383 383 goto done; 384 384 } ··· 406 406 } 407 407 if (div1_idx == 4) { 408 408 pr_debug("%s: lowest clock %ld, need %d\n", 409 - spi->dev.bus_id, rate / 10 / 8, hz); 409 + dev_name(&spi->dev), rate / 10 / 8, hz); 410 410 status = -EDOM; 411 411 goto done; 412 412 }
+1 -1
drivers/spi/orion_spi.c
··· 496 496 } 497 497 498 498 if (!request_mem_region(r->start, (r->end - r->start) + 1, 499 - pdev->dev.bus_id)) { 499 + dev_name(&pdev->dev))) { 500 500 status = -EBUSY; 501 501 goto out; 502 502 }
+2 -2
drivers/spi/pxa2xx_spi.c
··· 1333 1333 1334 1334 INIT_WORK(&drv_data->pump_messages, pump_messages); 1335 1335 drv_data->workqueue = create_singlethread_workqueue( 1336 - drv_data->master->dev.parent->bus_id); 1336 + dev_name(drv_data->master->dev.parent)); 1337 1337 if (drv_data->workqueue == NULL) 1338 1338 return -EBUSY; 1339 1339 ··· 1462 1462 drv_data->mask_sr = SSSR_TINT | SSSR_RFS | SSSR_TFS | SSSR_ROR; 1463 1463 } 1464 1464 1465 - status = request_irq(ssp->irq, ssp_int, 0, dev->bus_id, drv_data); 1465 + status = request_irq(ssp->irq, ssp_int, 0, dev_name(dev), drv_data); 1466 1466 if (status < 0) { 1467 1467 dev_err(&pdev->dev, "cannot get IRQ %d\n", ssp->irq); 1468 1468 goto out_error_master_alloc;
+2 -2
drivers/spi/spi_bfin5xx.c
··· 1160 1160 1161 1161 /* init messages workqueue */ 1162 1162 INIT_WORK(&drv_data->pump_messages, pump_messages); 1163 - drv_data->workqueue = 1164 - create_singlethread_workqueue(drv_data->master->dev.parent->bus_id); 1163 + drv_data->workqueue = create_singlethread_workqueue( 1164 + dev_name(drv_data->master->dev.parent)); 1165 1165 if (drv_data->workqueue == NULL) 1166 1166 return -EBUSY; 1167 1167
+1 -1
drivers/spi/spi_gpio.c
··· 191 191 return -EINVAL; 192 192 193 193 if (!spi->controller_state) { 194 - status = gpio_request(cs, spi->dev.bus_id); 194 + status = gpio_request(cs, dev_name(&spi->dev)); 195 195 if (status) 196 196 return status; 197 197 status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
+3 -2
drivers/spi/spi_imx.c
··· 1381 1381 1382 1382 INIT_WORK(&drv_data->work, pump_messages); 1383 1383 drv_data->workqueue = create_singlethread_workqueue( 1384 - drv_data->master->dev.parent->bus_id); 1384 + dev_name(drv_data->master->dev.parent)); 1385 1385 if (drv_data->workqueue == NULL) 1386 1386 return -EBUSY; 1387 1387 ··· 1525 1525 status = -ENODEV; 1526 1526 goto err_no_irqres; 1527 1527 } 1528 - status = request_irq(irq, spi_int, IRQF_DISABLED, dev->bus_id, drv_data); 1528 + status = request_irq(irq, spi_int, IRQF_DISABLED, 1529 + dev_name(dev), drv_data); 1529 1530 if (status < 0) { 1530 1531 dev_err(&pdev->dev, "probe - cannot get IRQ (%d)\n", status); 1531 1532 goto err_no_irqres;
+2 -2
drivers/spi/spi_mpc83xx.c
··· 637 637 INIT_LIST_HEAD(&mpc83xx_spi->queue); 638 638 639 639 mpc83xx_spi->workqueue = create_singlethread_workqueue( 640 - master->dev.parent->bus_id); 640 + dev_name(master->dev.parent)); 641 641 if (mpc83xx_spi->workqueue == NULL) { 642 642 ret = -EBUSY; 643 643 goto free_irq; ··· 649 649 650 650 printk(KERN_INFO 651 651 "%s: MPC83xx SPI Controller driver at 0x%p (irq = %d)\n", 652 - dev->dev.bus_id, mpc83xx_spi->base, mpc83xx_spi->irq); 652 + dev_name(&dev->dev), mpc83xx_spi->base, mpc83xx_spi->irq); 653 653 654 654 return ret; 655 655
+2 -1
drivers/spi/spi_txx9.c
··· 404 404 if (ret) 405 405 goto exit; 406 406 407 - c->workqueue = create_singlethread_workqueue(master->dev.parent->bus_id); 407 + c->workqueue = create_singlethread_workqueue( 408 + dev_name(master->dev.parent)); 408 409 if (!c->workqueue) 409 410 goto exit_busy; 410 411 c->last_chipselect = -1;
+4 -4
drivers/tc/tc.c
··· 86 86 slot); 87 87 goto out_err; 88 88 } 89 - sprintf(tdev->dev.bus_id, "tc%x", slot); 89 + dev_set_name(&tdev->dev, "tc%x", slot); 90 90 tdev->bus = tbus; 91 91 tdev->dev.parent = &tbus->dev; 92 92 tdev->dev.bus = &tc_bus_type; ··· 104 104 tdev->vendor[8] = 0; 105 105 tdev->name[8] = 0; 106 106 107 - pr_info("%s: %s %s %s\n", tdev->dev.bus_id, tdev->vendor, 107 + pr_info("%s: %s %s %s\n", dev_name(&tdev->dev), tdev->vendor, 108 108 tdev->name, tdev->firmware); 109 109 110 110 devsize = readb(module + offset + TC_SLOT_SIZE); ··· 118 118 } else { 119 119 printk(KERN_ERR "%s: Cannot provide slot space " 120 120 "(%dMiB required, up to %dMiB supported)\n", 121 - tdev->dev.bus_id, devsize >> 20, 121 + dev_name(&tdev->dev), devsize >> 20, 122 122 max(slotsize, extslotsize) >> 20); 123 123 kfree(tdev); 124 124 goto out_err; ··· 146 146 return 0; 147 147 148 148 INIT_LIST_HEAD(&tc_bus.devices); 149 - strcpy(tc_bus.dev.bus_id, "tc"); 149 + dev_set_name(&tc_bus.dev, "tc"); 150 150 device_register(&tc_bus.dev); 151 151 152 152 if (tc_bus.info.slot_size) {
+18
drivers/uio/Kconfig
··· 58 58 59 59 If you compile this as a module, it will be called uio_smx. 60 60 61 + config UIO_AEC 62 + tristate "AEC video timestamp device" 63 + depends on PCI 64 + default n 65 + help 66 + 67 + UIO driver for the Adrienne Electronics Corporation PCI time 68 + code device. 69 + 70 + This device differs from other UIO devices since it uses I/O 71 + ports instead of memory mapped I/O. In order to make it 72 + possible for UIO to work with this device a utility, uioport, 73 + can be used to read and write the ports: 74 + 75 + git clone git://ifup.org/philips/uioport.git 76 + 77 + If you compile this as a module, it will be called uio_aec. 78 + 61 79 config UIO_SERCOS3 62 80 tristate "Automata Sercos III PCI card driver" 63 81 default n
+1
drivers/uio/Makefile
··· 3 3 obj-$(CONFIG_UIO_PDRV) += uio_pdrv.o 4 4 obj-$(CONFIG_UIO_PDRV_GENIRQ) += uio_pdrv_genirq.o 5 5 obj-$(CONFIG_UIO_SMX) += uio_smx.o 6 + obj-$(CONFIG_UIO_AEC) += uio_aec.o 6 7 obj-$(CONFIG_UIO_SERCOS3) += uio_sercos3.o
+24 -1
drivers/uio/uio.c
··· 61 61 }; 62 62 #define to_map(map) container_of(map, struct uio_map, kobj) 63 63 64 + static ssize_t map_name_show(struct uio_mem *mem, char *buf) 65 + { 66 + if (unlikely(!mem->name)) 67 + mem->name = ""; 68 + 69 + return sprintf(buf, "%s\n", mem->name); 70 + } 71 + 64 72 static ssize_t map_addr_show(struct uio_mem *mem, char *buf) 65 73 { 66 74 return sprintf(buf, "0x%lx\n", mem->addr); ··· 90 82 ssize_t (*store)(struct uio_mem *, const char *, size_t); 91 83 }; 92 84 85 + static struct map_sysfs_entry name_attribute = 86 + __ATTR(name, S_IRUGO, map_name_show, NULL); 93 87 static struct map_sysfs_entry addr_attribute = 94 88 __ATTR(addr, S_IRUGO, map_addr_show, NULL); 95 89 static struct map_sysfs_entry size_attribute = ··· 100 90 __ATTR(offset, S_IRUGO, map_offset_show, NULL); 101 91 102 92 static struct attribute *attrs[] = { 93 + &name_attribute.attr, 103 94 &addr_attribute.attr, 104 95 &size_attribute.attr, 105 96 &offset_attribute.attr, ··· 144 133 }; 145 134 #define to_portio(portio) container_of(portio, struct uio_portio, kobj) 146 135 136 + static ssize_t portio_name_show(struct uio_port *port, char *buf) 137 + { 138 + if (unlikely(!port->name)) 139 + port->name = ""; 140 + 141 + return sprintf(buf, "%s\n", port->name); 142 + } 143 + 147 144 static ssize_t portio_start_show(struct uio_port *port, char *buf) 148 145 { 149 146 return sprintf(buf, "0x%lx\n", port->start); ··· 178 159 ssize_t (*store)(struct uio_port *, const char *, size_t); 179 160 }; 180 161 162 + static struct portio_sysfs_entry portio_name_attribute = 163 + __ATTR(name, S_IRUGO, portio_name_show, NULL); 181 164 static struct portio_sysfs_entry portio_start_attribute = 182 165 __ATTR(start, S_IRUGO, portio_start_show, NULL); 183 166 static struct portio_sysfs_entry portio_size_attribute = ··· 188 167 __ATTR(porttype, S_IRUGO, portio_porttype_show, NULL); 189 168 190 169 static struct attribute *portio_attrs[] = { 170 + &portio_name_attribute.attr, 191 171 &portio_start_attribute.attr, 192 172 &portio_size_attribute.attr, 193 173 &portio_porttype_attribute.attr, ··· 708 686 return -EINVAL; 709 687 710 688 requested_pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; 711 - actual_pages = (idev->info->mem[mi].size + PAGE_SIZE -1) >> PAGE_SHIFT; 689 + actual_pages = ((idev->info->mem[mi].addr & ~PAGE_MASK) 690 + + idev->info->mem[mi].size + PAGE_SIZE -1) >> PAGE_SHIFT; 712 691 if (requested_pages > actual_pages) 713 692 return -EINVAL; 714 693
+175
drivers/uio/uio_aec.c
··· 1 + /* 2 + * uio_aec.c -- simple driver for Adrienne Electronics Corp time code PCI device 3 + * 4 + * Copyright (C) 2008 Brandon Philips <brandon@ifup.org> 5 + * 6 + * This program is free software; you can redistribute it and/or modify it 7 + * under the terms of the GNU General Public License version 2 as published 8 + * by the Free Software Foundation. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + * You should have received a copy of the GNU General Public License along 16 + * with this program; if not, write to the Free Software Foundation, Inc., 59 17 + * Temple Place, Suite 330, Boston, MA 02111-1307, USA. 18 + */ 19 + 20 + #include <linux/kernel.h> 21 + #include <linux/module.h> 22 + #include <linux/pci.h> 23 + #include <linux/init.h> 24 + #include <linux/interrupt.h> 25 + #include <linux/cdev.h> 26 + #include <linux/fs.h> 27 + #include <linux/io.h> 28 + #include <linux/uaccess.h> 29 + #include <linux/uio_driver.h> 30 + 31 + #define PCI_VENDOR_ID_AEC 0xaecb 32 + #define PCI_DEVICE_ID_AEC_VITCLTC 0x6250 33 + 34 + #define INT_ENABLE_ADDR 0xFC 35 + #define INT_ENABLE 0x10 36 + #define INT_DISABLE 0x0 37 + 38 + #define INT_MASK_ADDR 0x2E 39 + #define INT_MASK_ALL 0x3F 40 + 41 + #define INTA_DRVR_ADDR 0xFE 42 + #define INTA_ENABLED_FLAG 0x08 43 + #define INTA_FLAG 0x01 44 + 45 + #define MAILBOX 0x0F 46 + 47 + static struct pci_device_id ids[] = { 48 + { PCI_DEVICE(PCI_VENDOR_ID_AEC, PCI_DEVICE_ID_AEC_VITCLTC), }, 49 + { 0, } 50 + }; 51 + MODULE_DEVICE_TABLE(pci, ids); 52 + 53 + static irqreturn_t aectc_irq(int irq, struct uio_info *dev_info) 54 + { 55 + void __iomem *int_flag = dev_info->priv + INTA_DRVR_ADDR; 56 + unsigned char status = ioread8(int_flag); 57 + 58 + 59 + if ((status & INTA_ENABLED_FLAG) && (status & INTA_FLAG)) { 60 + /* application writes 0x00 to 0x2F to get next interrupt */ 61 + status = ioread8(dev_info->priv + MAILBOX); 62 + return IRQ_HANDLED; 63 + } 64 + 65 + return IRQ_NONE; 66 + } 67 + 68 + static void print_board_data(struct pci_dev *pdev, struct uio_info *i) 69 + { 70 + dev_info(&pdev->dev, "PCI-TC board vendor: %x%x number: %x%x" 71 + " revision: %c%c\n", 72 + ioread8(i->priv + 0x01), 73 + ioread8(i->priv + 0x00), 74 + ioread8(i->priv + 0x03), 75 + ioread8(i->priv + 0x02), 76 + ioread8(i->priv + 0x06), 77 + ioread8(i->priv + 0x07)); 78 + } 79 + 80 + static int __devinit probe(struct pci_dev *pdev, const struct pci_device_id *id) 81 + { 82 + struct uio_info *info; 83 + int ret; 84 + 85 + info = kzalloc(sizeof(struct uio_info), GFP_KERNEL); 86 + if (!info) 87 + return -ENOMEM; 88 + 89 + if (pci_enable_device(pdev)) 90 + goto out_free; 91 + 92 + if (pci_request_regions(pdev, "aectc")) 93 + goto out_disable; 94 + 95 + info->name = "aectc"; 96 + info->port[0].start = pci_resource_start(pdev, 0); 97 + if (!info->port[0].start) 98 + goto out_release; 99 + info->priv = pci_iomap(pdev, 0, 0); 100 + if (!info->priv) 101 + goto out_release; 102 + info->port[0].size = pci_resource_len(pdev, 0); 103 + info->port[0].porttype = UIO_PORT_GPIO; 104 + 105 + info->version = "0.0.1"; 106 + info->irq = pdev->irq; 107 + info->irq_flags = IRQF_SHARED; 108 + info->handler = aectc_irq; 109 + 110 + print_board_data(pdev, info); 111 + ret = uio_register_device(&pdev->dev, info); 112 + if (ret) 113 + goto out_unmap; 114 + 115 + iowrite32(INT_ENABLE, info->priv + INT_ENABLE_ADDR); 116 + iowrite8(INT_MASK_ALL, info->priv + INT_MASK_ADDR); 117 + if (!(ioread8(info->priv + INTA_DRVR_ADDR) 118 + & INTA_ENABLED_FLAG)) 119 + dev_err(&pdev->dev, "aectc: interrupts not enabled\n"); 120 + 121 + pci_set_drvdata(pdev, info); 122 + 123 + return 0; 124 + 125 + out_unmap: 126 + pci_iounmap(pdev, info->priv); 127 + out_release: 128 + pci_release_regions(pdev); 129 + out_disable: 130 + pci_disable_device(pdev); 131 + out_free: 132 + kfree(info); 133 + return -ENODEV; 134 + } 135 + 136 + static void remove(struct pci_dev *pdev) 137 + { 138 + struct uio_info *info = pci_get_drvdata(pdev); 139 + 140 + /* disable interrupts */ 141 + iowrite8(INT_DISABLE, info->priv + INT_MASK_ADDR); 142 + iowrite32(INT_DISABLE, info->priv + INT_ENABLE_ADDR); 143 + /* read mailbox to ensure board drops irq */ 144 + ioread8(info->priv + MAILBOX); 145 + 146 + uio_unregister_device(info); 147 + pci_release_regions(pdev); 148 + pci_disable_device(pdev); 149 + pci_set_drvdata(pdev, NULL); 150 + iounmap(info->priv); 151 + 152 + kfree(info); 153 + } 154 + 155 + static struct pci_driver pci_driver = { 156 + .name = "aectc", 157 + .id_table = ids, 158 + .probe = probe, 159 + .remove = remove, 160 + }; 161 + 162 + static int __init aectc_init(void) 163 + { 164 + return pci_register_driver(&pci_driver); 165 + } 166 + 167 + static void __exit aectc_exit(void) 168 + { 169 + pci_unregister_driver(&pci_driver); 170 + } 171 + 172 + MODULE_LICENSE("GPL"); 173 + 174 + module_init(aectc_init); 175 + module_exit(aectc_exit);
+1 -1
drivers/usb/gadget/ci13xxx_udc.c
··· 2626 2626 INIT_LIST_HEAD(&udc->gadget.ep_list); 2627 2627 udc->gadget.ep0 = NULL; 2628 2628 2629 - strcpy(udc->gadget.dev.bus_id, "gadget"); 2629 + dev_set_name(&udc->gadget.dev, "gadget"); 2630 2630 udc->gadget.dev.dma_mask = dev->dma_mask; 2631 2631 udc->gadget.dev.parent = dev; 2632 2632 udc->gadget.dev.release = udc_release;
+2 -2
drivers/usb/gadget/imx_udc.c
··· 1186 1186 .ep0 = &controller.imx_ep[0].ep, 1187 1187 .name = driver_name, 1188 1188 .dev = { 1189 - .bus_id = "gadget", 1190 - }, 1189 + .init_name = "gadget", 1190 + }, 1191 1191 }, 1192 1192 1193 1193 .imx_ep[0] = {
+1 -1
drivers/usb/host/fhci-dbg.c
··· 108 108 { 109 109 struct device *dev = fhci_to_hcd(fhci)->self.controller; 110 110 111 - fhci->dfs_root = debugfs_create_dir(dev->bus_id, NULL); 111 + fhci->dfs_root = debugfs_create_dir(dev_name(dev), NULL); 112 112 if (!fhci->dfs_root) { 113 113 WARN_ON(1); 114 114 return;
+2 -2
drivers/usb/host/fhci-hcd.c
··· 583 583 if (sprop && strcmp(sprop, "host")) 584 584 return -ENODEV; 585 585 586 - hcd = usb_create_hcd(&fhci_driver, dev, dev->bus_id); 586 + hcd = usb_create_hcd(&fhci_driver, dev, dev_name(dev)); 587 587 if (!hcd) { 588 588 dev_err(dev, "could not create hcd\n"); 589 589 return -ENOMEM; ··· 650 650 } 651 651 } 652 652 653 - ret = gpio_request(gpio, dev->bus_id); 653 + ret = gpio_request(gpio, dev_name(dev)); 654 654 if (ret) { 655 655 dev_err(dev, "failed to request gpio %d", i); 656 656 goto err_gpios;
+16 -15
drivers/video/au1100fb.c
··· 457 457 458 458 /* AU1100 LCD controller device driver */ 459 459 460 - static int __init au1100fb_drv_probe(struct device *dev) 460 + static int __init au1100fb_drv_probe(struct platform_device *dev) 461 461 { 462 462 struct au1100fb_device *fbdev = NULL; 463 463 struct resource *regs_res; ··· 475 475 476 476 fbdev->panel = &known_lcd_panels[drv_info.panel_idx]; 477 477 478 - dev_set_drvdata(dev, (void*)fbdev); 478 + platform_set_drvdata(dev, (void *)fbdev); 479 479 480 480 /* Allocate region for our registers and map them */ 481 481 if (!(regs_res = platform_get_resource(to_platform_device(dev), ··· 583 583 fb_dealloc_cmap(&fbdev->info.cmap); 584 584 } 585 585 kfree(fbdev); 586 - dev_set_drvdata(dev, NULL); 586 + platform_set_drvdata(dev, NULL); 587 587 588 588 return 0; 589 589 } 590 590 591 - int au1100fb_drv_remove(struct device *dev) 591 + int au1100fb_drv_remove(struct platform_device *dev) 592 592 { 593 593 struct au1100fb_device *fbdev = NULL; 594 594 595 595 if (!dev) 596 596 return -ENODEV; 597 597 598 - fbdev = (struct au1100fb_device*) dev_get_drvdata(dev); 598 + fbdev = (struct au1100fb_device *) platform_get_drvdata(dev); 599 599 600 600 #if !defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_LOGO) 601 601 au1100fb_fb_blank(VESA_POWERDOWN, &fbdev->info); ··· 620 620 static u32 sys_clksrc; 621 621 static struct au1100fb_regs fbregs; 622 622 623 - int au1100fb_drv_suspend(struct device *dev, pm_message_t state) 623 + int au1100fb_drv_suspend(struct platform_device *dev, pm_message_t state) 624 624 { 625 - struct au1100fb_device *fbdev = dev_get_drvdata(dev); 625 + struct au1100fb_device *fbdev = platform_get_drvdata(dev); 626 626 627 627 if (!fbdev) 628 628 return 0; ··· 641 641 return 0; 642 642 } 643 643 644 - int au1100fb_drv_resume(struct device *dev) 644 + int au1100fb_drv_resume(struct platform_device *dev) 645 645 { 646 - struct au1100fb_device *fbdev = dev_get_drvdata(dev); 646 + struct au1100fb_device *fbdev = platform_get_drvdata(dev); 647 647 648 648 if (!fbdev) 649 649 return 0; ··· 663 663 #define au1100fb_drv_resume NULL 664 664 #endif 665 665 666 - static struct device_driver au1100fb_driver = { 667 - .name = "au1100-lcd", 668 - .bus = &platform_bus_type, 669 - 666 + static struct platform_driver au1100fb_driver = { 667 + .driver = { 668 + .name = "au1100-lcd", 669 + .owner = THIS_MODULE, 670 + }, 670 671 .probe = au1100fb_drv_probe, 671 672 .remove = au1100fb_drv_remove, 672 673 .suspend = au1100fb_drv_suspend, ··· 754 753 return ret; 755 754 } 756 755 757 - return driver_register(&au1100fb_driver); 756 + return platform_driver_register(&au1100fb_driver); 758 757 } 759 758 760 759 void __exit au1100fb_cleanup(void) 761 760 { 762 - driver_unregister(&au1100fb_driver); 761 + platform_driver_unregister(&au1100fb_driver); 763 762 764 763 kfree(drv_info.opt_mode); 765 764 }
+14 -11
drivers/video/au1200fb.c
··· 1622 1622 1623 1623 /* AU1200 LCD controller device driver */ 1624 1624 1625 - static int au1200fb_drv_probe(struct device *dev) 1625 + static int au1200fb_drv_probe(struct platform_device *dev) 1626 1626 { 1627 1627 struct au1200fb_device *fbdev; 1628 1628 unsigned long page; ··· 1645 1645 /* Allocate the framebuffer to the maximum screen size */ 1646 1646 fbdev->fb_len = (win->w[plane].xres * win->w[plane].yres * bpp) / 8; 1647 1647 1648 - fbdev->fb_mem = dma_alloc_noncoherent(dev, 1648 + fbdev->fb_mem = dma_alloc_noncoherent(&dev->dev, 1649 1649 PAGE_ALIGN(fbdev->fb_len), 1650 1650 &fbdev->fb_phys, GFP_KERNEL); 1651 1651 if (!fbdev->fb_mem) { ··· 1715 1715 return ret; 1716 1716 } 1717 1717 1718 - static int au1200fb_drv_remove(struct device *dev) 1718 + static int au1200fb_drv_remove(struct platform_device *dev) 1719 1719 { 1720 1720 struct au1200fb_device *fbdev; 1721 1721 int plane; ··· 1733 1733 /* Clean up all probe data */ 1734 1734 unregister_framebuffer(&fbdev->fb_info); 1735 1735 if (fbdev->fb_mem) 1736 - dma_free_noncoherent(dev, PAGE_ALIGN(fbdev->fb_len), 1736 + dma_free_noncoherent(&dev->dev, 1737 + PAGE_ALIGN(fbdev->fb_len), 1737 1738 fbdev->fb_mem, fbdev->fb_phys); 1738 1739 if (fbdev->fb_info.cmap.len != 0) 1739 1740 fb_dealloc_cmap(&fbdev->fb_info.cmap); ··· 1748 1747 } 1749 1748 1750 1749 #ifdef CONFIG_PM 1751 - static int au1200fb_drv_suspend(struct device *dev, u32 state, u32 level) 1750 + static int au1200fb_drv_suspend(struct platform_device *dev, u32 state) 1752 1751 { 1753 1752 /* TODO */ 1754 1753 return 0; 1755 1754 } 1756 1755 1757 - static int au1200fb_drv_resume(struct device *dev, u32 level) 1756 + static int au1200fb_drv_resume(struct platform_device *dev) 1758 1757 { 1759 1758 /* TODO */ 1760 1759 return 0; 1761 1760 } 1762 1761 #endif /* CONFIG_PM */ 1763 1762 1764 - static struct device_driver au1200fb_driver = { 1765 - .name = "au1200-lcd", 1766 - .bus = &platform_bus_type, 1763 + static struct platform_driver au1200fb_driver = { 1764 + .driver = { 1765 + .name = "au1200-lcd", 1766 + .owner = THIS_MODULE, 1767 + }, 1767 1768 .probe = au1200fb_drv_probe, 1768 1769 .remove = au1200fb_drv_remove, 1769 1770 #ifdef CONFIG_PM ··· 1909 1906 printk(KERN_INFO "Power management device entry for the au1200fb loaded.\n"); 1910 1907 #endif 1911 1908 1912 - return driver_register(&au1200fb_driver); 1909 + return platform_driver_register(&au1200fb_driver); 1913 1910 } 1914 1911 1915 1912 static void __exit au1200fb_cleanup(void) 1916 1913 { 1917 - driver_unregister(&au1200fb_driver); 1914 + platform_driver_unregister(&au1200fb_driver); 1918 1915 } 1919 1916 1920 1917 module_init(au1200fb_init);
+9 -8
drivers/video/pmag-ba-fb.c
··· 151 151 152 152 info = framebuffer_alloc(sizeof(struct pmagbafb_par), dev); 153 153 if (!info) { 154 - printk(KERN_ERR "%s: Cannot allocate memory\n", dev->bus_id); 154 + printk(KERN_ERR "%s: Cannot allocate memory\n", dev_name(dev)); 155 155 return -ENOMEM; 156 156 } 157 157 ··· 160 160 161 161 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { 162 162 printk(KERN_ERR "%s: Cannot allocate color map\n", 163 - dev->bus_id); 163 + dev_name(dev)); 164 164 err = -ENOMEM; 165 165 goto err_alloc; 166 166 } ··· 173 173 /* Request the I/O MEM resource. */ 174 174 start = tdev->resource.start; 175 175 len = tdev->resource.end - start + 1; 176 - if (!request_mem_region(start, len, dev->bus_id)) { 177 - printk(KERN_ERR "%s: Cannot reserve FB region\n", dev->bus_id); 176 + if (!request_mem_region(start, len, dev_name(dev))) { 177 + printk(KERN_ERR "%s: Cannot reserve FB region\n", 178 + dev_name(dev)); 178 179 err = -EBUSY; 179 180 goto err_cmap; 180 181 } ··· 184 183 info->fix.mmio_start = start; 185 184 par->mmio = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len); 186 185 if (!par->mmio) { 187 - printk(KERN_ERR "%s: Cannot map MMIO\n", dev->bus_id); 186 + printk(KERN_ERR "%s: Cannot map MMIO\n", dev_name(dev)); 188 187 err = -ENOMEM; 189 188 goto err_resource; 190 189 } ··· 195 194 info->screen_base = ioremap_nocache(info->fix.smem_start, 196 195 info->fix.smem_len); 197 196 if (!info->screen_base) { 198 - printk(KERN_ERR "%s: Cannot map FB\n", dev->bus_id); 197 + printk(KERN_ERR "%s: Cannot map FB\n", dev_name(dev)); 199 198 err = -ENOMEM; 200 199 goto err_mmio_map; 201 200 } ··· 206 205 err = register_framebuffer(info); 207 206 if (err < 0) { 208 207 printk(KERN_ERR "%s: Cannot register framebuffer\n", 209 - dev->bus_id); 208 + dev_name(dev)); 210 209 goto err_smem_map; 211 210 } 212 211 213 212 get_device(dev); 214 213 215 214 pr_info("fb%d: %s frame buffer device at %s\n", 216 - info->node, info->fix.id, dev->bus_id); 215 + info->node, info->fix.id, dev_name(dev)); 217 216 218 217 return 0; 219 218
+9 -8
drivers/video/pmagb-b-fb.c
··· 258 258 259 259 info = framebuffer_alloc(sizeof(struct pmagbbfb_par), dev); 260 260 if (!info) { 261 - printk(KERN_ERR "%s: Cannot allocate memory\n", dev->bus_id); 261 + printk(KERN_ERR "%s: Cannot allocate memory\n", dev_name(dev)); 262 262 return -ENOMEM; 263 263 } 264 264 ··· 267 267 268 268 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) { 269 269 printk(KERN_ERR "%s: Cannot allocate color map\n", 270 - dev->bus_id); 270 + dev_name(dev)); 271 271 err = -ENOMEM; 272 272 goto err_alloc; 273 273 } ··· 280 280 /* Request the I/O MEM resource. */ 281 281 start = tdev->resource.start; 282 282 len = tdev->resource.end - start + 1; 283 - if (!request_mem_region(start, len, dev->bus_id)) { 284 - printk(KERN_ERR "%s: Cannot reserve FB region\n", dev->bus_id); 283 + if (!request_mem_region(start, len, dev_name(dev))) { 284 + printk(KERN_ERR "%s: Cannot reserve FB region\n", 285 + dev_name(dev)); 285 286 err = -EBUSY; 286 287 goto err_cmap; 287 288 } ··· 291 290 info->fix.mmio_start = start; 292 291 par->mmio = ioremap_nocache(info->fix.mmio_start, info->fix.mmio_len); 293 292 if (!par->mmio) { 294 - printk(KERN_ERR "%s: Cannot map MMIO\n", dev->bus_id); 293 + printk(KERN_ERR "%s: Cannot map MMIO\n", dev_name(dev)); 295 294 err = -ENOMEM; 296 295 goto err_resource; 297 296 } ··· 302 301 info->fix.smem_start = start + PMAGB_B_FBMEM; 303 302 par->smem = ioremap_nocache(info->fix.smem_start, info->fix.smem_len); 304 303 if (!par->smem) { 305 - printk(KERN_ERR "%s: Cannot map FB\n", dev->bus_id); 304 + printk(KERN_ERR "%s: Cannot map FB\n", dev_name(dev)); 306 305 err = -ENOMEM; 307 306 goto err_mmio_map; 308 307 } ··· 317 316 err = register_framebuffer(info); 318 317 if (err < 0) { 319 318 printk(KERN_ERR "%s: Cannot register framebuffer\n", 320 - dev->bus_id); 319 + dev_name(dev)); 321 320 goto err_smem_map; 322 321 } 323 322 ··· 329 328 par->osc1 / 1000, par->osc1 % 1000); 330 329 331 330 pr_info("fb%d: %s frame buffer device at %s\n", 332 - info->node, info->fix.id, dev->bus_id); 331 + info->node, info->fix.id, dev_name(dev)); 333 332 pr_info("fb%d: Osc0: %s, Osc1: %s, Osc%u selected\n", 334 333 info->node, freq0, par->osc1 ? freq1 : "disabled", 335 334 par->osc1 != 0);
+1 -1
drivers/video/ps3fb.c
··· 1213 1213 dev->core.driver_data = info; 1214 1214 1215 1215 dev_info(info->device, "%s %s, using %u KiB of video memory\n", 1216 - dev_driver_string(info->dev), info->dev->bus_id, 1216 + dev_driver_string(info->dev), dev_name(info->dev), 1217 1217 info->fix.smem_len >> 10); 1218 1218 1219 1219 task = kthread_run(ps3fbd, info, DEVICE_NAME);
+1 -1
drivers/video/sh_mobile_lcdcfb.c
··· 737 737 } 738 738 739 739 error = request_irq(i, sh_mobile_lcdc_irq, IRQF_DISABLED, 740 - pdev->dev.bus_id, priv); 740 + dev_name(&pdev->dev), priv); 741 741 if (error) { 742 742 dev_err(&pdev->dev, "unable to request irq\n"); 743 743 goto err1;
+1 -1
drivers/video/tmiofb.c
··· 751 751 } 752 752 753 753 retval = request_irq(irq, &tmiofb_irq, IRQF_DISABLED, 754 - dev->dev.bus_id, info); 754 + dev_name(&dev->dev), info); 755 755 756 756 if (retval) 757 757 goto err_request_irq;
+12 -15
drivers/watchdog/rm9k_wdt.c
··· 59 59 static int wdt_gpi_notify(struct notifier_block *, unsigned long, void *); 60 60 static const struct resource *wdt_gpi_get_resource(struct platform_device *, 61 61 const char *, unsigned int); 62 - static int __init wdt_gpi_probe(struct device *); 63 - static int __exit wdt_gpi_remove(struct device *); 62 + static int __init wdt_gpi_probe(struct platform_device *); 63 + static int __exit wdt_gpi_remove(struct platform_device *); 64 64 65 65 66 66 static const char wdt_gpi_name[] = "wdt_gpi"; ··· 346 346 } 347 347 348 348 /* No hotplugging on the platform bus - use __init */ 349 - static int __init wdt_gpi_probe(struct device *dev) 349 + static int __init wdt_gpi_probe(struct platform_device *pdv) 350 350 { 351 351 int res; 352 - struct platform_device * const pdv = to_platform_device(dev); 353 352 const struct resource 354 353 * const rr = wdt_gpi_get_resource(pdv, WDT_RESOURCE_REGS, 355 354 IORESOURCE_MEM), ··· 373 374 return res; 374 375 } 375 376 376 - static int __exit wdt_gpi_remove(struct device *dev) 377 + static int __exit wdt_gpi_remove(struct platform_device *dev) 377 378 { 378 379 int res; 379 380 ··· 386 387 387 388 388 389 /* Device driver init & exit */ 389 - static struct device_driver wdt_gpi_driver = { 390 - .name = (char *) wdt_gpi_name, 391 - .bus = &platform_bus_type, 392 - .owner = THIS_MODULE, 390 + static struct platform_driver wgt_gpi_driver = { 391 + .driver = { 392 + .name = wdt_gpi_name, 393 + .owner = THIS_MODULE, 394 + }, 393 395 .probe = wdt_gpi_probe, 394 - .remove = __exit_p(wdt_gpi_remove), 395 - .shutdown = NULL, 396 - .suspend = NULL, 397 - .resume = NULL, 396 + .remove = __devexit_p(wdt_gpi_remove), 398 397 }; 399 398 400 399 static int __init wdt_gpi_init_module(void) ··· 400 403 atomic_set(&opencnt, 1); 401 404 if (timeout > MAX_TIMEOUT_SECONDS) 402 405 timeout = MAX_TIMEOUT_SECONDS; 403 - return driver_register(&wdt_gpi_driver); 406 + return platform_driver_register(&wdt_gpi_driver); 404 407 } 405 408 406 409 static void __exit wdt_gpi_cleanup_module(void) 407 410 { 408 - driver_unregister(&wdt_gpi_driver); 411 + platform_driver_unregister(&wdt_gpi_driver); 409 412 } 410 413 411 414 module_init(wdt_gpi_init_module);
+2 -2
drivers/zorro/zorro.c
··· 140 140 141 141 /* Initialize the Zorro bus */ 142 142 INIT_LIST_HEAD(&zorro_bus.devices); 143 - strcpy(zorro_bus.dev.bus_id, "zorro"); 143 + dev_set_name(&zorro_bus.dev, "zorro"); 144 144 error = device_register(&zorro_bus.dev); 145 145 if (error) { 146 146 pr_err("Zorro: Error registering zorro_bus\n"); ··· 167 167 if (request_resource(zorro_find_parent_resource(z), &z->resource)) 168 168 pr_err("Zorro: Address space collision on device %s %pR\n", 169 169 z->name, &z->resource); 170 - sprintf(z->dev.bus_id, "%02x", i); 170 + dev_set_name(&z->dev, "%02x", i); 171 171 z->dev.parent = &zorro_bus.dev; 172 172 z->dev.bus = &zorro_bus_type; 173 173 error = device_register(&z->dev);
+5 -5
fs/partitions/check.c
··· 400 400 pdev->devt = devt; 401 401 402 402 /* delay uevent until 'holders' subdir is created */ 403 - pdev->uevent_suppress = 1; 403 + dev_set_uevent_suppress(pdev, 1); 404 404 err = device_add(pdev); 405 405 if (err) 406 406 goto out_put; ··· 410 410 if (!p->holder_dir) 411 411 goto out_del; 412 412 413 - pdev->uevent_suppress = 0; 413 + dev_set_uevent_suppress(pdev, 0); 414 414 if (flags & ADDPART_FLAG_WHOLEDISK) { 415 415 err = device_create_file(pdev, &dev_attr_whole_disk); 416 416 if (err) ··· 422 422 rcu_assign_pointer(ptbl->part[partno], p); 423 423 424 424 /* suppress uevent if the disk supresses it */ 425 - if (!ddev->uevent_suppress) 425 + if (!dev_get_uevent_suppress(pdev)) 426 426 kobject_uevent(&pdev->kobj, KOBJ_ADD); 427 427 428 428 return p; ··· 455 455 dev_set_name(ddev, disk->disk_name); 456 456 457 457 /* delay uevents, until we scanned partition table */ 458 - ddev->uevent_suppress = 1; 458 + dev_set_uevent_suppress(ddev, 1); 459 459 460 460 if (device_add(ddev)) 461 461 return; ··· 490 490 491 491 exit: 492 492 /* announce disk after possible partitions are created */ 493 - ddev->uevent_suppress = 0; 493 + dev_set_uevent_suppress(ddev, 0); 494 494 kobject_uevent(&ddev->kobj, KOBJ_ADD); 495 495 496 496 /* announce possible partitions */
+240 -13
fs/sysfs/bin.c
··· 21 21 #include <linux/module.h> 22 22 #include <linux/slab.h> 23 23 #include <linux/mutex.h> 24 + #include <linux/mm.h> 24 25 25 26 #include <asm/uaccess.h> 26 27 27 28 #include "sysfs.h" 28 29 30 + /* 31 + * There's one bin_buffer for each open file. 32 + * 33 + * filp->private_data points to bin_buffer and 34 + * sysfs_dirent->s_bin_attr.buffers points to a the bin_buffer s 35 + * sysfs_dirent->s_bin_attr.buffers is protected by sysfs_bin_lock 36 + */ 37 + static DEFINE_MUTEX(sysfs_bin_lock); 38 + 29 39 struct bin_buffer { 30 - struct mutex mutex; 31 - void *buffer; 32 - int mmapped; 40 + struct mutex mutex; 41 + void *buffer; 42 + int mmapped; 43 + struct vm_operations_struct *vm_ops; 44 + struct file *file; 45 + struct hlist_node list; 33 46 }; 34 47 35 48 static int ··· 181 168 return count; 182 169 } 183 170 171 + static void bin_vma_open(struct vm_area_struct *vma) 172 + { 173 + struct file *file = vma->vm_file; 174 + struct bin_buffer *bb = file->private_data; 175 + struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; 176 + 177 + if (!bb->vm_ops || !bb->vm_ops->open) 178 + return; 179 + 180 + if (!sysfs_get_active_two(attr_sd)) 181 + return; 182 + 183 + bb->vm_ops->open(vma); 184 + 185 + sysfs_put_active_two(attr_sd); 186 + } 187 + 188 + static void bin_vma_close(struct vm_area_struct *vma) 189 + { 190 + struct file *file = vma->vm_file; 191 + struct bin_buffer *bb = file->private_data; 192 + struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; 193 + 194 + if (!bb->vm_ops || !bb->vm_ops->close) 195 + return; 196 + 197 + if (!sysfs_get_active_two(attr_sd)) 198 + return; 199 + 200 + bb->vm_ops->close(vma); 201 + 202 + sysfs_put_active_two(attr_sd); 203 + } 204 + 205 + static int bin_fault(struct vm_area_struct *vma, struct vm_fault *vmf) 206 + { 207 + struct file *file = vma->vm_file; 208 + struct bin_buffer *bb = file->private_data; 209 + struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; 210 + int ret; 211 + 212 + if (!bb->vm_ops || !bb->vm_ops->fault) 213 + return VM_FAULT_SIGBUS; 214 + 215 + if (!sysfs_get_active_two(attr_sd)) 216 + return VM_FAULT_SIGBUS; 217 + 218 + ret = bb->vm_ops->fault(vma, vmf); 219 + 220 + sysfs_put_active_two(attr_sd); 221 + return ret; 222 + } 223 + 224 + static int bin_page_mkwrite(struct vm_area_struct *vma, struct page *page) 225 + { 226 + struct file *file = vma->vm_file; 227 + struct bin_buffer *bb = file->private_data; 228 + struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; 229 + int ret; 230 + 231 + if (!bb->vm_ops) 232 + return -EINVAL; 233 + 234 + if (!bb->vm_ops->page_mkwrite) 235 + return 0; 236 + 237 + if (!sysfs_get_active_two(attr_sd)) 238 + return -EINVAL; 239 + 240 + ret = bb->vm_ops->page_mkwrite(vma, page); 241 + 242 + sysfs_put_active_two(attr_sd); 243 + return ret; 244 + } 245 + 246 + static int bin_access(struct vm_area_struct *vma, unsigned long addr, 247 + void *buf, int len, int write) 248 + { 249 + struct file *file = vma->vm_file; 250 + struct bin_buffer *bb = file->private_data; 251 + struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; 252 + int ret; 253 + 254 + if (!bb->vm_ops || !bb->vm_ops->access) 255 + return -EINVAL; 256 + 257 + if (!sysfs_get_active_two(attr_sd)) 258 + return -EINVAL; 259 + 260 + ret = bb->vm_ops->access(vma, addr, buf, len, write); 261 + 262 + sysfs_put_active_two(attr_sd); 263 + return ret; 264 + } 265 + 266 + #ifdef CONFIG_NUMA 267 + static int bin_set_policy(struct vm_area_struct *vma, struct mempolicy *new) 268 + { 269 + struct file *file = vma->vm_file; 270 + struct bin_buffer *bb = file->private_data; 271 + struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; 272 + int ret; 273 + 274 + if (!bb->vm_ops || !bb->vm_ops->set_policy) 275 + return 0; 276 + 277 + if (!sysfs_get_active_two(attr_sd)) 278 + return -EINVAL; 279 + 280 + ret = bb->vm_ops->set_policy(vma, new); 281 + 282 + sysfs_put_active_two(attr_sd); 283 + return ret; 284 + } 285 + 286 + static struct mempolicy *bin_get_policy(struct vm_area_struct *vma, 287 + unsigned long addr) 288 + { 289 + struct file *file = vma->vm_file; 290 + struct bin_buffer *bb = file->private_data; 291 + struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; 292 + struct mempolicy *pol; 293 + 294 + if (!bb->vm_ops || !bb->vm_ops->get_policy) 295 + return vma->vm_policy; 296 + 297 + if (!sysfs_get_active_two(attr_sd)) 298 + return vma->vm_policy; 299 + 300 + pol = bb->vm_ops->get_policy(vma, addr); 301 + 302 + sysfs_put_active_two(attr_sd); 303 + return pol; 304 + } 305 + 306 + static int bin_migrate(struct vm_area_struct *vma, const nodemask_t *from, 307 + const nodemask_t *to, unsigned long flags) 308 + { 309 + struct file *file = vma->vm_file; 310 + struct bin_buffer *bb = file->private_data; 311 + struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; 312 + int ret; 313 + 314 + if (!bb->vm_ops || !bb->vm_ops->migrate) 315 + return 0; 316 + 317 + if (!sysfs_get_active_two(attr_sd)) 318 + return 0; 319 + 320 + ret = bb->vm_ops->migrate(vma, from, to, flags); 321 + 322 + sysfs_put_active_two(attr_sd); 323 + return ret; 324 + } 325 + #endif 326 + 327 + static struct vm_operations_struct bin_vm_ops = { 328 + .open = bin_vma_open, 329 + .close = bin_vma_close, 330 + .fault = bin_fault, 331 + .page_mkwrite = bin_page_mkwrite, 332 + .access = bin_access, 333 + #ifdef CONFIG_NUMA 334 + .set_policy = bin_set_policy, 335 + .get_policy = bin_get_policy, 336 + .migrate = bin_migrate, 337 + #endif 338 + }; 339 + 184 340 static int mmap(struct file *file, struct vm_area_struct *vma) 185 341 { 186 342 struct bin_buffer *bb = file->private_data; ··· 361 179 mutex_lock(&bb->mutex); 362 180 363 181 /* need attr_sd for attr, its parent for kobj */ 182 + rc = -ENODEV; 364 183 if (!sysfs_get_active_two(attr_sd)) 365 - return -ENODEV; 184 + goto out_unlock; 366 185 367 186 rc = -EINVAL; 368 - if (attr->mmap) 369 - rc = attr->mmap(kobj, attr, vma); 187 + if (!attr->mmap) 188 + goto out_put; 370 189 371 - if (rc == 0 && !bb->mmapped) 372 - bb->mmapped = 1; 373 - else 374 - sysfs_put_active_two(attr_sd); 190 + rc = attr->mmap(kobj, attr, vma); 191 + if (rc) 192 + goto out_put; 375 193 194 + /* 195 + * PowerPC's pci_mmap of legacy_mem uses shmem_zero_setup() 196 + * to satisfy versions of X which crash if the mmap fails: that 197 + * substitutes a new vm_file, and we don't then want bin_vm_ops. 198 + */ 199 + if (vma->vm_file != file) 200 + goto out_put; 201 + 202 + rc = -EINVAL; 203 + if (bb->mmapped && bb->vm_ops != vma->vm_ops) 204 + goto out_put; 205 + 206 + rc = 0; 207 + bb->mmapped = 1; 208 + bb->vm_ops = vma->vm_ops; 209 + vma->vm_ops = &bin_vm_ops; 210 + out_put: 211 + sysfs_put_active_two(attr_sd); 212 + out_unlock: 376 213 mutex_unlock(&bb->mutex); 377 214 378 215 return rc; ··· 424 223 goto err_out; 425 224 426 225 mutex_init(&bb->mutex); 226 + bb->file = file; 427 227 file->private_data = bb; 228 + 229 + mutex_lock(&sysfs_bin_lock); 230 + hlist_add_head(&bb->list, &attr_sd->s_bin_attr.buffers); 231 + mutex_unlock(&sysfs_bin_lock); 428 232 429 233 /* open succeeded, put active references */ 430 234 sysfs_put_active_two(attr_sd); ··· 443 237 444 238 static int release(struct inode * inode, struct file * file) 445 239 { 446 - struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata; 447 240 struct bin_buffer *bb = file->private_data; 448 241 449 - if (bb->mmapped) 450 - sysfs_put_active_two(attr_sd); 242 + mutex_lock(&sysfs_bin_lock); 243 + hlist_del(&bb->list); 244 + mutex_unlock(&sysfs_bin_lock); 245 + 451 246 kfree(bb->buffer); 452 247 kfree(bb); 453 248 return 0; ··· 462 255 .open = open, 463 256 .release = release, 464 257 }; 258 + 259 + 260 + void unmap_bin_file(struct sysfs_dirent *attr_sd) 261 + { 262 + struct bin_buffer *bb; 263 + struct hlist_node *tmp; 264 + 265 + if (sysfs_type(attr_sd) != SYSFS_KOBJ_BIN_ATTR) 266 + return; 267 + 268 + mutex_lock(&sysfs_bin_lock); 269 + 270 + hlist_for_each_entry(bb, tmp, &attr_sd->s_bin_attr.buffers, list) { 271 + struct inode *inode = bb->file->f_path.dentry->d_inode; 272 + 273 + unmap_mapping_range(inode->i_mapping, 0, 0, 1); 274 + } 275 + 276 + mutex_unlock(&sysfs_bin_lock); 277 + } 465 278 466 279 /** 467 280 * sysfs_create_bin_file - create binary file for object.
+31 -2
fs/sysfs/dir.c
··· 434 434 } 435 435 436 436 /** 437 + * sysfs_pathname - return full path to sysfs dirent 438 + * @sd: sysfs_dirent whose path we want 439 + * @path: caller allocated buffer 440 + * 441 + * Gives the name "/" to the sysfs_root entry; any path returned 442 + * is relative to wherever sysfs is mounted. 443 + * 444 + * XXX: does no error checking on @path size 445 + */ 446 + static char *sysfs_pathname(struct sysfs_dirent *sd, char *path) 447 + { 448 + if (sd->s_parent) { 449 + sysfs_pathname(sd->s_parent, path); 450 + strcat(path, "/"); 451 + } 452 + strcat(path, sd->s_name); 453 + return path; 454 + } 455 + 456 + /** 437 457 * sysfs_add_one - add sysfs_dirent to parent 438 458 * @acxt: addrm context to use 439 459 * @sd: sysfs_dirent to be added ··· 478 458 int ret; 479 459 480 460 ret = __sysfs_add_one(acxt, sd); 481 - WARN(ret == -EEXIST, KERN_WARNING "sysfs: duplicate filename '%s' " 482 - "can not be created\n", sd->s_name); 461 + if (ret == -EEXIST) { 462 + char *path = kzalloc(PATH_MAX, GFP_KERNEL); 463 + WARN(1, KERN_WARNING 464 + "sysfs: cannot create duplicate filename '%s'\n", 465 + (path == NULL) ? sd->s_name : 466 + strcat(strcat(sysfs_pathname(acxt->parent_sd, path), "/"), 467 + sd->s_name)); 468 + kfree(path); 469 + } 470 + 483 471 return ret; 484 472 } 485 473 ··· 609 581 610 582 sysfs_drop_dentry(sd); 611 583 sysfs_deactivate(sd); 584 + unmap_bin_file(sd); 612 585 sysfs_put(sd); 613 586 } 614 587 }
+23 -3
fs/sysfs/file.c
··· 659 659 EXPORT_SYMBOL_GPL(sysfs_remove_file_from_group); 660 660 661 661 struct sysfs_schedule_callback_struct { 662 - struct kobject *kobj; 662 + struct list_head workq_list; 663 + struct kobject *kobj; 663 664 void (*func)(void *); 664 665 void *data; 665 666 struct module *owner; 666 667 struct work_struct work; 667 668 }; 668 669 670 + static DEFINE_MUTEX(sysfs_workq_mutex); 671 + static LIST_HEAD(sysfs_workq); 669 672 static void sysfs_schedule_callback_work(struct work_struct *work) 670 673 { 671 674 struct sysfs_schedule_callback_struct *ss = container_of(work, ··· 677 674 (ss->func)(ss->data); 678 675 kobject_put(ss->kobj); 679 676 module_put(ss->owner); 677 + mutex_lock(&sysfs_workq_mutex); 678 + list_del(&ss->workq_list); 679 + mutex_unlock(&sysfs_workq_mutex); 680 680 kfree(ss); 681 681 } 682 682 ··· 701 695 * until @func returns. 702 696 * 703 697 * Returns 0 if the request was submitted, -ENOMEM if storage could not 704 - * be allocated, -ENODEV if a reference to @owner isn't available. 698 + * be allocated, -ENODEV if a reference to @owner isn't available, 699 + * -EAGAIN if a callback has already been scheduled for @kobj. 705 700 */ 706 701 int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *), 707 702 void *data, struct module *owner) 708 703 { 709 - struct sysfs_schedule_callback_struct *ss; 704 + struct sysfs_schedule_callback_struct *ss, *tmp; 710 705 711 706 if (!try_module_get(owner)) 712 707 return -ENODEV; 708 + 709 + mutex_lock(&sysfs_workq_mutex); 710 + list_for_each_entry_safe(ss, tmp, &sysfs_workq, workq_list) 711 + if (ss->kobj == kobj) { 712 + mutex_unlock(&sysfs_workq_mutex); 713 + return -EAGAIN; 714 + } 715 + mutex_unlock(&sysfs_workq_mutex); 716 + 713 717 ss = kmalloc(sizeof(*ss), GFP_KERNEL); 714 718 if (!ss) { 715 719 module_put(owner); ··· 731 715 ss->data = data; 732 716 ss->owner = owner; 733 717 INIT_WORK(&ss->work, sysfs_schedule_callback_work); 718 + INIT_LIST_HEAD(&ss->workq_list); 719 + mutex_lock(&sysfs_workq_mutex); 720 + list_add_tail(&ss->workq_list, &sysfs_workq); 721 + mutex_unlock(&sysfs_workq_mutex); 734 722 schedule_work(&ss->work); 735 723 return 0; 736 724 }
+17
fs/sysfs/inode.c
··· 147 147 { 148 148 struct bin_attribute *bin_attr; 149 149 150 + inode->i_private = sysfs_get(sd); 150 151 inode->i_mapping->a_ops = &sysfs_aops; 151 152 inode->i_mapping->backing_dev_info = &sysfs_backing_dev_info; 152 153 inode->i_op = &sysfs_inode_operations; ··· 213 212 sysfs_init_inode(sd, inode); 214 213 215 214 return inode; 215 + } 216 + 217 + /* 218 + * The sysfs_dirent serves as both an inode and a directory entry for sysfs. 219 + * To prevent the sysfs inode numbers from being freed prematurely we take a 220 + * reference to sysfs_dirent from the sysfs inode. A 221 + * super_operations.delete_inode() implementation is needed to drop that 222 + * reference upon inode destruction. 223 + */ 224 + void sysfs_delete_inode(struct inode *inode) 225 + { 226 + struct sysfs_dirent *sd = inode->i_private; 227 + 228 + truncate_inode_pages(&inode->i_data, 0); 229 + clear_inode(inode); 230 + sysfs_put(sd); 216 231 } 217 232 218 233 int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name)
+4 -2
fs/sysfs/mount.c
··· 17 17 #include <linux/pagemap.h> 18 18 #include <linux/init.h> 19 19 #include <linux/module.h> 20 + #include <linux/magic.h> 20 21 21 22 #include "sysfs.h" 22 23 23 - /* Random magic number */ 24 - #define SYSFS_MAGIC 0x62656572 25 24 26 25 static struct vfsmount *sysfs_mount; 27 26 struct super_block * sysfs_sb = NULL; ··· 29 30 static const struct super_operations sysfs_ops = { 30 31 .statfs = simple_statfs, 31 32 .drop_inode = generic_delete_inode, 33 + .delete_inode = sysfs_delete_inode, 32 34 }; 33 35 34 36 struct sysfs_dirent sysfs_root = { ··· 53 53 sysfs_sb = sb; 54 54 55 55 /* get root inode, initialize and unlock it */ 56 + mutex_lock(&sysfs_mutex); 56 57 inode = sysfs_get_inode(&sysfs_root); 58 + mutex_unlock(&sysfs_mutex); 57 59 if (!inode) { 58 60 pr_debug("sysfs: could not get root inode\n"); 59 61 return -ENOMEM;
+3
fs/sysfs/sysfs.h
··· 28 28 29 29 struct sysfs_elem_bin_attr { 30 30 struct bin_attribute *bin_attr; 31 + struct hlist_head buffers; 31 32 }; 32 33 33 34 /* ··· 146 145 * inode.c 147 146 */ 148 147 struct inode *sysfs_get_inode(struct sysfs_dirent *sd); 148 + void sysfs_delete_inode(struct inode *inode); 149 149 int sysfs_setattr(struct dentry *dentry, struct iattr *iattr); 150 150 int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name); 151 151 int sysfs_inode_init(void); ··· 165 163 * bin.c 166 164 */ 167 165 extern const struct file_operations bin_fops; 166 + void unmap_bin_file(struct sysfs_dirent *attr_sd); 168 167 169 168 /* 170 169 * symlink.c
+6 -9
include/asm-generic/vmlinux.lds.h
··· 80 80 VMLINUX_SYMBOL(__start___tracepoints) = .; \ 81 81 *(__tracepoints) \ 82 82 VMLINUX_SYMBOL(__stop___tracepoints) = .; \ 83 + /* implement dynamic printk debug */ \ 84 + . = ALIGN(8); \ 85 + VMLINUX_SYMBOL(__start___verbose) = .; \ 86 + *(__verbose) \ 87 + VMLINUX_SYMBOL(__stop___verbose) = .; \ 83 88 LIKELY_PROFILE() \ 84 89 BRANCH_PROFILE() 85 90 ··· 314 309 CPU_DISCARD(init.data) \ 315 310 CPU_DISCARD(init.rodata) \ 316 311 MEM_DISCARD(init.data) \ 317 - MEM_DISCARD(init.rodata) \ 318 - /* implement dynamic printk debug */ \ 319 - VMLINUX_SYMBOL(__start___verbose_strings) = .; \ 320 - *(__verbose_strings) \ 321 - VMLINUX_SYMBOL(__stop___verbose_strings) = .; \ 322 - . = ALIGN(8); \ 323 - VMLINUX_SYMBOL(__start___verbose) = .; \ 324 - *(__verbose) \ 325 - VMLINUX_SYMBOL(__stop___verbose) = .; 312 + MEM_DISCARD(init.rodata) 326 313 327 314 #define INIT_TEXT \ 328 315 *(.init.text) \
+2 -2
include/linux/console.h
··· 137 137 int mda_console_init(void); 138 138 void prom_con_init(void); 139 139 140 - void vcs_make_sysfs(struct tty_struct *tty); 141 - void vcs_remove_sysfs(struct tty_struct *tty); 140 + void vcs_make_sysfs(int index); 141 + void vcs_remove_sysfs(int index); 142 142 143 143 /* Some debug stub to catch some of the obvious races in the VT code */ 144 144 #if 1
+25 -13
include/linux/device.h
··· 28 28 #define BUS_ID_SIZE 20 29 29 30 30 struct device; 31 + struct device_private; 31 32 struct device_driver; 32 33 struct driver_private; 33 34 struct class; ··· 148 147 extern struct device_driver *driver_find(const char *name, 149 148 struct bus_type *bus); 150 149 extern int driver_probe_done(void); 151 - extern int wait_for_device_probe(void); 150 + extern void wait_for_device_probe(void); 152 151 153 152 154 153 /* sysfs interface for exporting driver attributes */ ··· 368 367 }; 369 368 370 369 struct device { 371 - struct klist klist_children; 372 - struct klist_node knode_parent; /* node in sibling list */ 373 - struct klist_node knode_driver; 374 - struct klist_node knode_bus; 375 370 struct device *parent; 376 371 372 + struct device_private *p; 373 + 377 374 struct kobject kobj; 378 - char bus_id[BUS_ID_SIZE]; /* position on parent bus */ 379 - unsigned uevent_suppress:1; 380 375 const char *init_name; /* initial name of the device */ 381 376 struct device_type *type; 382 377 ··· 384 387 struct device_driver *driver; /* which driver has allocated this 385 388 device */ 386 389 void *driver_data; /* data private to the driver */ 387 - void *platform_data; /* Platform specific data, device 388 - core doesn't touch it */ 390 + 391 + void *platform_data; /* We will remove platform_data 392 + field if all platform devices 393 + pass its platform specific data 394 + from platform_device->platform_data, 395 + other kind of devices should not 396 + use platform_data. */ 389 397 struct dev_pm_info power; 390 398 391 399 #ifdef CONFIG_NUMA ··· 429 427 430 428 static inline const char *dev_name(const struct device *dev) 431 429 { 432 - /* will be changed into kobject_name(&dev->kobj) in the near future */ 433 - return dev->bus_id; 430 + return kobject_name(&dev->kobj); 434 431 } 435 432 436 433 extern int dev_set_name(struct device *dev, const char *name, ...) ··· 464 463 dev->driver_data = data; 465 464 } 466 465 466 + static inline unsigned int dev_get_uevent_suppress(const struct device *dev) 467 + { 468 + return dev->kobj.uevent_suppress; 469 + } 470 + 471 + static inline void dev_set_uevent_suppress(struct device *dev, int val) 472 + { 473 + dev->kobj.uevent_suppress = val; 474 + } 475 + 467 476 static inline int device_is_registered(struct device *dev) 468 477 { 469 478 return dev->kobj.state_in_sysfs; ··· 494 483 extern struct device *device_find_child(struct device *dev, void *data, 495 484 int (*match)(struct device *dev, void *data)); 496 485 extern int device_rename(struct device *dev, char *new_name); 497 - extern int device_move(struct device *dev, struct device *new_parent); 486 + extern int device_move(struct device *dev, struct device *new_parent, 487 + enum dpm_order dpm_order); 498 488 499 489 /* 500 490 * Root device objects for grouping under /sys/devices ··· 582 570 #if defined(DEBUG) 583 571 #define dev_dbg(dev, format, arg...) \ 584 572 dev_printk(KERN_DEBUG , dev , format , ## arg) 585 - #elif defined(CONFIG_DYNAMIC_PRINTK_DEBUG) 573 + #elif defined(CONFIG_DYNAMIC_DEBUG) 586 574 #define dev_dbg(dev, format, ...) do { \ 587 575 dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \ 588 576 } while (0)
+88
include/linux/dynamic_debug.h
··· 1 + #ifndef _DYNAMIC_DEBUG_H 2 + #define _DYNAMIC_DEBUG_H 3 + 4 + /* dynamic_printk_enabled, and dynamic_printk_enabled2 are bitmasks in which 5 + * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They 6 + * use independent hash functions, to reduce the chance of false positives. 7 + */ 8 + extern long long dynamic_debug_enabled; 9 + extern long long dynamic_debug_enabled2; 10 + 11 + /* 12 + * An instance of this structure is created in a special 13 + * ELF section at every dynamic debug callsite. At runtime, 14 + * the special section is treated as an array of these. 15 + */ 16 + struct _ddebug { 17 + /* 18 + * These fields are used to drive the user interface 19 + * for selecting and displaying debug callsites. 20 + */ 21 + const char *modname; 22 + const char *function; 23 + const char *filename; 24 + const char *format; 25 + char primary_hash; 26 + char secondary_hash; 27 + unsigned int lineno:24; 28 + /* 29 + * The flags field controls the behaviour at the callsite. 30 + * The bits here are changed dynamically when the user 31 + * writes commands to <debugfs>/dynamic_debug/ddebug 32 + */ 33 + #define _DPRINTK_FLAGS_PRINT (1<<0) /* printk() a message using the format */ 34 + #define _DPRINTK_FLAGS_DEFAULT 0 35 + unsigned int flags:8; 36 + } __attribute__((aligned(8))); 37 + 38 + 39 + int ddebug_add_module(struct _ddebug *tab, unsigned int n, 40 + const char *modname); 41 + 42 + #if defined(CONFIG_DYNAMIC_DEBUG) 43 + extern int ddebug_remove_module(char *mod_name); 44 + 45 + #define __dynamic_dbg_enabled(dd) ({ \ 46 + int __ret = 0; \ 47 + if (unlikely((dynamic_debug_enabled & (1LL << DEBUG_HASH)) && \ 48 + (dynamic_debug_enabled2 & (1LL << DEBUG_HASH2)))) \ 49 + if (unlikely(dd.flags)) \ 50 + __ret = 1; \ 51 + __ret; }) 52 + 53 + #define dynamic_pr_debug(fmt, ...) do { \ 54 + static struct _ddebug descriptor \ 55 + __used \ 56 + __attribute__((section("__verbose"), aligned(8))) = \ 57 + { KBUILD_MODNAME, __func__, __FILE__, fmt, DEBUG_HASH, \ 58 + DEBUG_HASH2, __LINE__, _DPRINTK_FLAGS_DEFAULT }; \ 59 + if (__dynamic_dbg_enabled(descriptor)) \ 60 + printk(KERN_DEBUG KBUILD_MODNAME ":" pr_fmt(fmt), \ 61 + ##__VA_ARGS__); \ 62 + } while (0) 63 + 64 + 65 + #define dynamic_dev_dbg(dev, fmt, ...) do { \ 66 + static struct _ddebug descriptor \ 67 + __used \ 68 + __attribute__((section("__verbose"), aligned(8))) = \ 69 + { KBUILD_MODNAME, __func__, __FILE__, fmt, DEBUG_HASH, \ 70 + DEBUG_HASH2, __LINE__, _DPRINTK_FLAGS_DEFAULT }; \ 71 + if (__dynamic_dbg_enabled(descriptor)) \ 72 + dev_printk(KERN_DEBUG, dev, \ 73 + KBUILD_MODNAME ": " pr_fmt(fmt),\ 74 + ##__VA_ARGS__); \ 75 + } while (0) 76 + 77 + #else 78 + 79 + static inline int ddebug_remove_module(char *mod) 80 + { 81 + return 0; 82 + } 83 + 84 + #define dynamic_pr_debug(fmt, ...) do { } while (0) 85 + #define dynamic_dev_dbg(dev, format, ...) do { } while (0) 86 + #endif 87 + 88 + #endif
-93
include/linux/dynamic_printk.h
··· 1 - #ifndef _DYNAMIC_PRINTK_H 2 - #define _DYNAMIC_PRINTK_H 3 - 4 - #define DYNAMIC_DEBUG_HASH_BITS 6 5 - #define DEBUG_HASH_TABLE_SIZE (1 << DYNAMIC_DEBUG_HASH_BITS) 6 - 7 - #define TYPE_BOOLEAN 1 8 - 9 - #define DYNAMIC_ENABLED_ALL 0 10 - #define DYNAMIC_ENABLED_NONE 1 11 - #define DYNAMIC_ENABLED_SOME 2 12 - 13 - extern int dynamic_enabled; 14 - 15 - /* dynamic_printk_enabled, and dynamic_printk_enabled2 are bitmasks in which 16 - * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They 17 - * use independent hash functions, to reduce the chance of false positives. 18 - */ 19 - extern long long dynamic_printk_enabled; 20 - extern long long dynamic_printk_enabled2; 21 - 22 - struct mod_debug { 23 - char *modname; 24 - char *logical_modname; 25 - char *flag_names; 26 - int type; 27 - int hash; 28 - int hash2; 29 - } __attribute__((aligned(8))); 30 - 31 - int register_dynamic_debug_module(char *mod_name, int type, char *share_name, 32 - char *flags, int hash, int hash2); 33 - 34 - #if defined(CONFIG_DYNAMIC_PRINTK_DEBUG) 35 - extern int unregister_dynamic_debug_module(char *mod_name); 36 - extern int __dynamic_dbg_enabled_helper(char *modname, int type, 37 - int value, int hash); 38 - 39 - #define __dynamic_dbg_enabled(module, type, value, level, hash) ({ \ 40 - int __ret = 0; \ 41 - if (unlikely((dynamic_printk_enabled & (1LL << DEBUG_HASH)) && \ 42 - (dynamic_printk_enabled2 & (1LL << DEBUG_HASH2)))) \ 43 - __ret = __dynamic_dbg_enabled_helper(module, type, \ 44 - value, hash);\ 45 - __ret; }) 46 - 47 - #define dynamic_pr_debug(fmt, ...) do { \ 48 - static char mod_name[] \ 49 - __attribute__((section("__verbose_strings"))) \ 50 - = KBUILD_MODNAME; \ 51 - static struct mod_debug descriptor \ 52 - __used \ 53 - __attribute__((section("__verbose"), aligned(8))) = \ 54 - { mod_name, mod_name, NULL, TYPE_BOOLEAN, DEBUG_HASH, DEBUG_HASH2 };\ 55 - if (__dynamic_dbg_enabled(KBUILD_MODNAME, TYPE_BOOLEAN, \ 56 - 0, 0, DEBUG_HASH)) \ 57 - printk(KERN_DEBUG KBUILD_MODNAME ":" fmt, \ 58 - ##__VA_ARGS__); \ 59 - } while (0) 60 - 61 - #define dynamic_dev_dbg(dev, format, ...) do { \ 62 - static char mod_name[] \ 63 - __attribute__((section("__verbose_strings"))) \ 64 - = KBUILD_MODNAME; \ 65 - static struct mod_debug descriptor \ 66 - __used \ 67 - __attribute__((section("__verbose"), aligned(8))) = \ 68 - { mod_name, mod_name, NULL, TYPE_BOOLEAN, DEBUG_HASH, DEBUG_HASH2 };\ 69 - if (__dynamic_dbg_enabled(KBUILD_MODNAME, TYPE_BOOLEAN, \ 70 - 0, 0, DEBUG_HASH)) \ 71 - dev_printk(KERN_DEBUG, dev, \ 72 - KBUILD_MODNAME ": " format, \ 73 - ##__VA_ARGS__); \ 74 - } while (0) 75 - 76 - #else 77 - 78 - static inline int unregister_dynamic_debug_module(const char *mod_name) 79 - { 80 - return 0; 81 - } 82 - static inline int __dynamic_dbg_enabled_helper(char *modname, int type, 83 - int value, int hash) 84 - { 85 - return 0; 86 - } 87 - 88 - #define __dynamic_dbg_enabled(module, type, value, level, hash) ({ 0; }) 89 - #define dynamic_pr_debug(fmt, ...) do { } while (0) 90 - #define dynamic_dev_dbg(dev, format, ...) do { } while (0) 91 - #endif 92 - 93 - #endif
+4 -3
include/linux/kernel.h
··· 16 16 #include <linux/log2.h> 17 17 #include <linux/typecheck.h> 18 18 #include <linux/ratelimit.h> 19 - #include <linux/dynamic_printk.h> 19 + #include <linux/dynamic_debug.h> 20 20 #include <asm/byteorder.h> 21 21 #include <asm/bug.h> 22 22 ··· 358 358 #if defined(DEBUG) 359 359 #define pr_debug(fmt, ...) \ 360 360 printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) 361 - #elif defined(CONFIG_DYNAMIC_PRINTK_DEBUG) 361 + #elif defined(CONFIG_DYNAMIC_DEBUG) 362 + /* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ 362 363 #define pr_debug(fmt, ...) do { \ 363 - dynamic_pr_debug(pr_fmt(fmt), ##__VA_ARGS__); \ 364 + dynamic_pr_debug(fmt, ##__VA_ARGS__); \ 364 365 } while (0) 365 366 #else 366 367 #define pr_debug(fmt, ...) \
+3
include/linux/kobject.h
··· 68 68 unsigned int state_in_sysfs:1; 69 69 unsigned int state_add_uevent_sent:1; 70 70 unsigned int state_remove_uevent_sent:1; 71 + unsigned int uevent_suppress:1; 71 72 }; 72 73 73 74 extern int kobject_set_name(struct kobject *kobj, const char *name, ...) 74 75 __attribute__((format(printf, 2, 3))); 76 + extern int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, 77 + va_list vargs); 75 78 76 79 static inline const char *kobject_name(const struct kobject *kobj) 77 80 {
+9
include/linux/mod_devicetable.h
··· 454 454 455 455 #define DMI_MATCH(a, b) { a, b } 456 456 457 + #define PLATFORM_NAME_SIZE 20 458 + #define PLATFORM_MODULE_PREFIX "platform:" 459 + 460 + struct platform_device_id { 461 + char name[PLATFORM_NAME_SIZE]; 462 + kernel_ulong_t driver_data 463 + __attribute__((aligned(sizeof(kernel_ulong_t)))); 464 + }; 465 + 457 466 #endif /* LINUX_MOD_DEVICETABLE_H */
+7
include/linux/platform_device.h
··· 12 12 #define _PLATFORM_DEVICE_H_ 13 13 14 14 #include <linux/device.h> 15 + #include <linux/mod_devicetable.h> 15 16 16 17 struct platform_device { 17 18 const char * name; ··· 20 19 struct device dev; 21 20 u32 num_resources; 22 21 struct resource * resource; 22 + void *platform_data; 23 + 24 + struct platform_device_id *id_entry; 23 25 }; 26 + 27 + #define platform_get_device_id(pdev) ((pdev)->id_entry) 24 28 25 29 #define to_platform_device(x) container_of((x), struct platform_device, dev) 26 30 ··· 62 56 int (*resume_early)(struct platform_device *); 63 57 int (*resume)(struct platform_device *); 64 58 struct device_driver driver; 59 + struct platform_device_id *id_table; 65 60 }; 66 61 67 62 extern int platform_driver_register(struct platform_driver *);
+11
include/linux/pm.h
··· 400 400 401 401 #else /* !CONFIG_PM_SLEEP */ 402 402 403 + #define device_pm_lock() do {} while (0) 404 + #define device_pm_unlock() do {} while (0) 405 + 403 406 static inline int device_suspend(pm_message_t state) 404 407 { 405 408 return 0; ··· 411 408 #define suspend_report_result(fn, ret) do {} while (0) 412 409 413 410 #endif /* !CONFIG_PM_SLEEP */ 411 + 412 + /* How to reorder dpm_list after device_move() */ 413 + enum dpm_order { 414 + DPM_ORDER_NONE, 415 + DPM_ORDER_DEV_AFTER_PARENT, 416 + DPM_ORDER_PARENT_BEFORE_DEV, 417 + DPM_ORDER_DEV_LAST, 418 + }; 414 419 415 420 /* 416 421 * Global Power Management flags
+4
include/linux/uio_driver.h
··· 22 22 23 23 /** 24 24 * struct uio_mem - description of a UIO memory region 25 + * @name: name of the memory region for identification 25 26 * @addr: address of the device's memory 26 27 * @size: size of IO 27 28 * @memtype: type of memory addr points to ··· 30 29 * @map: for use by the UIO core only. 31 30 */ 32 31 struct uio_mem { 32 + const char *name; 33 33 unsigned long addr; 34 34 unsigned long size; 35 35 int memtype; ··· 44 42 45 43 /** 46 44 * struct uio_port - description of a UIO port region 45 + * @name: name of the port region for identification 47 46 * @start: start of port region 48 47 * @size: size of port region 49 48 * @porttype: type of port (see UIO_PORT_* below) 50 49 * @portio: for use by the UIO core only. 51 50 */ 52 51 struct uio_port { 52 + const char *name; 53 53 unsigned long start; 54 54 unsigned long size; 55 55 int porttype;
+1 -1
include/linux/wimax/debug.h
··· 178 178 WARN_ON(1); 179 179 } else 180 180 snprintf(head, head_size, "%s %s: ", 181 - dev_driver_string(dev), dev->bus_id); 181 + dev_driver_string(dev), dev_name(dev)); 182 182 } 183 183 184 184
+10 -15
kernel/module.c
··· 822 822 mutex_lock(&module_mutex); 823 823 /* Store the name of the last unloaded module for diagnostic purposes */ 824 824 strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); 825 - unregister_dynamic_debug_module(mod->name); 825 + ddebug_remove_module(mod->name); 826 826 free_module(mod); 827 827 828 828 out: ··· 1827 1827 } 1828 1828 #endif /* CONFIG_KALLSYMS */ 1829 1829 1830 - static void dynamic_printk_setup(struct mod_debug *debug, unsigned int num) 1830 + static void dynamic_debug_setup(struct _ddebug *debug, unsigned int num) 1831 1831 { 1832 - #ifdef CONFIG_DYNAMIC_PRINTK_DEBUG 1833 - unsigned int i; 1834 - 1835 - for (i = 0; i < num; i++) { 1836 - register_dynamic_debug_module(debug[i].modname, 1837 - debug[i].type, 1838 - debug[i].logical_modname, 1839 - debug[i].flag_names, 1840 - debug[i].hash, debug[i].hash2); 1841 - } 1842 - #endif /* CONFIG_DYNAMIC_PRINTK_DEBUG */ 1832 + #ifdef CONFIG_DYNAMIC_DEBUG 1833 + if (ddebug_add_module(debug, num, debug->modname)) 1834 + printk(KERN_ERR "dynamic debug error adding module: %s\n", 1835 + debug->modname); 1836 + #endif 1843 1837 } 1844 1838 1845 1839 static void *module_alloc_update_bounds(unsigned long size) ··· 2207 2213 add_kallsyms(mod, sechdrs, symindex, strindex, secstrings); 2208 2214 2209 2215 if (!mod->taints) { 2210 - struct mod_debug *debug; 2216 + struct _ddebug *debug; 2211 2217 unsigned int num_debug; 2212 2218 2213 2219 debug = section_objs(hdr, sechdrs, secstrings, "__verbose", 2214 2220 sizeof(*debug), &num_debug); 2215 - dynamic_printk_setup(debug, num_debug); 2221 + if (debug) 2222 + dynamic_debug_setup(debug, num_debug); 2216 2223 } 2217 2224 2218 2225 /* sechdrs[0].sh_size is always zero */
+42 -32
lib/Kconfig.debug
··· 847 847 848 848 Say N if you are unsure. 849 849 850 - config DYNAMIC_PRINTK_DEBUG 851 - bool "Enable dynamic printk() call support" 850 + config DYNAMIC_DEBUG 851 + bool "Enable dynamic printk() support" 852 852 default n 853 853 depends on PRINTK 854 + depends on DEBUG_FS 854 855 select PRINTK_DEBUG 855 856 help 856 857 857 858 Compiles debug level messages into the kernel, which would not 858 859 otherwise be available at runtime. These messages can then be 859 - enabled/disabled on a per module basis. This mechanism implicitly 860 - enables all pr_debug() and dev_dbg() calls. The impact of this 861 - compile option is a larger kernel text size of about 2%. 860 + enabled/disabled based on various levels of scope - per source file, 861 + function, module, format string, and line number. This mechanism 862 + implicitly enables all pr_debug() and dev_dbg() calls. The impact of 863 + this compile option is a larger kernel text size of about 2%. 862 864 863 865 Usage: 864 866 865 - Dynamic debugging is controlled by the debugfs file, 866 - dynamic_printk/modules. This file contains a list of the modules that 867 - can be enabled. The format of the file is the module name, followed 868 - by a set of flags that can be enabled. The first flag is always the 869 - 'enabled' flag. For example: 867 + Dynamic debugging is controlled via the 'dynamic_debug/ddebug' file, 868 + which is contained in the 'debugfs' filesystem. Thus, the debugfs 869 + filesystem must first be mounted before making use of this feature. 870 + We refer the control file as: <debugfs>/dynamic_debug/ddebug. This 871 + file contains a list of the debug statements that can be enabled. The 872 + format for each line of the file is: 870 873 871 - <module_name> <enabled=0/1> 872 - . 873 - . 874 - . 874 + filename:lineno [module]function flags format 875 875 876 - <module_name> : Name of the module in which the debug call resides 877 - <enabled=0/1> : whether the messages are enabled or not 876 + filename : source file of the debug statement 877 + lineno : line number of the debug statement 878 + module : module that contains the debug statement 879 + function : function that contains the debug statement 880 + flags : 'p' means the line is turned 'on' for printing 881 + format : the format used for the debug statement 878 882 879 883 From a live system: 880 884 881 - snd_hda_intel enabled=0 882 - fixup enabled=0 883 - driver enabled=0 885 + nullarbor:~ # cat <debugfs>/dynamic_debug/ddebug 886 + # filename:lineno [module]function flags format 887 + fs/aio.c:222 [aio]__put_ioctx - "__put_ioctx:\040freeing\040%p\012" 888 + fs/aio.c:248 [aio]ioctx_alloc - "ENOMEM:\040nr_events\040too\040high\012" 889 + fs/aio.c:1770 [aio]sys_io_cancel - "calling\040cancel\012" 884 890 885 - Enable a module: 891 + Example usage: 886 892 887 - $echo "set enabled=1 <module_name>" > dynamic_printk/modules 893 + // enable the message at line 1603 of file svcsock.c 894 + nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > 895 + <debugfs>/dynamic_debug/ddebug 888 896 889 - Disable a module: 897 + // enable all the messages in file svcsock.c 898 + nullarbor:~ # echo -n 'file svcsock.c +p' > 899 + <debugfs>/dynamic_debug/ddebug 890 900 891 - $echo "set enabled=0 <module_name>" > dynamic_printk/modules 901 + // enable all the messages in the NFS server module 902 + nullarbor:~ # echo -n 'module nfsd +p' > 903 + <debugfs>/dynamic_debug/ddebug 892 904 893 - Enable all modules: 905 + // enable all 12 messages in the function svc_process() 906 + nullarbor:~ # echo -n 'func svc_process +p' > 907 + <debugfs>/dynamic_debug/ddebug 894 908 895 - $echo "set enabled=1 all" > dynamic_printk/modules 909 + // disable all 12 messages in the function svc_process() 910 + nullarbor:~ # echo -n 'func svc_process -p' > 911 + <debugfs>/dynamic_debug/ddebug 896 912 897 - Disable all modules: 898 - 899 - $echo "set enabled=0 all" > dynamic_printk/modules 900 - 901 - Finally, passing "dynamic_printk" at the command line enables 902 - debugging for all modules. This mode can be turned off via the above 903 - disable command. 913 + See Documentation/dynamic-debug-howto.txt for additional information. 904 914 905 915 source "samples/Kconfig" 906 916
+1 -1
lib/Makefile
··· 82 82 83 83 obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o 84 84 85 - obj-$(CONFIG_DYNAMIC_PRINTK_DEBUG) += dynamic_printk.o 85 + obj-$(CONFIG_DYNAMIC_DEBUG) += dynamic_debug.o 86 86 87 87 obj-$(CONFIG_NLATTR) += nlattr.o 88 88
+769
lib/dynamic_debug.c
··· 1 + /* 2 + * lib/dynamic_debug.c 3 + * 4 + * make pr_debug()/dev_dbg() calls runtime configurable based upon their 5 + * source module. 6 + * 7 + * Copyright (C) 2008 Jason Baron <jbaron@redhat.com> 8 + * By Greg Banks <gnb@melbourne.sgi.com> 9 + * Copyright (c) 2008 Silicon Graphics Inc. All Rights Reserved. 10 + */ 11 + 12 + #include <linux/kernel.h> 13 + #include <linux/module.h> 14 + #include <linux/moduleparam.h> 15 + #include <linux/kallsyms.h> 16 + #include <linux/version.h> 17 + #include <linux/types.h> 18 + #include <linux/mutex.h> 19 + #include <linux/proc_fs.h> 20 + #include <linux/seq_file.h> 21 + #include <linux/list.h> 22 + #include <linux/sysctl.h> 23 + #include <linux/ctype.h> 24 + #include <linux/uaccess.h> 25 + #include <linux/dynamic_debug.h> 26 + #include <linux/debugfs.h> 27 + 28 + extern struct _ddebug __start___verbose[]; 29 + extern struct _ddebug __stop___verbose[]; 30 + 31 + /* dynamic_debug_enabled, and dynamic_debug_enabled2 are bitmasks in which 32 + * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They 33 + * use independent hash functions, to reduce the chance of false positives. 34 + */ 35 + long long dynamic_debug_enabled; 36 + EXPORT_SYMBOL_GPL(dynamic_debug_enabled); 37 + long long dynamic_debug_enabled2; 38 + EXPORT_SYMBOL_GPL(dynamic_debug_enabled2); 39 + 40 + struct ddebug_table { 41 + struct list_head link; 42 + char *mod_name; 43 + unsigned int num_ddebugs; 44 + unsigned int num_enabled; 45 + struct _ddebug *ddebugs; 46 + }; 47 + 48 + struct ddebug_query { 49 + const char *filename; 50 + const char *module; 51 + const char *function; 52 + const char *format; 53 + unsigned int first_lineno, last_lineno; 54 + }; 55 + 56 + struct ddebug_iter { 57 + struct ddebug_table *table; 58 + unsigned int idx; 59 + }; 60 + 61 + static DEFINE_MUTEX(ddebug_lock); 62 + static LIST_HEAD(ddebug_tables); 63 + static int verbose = 0; 64 + 65 + /* Return the last part of a pathname */ 66 + static inline const char *basename(const char *path) 67 + { 68 + const char *tail = strrchr(path, '/'); 69 + return tail ? tail+1 : path; 70 + } 71 + 72 + /* format a string into buf[] which describes the _ddebug's flags */ 73 + static char *ddebug_describe_flags(struct _ddebug *dp, char *buf, 74 + size_t maxlen) 75 + { 76 + char *p = buf; 77 + 78 + BUG_ON(maxlen < 4); 79 + if (dp->flags & _DPRINTK_FLAGS_PRINT) 80 + *p++ = 'p'; 81 + if (p == buf) 82 + *p++ = '-'; 83 + *p = '\0'; 84 + 85 + return buf; 86 + } 87 + 88 + /* 89 + * must be called with ddebug_lock held 90 + */ 91 + 92 + static int disabled_hash(char hash, bool first_table) 93 + { 94 + struct ddebug_table *dt; 95 + char table_hash_value; 96 + 97 + list_for_each_entry(dt, &ddebug_tables, link) { 98 + if (first_table) 99 + table_hash_value = dt->ddebugs->primary_hash; 100 + else 101 + table_hash_value = dt->ddebugs->secondary_hash; 102 + if (dt->num_enabled && (hash == table_hash_value)) 103 + return 0; 104 + } 105 + return 1; 106 + } 107 + 108 + /* 109 + * Search the tables for _ddebug's which match the given 110 + * `query' and apply the `flags' and `mask' to them. Tells 111 + * the user which ddebug's were changed, or whether none 112 + * were matched. 113 + */ 114 + static void ddebug_change(const struct ddebug_query *query, 115 + unsigned int flags, unsigned int mask) 116 + { 117 + int i; 118 + struct ddebug_table *dt; 119 + unsigned int newflags; 120 + unsigned int nfound = 0; 121 + char flagbuf[8]; 122 + 123 + /* search for matching ddebugs */ 124 + mutex_lock(&ddebug_lock); 125 + list_for_each_entry(dt, &ddebug_tables, link) { 126 + 127 + /* match against the module name */ 128 + if (query->module != NULL && 129 + strcmp(query->module, dt->mod_name)) 130 + continue; 131 + 132 + for (i = 0 ; i < dt->num_ddebugs ; i++) { 133 + struct _ddebug *dp = &dt->ddebugs[i]; 134 + 135 + /* match against the source filename */ 136 + if (query->filename != NULL && 137 + strcmp(query->filename, dp->filename) && 138 + strcmp(query->filename, basename(dp->filename))) 139 + continue; 140 + 141 + /* match against the function */ 142 + if (query->function != NULL && 143 + strcmp(query->function, dp->function)) 144 + continue; 145 + 146 + /* match against the format */ 147 + if (query->format != NULL && 148 + strstr(dp->format, query->format) == NULL) 149 + continue; 150 + 151 + /* match against the line number range */ 152 + if (query->first_lineno && 153 + dp->lineno < query->first_lineno) 154 + continue; 155 + if (query->last_lineno && 156 + dp->lineno > query->last_lineno) 157 + continue; 158 + 159 + nfound++; 160 + 161 + newflags = (dp->flags & mask) | flags; 162 + if (newflags == dp->flags) 163 + continue; 164 + 165 + if (!newflags) 166 + dt->num_enabled--; 167 + else if (!dp-flags) 168 + dt->num_enabled++; 169 + dp->flags = newflags; 170 + if (newflags) { 171 + dynamic_debug_enabled |= 172 + (1LL << dp->primary_hash); 173 + dynamic_debug_enabled2 |= 174 + (1LL << dp->secondary_hash); 175 + } else { 176 + if (disabled_hash(dp->primary_hash, true)) 177 + dynamic_debug_enabled &= 178 + ~(1LL << dp->primary_hash); 179 + if (disabled_hash(dp->secondary_hash, false)) 180 + dynamic_debug_enabled2 &= 181 + ~(1LL << dp->secondary_hash); 182 + } 183 + if (verbose) 184 + printk(KERN_INFO 185 + "ddebug: changed %s:%d [%s]%s %s\n", 186 + dp->filename, dp->lineno, 187 + dt->mod_name, dp->function, 188 + ddebug_describe_flags(dp, flagbuf, 189 + sizeof(flagbuf))); 190 + } 191 + } 192 + mutex_unlock(&ddebug_lock); 193 + 194 + if (!nfound && verbose) 195 + printk(KERN_INFO "ddebug: no matches for query\n"); 196 + } 197 + 198 + /* 199 + * Split the buffer `buf' into space-separated words. 200 + * Handles simple " and ' quoting, i.e. without nested, 201 + * embedded or escaped \". Return the number of words 202 + * or <0 on error. 203 + */ 204 + static int ddebug_tokenize(char *buf, char *words[], int maxwords) 205 + { 206 + int nwords = 0; 207 + 208 + while (*buf) { 209 + char *end; 210 + 211 + /* Skip leading whitespace */ 212 + while (*buf && isspace(*buf)) 213 + buf++; 214 + if (!*buf) 215 + break; /* oh, it was trailing whitespace */ 216 + 217 + /* Run `end' over a word, either whitespace separated or quoted */ 218 + if (*buf == '"' || *buf == '\'') { 219 + int quote = *buf++; 220 + for (end = buf ; *end && *end != quote ; end++) 221 + ; 222 + if (!*end) 223 + return -EINVAL; /* unclosed quote */ 224 + } else { 225 + for (end = buf ; *end && !isspace(*end) ; end++) 226 + ; 227 + BUG_ON(end == buf); 228 + } 229 + /* Here `buf' is the start of the word, `end' is one past the end */ 230 + 231 + if (nwords == maxwords) 232 + return -EINVAL; /* ran out of words[] before bytes */ 233 + if (*end) 234 + *end++ = '\0'; /* terminate the word */ 235 + words[nwords++] = buf; 236 + buf = end; 237 + } 238 + 239 + if (verbose) { 240 + int i; 241 + printk(KERN_INFO "%s: split into words:", __func__); 242 + for (i = 0 ; i < nwords ; i++) 243 + printk(" \"%s\"", words[i]); 244 + printk("\n"); 245 + } 246 + 247 + return nwords; 248 + } 249 + 250 + /* 251 + * Parse a single line number. Note that the empty string "" 252 + * is treated as a special case and converted to zero, which 253 + * is later treated as a "don't care" value. 254 + */ 255 + static inline int parse_lineno(const char *str, unsigned int *val) 256 + { 257 + char *end = NULL; 258 + BUG_ON(str == NULL); 259 + if (*str == '\0') { 260 + *val = 0; 261 + return 0; 262 + } 263 + *val = simple_strtoul(str, &end, 10); 264 + return end == NULL || end == str || *end != '\0' ? -EINVAL : 0; 265 + } 266 + 267 + /* 268 + * Undo octal escaping in a string, inplace. This is useful to 269 + * allow the user to express a query which matches a format 270 + * containing embedded spaces. 271 + */ 272 + #define isodigit(c) ((c) >= '0' && (c) <= '7') 273 + static char *unescape(char *str) 274 + { 275 + char *in = str; 276 + char *out = str; 277 + 278 + while (*in) { 279 + if (*in == '\\') { 280 + if (in[1] == '\\') { 281 + *out++ = '\\'; 282 + in += 2; 283 + continue; 284 + } else if (in[1] == 't') { 285 + *out++ = '\t'; 286 + in += 2; 287 + continue; 288 + } else if (in[1] == 'n') { 289 + *out++ = '\n'; 290 + in += 2; 291 + continue; 292 + } else if (isodigit(in[1]) && 293 + isodigit(in[2]) && 294 + isodigit(in[3])) { 295 + *out++ = ((in[1] - '0')<<6) | 296 + ((in[2] - '0')<<3) | 297 + (in[3] - '0'); 298 + in += 4; 299 + continue; 300 + } 301 + } 302 + *out++ = *in++; 303 + } 304 + *out = '\0'; 305 + 306 + return str; 307 + } 308 + 309 + /* 310 + * Parse words[] as a ddebug query specification, which is a series 311 + * of (keyword, value) pairs chosen from these possibilities: 312 + * 313 + * func <function-name> 314 + * file <full-pathname> 315 + * file <base-filename> 316 + * module <module-name> 317 + * format <escaped-string-to-find-in-format> 318 + * line <lineno> 319 + * line <first-lineno>-<last-lineno> // where either may be empty 320 + */ 321 + static int ddebug_parse_query(char *words[], int nwords, 322 + struct ddebug_query *query) 323 + { 324 + unsigned int i; 325 + 326 + /* check we have an even number of words */ 327 + if (nwords % 2 != 0) 328 + return -EINVAL; 329 + memset(query, 0, sizeof(*query)); 330 + 331 + for (i = 0 ; i < nwords ; i += 2) { 332 + if (!strcmp(words[i], "func")) 333 + query->function = words[i+1]; 334 + else if (!strcmp(words[i], "file")) 335 + query->filename = words[i+1]; 336 + else if (!strcmp(words[i], "module")) 337 + query->module = words[i+1]; 338 + else if (!strcmp(words[i], "format")) 339 + query->format = unescape(words[i+1]); 340 + else if (!strcmp(words[i], "line")) { 341 + char *first = words[i+1]; 342 + char *last = strchr(first, '-'); 343 + if (last) 344 + *last++ = '\0'; 345 + if (parse_lineno(first, &query->first_lineno) < 0) 346 + return -EINVAL; 347 + if (last != NULL) { 348 + /* range <first>-<last> */ 349 + if (parse_lineno(last, &query->last_lineno) < 0) 350 + return -EINVAL; 351 + } else { 352 + query->last_lineno = query->first_lineno; 353 + } 354 + } else { 355 + if (verbose) 356 + printk(KERN_ERR "%s: unknown keyword \"%s\"\n", 357 + __func__, words[i]); 358 + return -EINVAL; 359 + } 360 + } 361 + 362 + if (verbose) 363 + printk(KERN_INFO "%s: q->function=\"%s\" q->filename=\"%s\" " 364 + "q->module=\"%s\" q->format=\"%s\" q->lineno=%u-%u\n", 365 + __func__, query->function, query->filename, 366 + query->module, query->format, query->first_lineno, 367 + query->last_lineno); 368 + 369 + return 0; 370 + } 371 + 372 + /* 373 + * Parse `str' as a flags specification, format [-+=][p]+. 374 + * Sets up *maskp and *flagsp to be used when changing the 375 + * flags fields of matched _ddebug's. Returns 0 on success 376 + * or <0 on error. 377 + */ 378 + static int ddebug_parse_flags(const char *str, unsigned int *flagsp, 379 + unsigned int *maskp) 380 + { 381 + unsigned flags = 0; 382 + int op = '='; 383 + 384 + switch (*str) { 385 + case '+': 386 + case '-': 387 + case '=': 388 + op = *str++; 389 + break; 390 + default: 391 + return -EINVAL; 392 + } 393 + if (verbose) 394 + printk(KERN_INFO "%s: op='%c'\n", __func__, op); 395 + 396 + for ( ; *str ; ++str) { 397 + switch (*str) { 398 + case 'p': 399 + flags |= _DPRINTK_FLAGS_PRINT; 400 + break; 401 + default: 402 + return -EINVAL; 403 + } 404 + } 405 + if (flags == 0) 406 + return -EINVAL; 407 + if (verbose) 408 + printk(KERN_INFO "%s: flags=0x%x\n", __func__, flags); 409 + 410 + /* calculate final *flagsp, *maskp according to mask and op */ 411 + switch (op) { 412 + case '=': 413 + *maskp = 0; 414 + *flagsp = flags; 415 + break; 416 + case '+': 417 + *maskp = ~0U; 418 + *flagsp = flags; 419 + break; 420 + case '-': 421 + *maskp = ~flags; 422 + *flagsp = 0; 423 + break; 424 + } 425 + if (verbose) 426 + printk(KERN_INFO "%s: *flagsp=0x%x *maskp=0x%x\n", 427 + __func__, *flagsp, *maskp); 428 + return 0; 429 + } 430 + 431 + /* 432 + * File_ops->write method for <debugfs>/dynamic_debug/conrol. Gathers the 433 + * command text from userspace, parses and executes it. 434 + */ 435 + static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf, 436 + size_t len, loff_t *offp) 437 + { 438 + unsigned int flags = 0, mask = 0; 439 + struct ddebug_query query; 440 + #define MAXWORDS 9 441 + int nwords; 442 + char *words[MAXWORDS]; 443 + char tmpbuf[256]; 444 + 445 + if (len == 0) 446 + return 0; 447 + /* we don't check *offp -- multiple writes() are allowed */ 448 + if (len > sizeof(tmpbuf)-1) 449 + return -E2BIG; 450 + if (copy_from_user(tmpbuf, ubuf, len)) 451 + return -EFAULT; 452 + tmpbuf[len] = '\0'; 453 + if (verbose) 454 + printk(KERN_INFO "%s: read %d bytes from userspace\n", 455 + __func__, (int)len); 456 + 457 + nwords = ddebug_tokenize(tmpbuf, words, MAXWORDS); 458 + if (nwords < 0) 459 + return -EINVAL; 460 + if (ddebug_parse_query(words, nwords-1, &query)) 461 + return -EINVAL; 462 + if (ddebug_parse_flags(words[nwords-1], &flags, &mask)) 463 + return -EINVAL; 464 + 465 + /* actually go and implement the change */ 466 + ddebug_change(&query, flags, mask); 467 + 468 + *offp += len; 469 + return len; 470 + } 471 + 472 + /* 473 + * Set the iterator to point to the first _ddebug object 474 + * and return a pointer to that first object. Returns 475 + * NULL if there are no _ddebugs at all. 476 + */ 477 + static struct _ddebug *ddebug_iter_first(struct ddebug_iter *iter) 478 + { 479 + if (list_empty(&ddebug_tables)) { 480 + iter->table = NULL; 481 + iter->idx = 0; 482 + return NULL; 483 + } 484 + iter->table = list_entry(ddebug_tables.next, 485 + struct ddebug_table, link); 486 + iter->idx = 0; 487 + return &iter->table->ddebugs[iter->idx]; 488 + } 489 + 490 + /* 491 + * Advance the iterator to point to the next _ddebug 492 + * object from the one the iterator currently points at, 493 + * and returns a pointer to the new _ddebug. Returns 494 + * NULL if the iterator has seen all the _ddebugs. 495 + */ 496 + static struct _ddebug *ddebug_iter_next(struct ddebug_iter *iter) 497 + { 498 + if (iter->table == NULL) 499 + return NULL; 500 + if (++iter->idx == iter->table->num_ddebugs) { 501 + /* iterate to next table */ 502 + iter->idx = 0; 503 + if (list_is_last(&iter->table->link, &ddebug_tables)) { 504 + iter->table = NULL; 505 + return NULL; 506 + } 507 + iter->table = list_entry(iter->table->link.next, 508 + struct ddebug_table, link); 509 + } 510 + return &iter->table->ddebugs[iter->idx]; 511 + } 512 + 513 + /* 514 + * Seq_ops start method. Called at the start of every 515 + * read() call from userspace. Takes the ddebug_lock and 516 + * seeks the seq_file's iterator to the given position. 517 + */ 518 + static void *ddebug_proc_start(struct seq_file *m, loff_t *pos) 519 + { 520 + struct ddebug_iter *iter = m->private; 521 + struct _ddebug *dp; 522 + int n = *pos; 523 + 524 + if (verbose) 525 + printk(KERN_INFO "%s: called m=%p *pos=%lld\n", 526 + __func__, m, (unsigned long long)*pos); 527 + 528 + mutex_lock(&ddebug_lock); 529 + 530 + if (!n) 531 + return SEQ_START_TOKEN; 532 + if (n < 0) 533 + return NULL; 534 + dp = ddebug_iter_first(iter); 535 + while (dp != NULL && --n > 0) 536 + dp = ddebug_iter_next(iter); 537 + return dp; 538 + } 539 + 540 + /* 541 + * Seq_ops next method. Called several times within a read() 542 + * call from userspace, with ddebug_lock held. Walks to the 543 + * next _ddebug object with a special case for the header line. 544 + */ 545 + static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos) 546 + { 547 + struct ddebug_iter *iter = m->private; 548 + struct _ddebug *dp; 549 + 550 + if (verbose) 551 + printk(KERN_INFO "%s: called m=%p p=%p *pos=%lld\n", 552 + __func__, m, p, (unsigned long long)*pos); 553 + 554 + if (p == SEQ_START_TOKEN) 555 + dp = ddebug_iter_first(iter); 556 + else 557 + dp = ddebug_iter_next(iter); 558 + ++*pos; 559 + return dp; 560 + } 561 + 562 + /* 563 + * Seq_ops show method. Called several times within a read() 564 + * call from userspace, with ddebug_lock held. Formats the 565 + * current _ddebug as a single human-readable line, with a 566 + * special case for the header line. 567 + */ 568 + static int ddebug_proc_show(struct seq_file *m, void *p) 569 + { 570 + struct ddebug_iter *iter = m->private; 571 + struct _ddebug *dp = p; 572 + char flagsbuf[8]; 573 + 574 + if (verbose) 575 + printk(KERN_INFO "%s: called m=%p p=%p\n", 576 + __func__, m, p); 577 + 578 + if (p == SEQ_START_TOKEN) { 579 + seq_puts(m, 580 + "# filename:lineno [module]function flags format\n"); 581 + return 0; 582 + } 583 + 584 + seq_printf(m, "%s:%u [%s]%s %s \"", 585 + dp->filename, dp->lineno, 586 + iter->table->mod_name, dp->function, 587 + ddebug_describe_flags(dp, flagsbuf, sizeof(flagsbuf))); 588 + seq_escape(m, dp->format, "\t\r\n\""); 589 + seq_puts(m, "\"\n"); 590 + 591 + return 0; 592 + } 593 + 594 + /* 595 + * Seq_ops stop method. Called at the end of each read() 596 + * call from userspace. Drops ddebug_lock. 597 + */ 598 + static void ddebug_proc_stop(struct seq_file *m, void *p) 599 + { 600 + if (verbose) 601 + printk(KERN_INFO "%s: called m=%p p=%p\n", 602 + __func__, m, p); 603 + mutex_unlock(&ddebug_lock); 604 + } 605 + 606 + static const struct seq_operations ddebug_proc_seqops = { 607 + .start = ddebug_proc_start, 608 + .next = ddebug_proc_next, 609 + .show = ddebug_proc_show, 610 + .stop = ddebug_proc_stop 611 + }; 612 + 613 + /* 614 + * File_ops->open method for <debugfs>/dynamic_debug/control. Does the seq_file 615 + * setup dance, and also creates an iterator to walk the _ddebugs. 616 + * Note that we create a seq_file always, even for O_WRONLY files 617 + * where it's not needed, as doing so simplifies the ->release method. 618 + */ 619 + static int ddebug_proc_open(struct inode *inode, struct file *file) 620 + { 621 + struct ddebug_iter *iter; 622 + int err; 623 + 624 + if (verbose) 625 + printk(KERN_INFO "%s: called\n", __func__); 626 + 627 + iter = kzalloc(sizeof(*iter), GFP_KERNEL); 628 + if (iter == NULL) 629 + return -ENOMEM; 630 + 631 + err = seq_open(file, &ddebug_proc_seqops); 632 + if (err) { 633 + kfree(iter); 634 + return err; 635 + } 636 + ((struct seq_file *) file->private_data)->private = iter; 637 + return 0; 638 + } 639 + 640 + static const struct file_operations ddebug_proc_fops = { 641 + .owner = THIS_MODULE, 642 + .open = ddebug_proc_open, 643 + .read = seq_read, 644 + .llseek = seq_lseek, 645 + .release = seq_release_private, 646 + .write = ddebug_proc_write 647 + }; 648 + 649 + /* 650 + * Allocate a new ddebug_table for the given module 651 + * and add it to the global list. 652 + */ 653 + int ddebug_add_module(struct _ddebug *tab, unsigned int n, 654 + const char *name) 655 + { 656 + struct ddebug_table *dt; 657 + char *new_name; 658 + 659 + dt = kzalloc(sizeof(*dt), GFP_KERNEL); 660 + if (dt == NULL) 661 + return -ENOMEM; 662 + new_name = kstrdup(name, GFP_KERNEL); 663 + if (new_name == NULL) { 664 + kfree(dt); 665 + return -ENOMEM; 666 + } 667 + dt->mod_name = new_name; 668 + dt->num_ddebugs = n; 669 + dt->num_enabled = 0; 670 + dt->ddebugs = tab; 671 + 672 + mutex_lock(&ddebug_lock); 673 + list_add_tail(&dt->link, &ddebug_tables); 674 + mutex_unlock(&ddebug_lock); 675 + 676 + if (verbose) 677 + printk(KERN_INFO "%u debug prints in module %s\n", 678 + n, dt->mod_name); 679 + return 0; 680 + } 681 + EXPORT_SYMBOL_GPL(ddebug_add_module); 682 + 683 + static void ddebug_table_free(struct ddebug_table *dt) 684 + { 685 + list_del_init(&dt->link); 686 + kfree(dt->mod_name); 687 + kfree(dt); 688 + } 689 + 690 + /* 691 + * Called in response to a module being unloaded. Removes 692 + * any ddebug_table's which point at the module. 693 + */ 694 + int ddebug_remove_module(char *mod_name) 695 + { 696 + struct ddebug_table *dt, *nextdt; 697 + int ret = -ENOENT; 698 + 699 + if (verbose) 700 + printk(KERN_INFO "%s: removing module \"%s\"\n", 701 + __func__, mod_name); 702 + 703 + mutex_lock(&ddebug_lock); 704 + list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) { 705 + if (!strcmp(dt->mod_name, mod_name)) { 706 + ddebug_table_free(dt); 707 + ret = 0; 708 + } 709 + } 710 + mutex_unlock(&ddebug_lock); 711 + return ret; 712 + } 713 + EXPORT_SYMBOL_GPL(ddebug_remove_module); 714 + 715 + static void ddebug_remove_all_tables(void) 716 + { 717 + mutex_lock(&ddebug_lock); 718 + while (!list_empty(&ddebug_tables)) { 719 + struct ddebug_table *dt = list_entry(ddebug_tables.next, 720 + struct ddebug_table, 721 + link); 722 + ddebug_table_free(dt); 723 + } 724 + mutex_unlock(&ddebug_lock); 725 + } 726 + 727 + static int __init dynamic_debug_init(void) 728 + { 729 + struct dentry *dir, *file; 730 + struct _ddebug *iter, *iter_start; 731 + const char *modname = NULL; 732 + int ret = 0; 733 + int n = 0; 734 + 735 + dir = debugfs_create_dir("dynamic_debug", NULL); 736 + if (!dir) 737 + return -ENOMEM; 738 + file = debugfs_create_file("control", 0644, dir, NULL, 739 + &ddebug_proc_fops); 740 + if (!file) { 741 + debugfs_remove(dir); 742 + return -ENOMEM; 743 + } 744 + if (__start___verbose != __stop___verbose) { 745 + iter = __start___verbose; 746 + modname = iter->modname; 747 + iter_start = iter; 748 + for (; iter < __stop___verbose; iter++) { 749 + if (strcmp(modname, iter->modname)) { 750 + ret = ddebug_add_module(iter_start, n, modname); 751 + if (ret) 752 + goto out_free; 753 + n = 0; 754 + modname = iter->modname; 755 + iter_start = iter; 756 + } 757 + n++; 758 + } 759 + ret = ddebug_add_module(iter_start, n, modname); 760 + } 761 + out_free: 762 + if (ret) { 763 + ddebug_remove_all_tables(); 764 + debugfs_remove(dir); 765 + debugfs_remove(file); 766 + } 767 + return 0; 768 + } 769 + module_init(dynamic_debug_init);
-414
lib/dynamic_printk.c
··· 1 - /* 2 - * lib/dynamic_printk.c 3 - * 4 - * make pr_debug()/dev_dbg() calls runtime configurable based upon their 5 - * their source module. 6 - * 7 - * Copyright (C) 2008 Red Hat, Inc., Jason Baron <jbaron@redhat.com> 8 - */ 9 - 10 - #include <linux/kernel.h> 11 - #include <linux/module.h> 12 - #include <linux/uaccess.h> 13 - #include <linux/seq_file.h> 14 - #include <linux/debugfs.h> 15 - #include <linux/fs.h> 16 - 17 - extern struct mod_debug __start___verbose[]; 18 - extern struct mod_debug __stop___verbose[]; 19 - 20 - struct debug_name { 21 - struct hlist_node hlist; 22 - struct hlist_node hlist2; 23 - int hash1; 24 - int hash2; 25 - char *name; 26 - int enable; 27 - int type; 28 - }; 29 - 30 - static int nr_entries; 31 - static int num_enabled; 32 - int dynamic_enabled = DYNAMIC_ENABLED_NONE; 33 - static struct hlist_head module_table[DEBUG_HASH_TABLE_SIZE] = 34 - { [0 ... DEBUG_HASH_TABLE_SIZE-1] = HLIST_HEAD_INIT }; 35 - static struct hlist_head module_table2[DEBUG_HASH_TABLE_SIZE] = 36 - { [0 ... DEBUG_HASH_TABLE_SIZE-1] = HLIST_HEAD_INIT }; 37 - static DECLARE_MUTEX(debug_list_mutex); 38 - 39 - /* dynamic_printk_enabled, and dynamic_printk_enabled2 are bitmasks in which 40 - * bit n is set to 1 if any modname hashes into the bucket n, 0 otherwise. They 41 - * use independent hash functions, to reduce the chance of false positives. 42 - */ 43 - long long dynamic_printk_enabled; 44 - EXPORT_SYMBOL_GPL(dynamic_printk_enabled); 45 - long long dynamic_printk_enabled2; 46 - EXPORT_SYMBOL_GPL(dynamic_printk_enabled2); 47 - 48 - /* returns the debug module pointer. */ 49 - static struct debug_name *find_debug_module(char *module_name) 50 - { 51 - int i; 52 - struct hlist_head *head; 53 - struct hlist_node *node; 54 - struct debug_name *element; 55 - 56 - element = NULL; 57 - for (i = 0; i < DEBUG_HASH_TABLE_SIZE; i++) { 58 - head = &module_table[i]; 59 - hlist_for_each_entry_rcu(element, node, head, hlist) 60 - if (!strcmp(element->name, module_name)) 61 - return element; 62 - } 63 - return NULL; 64 - } 65 - 66 - /* returns the debug module pointer. */ 67 - static struct debug_name *find_debug_module_hash(char *module_name, int hash) 68 - { 69 - struct hlist_head *head; 70 - struct hlist_node *node; 71 - struct debug_name *element; 72 - 73 - element = NULL; 74 - head = &module_table[hash]; 75 - hlist_for_each_entry_rcu(element, node, head, hlist) 76 - if (!strcmp(element->name, module_name)) 77 - return element; 78 - return NULL; 79 - } 80 - 81 - /* caller must hold mutex*/ 82 - static int __add_debug_module(char *mod_name, int hash, int hash2) 83 - { 84 - struct debug_name *new; 85 - char *module_name; 86 - int ret = 0; 87 - 88 - if (find_debug_module(mod_name)) { 89 - ret = -EINVAL; 90 - goto out; 91 - } 92 - module_name = kmalloc(strlen(mod_name) + 1, GFP_KERNEL); 93 - if (!module_name) { 94 - ret = -ENOMEM; 95 - goto out; 96 - } 97 - module_name = strcpy(module_name, mod_name); 98 - module_name[strlen(mod_name)] = '\0'; 99 - new = kzalloc(sizeof(struct debug_name), GFP_KERNEL); 100 - if (!new) { 101 - kfree(module_name); 102 - ret = -ENOMEM; 103 - goto out; 104 - } 105 - INIT_HLIST_NODE(&new->hlist); 106 - INIT_HLIST_NODE(&new->hlist2); 107 - new->name = module_name; 108 - new->hash1 = hash; 109 - new->hash2 = hash2; 110 - hlist_add_head_rcu(&new->hlist, &module_table[hash]); 111 - hlist_add_head_rcu(&new->hlist2, &module_table2[hash2]); 112 - nr_entries++; 113 - out: 114 - return ret; 115 - } 116 - 117 - int unregister_dynamic_debug_module(char *mod_name) 118 - { 119 - struct debug_name *element; 120 - int ret = 0; 121 - 122 - down(&debug_list_mutex); 123 - element = find_debug_module(mod_name); 124 - if (!element) { 125 - ret = -EINVAL; 126 - goto out; 127 - } 128 - hlist_del_rcu(&element->hlist); 129 - hlist_del_rcu(&element->hlist2); 130 - synchronize_rcu(); 131 - kfree(element->name); 132 - if (element->enable) 133 - num_enabled--; 134 - kfree(element); 135 - nr_entries--; 136 - out: 137 - up(&debug_list_mutex); 138 - return ret; 139 - } 140 - EXPORT_SYMBOL_GPL(unregister_dynamic_debug_module); 141 - 142 - int register_dynamic_debug_module(char *mod_name, int type, char *share_name, 143 - char *flags, int hash, int hash2) 144 - { 145 - struct debug_name *elem; 146 - int ret = 0; 147 - 148 - down(&debug_list_mutex); 149 - elem = find_debug_module(mod_name); 150 - if (!elem) { 151 - if (__add_debug_module(mod_name, hash, hash2)) 152 - goto out; 153 - elem = find_debug_module(mod_name); 154 - if (dynamic_enabled == DYNAMIC_ENABLED_ALL && 155 - !strcmp(mod_name, share_name)) { 156 - elem->enable = true; 157 - num_enabled++; 158 - } 159 - } 160 - elem->type |= type; 161 - out: 162 - up(&debug_list_mutex); 163 - return ret; 164 - } 165 - EXPORT_SYMBOL_GPL(register_dynamic_debug_module); 166 - 167 - int __dynamic_dbg_enabled_helper(char *mod_name, int type, int value, int hash) 168 - { 169 - struct debug_name *elem; 170 - int ret = 0; 171 - 172 - if (dynamic_enabled == DYNAMIC_ENABLED_ALL) 173 - return 1; 174 - rcu_read_lock(); 175 - elem = find_debug_module_hash(mod_name, hash); 176 - if (elem && elem->enable) 177 - ret = 1; 178 - rcu_read_unlock(); 179 - return ret; 180 - } 181 - EXPORT_SYMBOL_GPL(__dynamic_dbg_enabled_helper); 182 - 183 - static void set_all(bool enable) 184 - { 185 - struct debug_name *e; 186 - struct hlist_node *node; 187 - int i; 188 - long long enable_mask; 189 - 190 - for (i = 0; i < DEBUG_HASH_TABLE_SIZE; i++) { 191 - if (module_table[i].first != NULL) { 192 - hlist_for_each_entry(e, node, &module_table[i], hlist) { 193 - e->enable = enable; 194 - } 195 - } 196 - } 197 - if (enable) 198 - enable_mask = ULLONG_MAX; 199 - else 200 - enable_mask = 0; 201 - dynamic_printk_enabled = enable_mask; 202 - dynamic_printk_enabled2 = enable_mask; 203 - } 204 - 205 - static int disabled_hash(int i, bool first_table) 206 - { 207 - struct debug_name *e; 208 - struct hlist_node *node; 209 - 210 - if (first_table) { 211 - hlist_for_each_entry(e, node, &module_table[i], hlist) { 212 - if (e->enable) 213 - return 0; 214 - } 215 - } else { 216 - hlist_for_each_entry(e, node, &module_table2[i], hlist2) { 217 - if (e->enable) 218 - return 0; 219 - } 220 - } 221 - return 1; 222 - } 223 - 224 - static ssize_t pr_debug_write(struct file *file, const char __user *buf, 225 - size_t length, loff_t *ppos) 226 - { 227 - char *buffer, *s, *value_str, *setting_str; 228 - int err, value; 229 - struct debug_name *elem = NULL; 230 - int all = 0; 231 - 232 - if (length > PAGE_SIZE || length < 0) 233 - return -EINVAL; 234 - 235 - buffer = (char *)__get_free_page(GFP_KERNEL); 236 - if (!buffer) 237 - return -ENOMEM; 238 - 239 - err = -EFAULT; 240 - if (copy_from_user(buffer, buf, length)) 241 - goto out; 242 - 243 - err = -EINVAL; 244 - if (length < PAGE_SIZE) 245 - buffer[length] = '\0'; 246 - else if (buffer[PAGE_SIZE-1]) 247 - goto out; 248 - 249 - err = -EINVAL; 250 - down(&debug_list_mutex); 251 - 252 - if (strncmp("set", buffer, 3)) 253 - goto out_up; 254 - s = buffer + 3; 255 - setting_str = strsep(&s, "="); 256 - if (s == NULL) 257 - goto out_up; 258 - setting_str = strstrip(setting_str); 259 - value_str = strsep(&s, " "); 260 - if (s == NULL) 261 - goto out_up; 262 - s = strstrip(s); 263 - if (!strncmp(s, "all", 3)) 264 - all = 1; 265 - else 266 - elem = find_debug_module(s); 267 - if (!strncmp(setting_str, "enable", 6)) { 268 - value = !!simple_strtol(value_str, NULL, 10); 269 - if (all) { 270 - if (value) { 271 - set_all(true); 272 - num_enabled = nr_entries; 273 - dynamic_enabled = DYNAMIC_ENABLED_ALL; 274 - } else { 275 - set_all(false); 276 - num_enabled = 0; 277 - dynamic_enabled = DYNAMIC_ENABLED_NONE; 278 - } 279 - err = 0; 280 - } else if (elem) { 281 - if (value && (elem->enable == 0)) { 282 - dynamic_printk_enabled |= (1LL << elem->hash1); 283 - dynamic_printk_enabled2 |= (1LL << elem->hash2); 284 - elem->enable = 1; 285 - num_enabled++; 286 - dynamic_enabled = DYNAMIC_ENABLED_SOME; 287 - err = 0; 288 - printk(KERN_DEBUG 289 - "debugging enabled for module %s\n", 290 - elem->name); 291 - } else if (!value && (elem->enable == 1)) { 292 - elem->enable = 0; 293 - num_enabled--; 294 - if (disabled_hash(elem->hash1, true)) 295 - dynamic_printk_enabled &= 296 - ~(1LL << elem->hash1); 297 - if (disabled_hash(elem->hash2, false)) 298 - dynamic_printk_enabled2 &= 299 - ~(1LL << elem->hash2); 300 - if (num_enabled) 301 - dynamic_enabled = DYNAMIC_ENABLED_SOME; 302 - else 303 - dynamic_enabled = DYNAMIC_ENABLED_NONE; 304 - err = 0; 305 - printk(KERN_DEBUG 306 - "debugging disabled for module %s\n", 307 - elem->name); 308 - } 309 - } 310 - } 311 - if (!err) 312 - err = length; 313 - out_up: 314 - up(&debug_list_mutex); 315 - out: 316 - free_page((unsigned long)buffer); 317 - return err; 318 - } 319 - 320 - static void *pr_debug_seq_start(struct seq_file *f, loff_t *pos) 321 - { 322 - return (*pos < DEBUG_HASH_TABLE_SIZE) ? pos : NULL; 323 - } 324 - 325 - static void *pr_debug_seq_next(struct seq_file *s, void *v, loff_t *pos) 326 - { 327 - (*pos)++; 328 - if (*pos >= DEBUG_HASH_TABLE_SIZE) 329 - return NULL; 330 - return pos; 331 - } 332 - 333 - static void pr_debug_seq_stop(struct seq_file *s, void *v) 334 - { 335 - /* Nothing to do */ 336 - } 337 - 338 - static int pr_debug_seq_show(struct seq_file *s, void *v) 339 - { 340 - struct hlist_head *head; 341 - struct hlist_node *node; 342 - struct debug_name *elem; 343 - unsigned int i = *(loff_t *) v; 344 - 345 - rcu_read_lock(); 346 - head = &module_table[i]; 347 - hlist_for_each_entry_rcu(elem, node, head, hlist) { 348 - seq_printf(s, "%s enabled=%d", elem->name, elem->enable); 349 - seq_printf(s, "\n"); 350 - } 351 - rcu_read_unlock(); 352 - return 0; 353 - } 354 - 355 - static struct seq_operations pr_debug_seq_ops = { 356 - .start = pr_debug_seq_start, 357 - .next = pr_debug_seq_next, 358 - .stop = pr_debug_seq_stop, 359 - .show = pr_debug_seq_show 360 - }; 361 - 362 - static int pr_debug_open(struct inode *inode, struct file *filp) 363 - { 364 - return seq_open(filp, &pr_debug_seq_ops); 365 - } 366 - 367 - static const struct file_operations pr_debug_operations = { 368 - .open = pr_debug_open, 369 - .read = seq_read, 370 - .write = pr_debug_write, 371 - .llseek = seq_lseek, 372 - .release = seq_release, 373 - }; 374 - 375 - static int __init dynamic_printk_init(void) 376 - { 377 - struct dentry *dir, *file; 378 - struct mod_debug *iter; 379 - unsigned long value; 380 - 381 - dir = debugfs_create_dir("dynamic_printk", NULL); 382 - if (!dir) 383 - return -ENOMEM; 384 - file = debugfs_create_file("modules", 0644, dir, NULL, 385 - &pr_debug_operations); 386 - if (!file) { 387 - debugfs_remove(dir); 388 - return -ENOMEM; 389 - } 390 - for (value = (unsigned long)__start___verbose; 391 - value < (unsigned long)__stop___verbose; 392 - value += sizeof(struct mod_debug)) { 393 - iter = (struct mod_debug *)value; 394 - register_dynamic_debug_module(iter->modname, 395 - iter->type, 396 - iter->logical_modname, 397 - iter->flag_names, iter->hash, iter->hash2); 398 - } 399 - if (dynamic_enabled == DYNAMIC_ENABLED_ALL) 400 - set_all(true); 401 - return 0; 402 - } 403 - module_init(dynamic_printk_init); 404 - /* may want to move this earlier so we can get traces as early as possible */ 405 - 406 - static int __init dynamic_printk_setup(char *str) 407 - { 408 - if (str) 409 - return -ENOENT; 410 - dynamic_enabled = DYNAMIC_ENABLED_ALL; 411 - return 0; 412 - } 413 - /* Use early_param(), so we can get debug output as early as possible */ 414 - early_param("dynamic_printk", dynamic_printk_setup);
+1 -1
lib/kobject.c
··· 212 212 * @fmt: format string used to build the name 213 213 * @vargs: vargs to format the string. 214 214 */ 215 - static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, 215 + int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, 216 216 va_list vargs) 217 217 { 218 218 const char *old_name = kobj->name;
+8 -1
lib/kobject_uevent.c
··· 118 118 kset = top_kobj->kset; 119 119 uevent_ops = kset->uevent_ops; 120 120 121 + /* skip the event, if uevent_suppress is set*/ 122 + if (kobj->uevent_suppress) { 123 + pr_debug("kobject: '%s' (%p): %s: uevent_suppress " 124 + "caused the event to drop!\n", 125 + kobject_name(kobj), kobj, __func__); 126 + return 0; 127 + } 121 128 /* skip the event, if the filter returns zero. */ 122 129 if (uevent_ops && uevent_ops->filter) 123 130 if (!uevent_ops->filter(kset, kobj)) { ··· 255 248 goto exit; 256 249 257 250 retval = call_usermodehelper(argv[0], argv, 258 - env->envp, UMH_WAIT_EXEC); 251 + env->envp, UMH_NO_WAIT); 259 252 } 260 253 261 254 exit:
+1 -1
net/bluetooth/hci_sysfs.c
··· 140 140 dev = device_find_child(&conn->dev, NULL, __match_tty); 141 141 if (!dev) 142 142 break; 143 - device_move(dev, NULL); 143 + device_move(dev, NULL, DPM_ORDER_DEV_LAST); 144 144 put_device(dev); 145 145 } 146 146
+3 -2
net/bluetooth/rfcomm/tty.c
··· 731 731 remove_wait_queue(&dev->wait, &wait); 732 732 733 733 if (err == 0) 734 - device_move(dev->tty_dev, rfcomm_get_device(dev)); 734 + device_move(dev->tty_dev, rfcomm_get_device(dev), 735 + DPM_ORDER_DEV_AFTER_PARENT); 735 736 736 737 rfcomm_tty_copy_pending(dev); 737 738 ··· 752 751 753 752 if (atomic_dec_and_test(&dev->opened)) { 754 753 if (dev->tty_dev->parent) 755 - device_move(dev->tty_dev, NULL); 754 + device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST); 756 755 757 756 /* Close DLC and dettach TTY */ 758 757 rfcomm_dlc_close(dev->dlc, 0);
+1 -1
net/netfilter/nf_conntrack_pptp.c
··· 66 66 struct nf_conntrack_expect *exp) __read_mostly; 67 67 EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn); 68 68 69 - #if defined(DEBUG) || defined(CONFIG_DYNAMIC_PRINTK_DEBUG) 69 + #if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) 70 70 /* PptpControlMessageType names */ 71 71 const char *const pptp_msg_name[] = { 72 72 "UNKNOWN_MESSAGE",
+1 -1
scripts/Makefile.lib
··· 97 97 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") 98 98 99 99 #hash values 100 - ifdef CONFIG_DYNAMIC_PRINTK_DEBUG 100 + ifdef CONFIG_DYNAMIC_DEBUG 101 101 debug_flags = -D"DEBUG_HASH=$(shell ./scripts/basic/hash djb2 $(@D)$(modname))"\ 102 102 -D"DEBUG_HASH2=$(shell ./scripts/basic/hash r5 $(@D)$(modname))" 103 103 else
+12
scripts/mod/file2alias.c
··· 710 710 strcat(alias, ":"); 711 711 return 1; 712 712 } 713 + 714 + static int do_platform_entry(const char *filename, 715 + struct platform_device_id *id, char *alias) 716 + { 717 + sprintf(alias, PLATFORM_MODULE_PREFIX "%s", id->name); 718 + return 1; 719 + } 720 + 713 721 /* Ignore any prefix, eg. some architectures prepend _ */ 714 722 static inline int sym_is(const char *symbol, const char *name) 715 723 { ··· 857 849 do_table(symval, sym->st_size, 858 850 sizeof(struct dmi_system_id), "dmi", 859 851 do_dmi_entry, mod); 852 + else if (sym_is(symname, "__mod_platform_device_table")) 853 + do_table(symval, sym->st_size, 854 + sizeof(struct platform_device_id), "platform", 855 + do_platform_entry, mod); 860 856 free(zeros); 861 857 } 862 858