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: (46 commits)
UIO: Fix mapping of logical and virtual memory
UIO: add automata sercos3 pci card support
UIO: Change driver name of uio_pdrv
UIO: Add alignment warnings for uio-mem
Driver core: add bus_sort_breadthfirst() function
NET: convert the phy_device file to use bus_find_device_by_name
kobject: Cleanup kobject_rename and !CONFIG_SYSFS
kobject: Fix kobject_rename and !CONFIG_SYSFS
sysfs: Make dir and name args to sysfs_notify() const
platform: add new device registration helper
sysfs: use ilookup5() instead of ilookup5_nowait()
PNP: create device attributes via default device attributes
Driver core: make bus_find_device_by_name() more robust
usb: turn dev_warn+WARN_ON combos into dev_WARN
debug: use dev_WARN() rather than WARN_ON() in device_pm_add()
debug: Introduce a dev_WARN() function
sysfs: fix deadlock
device model: Do a quickcheck for driver binding before doing an expensive check
Driver core: Fix cleanup in device_create_vargs().
Driver core: Clarify device cleanup.
...

+1786 -617
+5
Documentation/kernel-parameters.txt
··· 1714 1714 autoconfiguration. 1715 1715 Ranges are in pairs (memory base and size). 1716 1716 1717 + dynamic_printk 1718 + Enables pr_debug()/dev_dbg() calls if 1719 + CONFIG_DYNAMIC_PRINTK_DEBUG has been enabled. These can also 1720 + be switched on/off via <debugfs>/dynamic_printk/modules 1721 + 1717 1722 print-fatal-signals= 1718 1723 [KNL] debug: print fatal signals 1719 1724 print-fatal-signals=1: print segfault info to
+4
Documentation/kobject.txt
··· 118 118 119 119 int kobject_rename(struct kobject *kobj, const char *new_name); 120 120 121 + Note kobject_rename does perform any locking or have a solid notion of 122 + what names are valid so the provide must provide their own sanity checking 123 + and serialization. 124 + 121 125 There is a function called kobject_set_name() but that is legacy cruft and 122 126 is being removed. If your code needs to call this function, it is 123 127 incorrect and needs to be fixed.
+2 -2
arch/mips/kernel/rtlx.c
··· 522 522 atomic_set(&channel_wqs[i].in_open, 0); 523 523 mutex_init(&channel_wqs[i].mutex); 524 524 525 - dev = device_create_drvdata(mt_class, NULL, MKDEV(major, i), 526 - NULL, "%s%d", module_name, i); 525 + dev = device_create(mt_class, NULL, MKDEV(major, i), NULL, 526 + "%s%d", module_name, i); 527 527 if (IS_ERR(dev)) { 528 528 err = PTR_ERR(dev); 529 529 goto out_chrdev;
+1 -2
arch/mips/sibyte/common/sb_tbprof.c
··· 576 576 577 577 tb_class = tbc; 578 578 579 - dev = device_create_drvdata(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), 580 - NULL, "tb"); 579 + dev = device_create(tbc, NULL, MKDEV(SBPROF_TB_MAJOR, 0), NULL, "tb"); 581 580 if (IS_ERR(dev)) { 582 581 err = PTR_ERR(dev); 583 582 goto out_class;
+2 -2
arch/x86/kernel/cpuid.c
··· 147 147 { 148 148 struct device *dev; 149 149 150 - dev = device_create_drvdata(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu), 151 - NULL, "cpu%d", cpu); 150 + dev = device_create(cpuid_class, NULL, MKDEV(CPUID_MAJOR, cpu), NULL, 151 + "cpu%d", cpu); 152 152 return IS_ERR(dev) ? PTR_ERR(dev) : 0; 153 153 } 154 154
+2
arch/x86/kernel/dumpstack_32.c
··· 13 13 #include <linux/kexec.h> 14 14 #include <linux/bug.h> 15 15 #include <linux/nmi.h> 16 + #include <linux/sysfs.h> 16 17 17 18 #include <asm/stacktrace.h> 18 19 ··· 344 343 printk("DEBUG_PAGEALLOC"); 345 344 #endif 346 345 printk("\n"); 346 + sysfs_printk_last_file(); 347 347 if (notify_die(DIE_OOPS, str, regs, err, 348 348 current->thread.trap_no, SIGSEGV) == NOTIFY_STOP) 349 349 return 1;
+2
arch/x86/kernel/dumpstack_64.c
··· 13 13 #include <linux/kexec.h> 14 14 #include <linux/bug.h> 15 15 #include <linux/nmi.h> 16 + #include <linux/sysfs.h> 16 17 17 18 #include <asm/stacktrace.h> 18 19 ··· 490 489 printk("DEBUG_PAGEALLOC"); 491 490 #endif 492 491 printk("\n"); 492 + sysfs_printk_last_file(); 493 493 if (notify_die(DIE_OOPS, str, regs, err, 494 494 current->thread.trap_no, SIGSEGV) == NOTIFY_STOP) 495 495 return 1;
+2 -2
arch/x86/kernel/msr.c
··· 163 163 { 164 164 struct device *dev; 165 165 166 - dev = device_create_drvdata(msr_class, NULL, MKDEV(MSR_MAJOR, cpu), 167 - NULL, "msr%d", cpu); 166 + dev = device_create(msr_class, NULL, MKDEV(MSR_MAJOR, cpu), NULL, 167 + "msr%d", cpu); 168 168 return IS_ERR(dev) ? PTR_ERR(dev) : 0; 169 169 } 170 170
+1 -2
block/bsg.c
··· 1024 1024 bcd->release = release; 1025 1025 kref_init(&bcd->ref); 1026 1026 dev = MKDEV(bsg_major, bcd->minor); 1027 - class_dev = device_create_drvdata(bsg_class, parent, dev, NULL, 1028 - "%s", devname); 1027 + class_dev = device_create(bsg_class, parent, dev, NULL, "%s", devname); 1029 1028 if (IS_ERR(class_dev)) { 1030 1029 ret = PTR_ERR(class_dev); 1031 1030 goto put_dev;
+51 -3
drivers/base/bus.c
··· 333 333 { 334 334 const char *name = data; 335 335 336 - if (strcmp(name, dev->bus_id) == 0) 337 - return 1; 338 - return 0; 336 + return sysfs_streq(name, dev->bus_id); 339 337 } 340 338 341 339 /** ··· 979 981 return &bus->p->klist_devices; 980 982 } 981 983 EXPORT_SYMBOL_GPL(bus_get_device_klist); 984 + 985 + /* 986 + * Yes, this forcably breaks the klist abstraction temporarily. It 987 + * just wants to sort the klist, not change reference counts and 988 + * take/drop locks rapidly in the process. It does all this while 989 + * holding the lock for the list, so objects can't otherwise be 990 + * added/removed while we're swizzling. 991 + */ 992 + static void device_insertion_sort_klist(struct device *a, struct list_head *list, 993 + int (*compare)(const struct device *a, 994 + const struct device *b)) 995 + { 996 + struct list_head *pos; 997 + struct klist_node *n; 998 + struct device *b; 999 + 1000 + list_for_each(pos, list) { 1001 + n = container_of(pos, struct klist_node, n_node); 1002 + b = container_of(n, struct device, knode_bus); 1003 + if (compare(a, b) <= 0) { 1004 + list_move_tail(&a->knode_bus.n_node, 1005 + &b->knode_bus.n_node); 1006 + return; 1007 + } 1008 + } 1009 + list_move_tail(&a->knode_bus.n_node, list); 1010 + } 1011 + 1012 + void bus_sort_breadthfirst(struct bus_type *bus, 1013 + int (*compare)(const struct device *a, 1014 + const struct device *b)) 1015 + { 1016 + LIST_HEAD(sorted_devices); 1017 + struct list_head *pos, *tmp; 1018 + struct klist_node *n; 1019 + struct device *dev; 1020 + struct klist *device_klist; 1021 + 1022 + device_klist = bus_get_device_klist(bus); 1023 + 1024 + spin_lock(&device_klist->k_lock); 1025 + list_for_each_safe(pos, tmp, &device_klist->k_list) { 1026 + n = container_of(pos, struct klist_node, n_node); 1027 + dev = container_of(n, struct device, knode_bus); 1028 + device_insertion_sort_klist(dev, &sorted_devices, compare); 1029 + } 1030 + list_splice(&sorted_devices, &device_klist->k_list); 1031 + spin_unlock(&device_klist->k_lock); 1032 + } 1033 + EXPORT_SYMBOL_GPL(bus_sort_breadthfirst); 982 1034 983 1035 int __init buses_init(void) 984 1036 {
+24 -6
drivers/base/core.c
··· 523 523 * device_initialize - init device structure. 524 524 * @dev: device. 525 525 * 526 - * This prepares the device for use by other layers, 527 - * including adding it to the device hierarchy. 526 + * This prepares the device for use by other layers by initializing 527 + * its fields. 528 528 * It is the first half of device_register(), if called by 529 - * that, though it can also be called separately, so one 530 - * may use @dev's fields (e.g. the refcount). 529 + * that function, though it can also be called separately, so one 530 + * may use @dev's fields. In particular, get_device()/put_device() 531 + * may be used for reference counting of @dev after calling this 532 + * function. 533 + * 534 + * NOTE: Use put_device() to give up your reference instead of freeing 535 + * @dev directly once you have called this function. 531 536 */ 532 537 void device_initialize(struct device *dev) 533 538 { ··· 840 835 * This is part 2 of device_register(), though may be called 841 836 * separately _iff_ device_initialize() has been called separately. 842 837 * 843 - * This adds it to the kobject hierarchy via kobject_add(), adds it 838 + * This adds @dev to the kobject hierarchy via kobject_add(), adds it 844 839 * to the global and sibling lists for the device, then 845 840 * adds it to the other relevant subsystems of the driver model. 841 + * 842 + * NOTE: _Never_ directly free @dev after calling this function, even 843 + * if it returned an error! Always use put_device() to give up your 844 + * reference instead. 846 845 */ 847 846 int device_add(struct device *dev) 848 847 { ··· 974 965 * I.e. you should only call the two helpers separately if 975 966 * have a clearly defined need to use and refcount the device 976 967 * before it is added to the hierarchy. 968 + * 969 + * NOTE: _Never_ directly free @dev after calling this function, even 970 + * if it returned an error! Always use put_device() to give up the 971 + * reference initialized in this function instead. 977 972 */ 978 973 int device_register(struct device *dev) 979 974 { ··· 1256 1243 return dev; 1257 1244 1258 1245 error: 1259 - kfree(dev); 1246 + put_device(dev); 1260 1247 return ERR_PTR(retval); 1261 1248 } 1262 1249 EXPORT_SYMBOL_GPL(device_create_vargs); ··· 1327 1314 * device_rename - renames a device 1328 1315 * @dev: the pointer to the struct device to be renamed 1329 1316 * @new_name: the new name of the device 1317 + * 1318 + * It is the responsibility of the caller to provide mutual 1319 + * exclusion between two different calls of device_rename 1320 + * on the same device to ensure that new_name is valid and 1321 + * won't conflict with other devices. 1330 1322 */ 1331 1323 int device_rename(struct device *dev, char *new_name) 1332 1324 {
+3
drivers/base/dd.c
··· 257 257 * is an error. 258 258 */ 259 259 260 + if (drv->bus->match && !drv->bus->match(dev, drv)) 261 + return 0; 262 + 260 263 if (dev->parent) /* Needed for USB */ 261 264 down(&dev->parent->sem); 262 265 down(&dev->sem);
+48 -1
drivers/base/platform.c
··· 394 394 } 395 395 EXPORT_SYMBOL_GPL(platform_device_register_simple); 396 396 397 + /** 398 + * platform_device_register_data 399 + * @parent: parent device for the device we're adding 400 + * @name: base name of the device we're adding 401 + * @id: instance id 402 + * @data: platform specific data for this platform device 403 + * @size: size of platform specific data 404 + * 405 + * This function creates a simple platform device that requires minimal 406 + * resource and memory management. Canned release function freeing memory 407 + * allocated for the device allows drivers using such devices to be 408 + * unloaded without waiting for the last reference to the device to be 409 + * dropped. 410 + */ 411 + struct platform_device *platform_device_register_data( 412 + struct device *parent, 413 + const char *name, int id, 414 + const void *data, size_t size) 415 + { 416 + struct platform_device *pdev; 417 + int retval; 418 + 419 + pdev = platform_device_alloc(name, id); 420 + if (!pdev) { 421 + retval = -ENOMEM; 422 + goto error; 423 + } 424 + 425 + pdev->dev.parent = parent; 426 + 427 + if (size) { 428 + retval = platform_device_add_data(pdev, data, size); 429 + if (retval) 430 + goto error; 431 + } 432 + 433 + retval = platform_device_add(pdev); 434 + if (retval) 435 + goto error; 436 + 437 + return pdev; 438 + 439 + error: 440 + platform_device_put(pdev); 441 + return ERR_PTR(retval); 442 + } 443 + 397 444 static int platform_drv_probe(struct device *_dev) 398 445 { 399 446 struct platform_driver *drv = to_platform_driver(_dev->driver); ··· 912 865 913 866 #endif /* !CONFIG_HIBERNATION */ 914 867 915 - struct pm_ext_ops platform_pm_ops = { 868 + static struct pm_ext_ops platform_pm_ops = { 916 869 .base = { 917 870 .prepare = platform_pm_prepare, 918 871 .complete = platform_pm_complete,
+1 -1
drivers/base/power/main.c
··· 83 83 * transition is in progress in order to avoid leaving them 84 84 * unhandled down the road 85 85 */ 86 - WARN_ON(true); 86 + dev_WARN(dev, "Parentless device registered during a PM transaction\n"); 87 87 } 88 88 89 89 list_add_tail(&dev->power.entry, &dpm_list);
+3 -3
drivers/block/aoe/aoechr.c
··· 284 284 return PTR_ERR(aoe_class); 285 285 } 286 286 for (i = 0; i < ARRAY_SIZE(chardevs); ++i) 287 - device_create_drvdata(aoe_class, NULL, 288 - MKDEV(AOE_MAJOR, chardevs[i].minor), 289 - NULL, chardevs[i].name); 287 + device_create(aoe_class, NULL, 288 + MKDEV(AOE_MAJOR, chardevs[i].minor), NULL, 289 + chardevs[i].name); 290 290 291 291 return 0; 292 292 }
+2 -3
drivers/block/paride/pg.c
··· 686 686 for (unit = 0; unit < PG_UNITS; unit++) { 687 687 struct pg *dev = &devices[unit]; 688 688 if (dev->present) 689 - device_create_drvdata(pg_class, NULL, 690 - MKDEV(major, unit), NULL, 691 - "pg%u", unit); 689 + device_create(pg_class, NULL, MKDEV(major, unit), NULL, 690 + "pg%u", unit); 692 691 } 693 692 err = 0; 694 693 goto out;
+4 -6
drivers/block/paride/pt.c
··· 979 979 980 980 for (unit = 0; unit < PT_UNITS; unit++) 981 981 if (pt[unit].present) { 982 - device_create_drvdata(pt_class, NULL, 983 - MKDEV(major, unit), NULL, 984 - "pt%d", unit); 985 - device_create_drvdata(pt_class, NULL, 986 - MKDEV(major, unit + 128), NULL, 987 - "pt%dn", unit); 982 + device_create(pt_class, NULL, MKDEV(major, unit), NULL, 983 + "pt%d", unit); 984 + device_create(pt_class, NULL, MKDEV(major, unit + 128), 985 + NULL, "pt%dn", unit); 988 986 } 989 987 goto out; 990 988
+2 -3
drivers/block/pktcdvd.c
··· 302 302 static void pkt_sysfs_dev_new(struct pktcdvd_device *pd) 303 303 { 304 304 if (class_pktcdvd) { 305 - pd->dev = device_create_drvdata(class_pktcdvd, NULL, 306 - pd->pkt_dev, NULL, 307 - "%s", pd->name); 305 + pd->dev = device_create(class_pktcdvd, NULL, pd->pkt_dev, NULL, 306 + "%s", pd->name); 308 307 if (IS_ERR(pd->dev)) 309 308 pd->dev = NULL; 310 309 }
+2 -3
drivers/char/bsr.c
··· 229 229 if (result) 230 230 goto out_err; 231 231 232 - cur->bsr_device = device_create_drvdata(bsr_class, NULL, 233 - cur->bsr_dev, 234 - cur, cur->bsr_name); 232 + cur->bsr_device = device_create(bsr_class, NULL, cur->bsr_dev, 233 + cur, cur->bsr_name); 235 234 if (!cur->bsr_device) { 236 235 printk(KERN_ERR "device_create failed for %s\n", 237 236 cur->bsr_name);
+2 -2
drivers/char/dsp56k.c
··· 508 508 err = PTR_ERR(dsp56k_class); 509 509 goto out_chrdev; 510 510 } 511 - device_create_drvdata(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), 512 - NULL, "dsp56k"); 511 + device_create(dsp56k_class, NULL, MKDEV(DSP56K_MAJOR, 0), NULL, 512 + "dsp56k"); 513 513 514 514 printk(banner); 515 515 goto out;
+6 -6
drivers/char/ip2/ip2main.c
··· 745 745 746 746 pB = i2BoardPtrTable[i]; 747 747 if (pB != NULL) { 748 - device_create_drvdata(ip2_class, NULL, 749 - MKDEV(IP2_IPL_MAJOR, 4 * i), 750 - NULL, "ipl%d", i); 751 - device_create_drvdata(ip2_class, NULL, 752 - MKDEV(IP2_IPL_MAJOR, 4 * i + 1), 753 - NULL, "stat%d", i); 748 + device_create(ip2_class, NULL, 749 + MKDEV(IP2_IPL_MAJOR, 4 * i), 750 + NULL, "ipl%d", i); 751 + device_create(ip2_class, NULL, 752 + MKDEV(IP2_IPL_MAJOR, 4 * i + 1), 753 + NULL, "stat%d", i); 754 754 755 755 for (box = 0; box < ABS_MAX_BOXES; box++) 756 756 for (j = 0; j < ABS_BIGGEST_BOX; j++)
+1 -1
drivers/char/ipmi/ipmi_devintf.c
··· 871 871 entry->dev = dev; 872 872 873 873 mutex_lock(&reg_list_mutex); 874 - device_create_drvdata(ipmi_class, device, dev, NULL, "ipmi%d", if_num); 874 + device_create(ipmi_class, device, dev, NULL, "ipmi%d", if_num); 875 875 list_add(&entry->link, &reg_list); 876 876 mutex_unlock(&reg_list_mutex); 877 877 }
+2 -3
drivers/char/istallion.c
··· 4600 4600 4601 4601 istallion_class = class_create(THIS_MODULE, "staliomem"); 4602 4602 for (i = 0; i < 4; i++) 4603 - device_create_drvdata(istallion_class, NULL, 4604 - MKDEV(STL_SIOMEMMAJOR, i), 4605 - NULL, "staliomem%d", i); 4603 + device_create(istallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i), 4604 + NULL, "staliomem%d", i); 4606 4605 4607 4606 return 0; 4608 4607 err_deinit:
+2 -2
drivers/char/lp.c
··· 813 813 if (reset) 814 814 lp_reset(nr); 815 815 816 - device_create_drvdata(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL, 817 - "lp%d", nr); 816 + device_create(lp_class, port->dev, MKDEV(LP_MAJOR, nr), NULL, 817 + "lp%d", nr); 818 818 819 819 printk(KERN_INFO "lp%d: using %s (%s).\n", nr, port->name, 820 820 (port->irq == PARPORT_IRQ_NONE)?"polling":"interrupt-driven");
+3 -3
drivers/char/mem.c
··· 992 992 993 993 mem_class = class_create(THIS_MODULE, "mem"); 994 994 for (i = 0; i < ARRAY_SIZE(devlist); i++) 995 - device_create_drvdata(mem_class, NULL, 996 - MKDEV(MEM_MAJOR, devlist[i].minor), 997 - NULL, devlist[i].name); 995 + device_create(mem_class, NULL, 996 + MKDEV(MEM_MAJOR, devlist[i].minor), NULL, 997 + devlist[i].name); 998 998 999 999 return 0; 1000 1000 }
+2 -2
drivers/char/misc.c
··· 217 217 misc_minors[misc->minor >> 3] |= 1 << (misc->minor & 7); 218 218 dev = MKDEV(MISC_MAJOR, misc->minor); 219 219 220 - misc->this_device = device_create_drvdata(misc_class, misc->parent, 221 - dev, NULL, "%s", misc->name); 220 + misc->this_device = device_create(misc_class, misc->parent, dev, NULL, 221 + "%s", misc->name); 222 222 if (IS_ERR(misc->this_device)) { 223 223 err = PTR_ERR(misc->this_device); 224 224 goto out;
+1 -1
drivers/char/pcmcia/cm4000_cs.c
··· 1871 1871 return ret; 1872 1872 } 1873 1873 1874 - device_create_drvdata(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i); 1874 + device_create(cmm_class, NULL, MKDEV(major, i), NULL, "cmm%d", i); 1875 1875 1876 1876 return 0; 1877 1877 }
+1 -2
drivers/char/pcmcia/cm4040_cs.c
··· 637 637 return ret; 638 638 } 639 639 640 - device_create_drvdata(cmx_class, NULL, MKDEV(major, i), NULL, 641 - "cmx%d", i); 640 + device_create(cmx_class, NULL, MKDEV(major, i), NULL, "cmx%d", i); 642 641 643 642 return 0; 644 643 }
+2 -3
drivers/char/ppdev.c
··· 760 760 761 761 static void pp_attach(struct parport *port) 762 762 { 763 - device_create_drvdata(ppdev_class, port->dev, 764 - MKDEV(PP_MAJOR, port->number), 765 - NULL, "parport%d", port->number); 763 + device_create(ppdev_class, port->dev, MKDEV(PP_MAJOR, port->number), 764 + NULL, "parport%d", port->number); 766 765 } 767 766 768 767 static void pp_detach(struct parport *port)
+3 -4
drivers/char/raw.c
··· 131 131 static void bind_device(struct raw_config_request *rq) 132 132 { 133 133 device_destroy(raw_class, MKDEV(RAW_MAJOR, rq->raw_minor)); 134 - device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), 135 - NULL, "raw%d", rq->raw_minor); 134 + device_create(raw_class, NULL, MKDEV(RAW_MAJOR, rq->raw_minor), NULL, 135 + "raw%d", rq->raw_minor); 136 136 } 137 137 138 138 /* ··· 283 283 ret = PTR_ERR(raw_class); 284 284 goto error_region; 285 285 } 286 - device_create_drvdata(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, 287 - "rawctl"); 286 + device_create(raw_class, NULL, MKDEV(RAW_MAJOR, 0), NULL, "rawctl"); 288 287 289 288 return 0; 290 289
+2 -2
drivers/char/snsc.c
··· 444 444 continue; 445 445 } 446 446 447 - device_create_drvdata(snsc_class, NULL, dev, NULL, 448 - "%s", devname); 447 + device_create(snsc_class, NULL, dev, NULL, 448 + "%s", devname); 449 449 450 450 ia64_sn_irtr_intr_enable(scd->scd_nasid, 451 451 0 /*ignored */ ,
+2 -2
drivers/char/stallion.c
··· 4743 4743 if (IS_ERR(stallion_class)) 4744 4744 printk("STALLION: failed to create class\n"); 4745 4745 for (i = 0; i < 4; i++) 4746 - device_create_drvdata(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i), 4747 - NULL, "staliomem%d", i); 4746 + device_create(stallion_class, NULL, MKDEV(STL_SIOMEMMAJOR, i), 4747 + NULL, "staliomem%d", i); 4748 4748 4749 4749 return 0; 4750 4750 err_unrtty:
+1 -1
drivers/char/tty_io.c
··· 2850 2850 else 2851 2851 tty_line_name(driver, index, name); 2852 2852 2853 - return device_create_drvdata(tty_class, device, dev, NULL, name); 2853 + return device_create(tty_class, device, dev, NULL, name); 2854 2854 } 2855 2855 EXPORT_SYMBOL(tty_register_device); 2856 2856
+6 -6
drivers/char/vc_screen.c
··· 481 481 482 482 void vcs_make_sysfs(struct tty_struct *tty) 483 483 { 484 - device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 1), 485 - NULL, "vcs%u", tty->index + 1); 486 - device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, tty->index + 129), 487 - NULL, "vcsa%u", tty->index + 1); 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); 488 488 } 489 489 490 490 void vcs_remove_sysfs(struct tty_struct *tty) ··· 499 499 panic("unable to get major %d for vcs device", VCS_MAJOR); 500 500 vc_class = class_create(THIS_MODULE, "vc"); 501 501 502 - device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); 503 - device_create_drvdata(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); 502 + device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 0), NULL, "vcs"); 503 + device_create(vc_class, NULL, MKDEV(VCS_MAJOR, 128), NULL, "vcsa"); 504 504 return 0; 505 505 }
+4 -4
drivers/char/viotape.c
··· 886 886 state[i].cur_part = 0; 887 887 for (j = 0; j < MAX_PARTITIONS; ++j) 888 888 state[i].part_stat_rwi[j] = VIOT_IDLE; 889 - device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i), 890 - NULL, "iseries!vt%d", i); 891 - device_create_drvdata(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), 892 - NULL, "iseries!nvt%d", i); 889 + device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i), NULL, 890 + "iseries!vt%d", i); 891 + device_create(tape_class, NULL, MKDEV(VIOTAPE_MAJOR, i | 0x80), NULL, 892 + "iseries!nvt%d", i); 893 893 printk(VIOTAPE_KERN_INFO "tape iseries/vt%d is iSeries " 894 894 "resource %10.10s type %4.4s, model %3.3s\n", 895 895 i, viotape_unitinfo[i].rsrcname,
+1 -2
drivers/char/xilinx_hwicap/xilinx_hwicap.c
··· 657 657 goto failed3; 658 658 } 659 659 660 - device_create_drvdata(icap_class, dev, devt, NULL, 661 - "%s%d", DRIVER_NAME, id); 660 + device_create(icap_class, dev, devt, NULL, "%s%d", DRIVER_NAME, id); 662 661 return 0; /* success */ 663 662 664 663 failed3:
+3 -5
drivers/dca/dca-sysfs.c
··· 15 15 struct device *cd; 16 16 static int req_count; 17 17 18 - cd = device_create_drvdata(dca_class, dca->cd, 19 - MKDEV(0, slot + 1), NULL, 20 - "requester%d", req_count++); 18 + cd = device_create(dca_class, dca->cd, MKDEV(0, slot + 1), NULL, 19 + "requester%d", req_count++); 21 20 if (IS_ERR(cd)) 22 21 return PTR_ERR(cd); 23 22 return 0; ··· 47 48 return err; 48 49 } 49 50 50 - cd = device_create_drvdata(dca_class, dev, MKDEV(0, 0), NULL, 51 - "dca%d", dca->id); 51 + cd = device_create(dca_class, dev, MKDEV(0, 0), NULL, "dca%d", dca->id); 52 52 if (IS_ERR(cd)) { 53 53 spin_lock(&dca_idr_lock); 54 54 idr_remove(&dca_idr, dca->id);
+9 -9
drivers/firmware/iscsi_ibft.c
··· 334 334 /* 335 335 * Routines for parsing the iBFT data to be human readable. 336 336 */ 337 - ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry, 338 - struct ibft_attribute *attr, 339 - char *buf) 337 + static ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry, 338 + struct ibft_attribute *attr, 339 + char *buf) 340 340 { 341 341 struct ibft_initiator *initiator = entry->initiator; 342 342 void *ibft_loc = entry->header; ··· 376 376 return str - buf; 377 377 } 378 378 379 - ssize_t ibft_attr_show_nic(struct ibft_kobject *entry, 380 - struct ibft_attribute *attr, 381 - char *buf) 379 + static ssize_t ibft_attr_show_nic(struct ibft_kobject *entry, 380 + struct ibft_attribute *attr, 381 + char *buf) 382 382 { 383 383 struct ibft_nic *nic = entry->nic; 384 384 void *ibft_loc = entry->header; ··· 440 440 return str - buf; 441 441 }; 442 442 443 - ssize_t ibft_attr_show_target(struct ibft_kobject *entry, 444 - struct ibft_attribute *attr, 445 - char *buf) 443 + static ssize_t ibft_attr_show_target(struct ibft_kobject *entry, 444 + struct ibft_attribute *attr, 445 + char *buf) 446 446 { 447 447 struct ibft_tgt *tgt = entry->tgt; 448 448 void *ibft_loc = entry->header;
+2 -3
drivers/hid/hidraw.c
··· 326 326 goto out; 327 327 } 328 328 329 - dev->dev = device_create_drvdata(hidraw_class, NULL, 330 - MKDEV(hidraw_major, minor), NULL, 331 - "%s%d", "hidraw", minor); 329 + dev->dev = device_create(hidraw_class, NULL, MKDEV(hidraw_major, minor), 330 + NULL, "%s%d", "hidraw", minor); 332 331 333 332 if (IS_ERR(dev->dev)) { 334 333 spin_lock(&minors_lock);
+2 -2
drivers/hwmon/hwmon.c
··· 55 55 return ERR_PTR(err); 56 56 57 57 id = id & MAX_ID_MASK; 58 - hwdev = device_create_drvdata(hwmon_class, dev, MKDEV(0, 0), NULL, 59 - HWMON_ID_FORMAT, id); 58 + hwdev = device_create(hwmon_class, dev, MKDEV(0, 0), NULL, 59 + HWMON_ID_FORMAT, id); 60 60 61 61 if (IS_ERR(hwdev)) { 62 62 spin_lock(&idr_lock);
+3 -3
drivers/i2c/i2c-dev.c
··· 521 521 return PTR_ERR(i2c_dev); 522 522 523 523 /* register this i2c device with the driver core */ 524 - i2c_dev->dev = device_create_drvdata(i2c_dev_class, &adap->dev, 525 - MKDEV(I2C_MAJOR, adap->nr), 526 - NULL, "i2c-%d", adap->nr); 524 + i2c_dev->dev = device_create(i2c_dev_class, &adap->dev, 525 + MKDEV(I2C_MAJOR, adap->nr), NULL, 526 + "i2c-%d", adap->nr); 527 527 if (IS_ERR(i2c_dev->dev)) { 528 528 res = PTR_ERR(i2c_dev->dev); 529 529 goto error;
+2 -2
drivers/ide/ide-probe.c
··· 657 657 goto out; 658 658 } 659 659 660 - hwif->portdev = device_create_drvdata(ide_port_class, &hwif->gendev, 661 - MKDEV(0, 0), hwif, hwif->name); 660 + hwif->portdev = device_create(ide_port_class, &hwif->gendev, 661 + MKDEV(0, 0), hwif, hwif->name); 662 662 if (IS_ERR(hwif->portdev)) { 663 663 ret = PTR_ERR(hwif->portdev); 664 664 device_unregister(&hwif->gendev);
+5 -6
drivers/ide/ide-tape.c
··· 2420 2420 2421 2421 idetape_setup(drive, tape, minor); 2422 2422 2423 - device_create_drvdata(idetape_sysfs_class, &drive->gendev, 2424 - MKDEV(IDETAPE_MAJOR, minor), NULL, 2425 - "%s", tape->name); 2426 - device_create_drvdata(idetape_sysfs_class, &drive->gendev, 2427 - MKDEV(IDETAPE_MAJOR, minor + 128), NULL, 2428 - "n%s", tape->name); 2423 + device_create(idetape_sysfs_class, &drive->gendev, 2424 + MKDEV(IDETAPE_MAJOR, minor), NULL, "%s", tape->name); 2425 + device_create(idetape_sysfs_class, &drive->gendev, 2426 + MKDEV(IDETAPE_MAJOR, minor + 128), NULL, 2427 + "n%s", tape->name); 2429 2428 2430 2429 g->fops = &idetape_block_ops; 2431 2430 ide_register_region(g);
+4 -4
drivers/ieee1394/dv1394.c
··· 2296 2296 2297 2297 ohci = (struct ti_ohci *)host->hostdata; 2298 2298 2299 - device_create_drvdata(hpsb_protocol_class, NULL, 2300 - MKDEV(IEEE1394_MAJOR, 2301 - IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), NULL, 2302 - "dv1394-%d", id); 2299 + device_create(hpsb_protocol_class, NULL, 2300 + MKDEV(IEEE1394_MAJOR, 2301 + IEEE1394_MINOR_BLOCK_DV1394 * 16 + (id<<2)), 2302 + NULL, "dv1394-%d", id); 2303 2303 2304 2304 dv1394_init(ohci, DV1394_NTSC, MODE_RECEIVE); 2305 2305 dv1394_init(ohci, DV1394_NTSC, MODE_TRANSMIT);
+4 -4
drivers/ieee1394/raw1394.c
··· 3010 3010 hpsb_register_highlevel(&raw1394_highlevel); 3011 3011 3012 3012 if (IS_ERR 3013 - (device_create_drvdata( 3014 - hpsb_protocol_class, NULL, 3015 - MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), 3016 - NULL, RAW1394_DEVICE_NAME))) { 3013 + (device_create(hpsb_protocol_class, NULL, 3014 + MKDEV(IEEE1394_MAJOR, 3015 + IEEE1394_MINOR_BLOCK_RAW1394 * 16), 3016 + NULL, RAW1394_DEVICE_NAME))) { 3017 3017 ret = -EFAULT; 3018 3018 goto out_unreg; 3019 3019 }
+2 -3
drivers/ieee1394/video1394.c
··· 1341 1341 hpsb_set_hostinfo_key(&video1394_highlevel, host, ohci->host->id); 1342 1342 1343 1343 minor = IEEE1394_MINOR_BLOCK_VIDEO1394 * 16 + ohci->host->id; 1344 - device_create_drvdata(hpsb_protocol_class, NULL, 1345 - MKDEV(IEEE1394_MAJOR, minor), NULL, 1346 - "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id); 1344 + device_create(hpsb_protocol_class, NULL, MKDEV(IEEE1394_MAJOR, minor), 1345 + NULL, "%s-%d", VIDEO1394_DRIVER_NAME, ohci->host->id); 1347 1346 } 1348 1347 1349 1348
+3 -3
drivers/infiniband/core/cm.c
··· 3691 3691 cm_dev->ib_device = ib_device; 3692 3692 cm_get_ack_delay(cm_dev); 3693 3693 3694 - cm_dev->device = device_create_drvdata(&cm_class, &ib_device->dev, 3695 - MKDEV(0, 0), NULL, 3696 - "%s", ib_device->name); 3694 + cm_dev->device = device_create(&cm_class, &ib_device->dev, 3695 + MKDEV(0, 0), NULL, 3696 + "%s", ib_device->name); 3697 3697 if (!cm_dev->device) { 3698 3698 kfree(cm_dev); 3699 3699 return;
+6 -6
drivers/infiniband/core/user_mad.c
··· 1016 1016 if (cdev_add(port->cdev, base_dev + port->dev_num, 1)) 1017 1017 goto err_cdev; 1018 1018 1019 - port->dev = device_create_drvdata(umad_class, device->dma_device, 1020 - port->cdev->dev, port, 1021 - "umad%d", port->dev_num); 1019 + port->dev = device_create(umad_class, device->dma_device, 1020 + port->cdev->dev, port, 1021 + "umad%d", port->dev_num); 1022 1022 if (IS_ERR(port->dev)) 1023 1023 goto err_cdev; 1024 1024 ··· 1036 1036 if (cdev_add(port->sm_cdev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) 1037 1037 goto err_sm_cdev; 1038 1038 1039 - port->sm_dev = device_create_drvdata(umad_class, device->dma_device, 1040 - port->sm_cdev->dev, port, 1041 - "issm%d", port->dev_num); 1039 + port->sm_dev = device_create(umad_class, device->dma_device, 1040 + port->sm_cdev->dev, port, 1041 + "issm%d", port->dev_num); 1042 1042 if (IS_ERR(port->sm_dev)) 1043 1043 goto err_sm_cdev; 1044 1044
+3 -6
drivers/infiniband/core/uverbs_main.c
··· 764 764 if (cdev_add(uverbs_dev->cdev, IB_UVERBS_BASE_DEV + uverbs_dev->devnum, 1)) 765 765 goto err_cdev; 766 766 767 - uverbs_dev->dev = device_create_drvdata(uverbs_class, 768 - device->dma_device, 769 - uverbs_dev->cdev->dev, 770 - uverbs_dev, 771 - "uverbs%d", 772 - uverbs_dev->devnum); 767 + uverbs_dev->dev = device_create(uverbs_class, device->dma_device, 768 + uverbs_dev->cdev->dev, uverbs_dev, 769 + "uverbs%d", uverbs_dev->devnum); 773 770 if (IS_ERR(uverbs_dev->dev)) 774 771 goto err_cdev; 775 772
+1 -1
drivers/infiniband/hw/ipath/ipath_file_ops.c
··· 2455 2455 goto err_cdev; 2456 2456 } 2457 2457 2458 - device = device_create_drvdata(ipath_class, NULL, dev, NULL, name); 2458 + device = device_create(ipath_class, NULL, dev, NULL, name); 2459 2459 2460 2460 if (IS_ERR(device)) { 2461 2461 ret = PTR_ERR(device);
+1 -2
drivers/isdn/capi/capi.c
··· 1553 1553 return PTR_ERR(capi_class); 1554 1554 } 1555 1555 1556 - device_create_drvdata(capi_class, NULL, MKDEV(capi_major, 0), NULL, 1557 - "capi"); 1556 + device_create(capi_class, NULL, MKDEV(capi_major, 0), NULL, "capi"); 1558 1557 1559 1558 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE 1560 1559 if (capinc_tty_init() < 0) {
+2 -2
drivers/leds/led-class.c
··· 103 103 { 104 104 int rc; 105 105 106 - led_cdev->dev = device_create_drvdata(leds_class, parent, 0, led_cdev, 107 - "%s", led_cdev->name); 106 + led_cdev->dev = device_create(leds_class, parent, 0, led_cdev, 107 + "%s", led_cdev->name); 108 108 if (IS_ERR(led_cdev->dev)) 109 109 return PTR_ERR(led_cdev->dev); 110 110
+1 -2
drivers/macintosh/adb.c
··· 862 862 adb_dev_class = class_create(THIS_MODULE, "adb"); 863 863 if (IS_ERR(adb_dev_class)) 864 864 return; 865 - device_create_drvdata(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, 866 - "adb"); 865 + device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb"); 867 866 868 867 platform_device_register(&adb_pfdev); 869 868 platform_driver_probe(&adb_pfdrv, adb_dummy_probe);
+1 -1
drivers/media/dvb/dvb-core/dvbdev.c
··· 233 233 234 234 mutex_unlock(&dvbdev_register_lock); 235 235 236 - clsdev = device_create_drvdata(dvb_class, adap->device, 236 + clsdev = device_create(dvb_class, adap->device, 237 237 MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)), 238 238 NULL, "dvb%d.%s%d", adap->num, dnames[type], id); 239 239 if (IS_ERR(clsdev)) {
+3 -3
drivers/misc/phantom.c
··· 399 399 goto err_irq; 400 400 } 401 401 402 - if (IS_ERR(device_create_drvdata(phantom_class, &pdev->dev, 403 - MKDEV(phantom_major, minor), 404 - NULL, "phantom%u", minor))) 402 + if (IS_ERR(device_create(phantom_class, &pdev->dev, 403 + MKDEV(phantom_major, minor), NULL, 404 + "phantom%u", minor))) 405 405 dev_err(&pdev->dev, "can't create device\n"); 406 406 407 407 pci_set_drvdata(pdev, pht);
+4 -6
drivers/mtd/mtdchar.c
··· 26 26 if (!mtd) 27 27 return; 28 28 29 - device_create_drvdata(mtd_class, NULL, 30 - MKDEV(MTD_CHAR_MAJOR, mtd->index*2), 31 - NULL, "mtd%d", mtd->index); 29 + device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2), 30 + NULL, "mtd%d", mtd->index); 32 31 33 - device_create_drvdata(mtd_class, NULL, 34 - MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), 35 - NULL, "mtd%dro", mtd->index); 32 + device_create(mtd_class, NULL, MKDEV(MTD_CHAR_MAJOR, mtd->index*2+1), 33 + NULL, "mtd%dro", mtd->index); 36 34 } 37 35 38 36 static void mtd_notify_remove(struct mtd_info* mtd)
+1 -7
drivers/net/phy/phy_device.c
··· 309 309 } 310 310 EXPORT_SYMBOL(phy_disconnect); 311 311 312 - static int phy_compare_id(struct device *dev, void *data) 313 - { 314 - return strcmp((char *)data, dev->bus_id) ? 0 : 1; 315 - } 316 - 317 312 /** 318 313 * phy_attach - attach a network device to a particular PHY device 319 314 * @dev: network device to attach ··· 332 337 333 338 /* Search the list of PHY devices on the mdio bus for the 334 339 * PHY with the requested name */ 335 - d = bus_find_device(bus, NULL, (void *)bus_id, phy_compare_id); 336 - 340 + d = bus_find_device_by_name(bus, NULL, bus_id); 337 341 if (d) { 338 342 phydev = to_phy_device(d); 339 343 } else {
+2 -2
drivers/net/ppp_generic.c
··· 866 866 err = PTR_ERR(ppp_class); 867 867 goto out_chrdev; 868 868 } 869 - device_create_drvdata(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), 870 - NULL, "ppp"); 869 + device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL, 870 + "ppp"); 871 871 } 872 872 873 873 out:
+2 -2
drivers/net/wan/cosa.c
··· 388 388 goto out_chrdev; 389 389 } 390 390 for (i = 0; i < nr_cards; i++) 391 - device_create_drvdata(cosa_class, NULL, MKDEV(cosa_major, i), 392 - NULL, "cosa%d", i); 391 + device_create(cosa_class, NULL, MKDEV(cosa_major, i), NULL, 392 + "cosa%d", i); 393 393 err = 0; 394 394 goto out; 395 395
+3 -3
drivers/net/wireless/mac80211_hwsim.c
··· 533 533 data = hw->priv; 534 534 data->hw = hw; 535 535 536 - data->dev = device_create_drvdata(hwsim_class, NULL, 0, hw, 537 - "hwsim%d", i); 536 + data->dev = device_create(hwsim_class, NULL, 0, hw, 537 + "hwsim%d", i); 538 538 if (IS_ERR(data->dev)) { 539 539 printk(KERN_DEBUG 540 - "mac80211_hwsim: device_create_drvdata " 540 + "mac80211_hwsim: device_create " 541 541 "failed (%ld)\n", PTR_ERR(data->dev)); 542 542 err = -ENOMEM; 543 543 goto failed_drvdata;
+5 -45
drivers/pci/probe.c
··· 1237 1237 EXPORT_SYMBOL_GPL(pci_scan_child_bus); 1238 1238 #endif 1239 1239 1240 - static int __init pci_sort_bf_cmp(const struct pci_dev *a, const struct pci_dev *b) 1240 + static int __init pci_sort_bf_cmp(const struct device *d_a, const struct device *d_b) 1241 1241 { 1242 + const struct pci_dev *a = to_pci_dev(d_a); 1243 + const struct pci_dev *b = to_pci_dev(d_b); 1244 + 1242 1245 if (pci_domain_nr(a->bus) < pci_domain_nr(b->bus)) return -1; 1243 1246 else if (pci_domain_nr(a->bus) > pci_domain_nr(b->bus)) return 1; 1244 1247 ··· 1254 1251 return 0; 1255 1252 } 1256 1253 1257 - /* 1258 - * Yes, this forcably breaks the klist abstraction temporarily. It 1259 - * just wants to sort the klist, not change reference counts and 1260 - * take/drop locks rapidly in the process. It does all this while 1261 - * holding the lock for the list, so objects can't otherwise be 1262 - * added/removed while we're swizzling. 1263 - */ 1264 - static void __init pci_insertion_sort_klist(struct pci_dev *a, struct list_head *list) 1265 - { 1266 - struct list_head *pos; 1267 - struct klist_node *n; 1268 - struct device *dev; 1269 - struct pci_dev *b; 1270 - 1271 - list_for_each(pos, list) { 1272 - n = container_of(pos, struct klist_node, n_node); 1273 - dev = container_of(n, struct device, knode_bus); 1274 - b = to_pci_dev(dev); 1275 - if (pci_sort_bf_cmp(a, b) <= 0) { 1276 - list_move_tail(&a->dev.knode_bus.n_node, &b->dev.knode_bus.n_node); 1277 - return; 1278 - } 1279 - } 1280 - list_move_tail(&a->dev.knode_bus.n_node, list); 1281 - } 1282 - 1283 1254 void __init pci_sort_breadthfirst(void) 1284 1255 { 1285 - LIST_HEAD(sorted_devices); 1286 - struct list_head *pos, *tmp; 1287 - struct klist_node *n; 1288 - struct device *dev; 1289 - struct pci_dev *pdev; 1290 - struct klist *device_klist; 1291 - 1292 - device_klist = bus_get_device_klist(&pci_bus_type); 1293 - 1294 - spin_lock(&device_klist->k_lock); 1295 - list_for_each_safe(pos, tmp, &device_klist->k_list) { 1296 - n = container_of(pos, struct klist_node, n_node); 1297 - dev = container_of(n, struct device, knode_bus); 1298 - pdev = to_pci_dev(dev); 1299 - pci_insertion_sort_klist(pdev, &sorted_devices); 1300 - } 1301 - list_splice(&sorted_devices, &device_klist->k_list); 1302 - spin_unlock(&device_klist->k_lock); 1256 + bus_sort_breadthfirst(&pci_bus_type, &pci_sort_bf_cmp); 1303 1257 }
+1 -1
drivers/pnp/base.h
··· 4 4 */ 5 5 6 6 extern spinlock_t pnp_lock; 7 + extern struct device_attribute pnp_interface_attrs[]; 7 8 void *pnp_alloc(long size); 8 9 9 10 int pnp_register_protocol(struct pnp_protocol *protocol); ··· 17 16 18 17 int pnp_add_device(struct pnp_dev *dev); 19 18 struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id); 20 - int pnp_interface_attach_device(struct pnp_dev *dev); 21 19 22 20 int pnp_add_card(struct pnp_card *card); 23 21 void pnp_remove_card(struct pnp_card *card);
+1 -9
drivers/pnp/core.c
··· 159 159 160 160 int __pnp_add_device(struct pnp_dev *dev) 161 161 { 162 - int ret; 163 - 164 162 pnp_fixup_device(dev); 165 163 dev->status = PNP_READY; 166 164 spin_lock(&pnp_lock); 167 165 list_add_tail(&dev->global_list, &pnp_global); 168 166 list_add_tail(&dev->protocol_list, &dev->protocol->devices); 169 167 spin_unlock(&pnp_lock); 170 - 171 - ret = device_register(&dev->dev); 172 - if (ret) 173 - return ret; 174 - 175 - pnp_interface_attach_device(dev); 176 - return 0; 168 + return device_register(&dev->dev); 177 169 } 178 170 179 171 /*
+1
drivers/pnp/driver.c
··· 206 206 .remove = pnp_device_remove, 207 207 .suspend = pnp_bus_suspend, 208 208 .resume = pnp_bus_resume, 209 + .dev_attrs = pnp_interface_attrs, 209 210 }; 210 211 211 212 int pnp_register_driver(struct pnp_driver *drv)
+8 -29
drivers/pnp/interface.c
··· 243 243 return ret; 244 244 } 245 245 246 - static DEVICE_ATTR(options, S_IRUGO, pnp_show_options, NULL); 247 - 248 246 static ssize_t pnp_show_current_resources(struct device *dmdev, 249 247 struct device_attribute *attr, 250 248 char *buf) ··· 418 420 return count; 419 421 } 420 422 421 - static DEVICE_ATTR(resources, S_IRUGO | S_IWUSR, 422 - pnp_show_current_resources, pnp_set_current_resources); 423 - 424 423 static ssize_t pnp_show_current_ids(struct device *dmdev, 425 424 struct device_attribute *attr, char *buf) 426 425 { ··· 432 437 return (str - buf); 433 438 } 434 439 435 - static DEVICE_ATTR(id, S_IRUGO, pnp_show_current_ids, NULL); 436 - 437 - int pnp_interface_attach_device(struct pnp_dev *dev) 438 - { 439 - int rc = device_create_file(&dev->dev, &dev_attr_options); 440 - 441 - if (rc) 442 - goto err; 443 - rc = device_create_file(&dev->dev, &dev_attr_resources); 444 - if (rc) 445 - goto err_opt; 446 - rc = device_create_file(&dev->dev, &dev_attr_id); 447 - if (rc) 448 - goto err_res; 449 - 450 - return 0; 451 - 452 - err_res: 453 - device_remove_file(&dev->dev, &dev_attr_resources); 454 - err_opt: 455 - device_remove_file(&dev->dev, &dev_attr_options); 456 - err: 457 - return rc; 458 - } 440 + struct device_attribute pnp_interface_attrs[] = { 441 + __ATTR(resources, S_IRUGO | S_IWUSR, 442 + pnp_show_current_resources, 443 + pnp_set_current_resources), 444 + __ATTR(options, S_IRUGO, pnp_show_options, NULL), 445 + __ATTR(id, S_IRUGO, pnp_show_current_ids, NULL), 446 + __ATTR_NULL, 447 + };
+2 -2
drivers/power/power_supply_core.c
··· 91 91 { 92 92 int rc = 0; 93 93 94 - psy->dev = device_create_drvdata(power_supply_class, parent, 0, 95 - psy, "%s", psy->name); 94 + psy->dev = device_create(power_supply_class, parent, 0, psy, 95 + "%s", psy->name); 96 96 if (IS_ERR(psy->dev)) { 97 97 rc = PTR_ERR(psy->dev); 98 98 goto dev_create_failed;
+6 -8
drivers/s390/char/raw3270.c
··· 1168 1168 if (rc) 1169 1169 goto out; 1170 1170 1171 - rp->clttydev = device_create_drvdata(class3270, &rp->cdev->dev, 1172 - MKDEV(IBM_TTY3270_MAJOR, rp->minor), 1173 - NULL, 1174 - "tty%s", dev_name(&rp->cdev->dev)); 1171 + rp->clttydev = device_create(class3270, &rp->cdev->dev, 1172 + MKDEV(IBM_TTY3270_MAJOR, rp->minor), NULL, 1173 + "tty%s", dev_name(&rp->cdev->dev)); 1175 1174 if (IS_ERR(rp->clttydev)) { 1176 1175 rc = PTR_ERR(rp->clttydev); 1177 1176 goto out_ttydev; 1178 1177 } 1179 1178 1180 - rp->cltubdev = device_create_drvdata(class3270, &rp->cdev->dev, 1181 - MKDEV(IBM_FS3270_MAJOR, rp->minor), 1182 - NULL, 1183 - "tub%s", dev_name(&rp->cdev->dev)); 1179 + rp->cltubdev = device_create(class3270, &rp->cdev->dev, 1180 + MKDEV(IBM_FS3270_MAJOR, rp->minor), NULL, 1181 + "tub%s", dev_name(&rp->cdev->dev)); 1184 1182 if (!IS_ERR(rp->cltubdev)) 1185 1183 goto out; 1186 1184
+3 -3
drivers/s390/char/tape_class.c
··· 69 69 if (rc) 70 70 goto fail_with_cdev; 71 71 72 - tcd->class_device = device_create_drvdata(tape_class, device, 73 - tcd->char_device->dev, 74 - NULL, "%s", tcd->device_name); 72 + tcd->class_device = device_create(tape_class, device, 73 + tcd->char_device->dev, NULL, 74 + "%s", tcd->device_name); 75 75 rc = IS_ERR(tcd->class_device) ? PTR_ERR(tcd->class_device) : 0; 76 76 if (rc) 77 77 goto fail_with_cdev;
+4 -4
drivers/s390/char/vmlogrdr.c
··· 747 747 device_unregister(dev); 748 748 return ret; 749 749 } 750 - priv->class_device = device_create_drvdata(vmlogrdr_class, dev, 751 - MKDEV(vmlogrdr_major, 752 - priv->minor_num), 753 - priv, "%s", dev_name(dev)); 750 + priv->class_device = device_create(vmlogrdr_class, dev, 751 + MKDEV(vmlogrdr_major, 752 + priv->minor_num), 753 + priv, "%s", dev_name(dev)); 754 754 if (IS_ERR(priv->class_device)) { 755 755 ret = PTR_ERR(priv->class_device); 756 756 priv->class_device=NULL;
+2 -3
drivers/s390/char/vmur.c
··· 896 896 goto fail_free_cdev; 897 897 } 898 898 899 - urd->device = device_create_drvdata(vmur_class, NULL, 900 - urd->char_device->dev, NULL, 901 - "%s", node_id); 899 + urd->device = device_create(vmur_class, NULL, urd->char_device->dev, 900 + NULL, "%s", node_id); 902 901 if (IS_ERR(urd->device)) { 903 902 rc = PTR_ERR(urd->device); 904 903 TRACE("ur_set_online: device_create rc=%d\n", rc);
+3 -3
drivers/scsi/ch.c
··· 914 914 ch->minor = minor; 915 915 sprintf(ch->name,"ch%d",ch->minor); 916 916 917 - class_dev = device_create_drvdata(ch_sysfs_class, dev, 918 - MKDEV(SCSI_CHANGER_MAJOR, ch->minor), 919 - ch, "s%s", ch->name); 917 + class_dev = device_create(ch_sysfs_class, dev, 918 + MKDEV(SCSI_CHANGER_MAJOR, ch->minor), ch, 919 + "s%s", ch->name); 920 920 if (IS_ERR(class_dev)) { 921 921 printk(KERN_WARNING "ch%d: device_create failed\n", 922 922 ch->minor);
+1 -1
drivers/scsi/dpt_i2o.c
··· 271 271 pHba->initialized = TRUE; 272 272 pHba->state &= ~DPTI_STATE_RESET; 273 273 if (adpt_sysfs_class) { 274 - struct device *dev = device_create_drvdata(adpt_sysfs_class, 274 + struct device *dev = device_create(adpt_sysfs_class, 275 275 NULL, MKDEV(DPTI_I2O_MAJOR, pHba->unit), NULL, 276 276 "dpti%d", pHba->unit); 277 277 if (IS_ERR(dev)) {
+2 -1
drivers/scsi/osst.c
··· 5708 5708 struct device *osst_member; 5709 5709 int err; 5710 5710 5711 - osst_member = device_create_drvdata(osst_sysfs_class, device, dev, STp, "%s", name); 5711 + osst_member = device_create(osst_sysfs_class, device, dev, STp, 5712 + "%s", name); 5712 5713 if (IS_ERR(osst_member)) { 5713 5714 printk(KERN_WARNING "osst :W: Unable to add sysfs class member %s\n", name); 5714 5715 return PTR_ERR(osst_member);
+4 -6
drivers/scsi/sg.c
··· 1450 1450 if (sg_sysfs_valid) { 1451 1451 struct device *sg_class_member; 1452 1452 1453 - sg_class_member = device_create_drvdata(sg_sysfs_class, 1454 - cl_dev->parent, 1455 - MKDEV(SCSI_GENERIC_MAJOR, 1456 - sdp->index), 1457 - sdp, 1458 - "%s", disk->disk_name); 1453 + sg_class_member = device_create(sg_sysfs_class, cl_dev->parent, 1454 + MKDEV(SCSI_GENERIC_MAJOR, 1455 + sdp->index), 1456 + sdp, "%s", disk->disk_name); 1459 1457 if (IS_ERR(sg_class_member)) { 1460 1458 printk(KERN_ERR "sg_add: " 1461 1459 "device_create failed\n");
+4 -7
drivers/scsi/st.c
··· 4428 4428 snprintf(name, 10, "%s%s%s", rew ? "n" : "", 4429 4429 STp->disk->disk_name, st_formats[i]); 4430 4430 st_class_member = 4431 - device_create_drvdata(st_sysfs_class, 4432 - &STp->device->sdev_gendev, 4433 - MKDEV(SCSI_TAPE_MAJOR, 4434 - TAPE_MINOR(dev_num, 4435 - mode, rew)), 4436 - &STp->modes[mode], 4437 - "%s", name); 4431 + device_create(st_sysfs_class, &STp->device->sdev_gendev, 4432 + MKDEV(SCSI_TAPE_MAJOR, 4433 + TAPE_MINOR(dev_num, mode, rew)), 4434 + &STp->modes[mode], "%s", name); 4438 4435 if (IS_ERR(st_class_member)) { 4439 4436 printk(KERN_WARNING "st%d: device_create failed\n", 4440 4437 dev_num);
+3 -4
drivers/spi/spidev.c
··· 583 583 struct device *dev; 584 584 585 585 spidev->devt = MKDEV(SPIDEV_MAJOR, minor); 586 - dev = device_create_drvdata(spidev_class, &spi->dev, 587 - spidev->devt, spidev, 588 - "spidev%d.%d", 589 - spi->master->bus_num, spi->chip_select); 586 + dev = device_create(spidev_class, &spi->dev, spidev->devt, 587 + spidev, "spidev%d.%d", 588 + spi->master->bus_num, spi->chip_select); 590 589 status = IS_ERR(dev) ? PTR_ERR(dev) : 0; 591 590 } else { 592 591 dev_dbg(&spi->dev, "no minor number available!\n");
+13
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_SERCOS3 62 + tristate "Automata Sercos III PCI card driver" 63 + default n 64 + help 65 + Userspace I/O interface for the Sercos III PCI card from 66 + Automata GmbH. The userspace part of this driver will be 67 + available for download from the Automata GmbH web site. 68 + 69 + Automata GmbH: http://www.automataweb.com 70 + Sercos III interface: http://www.sercos.com 71 + 72 + If you compile this as a module, it will be called uio_sercos3. 73 + 61 74 endif
+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_SERCOS3) += uio_sercos3.o
+21 -5
drivers/uio/uio.c
··· 67 67 return sprintf(buf, "0x%lx\n", mem->size); 68 68 } 69 69 70 + static ssize_t map_offset_show(struct uio_mem *mem, char *buf) 71 + { 72 + return sprintf(buf, "0x%lx\n", mem->addr & ~PAGE_MASK); 73 + } 74 + 70 75 struct uio_sysfs_entry { 71 76 struct attribute attr; 72 77 ssize_t (*show)(struct uio_mem *, char *); ··· 82 77 __ATTR(addr, S_IRUGO, map_addr_show, NULL); 83 78 static struct uio_sysfs_entry size_attribute = 84 79 __ATTR(size, S_IRUGO, map_size_show, NULL); 80 + static struct uio_sysfs_entry offset_attribute = 81 + __ATTR(offset, S_IRUGO, map_offset_show, NULL); 85 82 86 83 static struct attribute *attrs[] = { 87 84 &addr_attribute.attr, 88 85 &size_attribute.attr, 86 + &offset_attribute.attr, 89 87 NULL, /* need to NULL terminate the list of attributes */ 90 88 }; 91 89 ··· 490 482 { 491 483 struct uio_device *idev = vma->vm_private_data; 492 484 struct page *page; 485 + unsigned long offset; 493 486 494 487 int mi = uio_find_mem_index(vma); 495 488 if (mi < 0) 496 489 return VM_FAULT_SIGBUS; 497 490 491 + /* 492 + * We need to subtract mi because userspace uses offset = N*PAGE_SIZE 493 + * to use mem[N]. 494 + */ 495 + offset = (vmf->pgoff - mi) << PAGE_SHIFT; 496 + 498 497 if (idev->info->mem[mi].memtype == UIO_MEM_LOGICAL) 499 - page = virt_to_page(idev->info->mem[mi].addr); 498 + page = virt_to_page(idev->info->mem[mi].addr + offset); 500 499 else 501 - page = vmalloc_to_page((void*)idev->info->mem[mi].addr); 500 + page = vmalloc_to_page((void *)idev->info->mem[mi].addr 501 + + offset); 502 502 get_page(page); 503 503 vmf->page = page; 504 504 return 0; ··· 698 682 if (ret) 699 683 goto err_get_minor; 700 684 701 - idev->dev = device_create_drvdata(uio_class->class, parent, 702 - MKDEV(uio_major, idev->minor), idev, 703 - "uio%d", idev->minor); 685 + idev->dev = device_create(uio_class->class, parent, 686 + MKDEV(uio_major, idev->minor), idev, 687 + "uio%d", idev->minor); 704 688 if (IS_ERR(idev->dev)) { 705 689 printk(KERN_ERR "UIO: device register failed\n"); 706 690 ret = PTR_ERR(idev->dev);
+1 -1
drivers/uio/uio_pdrv.c
··· 12 12 #include <linux/uio_driver.h> 13 13 #include <linux/stringify.h> 14 14 15 - #define DRIVER_NAME "uio" 15 + #define DRIVER_NAME "uio_pdrv" 16 16 17 17 struct uio_platdata { 18 18 struct uio_info *uioinfo;
+243
drivers/uio/uio_sercos3.c
··· 1 + /* sercos3: UIO driver for the Automata Sercos III PCI card 2 + 3 + Copyright (C) 2008 Linutronix GmbH 4 + Author: John Ogness <john.ogness@linutronix.de> 5 + 6 + This is a straight-forward UIO driver, where interrupts are disabled 7 + by the interrupt handler and re-enabled via a write to the UIO device 8 + by the userspace-part. 9 + 10 + The only part that may seem odd is the use of a logical OR when 11 + storing and restoring enabled interrupts. This is done because the 12 + userspace-part could directly modify the Interrupt Enable Register 13 + at any time. To reduce possible conflicts, the kernel driver uses 14 + a logical OR to make more controlled changes (rather than blindly 15 + overwriting previous values). 16 + 17 + Race conditions exist if the userspace-part directly modifies the 18 + Interrupt Enable Register while in operation. The consequences are 19 + that certain interrupts would fail to be enabled or disabled. For 20 + this reason, the userspace-part should only directly modify the 21 + Interrupt Enable Register at the beginning (to get things going). 22 + The userspace-part can safely disable interrupts at any time using 23 + a write to the UIO device. 24 + */ 25 + 26 + #include <linux/device.h> 27 + #include <linux/module.h> 28 + #include <linux/pci.h> 29 + #include <linux/uio_driver.h> 30 + #include <linux/io.h> 31 + 32 + /* ID's for SERCOS III PCI card (PLX 9030) */ 33 + #define SERCOS_SUB_VENDOR_ID 0x1971 34 + #define SERCOS_SUB_SYSID_3530 0x3530 35 + #define SERCOS_SUB_SYSID_3535 0x3535 36 + #define SERCOS_SUB_SYSID_3780 0x3780 37 + 38 + /* Interrupt Enable Register */ 39 + #define IER0_OFFSET 0x08 40 + 41 + /* Interrupt Status Register */ 42 + #define ISR0_OFFSET 0x18 43 + 44 + struct sercos3_priv { 45 + u32 ier0_cache; 46 + spinlock_t ier0_cache_lock; 47 + }; 48 + 49 + /* this function assumes ier0_cache_lock is locked! */ 50 + static void sercos3_disable_interrupts(struct uio_info *info, 51 + struct sercos3_priv *priv) 52 + { 53 + void __iomem *ier0 = info->mem[3].internal_addr + IER0_OFFSET; 54 + 55 + /* add enabled interrupts to cache */ 56 + priv->ier0_cache |= ioread32(ier0); 57 + 58 + /* disable interrupts */ 59 + iowrite32(0, ier0); 60 + } 61 + 62 + /* this function assumes ier0_cache_lock is locked! */ 63 + static void sercos3_enable_interrupts(struct uio_info *info, 64 + struct sercos3_priv *priv) 65 + { 66 + void __iomem *ier0 = info->mem[3].internal_addr + IER0_OFFSET; 67 + 68 + /* restore previously enabled interrupts */ 69 + iowrite32(ioread32(ier0) | priv->ier0_cache, ier0); 70 + priv->ier0_cache = 0; 71 + } 72 + 73 + static irqreturn_t sercos3_handler(int irq, struct uio_info *info) 74 + { 75 + struct sercos3_priv *priv = info->priv; 76 + void __iomem *isr0 = info->mem[3].internal_addr + ISR0_OFFSET; 77 + void __iomem *ier0 = info->mem[3].internal_addr + IER0_OFFSET; 78 + 79 + if (!(ioread32(isr0) & ioread32(ier0))) 80 + return IRQ_NONE; 81 + 82 + spin_lock(&priv->ier0_cache_lock); 83 + sercos3_disable_interrupts(info, priv); 84 + spin_unlock(&priv->ier0_cache_lock); 85 + 86 + return IRQ_HANDLED; 87 + } 88 + 89 + static int sercos3_irqcontrol(struct uio_info *info, s32 irq_on) 90 + { 91 + struct sercos3_priv *priv = info->priv; 92 + 93 + spin_lock_irq(&priv->ier0_cache_lock); 94 + if (irq_on) 95 + sercos3_enable_interrupts(info, priv); 96 + else 97 + sercos3_disable_interrupts(info, priv); 98 + spin_unlock_irq(&priv->ier0_cache_lock); 99 + 100 + return 0; 101 + } 102 + 103 + static int sercos3_setup_iomem(struct pci_dev *dev, struct uio_info *info, 104 + int n, int pci_bar) 105 + { 106 + info->mem[n].addr = pci_resource_start(dev, pci_bar); 107 + if (!info->mem[n].addr) 108 + return -1; 109 + info->mem[n].internal_addr = ioremap(pci_resource_start(dev, pci_bar), 110 + pci_resource_len(dev, pci_bar)); 111 + if (!info->mem[n].internal_addr) 112 + return -1; 113 + info->mem[n].size = pci_resource_len(dev, pci_bar); 114 + info->mem[n].memtype = UIO_MEM_PHYS; 115 + return 0; 116 + } 117 + 118 + static int __devinit sercos3_pci_probe(struct pci_dev *dev, 119 + const struct pci_device_id *id) 120 + { 121 + struct uio_info *info; 122 + struct sercos3_priv *priv; 123 + int i; 124 + 125 + info = kzalloc(sizeof(struct uio_info), GFP_KERNEL); 126 + if (!info) 127 + return -ENOMEM; 128 + 129 + priv = kzalloc(sizeof(struct sercos3_priv), GFP_KERNEL); 130 + if (!priv) 131 + goto out_free; 132 + 133 + if (pci_enable_device(dev)) 134 + goto out_free_priv; 135 + 136 + if (pci_request_regions(dev, "sercos3")) 137 + goto out_disable; 138 + 139 + /* we only need PCI BAR's 0, 2, 3, 4, 5 */ 140 + if (sercos3_setup_iomem(dev, info, 0, 0)) 141 + goto out_unmap; 142 + if (sercos3_setup_iomem(dev, info, 1, 2)) 143 + goto out_unmap; 144 + if (sercos3_setup_iomem(dev, info, 2, 3)) 145 + goto out_unmap; 146 + if (sercos3_setup_iomem(dev, info, 3, 4)) 147 + goto out_unmap; 148 + if (sercos3_setup_iomem(dev, info, 4, 5)) 149 + goto out_unmap; 150 + 151 + spin_lock_init(&priv->ier0_cache_lock); 152 + info->priv = priv; 153 + info->name = "Sercos_III_PCI"; 154 + info->version = "0.0.1"; 155 + info->irq = dev->irq; 156 + info->irq_flags = IRQF_DISABLED | IRQF_SHARED; 157 + info->handler = sercos3_handler; 158 + info->irqcontrol = sercos3_irqcontrol; 159 + 160 + pci_set_drvdata(dev, info); 161 + 162 + if (uio_register_device(&dev->dev, info)) 163 + goto out_unmap; 164 + 165 + return 0; 166 + 167 + out_unmap: 168 + for (i = 0; i < 5; i++) { 169 + if (info->mem[i].internal_addr) 170 + iounmap(info->mem[i].internal_addr); 171 + } 172 + pci_release_regions(dev); 173 + out_disable: 174 + pci_disable_device(dev); 175 + out_free_priv: 176 + kfree(priv); 177 + out_free: 178 + kfree(info); 179 + return -ENODEV; 180 + } 181 + 182 + static void sercos3_pci_remove(struct pci_dev *dev) 183 + { 184 + struct uio_info *info = pci_get_drvdata(dev); 185 + int i; 186 + 187 + uio_unregister_device(info); 188 + pci_release_regions(dev); 189 + pci_disable_device(dev); 190 + pci_set_drvdata(dev, NULL); 191 + for (i = 0; i < 5; i++) { 192 + if (info->mem[i].internal_addr) 193 + iounmap(info->mem[i].internal_addr); 194 + } 195 + kfree(info->priv); 196 + kfree(info); 197 + } 198 + 199 + static struct pci_device_id sercos3_pci_ids[] __devinitdata = { 200 + { 201 + .vendor = PCI_VENDOR_ID_PLX, 202 + .device = PCI_DEVICE_ID_PLX_9030, 203 + .subvendor = SERCOS_SUB_VENDOR_ID, 204 + .subdevice = SERCOS_SUB_SYSID_3530, 205 + }, 206 + { 207 + .vendor = PCI_VENDOR_ID_PLX, 208 + .device = PCI_DEVICE_ID_PLX_9030, 209 + .subvendor = SERCOS_SUB_VENDOR_ID, 210 + .subdevice = SERCOS_SUB_SYSID_3535, 211 + }, 212 + { 213 + .vendor = PCI_VENDOR_ID_PLX, 214 + .device = PCI_DEVICE_ID_PLX_9030, 215 + .subvendor = SERCOS_SUB_VENDOR_ID, 216 + .subdevice = SERCOS_SUB_SYSID_3780, 217 + }, 218 + { 0, } 219 + }; 220 + 221 + static struct pci_driver sercos3_pci_driver = { 222 + .name = "sercos3", 223 + .id_table = sercos3_pci_ids, 224 + .probe = sercos3_pci_probe, 225 + .remove = sercos3_pci_remove, 226 + }; 227 + 228 + static int __init sercos3_init_module(void) 229 + { 230 + return pci_register_driver(&sercos3_pci_driver); 231 + } 232 + 233 + static void __exit sercos3_exit_module(void) 234 + { 235 + pci_unregister_driver(&sercos3_pci_driver); 236 + } 237 + 238 + module_init(sercos3_init_module); 239 + module_exit(sercos3_exit_module); 240 + 241 + MODULE_DESCRIPTION("UIO driver for the Automata Sercos III PCI card"); 242 + MODULE_AUTHOR("John Ogness <john.ogness@linutronix.de>"); 243 + MODULE_LICENSE("GPL v2");
+3 -3
drivers/usb/core/devio.c
··· 1729 1729 { 1730 1730 struct device *cldev; 1731 1731 1732 - cldev = device_create_drvdata(usb_classdev_class, &dev->dev, 1733 - dev->dev.devt, NULL, "usbdev%d.%d", 1734 - dev->bus->busnum, dev->devnum); 1732 + cldev = device_create(usb_classdev_class, &dev->dev, dev->dev.devt, 1733 + NULL, "usbdev%d.%d", dev->bus->busnum, 1734 + dev->devnum); 1735 1735 if (IS_ERR(cldev)) 1736 1736 return PTR_ERR(cldev); 1737 1737 dev->usb_classdev = cldev;
+3 -3
drivers/usb/core/file.c
··· 196 196 ++temp; 197 197 else 198 198 temp = name; 199 - intf->usb_dev = device_create_drvdata(usb_class->class, &intf->dev, 200 - MKDEV(USB_MAJOR, minor), NULL, 201 - "%s", temp); 199 + intf->usb_dev = device_create(usb_class->class, &intf->dev, 200 + MKDEV(USB_MAJOR, minor), NULL, 201 + "%s", temp); 202 202 if (IS_ERR(intf->usb_dev)) { 203 203 down_write(&minor_rwsem); 204 204 usb_minors[intf->minor] = NULL;
+2 -3
drivers/usb/core/hcd.c
··· 818 818 set_bit (busnum, busmap.busmap); 819 819 bus->busnum = busnum; 820 820 821 - bus->dev = device_create_drvdata(usb_host_class, bus->controller, 822 - MKDEV(0, 0), bus, 823 - "usb_host%d", busnum); 821 + bus->dev = device_create(usb_host_class, bus->controller, MKDEV(0, 0), 822 + bus, "usb_host%d", busnum); 824 823 result = PTR_ERR(bus->dev); 825 824 if (IS_ERR(bus->dev)) 826 825 goto error_create_class_dev;
+7 -16
drivers/usb/gadget/Makefile
··· 22 22 # 23 23 # USB gadget drivers 24 24 # 25 - C_UTILS = composite.o usbstring.o config.o epautoconf.o 26 - 27 - g_zero-objs := zero.o f_sourcesink.o f_loopback.o $(C_UTILS) 28 - g_ether-objs := ether.o u_ether.o f_subset.o f_ecm.o $(C_UTILS) 29 - g_serial-objs := serial.o u_serial.o f_acm.o f_serial.o $(C_UTILS) 30 - g_midi-objs := gmidi.o usbstring.o config.o epautoconf.o 25 + g_zero-objs := zero.o 26 + g_ether-objs := ether.o 27 + g_serial-objs := serial.o 28 + g_midi-objs := gmidi.o 31 29 gadgetfs-objs := inode.o 32 - g_file_storage-objs := file_storage.o usbstring.o config.o \ 33 - epautoconf.o 34 - g_printer-objs := printer.o usbstring.o config.o \ 35 - epautoconf.o 36 - g_cdc-objs := cdc2.o u_ether.o f_ecm.o \ 37 - u_serial.o f_acm.o $(C_UTILS) 30 + g_file_storage-objs := file_storage.o 31 + g_printer-objs := printer.o 32 + g_cdc-objs := cdc2.o 38 33 39 - ifeq ($(CONFIG_USB_ETH_RNDIS),y) 40 - g_ether-objs += f_rndis.o rndis.o 41 - endif 42 - 43 34 obj-$(CONFIG_USB_ZERO) += g_zero.o 44 35 obj-$(CONFIG_USB_ETH) += g_ether.o 45 36 obj-$(CONFIG_USB_GADGETFS) += gadgetfs.o
+23 -2
drivers/usb/gadget/cdc2.c
··· 43 43 44 44 /*-------------------------------------------------------------------------*/ 45 45 46 + /* 47 + * Kbuild is not very cooperative with respect to linking separately 48 + * compiled library objects into one module. So for now we won't use 49 + * separate compilation ... ensuring init/exit sections work to shrink 50 + * the runtime footprint, and giving us at least some parts of what 51 + * a "gcc --combine ... part1.c part2.c part3.c ... " build would. 52 + */ 53 + 54 + #include "composite.c" 55 + #include "usbstring.c" 56 + #include "config.c" 57 + #include "epautoconf.c" 58 + #include "u_serial.c" 59 + #include "f_acm.c" 60 + #include "f_ecm.c" 61 + #include "u_ether.c" 62 + 63 + /*-------------------------------------------------------------------------*/ 64 + 46 65 static struct usb_device_descriptor device_desc = { 47 66 .bLength = sizeof device_desc, 48 67 .bDescriptorType = USB_DT_DEVICE, ··· 167 148 int status; 168 149 169 150 if (!can_support_ecm(cdev->gadget)) { 170 - ERROR(cdev, "controller '%s' not usable\n", gadget->name); 151 + dev_err(&gadget->dev, "controller '%s' not usable\n", 152 + gadget->name); 171 153 return -EINVAL; 172 154 } 173 155 ··· 223 203 if (status < 0) 224 204 goto fail1; 225 205 226 - INFO(cdev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC); 206 + dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", 207 + DRIVER_DESC); 227 208 228 209 return 0; 229 210
+26 -2
drivers/usb/gadget/ether.c
··· 96 96 97 97 /*-------------------------------------------------------------------------*/ 98 98 99 + /* 100 + * Kbuild is not very cooperative with respect to linking separately 101 + * compiled library objects into one module. So for now we won't use 102 + * separate compilation ... ensuring init/exit sections work to shrink 103 + * the runtime footprint, and giving us at least some parts of what 104 + * a "gcc --combine ... part1.c part2.c part3.c ... " build would. 105 + */ 106 + #include "composite.c" 107 + #include "usbstring.c" 108 + #include "config.c" 109 + #include "epautoconf.c" 110 + 111 + #include "f_ecm.c" 112 + #include "f_subset.c" 113 + #ifdef CONFIG_USB_ETH_RNDIS 114 + #include "f_rndis.c" 115 + #include "rndis.c" 116 + #endif 117 + #include "u_ether.c" 118 + 119 + /*-------------------------------------------------------------------------*/ 120 + 99 121 /* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! 100 122 * Instead: allocate your own, using normal USB-IF procedures. 101 123 */ ··· 315 293 * but if the controller isn't recognized at all then 316 294 * that assumption is a bit more likely to be wrong. 317 295 */ 318 - WARNING(cdev, "controller '%s' not recognized; trying %s\n", 296 + dev_warn(&gadget->dev, 297 + "controller '%s' not recognized; trying %s\n", 319 298 gadget->name, 320 299 eth_config_driver.label); 321 300 device_desc.bcdDevice = ··· 355 332 if (status < 0) 356 333 goto fail; 357 334 358 - INFO(cdev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC); 335 + dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", 336 + DRIVER_DESC); 359 337 360 338 return 0; 361 339
+54 -54
drivers/usb/gadget/f_ecm.c
··· 83 83 } 84 84 85 85 /* peak (theoretical) bulk transfer rate in bits-per-second */ 86 - static inline unsigned bitrate(struct usb_gadget *g) 86 + static inline unsigned ecm_bitrate(struct usb_gadget *g) 87 87 { 88 88 if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH) 89 89 return 13 * 512 * 8 * 1000 * 8; ··· 107 107 */ 108 108 109 109 #define LOG2_STATUS_INTERVAL_MSEC 5 /* 1 << 5 == 32 msec */ 110 - #define STATUS_BYTECOUNT 16 /* 8 byte header + data */ 110 + #define ECM_STATUS_BYTECOUNT 16 /* 8 byte header + data */ 111 111 112 112 113 113 /* interface descriptor: */ ··· 125 125 /* .iInterface = DYNAMIC */ 126 126 }; 127 127 128 - static struct usb_cdc_header_desc header_desc __initdata = { 129 - .bLength = sizeof header_desc, 128 + static struct usb_cdc_header_desc ecm_header_desc __initdata = { 129 + .bLength = sizeof ecm_header_desc, 130 130 .bDescriptorType = USB_DT_CS_INTERFACE, 131 131 .bDescriptorSubType = USB_CDC_HEADER_TYPE, 132 132 ··· 141 141 /* .bSlaveInterface0 = DYNAMIC */ 142 142 }; 143 143 144 - static struct usb_cdc_ether_desc ether_desc __initdata = { 145 - .bLength = sizeof ether_desc, 144 + static struct usb_cdc_ether_desc ecm_desc __initdata = { 145 + .bLength = sizeof ecm_desc, 146 146 .bDescriptorType = USB_DT_CS_INTERFACE, 147 147 .bDescriptorSubType = USB_CDC_ETHERNET_TYPE, 148 148 ··· 186 186 187 187 /* full speed support: */ 188 188 189 - static struct usb_endpoint_descriptor fs_notify_desc __initdata = { 189 + static struct usb_endpoint_descriptor fs_ecm_notify_desc __initdata = { 190 190 .bLength = USB_DT_ENDPOINT_SIZE, 191 191 .bDescriptorType = USB_DT_ENDPOINT, 192 192 193 193 .bEndpointAddress = USB_DIR_IN, 194 194 .bmAttributes = USB_ENDPOINT_XFER_INT, 195 - .wMaxPacketSize = __constant_cpu_to_le16(STATUS_BYTECOUNT), 195 + .wMaxPacketSize = __constant_cpu_to_le16(ECM_STATUS_BYTECOUNT), 196 196 .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC, 197 197 }; 198 198 199 - static struct usb_endpoint_descriptor fs_in_desc __initdata = { 199 + static struct usb_endpoint_descriptor fs_ecm_in_desc __initdata = { 200 200 .bLength = USB_DT_ENDPOINT_SIZE, 201 201 .bDescriptorType = USB_DT_ENDPOINT, 202 202 ··· 204 204 .bmAttributes = USB_ENDPOINT_XFER_BULK, 205 205 }; 206 206 207 - static struct usb_endpoint_descriptor fs_out_desc __initdata = { 207 + static struct usb_endpoint_descriptor fs_ecm_out_desc __initdata = { 208 208 .bLength = USB_DT_ENDPOINT_SIZE, 209 209 .bDescriptorType = USB_DT_ENDPOINT, 210 210 ··· 212 212 .bmAttributes = USB_ENDPOINT_XFER_BULK, 213 213 }; 214 214 215 - static struct usb_descriptor_header *eth_fs_function[] __initdata = { 215 + static struct usb_descriptor_header *ecm_fs_function[] __initdata = { 216 216 /* CDC ECM control descriptors */ 217 217 (struct usb_descriptor_header *) &ecm_control_intf, 218 - (struct usb_descriptor_header *) &header_desc, 218 + (struct usb_descriptor_header *) &ecm_header_desc, 219 219 (struct usb_descriptor_header *) &ecm_union_desc, 220 - (struct usb_descriptor_header *) &ether_desc, 220 + (struct usb_descriptor_header *) &ecm_desc, 221 221 /* NOTE: status endpoint might need to be removed */ 222 - (struct usb_descriptor_header *) &fs_notify_desc, 222 + (struct usb_descriptor_header *) &fs_ecm_notify_desc, 223 223 /* data interface, altsettings 0 and 1 */ 224 224 (struct usb_descriptor_header *) &ecm_data_nop_intf, 225 225 (struct usb_descriptor_header *) &ecm_data_intf, 226 - (struct usb_descriptor_header *) &fs_in_desc, 227 - (struct usb_descriptor_header *) &fs_out_desc, 226 + (struct usb_descriptor_header *) &fs_ecm_in_desc, 227 + (struct usb_descriptor_header *) &fs_ecm_out_desc, 228 228 NULL, 229 229 }; 230 230 231 231 /* high speed support: */ 232 232 233 - static struct usb_endpoint_descriptor hs_notify_desc __initdata = { 233 + static struct usb_endpoint_descriptor hs_ecm_notify_desc __initdata = { 234 234 .bLength = USB_DT_ENDPOINT_SIZE, 235 235 .bDescriptorType = USB_DT_ENDPOINT, 236 236 237 237 .bEndpointAddress = USB_DIR_IN, 238 238 .bmAttributes = USB_ENDPOINT_XFER_INT, 239 - .wMaxPacketSize = __constant_cpu_to_le16(STATUS_BYTECOUNT), 239 + .wMaxPacketSize = __constant_cpu_to_le16(ECM_STATUS_BYTECOUNT), 240 240 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4, 241 241 }; 242 - static struct usb_endpoint_descriptor hs_in_desc __initdata = { 242 + static struct usb_endpoint_descriptor hs_ecm_in_desc __initdata = { 243 243 .bLength = USB_DT_ENDPOINT_SIZE, 244 244 .bDescriptorType = USB_DT_ENDPOINT, 245 245 ··· 248 248 .wMaxPacketSize = __constant_cpu_to_le16(512), 249 249 }; 250 250 251 - static struct usb_endpoint_descriptor hs_out_desc __initdata = { 251 + static struct usb_endpoint_descriptor hs_ecm_out_desc __initdata = { 252 252 .bLength = USB_DT_ENDPOINT_SIZE, 253 253 .bDescriptorType = USB_DT_ENDPOINT, 254 254 ··· 257 257 .wMaxPacketSize = __constant_cpu_to_le16(512), 258 258 }; 259 259 260 - static struct usb_descriptor_header *eth_hs_function[] __initdata = { 260 + static struct usb_descriptor_header *ecm_hs_function[] __initdata = { 261 261 /* CDC ECM control descriptors */ 262 262 (struct usb_descriptor_header *) &ecm_control_intf, 263 - (struct usb_descriptor_header *) &header_desc, 263 + (struct usb_descriptor_header *) &ecm_header_desc, 264 264 (struct usb_descriptor_header *) &ecm_union_desc, 265 - (struct usb_descriptor_header *) &ether_desc, 265 + (struct usb_descriptor_header *) &ecm_desc, 266 266 /* NOTE: status endpoint might need to be removed */ 267 - (struct usb_descriptor_header *) &hs_notify_desc, 267 + (struct usb_descriptor_header *) &hs_ecm_notify_desc, 268 268 /* data interface, altsettings 0 and 1 */ 269 269 (struct usb_descriptor_header *) &ecm_data_nop_intf, 270 270 (struct usb_descriptor_header *) &ecm_data_intf, 271 - (struct usb_descriptor_header *) &hs_in_desc, 272 - (struct usb_descriptor_header *) &hs_out_desc, 271 + (struct usb_descriptor_header *) &hs_ecm_in_desc, 272 + (struct usb_descriptor_header *) &hs_ecm_out_desc, 273 273 NULL, 274 274 }; 275 275 ··· 329 329 event->bNotificationType = USB_CDC_NOTIFY_SPEED_CHANGE; 330 330 event->wValue = cpu_to_le16(0); 331 331 event->wLength = cpu_to_le16(8); 332 - req->length = STATUS_BYTECOUNT; 332 + req->length = ECM_STATUS_BYTECOUNT; 333 333 334 334 /* SPEED_CHANGE data is up/down speeds in bits/sec */ 335 335 data = req->buf + sizeof *event; 336 - data[0] = cpu_to_le32(bitrate(cdev->gadget)); 336 + data[0] = cpu_to_le32(ecm_bitrate(cdev->gadget)); 337 337 data[1] = data[0]; 338 338 339 - DBG(cdev, "notify speed %d\n", bitrate(cdev->gadget)); 339 + DBG(cdev, "notify speed %d\n", ecm_bitrate(cdev->gadget)); 340 340 ecm->notify_state = ECM_NOTIFY_NONE; 341 341 break; 342 342 } ··· 628 628 status = -ENODEV; 629 629 630 630 /* allocate instance-specific endpoints */ 631 - ep = usb_ep_autoconfig(cdev->gadget, &fs_in_desc); 631 + ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_in_desc); 632 632 if (!ep) 633 633 goto fail; 634 634 ecm->port.in_ep = ep; 635 635 ep->driver_data = cdev; /* claim */ 636 636 637 - ep = usb_ep_autoconfig(cdev->gadget, &fs_out_desc); 637 + ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_out_desc); 638 638 if (!ep) 639 639 goto fail; 640 640 ecm->port.out_ep = ep; ··· 644 644 * don't treat it that way. It's simpler, and some newer CDC 645 645 * profiles (wireless handsets) no longer treat it as optional. 646 646 */ 647 - ep = usb_ep_autoconfig(cdev->gadget, &fs_notify_desc); 647 + ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_notify_desc); 648 648 if (!ep) 649 649 goto fail; 650 650 ecm->notify = ep; ··· 656 656 ecm->notify_req = usb_ep_alloc_request(ep, GFP_KERNEL); 657 657 if (!ecm->notify_req) 658 658 goto fail; 659 - ecm->notify_req->buf = kmalloc(STATUS_BYTECOUNT, GFP_KERNEL); 659 + ecm->notify_req->buf = kmalloc(ECM_STATUS_BYTECOUNT, GFP_KERNEL); 660 660 if (!ecm->notify_req->buf) 661 661 goto fail; 662 662 ecm->notify_req->context = ecm; 663 663 ecm->notify_req->complete = ecm_notify_complete; 664 664 665 665 /* copy descriptors, and track endpoint copies */ 666 - f->descriptors = usb_copy_descriptors(eth_fs_function); 666 + f->descriptors = usb_copy_descriptors(ecm_fs_function); 667 667 if (!f->descriptors) 668 668 goto fail; 669 669 670 - ecm->fs.in = usb_find_endpoint(eth_fs_function, 671 - f->descriptors, &fs_in_desc); 672 - ecm->fs.out = usb_find_endpoint(eth_fs_function, 673 - f->descriptors, &fs_out_desc); 674 - ecm->fs.notify = usb_find_endpoint(eth_fs_function, 675 - f->descriptors, &fs_notify_desc); 670 + ecm->fs.in = usb_find_endpoint(ecm_fs_function, 671 + f->descriptors, &fs_ecm_in_desc); 672 + ecm->fs.out = usb_find_endpoint(ecm_fs_function, 673 + f->descriptors, &fs_ecm_out_desc); 674 + ecm->fs.notify = usb_find_endpoint(ecm_fs_function, 675 + f->descriptors, &fs_ecm_notify_desc); 676 676 677 677 /* support all relevant hardware speeds... we expect that when 678 678 * hardware is dual speed, all bulk-capable endpoints work at 679 679 * both speeds 680 680 */ 681 681 if (gadget_is_dualspeed(c->cdev->gadget)) { 682 - hs_in_desc.bEndpointAddress = 683 - fs_in_desc.bEndpointAddress; 684 - hs_out_desc.bEndpointAddress = 685 - fs_out_desc.bEndpointAddress; 686 - hs_notify_desc.bEndpointAddress = 687 - fs_notify_desc.bEndpointAddress; 682 + hs_ecm_in_desc.bEndpointAddress = 683 + fs_ecm_in_desc.bEndpointAddress; 684 + hs_ecm_out_desc.bEndpointAddress = 685 + fs_ecm_out_desc.bEndpointAddress; 686 + hs_ecm_notify_desc.bEndpointAddress = 687 + fs_ecm_notify_desc.bEndpointAddress; 688 688 689 689 /* copy descriptors, and track endpoint copies */ 690 - f->hs_descriptors = usb_copy_descriptors(eth_hs_function); 690 + f->hs_descriptors = usb_copy_descriptors(ecm_hs_function); 691 691 if (!f->hs_descriptors) 692 692 goto fail; 693 693 694 - ecm->hs.in = usb_find_endpoint(eth_hs_function, 695 - f->hs_descriptors, &hs_in_desc); 696 - ecm->hs.out = usb_find_endpoint(eth_hs_function, 697 - f->hs_descriptors, &hs_out_desc); 698 - ecm->hs.notify = usb_find_endpoint(eth_hs_function, 699 - f->hs_descriptors, &hs_notify_desc); 694 + ecm->hs.in = usb_find_endpoint(ecm_hs_function, 695 + f->hs_descriptors, &hs_ecm_in_desc); 696 + ecm->hs.out = usb_find_endpoint(ecm_hs_function, 697 + f->hs_descriptors, &hs_ecm_out_desc); 698 + ecm->hs.notify = usb_find_endpoint(ecm_hs_function, 699 + f->hs_descriptors, &hs_ecm_notify_desc); 700 700 } 701 701 702 702 /* NOTE: all that is done without knowing or caring about ··· 795 795 if (status < 0) 796 796 return status; 797 797 ecm_string_defs[1].id = status; 798 - ether_desc.iMACAddress = status; 798 + ecm_desc.iMACAddress = status; 799 799 } 800 800 801 801 /* allocate and initialize one new instance */
+18 -16
drivers/usb/gadget/f_loopback.c
··· 70 70 71 71 /* full speed support: */ 72 72 73 - static struct usb_endpoint_descriptor fs_source_desc = { 73 + static struct usb_endpoint_descriptor fs_loop_source_desc = { 74 74 .bLength = USB_DT_ENDPOINT_SIZE, 75 75 .bDescriptorType = USB_DT_ENDPOINT, 76 76 ··· 78 78 .bmAttributes = USB_ENDPOINT_XFER_BULK, 79 79 }; 80 80 81 - static struct usb_endpoint_descriptor fs_sink_desc = { 81 + static struct usb_endpoint_descriptor fs_loop_sink_desc = { 82 82 .bLength = USB_DT_ENDPOINT_SIZE, 83 83 .bDescriptorType = USB_DT_ENDPOINT, 84 84 ··· 88 88 89 89 static struct usb_descriptor_header *fs_loopback_descs[] = { 90 90 (struct usb_descriptor_header *) &loopback_intf, 91 - (struct usb_descriptor_header *) &fs_sink_desc, 92 - (struct usb_descriptor_header *) &fs_source_desc, 91 + (struct usb_descriptor_header *) &fs_loop_sink_desc, 92 + (struct usb_descriptor_header *) &fs_loop_source_desc, 93 93 NULL, 94 94 }; 95 95 96 96 /* high speed support: */ 97 97 98 - static struct usb_endpoint_descriptor hs_source_desc = { 98 + static struct usb_endpoint_descriptor hs_loop_source_desc = { 99 99 .bLength = USB_DT_ENDPOINT_SIZE, 100 100 .bDescriptorType = USB_DT_ENDPOINT, 101 101 ··· 103 103 .wMaxPacketSize = __constant_cpu_to_le16(512), 104 104 }; 105 105 106 - static struct usb_endpoint_descriptor hs_sink_desc = { 106 + static struct usb_endpoint_descriptor hs_loop_sink_desc = { 107 107 .bLength = USB_DT_ENDPOINT_SIZE, 108 108 .bDescriptorType = USB_DT_ENDPOINT, 109 109 ··· 113 113 114 114 static struct usb_descriptor_header *hs_loopback_descs[] = { 115 115 (struct usb_descriptor_header *) &loopback_intf, 116 - (struct usb_descriptor_header *) &hs_source_desc, 117 - (struct usb_descriptor_header *) &hs_sink_desc, 116 + (struct usb_descriptor_header *) &hs_loop_source_desc, 117 + (struct usb_descriptor_header *) &hs_loop_sink_desc, 118 118 NULL, 119 119 }; 120 120 ··· 152 152 153 153 /* allocate endpoints */ 154 154 155 - loop->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_source_desc); 155 + loop->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_loop_source_desc); 156 156 if (!loop->in_ep) { 157 157 autoconf_fail: 158 158 ERROR(cdev, "%s: can't autoconfigure on %s\n", ··· 161 161 } 162 162 loop->in_ep->driver_data = cdev; /* claim */ 163 163 164 - loop->out_ep = usb_ep_autoconfig(cdev->gadget, &fs_sink_desc); 164 + loop->out_ep = usb_ep_autoconfig(cdev->gadget, &fs_loop_sink_desc); 165 165 if (!loop->out_ep) 166 166 goto autoconf_fail; 167 167 loop->out_ep->driver_data = cdev; /* claim */ 168 168 169 169 /* support high speed hardware */ 170 170 if (gadget_is_dualspeed(c->cdev->gadget)) { 171 - hs_source_desc.bEndpointAddress = 172 - fs_source_desc.bEndpointAddress; 173 - hs_sink_desc.bEndpointAddress = 174 - fs_sink_desc.bEndpointAddress; 171 + hs_loop_source_desc.bEndpointAddress = 172 + fs_loop_source_desc.bEndpointAddress; 173 + hs_loop_sink_desc.bEndpointAddress = 174 + fs_loop_sink_desc.bEndpointAddress; 175 175 f->hs_descriptors = hs_loopback_descs; 176 176 } 177 177 ··· 255 255 struct usb_request *req; 256 256 unsigned i; 257 257 258 - src = ep_choose(cdev->gadget, &hs_source_desc, &fs_source_desc); 259 - sink = ep_choose(cdev->gadget, &hs_sink_desc, &fs_sink_desc); 258 + src = ep_choose(cdev->gadget, 259 + &hs_loop_source_desc, &fs_loop_source_desc); 260 + sink = ep_choose(cdev->gadget, 261 + &hs_loop_sink_desc, &fs_loop_sink_desc); 260 262 261 263 /* one endpoint writes data back IN to the host */ 262 264 ep = loop->in_ep;
+22 -22
drivers/usb/gadget/f_subset.c
··· 103 103 /* .iInterface = DYNAMIC */ 104 104 }; 105 105 106 - static struct usb_cdc_header_desc header_desc __initdata = { 107 - .bLength = sizeof header_desc, 106 + static struct usb_cdc_header_desc mdlm_header_desc __initdata = { 107 + .bLength = sizeof mdlm_header_desc, 108 108 .bDescriptorType = USB_DT_CS_INTERFACE, 109 109 .bDescriptorSubType = USB_CDC_HEADER_TYPE, 110 110 ··· 152 152 153 153 /* full speed support: */ 154 154 155 - static struct usb_endpoint_descriptor fs_in_desc __initdata = { 155 + static struct usb_endpoint_descriptor fs_subset_in_desc __initdata = { 156 156 .bLength = USB_DT_ENDPOINT_SIZE, 157 157 .bDescriptorType = USB_DT_ENDPOINT, 158 158 ··· 160 160 .bmAttributes = USB_ENDPOINT_XFER_BULK, 161 161 }; 162 162 163 - static struct usb_endpoint_descriptor fs_out_desc __initdata = { 163 + static struct usb_endpoint_descriptor fs_subset_out_desc __initdata = { 164 164 .bLength = USB_DT_ENDPOINT_SIZE, 165 165 .bDescriptorType = USB_DT_ENDPOINT, 166 166 ··· 170 170 171 171 static struct usb_descriptor_header *fs_eth_function[] __initdata = { 172 172 (struct usb_descriptor_header *) &subset_data_intf, 173 - (struct usb_descriptor_header *) &header_desc, 173 + (struct usb_descriptor_header *) &mdlm_header_desc, 174 174 (struct usb_descriptor_header *) &mdlm_desc, 175 175 (struct usb_descriptor_header *) &mdlm_detail_desc, 176 176 (struct usb_descriptor_header *) &ether_desc, 177 - (struct usb_descriptor_header *) &fs_in_desc, 178 - (struct usb_descriptor_header *) &fs_out_desc, 177 + (struct usb_descriptor_header *) &fs_subset_in_desc, 178 + (struct usb_descriptor_header *) &fs_subset_out_desc, 179 179 NULL, 180 180 }; 181 181 182 182 /* high speed support: */ 183 183 184 - static struct usb_endpoint_descriptor hs_in_desc __initdata = { 184 + static struct usb_endpoint_descriptor hs_subset_in_desc __initdata = { 185 185 .bLength = USB_DT_ENDPOINT_SIZE, 186 186 .bDescriptorType = USB_DT_ENDPOINT, 187 187 ··· 189 189 .wMaxPacketSize = __constant_cpu_to_le16(512), 190 190 }; 191 191 192 - static struct usb_endpoint_descriptor hs_out_desc __initdata = { 192 + static struct usb_endpoint_descriptor hs_subset_out_desc __initdata = { 193 193 .bLength = USB_DT_ENDPOINT_SIZE, 194 194 .bDescriptorType = USB_DT_ENDPOINT, 195 195 ··· 199 199 200 200 static struct usb_descriptor_header *hs_eth_function[] __initdata = { 201 201 (struct usb_descriptor_header *) &subset_data_intf, 202 - (struct usb_descriptor_header *) &header_desc, 202 + (struct usb_descriptor_header *) &mdlm_header_desc, 203 203 (struct usb_descriptor_header *) &mdlm_desc, 204 204 (struct usb_descriptor_header *) &mdlm_detail_desc, 205 205 (struct usb_descriptor_header *) &ether_desc, 206 - (struct usb_descriptor_header *) &hs_in_desc, 207 - (struct usb_descriptor_header *) &hs_out_desc, 206 + (struct usb_descriptor_header *) &hs_subset_in_desc, 207 + (struct usb_descriptor_header *) &hs_subset_out_desc, 208 208 NULL, 209 209 }; 210 210 ··· 281 281 status = -ENODEV; 282 282 283 283 /* allocate instance-specific endpoints */ 284 - ep = usb_ep_autoconfig(cdev->gadget, &fs_in_desc); 284 + ep = usb_ep_autoconfig(cdev->gadget, &fs_subset_in_desc); 285 285 if (!ep) 286 286 goto fail; 287 287 geth->port.in_ep = ep; 288 288 ep->driver_data = cdev; /* claim */ 289 289 290 - ep = usb_ep_autoconfig(cdev->gadget, &fs_out_desc); 290 + ep = usb_ep_autoconfig(cdev->gadget, &fs_subset_out_desc); 291 291 if (!ep) 292 292 goto fail; 293 293 geth->port.out_ep = ep; ··· 297 297 f->descriptors = usb_copy_descriptors(fs_eth_function); 298 298 299 299 geth->fs.in = usb_find_endpoint(fs_eth_function, 300 - f->descriptors, &fs_in_desc); 300 + f->descriptors, &fs_subset_in_desc); 301 301 geth->fs.out = usb_find_endpoint(fs_eth_function, 302 - f->descriptors, &fs_out_desc); 302 + f->descriptors, &fs_subset_out_desc); 303 303 304 304 305 305 /* support all relevant hardware speeds... we expect that when ··· 307 307 * both speeds 308 308 */ 309 309 if (gadget_is_dualspeed(c->cdev->gadget)) { 310 - hs_in_desc.bEndpointAddress = 311 - fs_in_desc.bEndpointAddress; 312 - hs_out_desc.bEndpointAddress = 313 - fs_out_desc.bEndpointAddress; 310 + hs_subset_in_desc.bEndpointAddress = 311 + fs_subset_in_desc.bEndpointAddress; 312 + hs_subset_out_desc.bEndpointAddress = 313 + fs_subset_out_desc.bEndpointAddress; 314 314 315 315 /* copy descriptors, and track endpoint copies */ 316 316 f->hs_descriptors = usb_copy_descriptors(hs_eth_function); 317 317 318 318 geth->hs.in = usb_find_endpoint(hs_eth_function, 319 - f->hs_descriptors, &hs_in_desc); 319 + f->hs_descriptors, &hs_subset_in_desc); 320 320 geth->hs.out = usb_find_endpoint(hs_eth_function, 321 - f->hs_descriptors, &hs_out_desc); 321 + f->hs_descriptors, &hs_subset_out_desc); 322 322 } 323 323 324 324 /* NOTE: all that is done without knowing or caring about
+12
drivers/usb/gadget/file_storage.c
··· 245 245 #include "gadget_chips.h" 246 246 247 247 248 + 249 + /* 250 + * Kbuild is not very cooperative with respect to linking separately 251 + * compiled library objects into one module. So for now we won't use 252 + * separate compilation ... ensuring init/exit sections work to shrink 253 + * the runtime footprint, and giving us at least some parts of what 254 + * a "gcc --combine ... part1.c part2.c part3.c ... " build would. 255 + */ 256 + #include "usbstring.c" 257 + #include "config.c" 258 + #include "epautoconf.c" 259 + 248 260 /*-------------------------------------------------------------------------*/ 249 261 250 262 #define DRIVER_DESC "File-backed Storage Gadget"
+15
drivers/usb/gadget/gmidi.c
··· 35 35 36 36 #include "gadget_chips.h" 37 37 38 + 39 + /* 40 + * Kbuild is not very cooperative with respect to linking separately 41 + * compiled library objects into one module. So for now we won't use 42 + * separate compilation ... ensuring init/exit sections work to shrink 43 + * the runtime footprint, and giving us at least some parts of what 44 + * a "gcc --combine ... part1.c part2.c part3.c ... " build would. 45 + */ 46 + #include "usbstring.c" 47 + #include "config.c" 48 + #include "epautoconf.c" 49 + 50 + /*-------------------------------------------------------------------------*/ 51 + 52 + 38 53 MODULE_AUTHOR("Ben Williamson"); 39 54 MODULE_LICENSE("GPL v2"); 40 55
+16 -2
drivers/usb/gadget/printer.c
··· 53 53 54 54 #include "gadget_chips.h" 55 55 56 + 57 + /* 58 + * Kbuild is not very cooperative with respect to linking separately 59 + * compiled library objects into one module. So for now we won't use 60 + * separate compilation ... ensuring init/exit sections work to shrink 61 + * the runtime footprint, and giving us at least some parts of what 62 + * a "gcc --combine ... part1.c part2.c part3.c ... " build would. 63 + */ 64 + #include "usbstring.c" 65 + #include "config.c" 66 + #include "epautoconf.c" 67 + 68 + /*-------------------------------------------------------------------------*/ 69 + 56 70 #define DRIVER_DESC "Printer Gadget" 57 71 #define DRIVER_VERSION "2007 OCT 06" 58 72 ··· 1374 1360 1375 1361 1376 1362 /* Setup the sysfs files for the printer gadget. */ 1377 - dev->pdev = device_create_drvdata(usb_gadget_class, NULL, 1378 - g_printer_devno, NULL, "g_printer"); 1363 + dev->pdev = device_create(usb_gadget_class, NULL, g_printer_devno, 1364 + NULL, "g_printer"); 1379 1365 if (IS_ERR(dev->pdev)) { 1380 1366 ERROR(dev, "Failed to create device: g_printer\n"); 1381 1367 goto fail;
+55 -60
drivers/usb/gadget/rndis.c
··· 57 57 #define rndis_debug 0 58 58 #endif 59 59 60 - #define DBG(str,args...) do { \ 61 - if (rndis_debug) \ 62 - pr_debug(str , ## args); \ 63 - } while (0) 64 - 65 60 #define RNDIS_MAX_CONFIGS 1 66 61 67 62 ··· 178 183 if (!resp) return -ENOMEM; 179 184 180 185 if (buf_len && rndis_debug > 1) { 181 - DBG("query OID %08x value, len %d:\n", OID, buf_len); 186 + pr_debug("query OID %08x value, len %d:\n", OID, buf_len); 182 187 for (i = 0; i < buf_len; i += 16) { 183 - DBG("%03d: %08x %08x %08x %08x\n", i, 188 + pr_debug("%03d: %08x %08x %08x %08x\n", i, 184 189 get_unaligned_le32(&buf[i]), 185 190 get_unaligned_le32(&buf[i + 4]), 186 191 get_unaligned_le32(&buf[i + 8]), ··· 204 209 205 210 /* mandatory */ 206 211 case OID_GEN_SUPPORTED_LIST: 207 - DBG("%s: OID_GEN_SUPPORTED_LIST\n", __func__); 212 + pr_debug("%s: OID_GEN_SUPPORTED_LIST\n", __func__); 208 213 length = sizeof (oid_supported_list); 209 214 count = length / sizeof (u32); 210 215 for (i = 0; i < count; i++) ··· 214 219 215 220 /* mandatory */ 216 221 case OID_GEN_HARDWARE_STATUS: 217 - DBG("%s: OID_GEN_HARDWARE_STATUS\n", __func__); 222 + pr_debug("%s: OID_GEN_HARDWARE_STATUS\n", __func__); 218 223 /* Bogus question! 219 224 * Hardware must be ready to receive high level protocols. 220 225 * BTW: ··· 227 232 228 233 /* mandatory */ 229 234 case OID_GEN_MEDIA_SUPPORTED: 230 - DBG("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__); 235 + pr_debug("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__); 231 236 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); 232 237 retval = 0; 233 238 break; 234 239 235 240 /* mandatory */ 236 241 case OID_GEN_MEDIA_IN_USE: 237 - DBG("%s: OID_GEN_MEDIA_IN_USE\n", __func__); 242 + pr_debug("%s: OID_GEN_MEDIA_IN_USE\n", __func__); 238 243 /* one medium, one transport... (maybe you do it better) */ 239 244 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); 240 245 retval = 0; ··· 242 247 243 248 /* mandatory */ 244 249 case OID_GEN_MAXIMUM_FRAME_SIZE: 245 - DBG("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__); 250 + pr_debug("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__); 246 251 if (rndis_per_dev_params [configNr].dev) { 247 252 *outbuf = cpu_to_le32 ( 248 253 rndis_per_dev_params [configNr].dev->mtu); ··· 253 258 /* mandatory */ 254 259 case OID_GEN_LINK_SPEED: 255 260 if (rndis_debug > 1) 256 - DBG("%s: OID_GEN_LINK_SPEED\n", __func__); 261 + pr_debug("%s: OID_GEN_LINK_SPEED\n", __func__); 257 262 if (rndis_per_dev_params [configNr].media_state 258 263 == NDIS_MEDIA_STATE_DISCONNECTED) 259 264 *outbuf = __constant_cpu_to_le32 (0); ··· 265 270 266 271 /* mandatory */ 267 272 case OID_GEN_TRANSMIT_BLOCK_SIZE: 268 - DBG("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__); 273 + pr_debug("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__); 269 274 if (rndis_per_dev_params [configNr].dev) { 270 275 *outbuf = cpu_to_le32 ( 271 276 rndis_per_dev_params [configNr].dev->mtu); ··· 275 280 276 281 /* mandatory */ 277 282 case OID_GEN_RECEIVE_BLOCK_SIZE: 278 - DBG("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__); 283 + pr_debug("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__); 279 284 if (rndis_per_dev_params [configNr].dev) { 280 285 *outbuf = cpu_to_le32 ( 281 286 rndis_per_dev_params [configNr].dev->mtu); ··· 285 290 286 291 /* mandatory */ 287 292 case OID_GEN_VENDOR_ID: 288 - DBG("%s: OID_GEN_VENDOR_ID\n", __func__); 293 + pr_debug("%s: OID_GEN_VENDOR_ID\n", __func__); 289 294 *outbuf = cpu_to_le32 ( 290 295 rndis_per_dev_params [configNr].vendorID); 291 296 retval = 0; ··· 293 298 294 299 /* mandatory */ 295 300 case OID_GEN_VENDOR_DESCRIPTION: 296 - DBG("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__); 301 + pr_debug("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__); 297 302 length = strlen (rndis_per_dev_params [configNr].vendorDescr); 298 303 memcpy (outbuf, 299 304 rndis_per_dev_params [configNr].vendorDescr, length); ··· 301 306 break; 302 307 303 308 case OID_GEN_VENDOR_DRIVER_VERSION: 304 - DBG("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __func__); 309 + pr_debug("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __func__); 305 310 /* Created as LE */ 306 311 *outbuf = rndis_driver_version; 307 312 retval = 0; ··· 309 314 310 315 /* mandatory */ 311 316 case OID_GEN_CURRENT_PACKET_FILTER: 312 - DBG("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__); 317 + pr_debug("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__); 313 318 *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter); 314 319 retval = 0; 315 320 break; 316 321 317 322 /* mandatory */ 318 323 case OID_GEN_MAXIMUM_TOTAL_SIZE: 319 - DBG("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__); 324 + pr_debug("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__); 320 325 *outbuf = __constant_cpu_to_le32(RNDIS_MAX_TOTAL_SIZE); 321 326 retval = 0; 322 327 break; ··· 324 329 /* mandatory */ 325 330 case OID_GEN_MEDIA_CONNECT_STATUS: 326 331 if (rndis_debug > 1) 327 - DBG("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__); 332 + pr_debug("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__); 328 333 *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] 329 334 .media_state); 330 335 retval = 0; 331 336 break; 332 337 333 338 case OID_GEN_PHYSICAL_MEDIUM: 334 - DBG("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__); 339 + pr_debug("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__); 335 340 *outbuf = __constant_cpu_to_le32 (0); 336 341 retval = 0; 337 342 break; ··· 341 346 * versions emit undefined RNDIS messages. DOCUMENT ALL THESE! 342 347 */ 343 348 case OID_GEN_MAC_OPTIONS: /* from WinME */ 344 - DBG("%s: OID_GEN_MAC_OPTIONS\n", __func__); 349 + pr_debug("%s: OID_GEN_MAC_OPTIONS\n", __func__); 345 350 *outbuf = __constant_cpu_to_le32( 346 351 NDIS_MAC_OPTION_RECEIVE_SERIALIZED 347 352 | NDIS_MAC_OPTION_FULL_DUPLEX); ··· 353 358 /* mandatory */ 354 359 case OID_GEN_XMIT_OK: 355 360 if (rndis_debug > 1) 356 - DBG("%s: OID_GEN_XMIT_OK\n", __func__); 361 + pr_debug("%s: OID_GEN_XMIT_OK\n", __func__); 357 362 if (stats) { 358 363 *outbuf = cpu_to_le32(stats->tx_packets 359 364 - stats->tx_errors - stats->tx_dropped); ··· 364 369 /* mandatory */ 365 370 case OID_GEN_RCV_OK: 366 371 if (rndis_debug > 1) 367 - DBG("%s: OID_GEN_RCV_OK\n", __func__); 372 + pr_debug("%s: OID_GEN_RCV_OK\n", __func__); 368 373 if (stats) { 369 374 *outbuf = cpu_to_le32(stats->rx_packets 370 375 - stats->rx_errors - stats->rx_dropped); ··· 375 380 /* mandatory */ 376 381 case OID_GEN_XMIT_ERROR: 377 382 if (rndis_debug > 1) 378 - DBG("%s: OID_GEN_XMIT_ERROR\n", __func__); 383 + pr_debug("%s: OID_GEN_XMIT_ERROR\n", __func__); 379 384 if (stats) { 380 385 *outbuf = cpu_to_le32(stats->tx_errors); 381 386 retval = 0; ··· 385 390 /* mandatory */ 386 391 case OID_GEN_RCV_ERROR: 387 392 if (rndis_debug > 1) 388 - DBG("%s: OID_GEN_RCV_ERROR\n", __func__); 393 + pr_debug("%s: OID_GEN_RCV_ERROR\n", __func__); 389 394 if (stats) { 390 395 *outbuf = cpu_to_le32(stats->rx_errors); 391 396 retval = 0; ··· 394 399 395 400 /* mandatory */ 396 401 case OID_GEN_RCV_NO_BUFFER: 397 - DBG("%s: OID_GEN_RCV_NO_BUFFER\n", __func__); 402 + pr_debug("%s: OID_GEN_RCV_NO_BUFFER\n", __func__); 398 403 if (stats) { 399 404 *outbuf = cpu_to_le32(stats->rx_dropped); 400 405 retval = 0; ··· 405 410 406 411 /* mandatory */ 407 412 case OID_802_3_PERMANENT_ADDRESS: 408 - DBG("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__); 413 + pr_debug("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__); 409 414 if (rndis_per_dev_params [configNr].dev) { 410 415 length = ETH_ALEN; 411 416 memcpy (outbuf, ··· 417 422 418 423 /* mandatory */ 419 424 case OID_802_3_CURRENT_ADDRESS: 420 - DBG("%s: OID_802_3_CURRENT_ADDRESS\n", __func__); 425 + pr_debug("%s: OID_802_3_CURRENT_ADDRESS\n", __func__); 421 426 if (rndis_per_dev_params [configNr].dev) { 422 427 length = ETH_ALEN; 423 428 memcpy (outbuf, ··· 429 434 430 435 /* mandatory */ 431 436 case OID_802_3_MULTICAST_LIST: 432 - DBG("%s: OID_802_3_MULTICAST_LIST\n", __func__); 437 + pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__); 433 438 /* Multicast base address only */ 434 439 *outbuf = __constant_cpu_to_le32 (0xE0000000); 435 440 retval = 0; ··· 437 442 438 443 /* mandatory */ 439 444 case OID_802_3_MAXIMUM_LIST_SIZE: 440 - DBG("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__); 445 + pr_debug("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__); 441 446 /* Multicast base address only */ 442 447 *outbuf = __constant_cpu_to_le32 (1); 443 448 retval = 0; 444 449 break; 445 450 446 451 case OID_802_3_MAC_OPTIONS: 447 - DBG("%s: OID_802_3_MAC_OPTIONS\n", __func__); 452 + pr_debug("%s: OID_802_3_MAC_OPTIONS\n", __func__); 448 453 break; 449 454 450 455 /* ieee802.3 statistics OIDs (table 4-4) */ 451 456 452 457 /* mandatory */ 453 458 case OID_802_3_RCV_ERROR_ALIGNMENT: 454 - DBG("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __func__); 459 + pr_debug("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __func__); 455 460 if (stats) { 456 461 *outbuf = cpu_to_le32(stats->rx_frame_errors); 457 462 retval = 0; ··· 460 465 461 466 /* mandatory */ 462 467 case OID_802_3_XMIT_ONE_COLLISION: 463 - DBG("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__); 468 + pr_debug("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__); 464 469 *outbuf = __constant_cpu_to_le32 (0); 465 470 retval = 0; 466 471 break; 467 472 468 473 /* mandatory */ 469 474 case OID_802_3_XMIT_MORE_COLLISIONS: 470 - DBG("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__); 475 + pr_debug("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__); 471 476 *outbuf = __constant_cpu_to_le32 (0); 472 477 retval = 0; 473 478 break; ··· 499 504 return -ENOMEM; 500 505 501 506 if (buf_len && rndis_debug > 1) { 502 - DBG("set OID %08x value, len %d:\n", OID, buf_len); 507 + pr_debug("set OID %08x value, len %d:\n", OID, buf_len); 503 508 for (i = 0; i < buf_len; i += 16) { 504 - DBG("%03d: %08x %08x %08x %08x\n", i, 509 + pr_debug("%03d: %08x %08x %08x %08x\n", i, 505 510 get_unaligned_le32(&buf[i]), 506 511 get_unaligned_le32(&buf[i + 4]), 507 512 get_unaligned_le32(&buf[i + 8]), ··· 520 525 * MULTICAST, ALL_MULTICAST, BROADCAST 521 526 */ 522 527 *params->filter = (u16)get_unaligned_le32(buf); 523 - DBG("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n", 528 + pr_debug("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n", 524 529 __func__, *params->filter); 525 530 526 531 /* this call has a significant side effect: it's ··· 542 547 543 548 case OID_802_3_MULTICAST_LIST: 544 549 /* I think we can ignore this */ 545 - DBG("%s: OID_802_3_MULTICAST_LIST\n", __func__); 550 + pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__); 546 551 retval = 0; 547 552 break; 548 553 ··· 601 606 rndis_resp_t *r; 602 607 struct rndis_params *params = rndis_per_dev_params + configNr; 603 608 604 - // DBG("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); 609 + /* pr_debug("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); */ 605 610 if (!params->dev) 606 611 return -ENOTSUPP; 607 612 ··· 654 659 BufOffset = le32_to_cpu (buf->InformationBufferOffset); 655 660 656 661 #ifdef VERBOSE_DEBUG 657 - DBG("%s: Length: %d\n", __func__, BufLength); 658 - DBG("%s: Offset: %d\n", __func__, BufOffset); 659 - DBG("%s: InfoBuffer: ", __func__); 662 + pr_debug("%s: Length: %d\n", __func__, BufLength); 663 + pr_debug("%s: Offset: %d\n", __func__, BufOffset); 664 + pr_debug("%s: InfoBuffer: ", __func__); 660 665 661 666 for (i = 0; i < BufLength; i++) { 662 - DBG("%02x ", *(((u8 *) buf) + i + 8 + BufOffset)); 667 + pr_debug("%02x ", *(((u8 *) buf) + i + 8 + BufOffset)); 663 668 } 664 669 665 - DBG("\n"); 670 + pr_debug("\n"); 666 671 #endif 667 672 668 673 resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_SET_CMPLT); ··· 816 821 /* For USB: responses may take up to 10 seconds */ 817 822 switch (MsgType) { 818 823 case REMOTE_NDIS_INITIALIZE_MSG: 819 - DBG("%s: REMOTE_NDIS_INITIALIZE_MSG\n", 824 + pr_debug("%s: REMOTE_NDIS_INITIALIZE_MSG\n", 820 825 __func__ ); 821 826 params->state = RNDIS_INITIALIZED; 822 827 return rndis_init_response (configNr, 823 828 (rndis_init_msg_type *) buf); 824 829 825 830 case REMOTE_NDIS_HALT_MSG: 826 - DBG("%s: REMOTE_NDIS_HALT_MSG\n", 831 + pr_debug("%s: REMOTE_NDIS_HALT_MSG\n", 827 832 __func__ ); 828 833 params->state = RNDIS_UNINITIALIZED; 829 834 if (params->dev) { ··· 841 846 (rndis_set_msg_type *) buf); 842 847 843 848 case REMOTE_NDIS_RESET_MSG: 844 - DBG("%s: REMOTE_NDIS_RESET_MSG\n", 849 + pr_debug("%s: REMOTE_NDIS_RESET_MSG\n", 845 850 __func__ ); 846 851 return rndis_reset_response (configNr, 847 852 (rndis_reset_msg_type *) buf); ··· 849 854 case REMOTE_NDIS_KEEPALIVE_MSG: 850 855 /* For USB: host does this every 5 seconds */ 851 856 if (rndis_debug > 1) 852 - DBG("%s: REMOTE_NDIS_KEEPALIVE_MSG\n", 857 + pr_debug("%s: REMOTE_NDIS_KEEPALIVE_MSG\n", 853 858 __func__ ); 854 859 return rndis_keepalive_response (configNr, 855 860 (rndis_keepalive_msg_type *) ··· 865 870 { 866 871 unsigned i; 867 872 for (i = 0; i < MsgLength; i += 16) { 868 - DBG("%03d: " 873 + pr_debug("%03d: " 869 874 " %02x %02x %02x %02x" 870 875 " %02x %02x %02x %02x" 871 876 " %02x %02x %02x %02x" ··· 900 905 rndis_per_dev_params [i].used = 1; 901 906 rndis_per_dev_params [i].resp_avail = resp_avail; 902 907 rndis_per_dev_params [i].v = v; 903 - DBG("%s: configNr = %d\n", __func__, i); 908 + pr_debug("%s: configNr = %d\n", __func__, i); 904 909 return i; 905 910 } 906 911 } 907 - DBG("failed\n"); 912 + pr_debug("failed\n"); 908 913 909 914 return -ENODEV; 910 915 } 911 916 912 917 void rndis_deregister (int configNr) 913 918 { 914 - DBG("%s: \n", __func__ ); 919 + pr_debug("%s: \n", __func__); 915 920 916 921 if (configNr >= RNDIS_MAX_CONFIGS) return; 917 922 rndis_per_dev_params [configNr].used = 0; ··· 921 926 922 927 int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter) 923 928 { 924 - DBG("%s:\n", __func__ ); 929 + pr_debug("%s:\n", __func__); 925 930 if (!dev) 926 931 return -EINVAL; 927 932 if (configNr >= RNDIS_MAX_CONFIGS) return -1; ··· 934 939 935 940 int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr) 936 941 { 937 - DBG("%s:\n", __func__ ); 942 + pr_debug("%s:\n", __func__); 938 943 if (!vendorDescr) return -1; 939 944 if (configNr >= RNDIS_MAX_CONFIGS) return -1; 940 945 ··· 946 951 947 952 int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed) 948 953 { 949 - DBG("%s: %u %u\n", __func__, medium, speed); 954 + pr_debug("%s: %u %u\n", __func__, medium, speed); 950 955 if (configNr >= RNDIS_MAX_CONFIGS) return -1; 951 956 952 957 rndis_per_dev_params [configNr].medium = medium; ··· 1109 1114 break; 1110 1115 default: 1111 1116 if (fl_speed) p->speed = speed; 1112 - else DBG("%c is not valid\n", c); 1117 + else pr_debug("%c is not valid\n", c); 1113 1118 break; 1114 1119 } 1115 1120 ··· 1154 1159 &rndis_proc_fops, 1155 1160 (void *)(rndis_per_dev_params + i)))) 1156 1161 { 1157 - DBG("%s :remove entries", __func__); 1162 + pr_debug("%s :remove entries", __func__); 1158 1163 while (i) { 1159 1164 sprintf (name, NAME_TEMPLATE, --i); 1160 1165 remove_proc_entry (name, NULL); 1161 1166 } 1162 - DBG("\n"); 1167 + pr_debug("\n"); 1163 1168 return -EIO; 1164 1169 } 1165 1170 #endif
+18
drivers/usb/gadget/serial.c
··· 30 30 31 31 /*-------------------------------------------------------------------------*/ 32 32 33 + /* 34 + * Kbuild is not very cooperative with respect to linking separately 35 + * compiled library objects into one module. So for now we won't use 36 + * separate compilation ... ensuring init/exit sections work to shrink 37 + * the runtime footprint, and giving us at least some parts of what 38 + * a "gcc --combine ... part1.c part2.c part3.c ... " build would. 39 + */ 40 + #include "composite.c" 41 + #include "usbstring.c" 42 + #include "config.c" 43 + #include "epautoconf.c" 44 + 45 + #include "f_acm.c" 46 + #include "f_serial.c" 47 + #include "u_serial.c" 48 + 49 + /*-------------------------------------------------------------------------*/ 50 + 33 51 /* Thanks to NetChip Technologies for donating this product ID. 34 52 * 35 53 * DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
+2 -2
drivers/usb/gadget/u_ether.c
··· 52 52 * this single "physical" link to be used by multiple virtual links.) 53 53 */ 54 54 55 - #define DRIVER_VERSION "29-May-2008" 55 + #define UETH__VERSION "29-May-2008" 56 56 57 57 struct eth_dev { 58 58 /* lock is held while accessing port_usb ··· 170 170 struct eth_dev *dev = netdev_priv(net); 171 171 172 172 strlcpy(p->driver, "g_ether", sizeof p->driver); 173 - strlcpy(p->version, DRIVER_VERSION, sizeof p->version); 173 + strlcpy(p->version, UETH__VERSION, sizeof p->version); 174 174 strlcpy(p->fw_version, dev->gadget->name, sizeof p->fw_version); 175 175 strlcpy(p->bus_info, dev_name(&dev->gadget->dev), sizeof p->bus_info); 176 176 }
+17
drivers/usb/gadget/zero.c
··· 59 59 60 60 /*-------------------------------------------------------------------------*/ 61 61 62 + /* 63 + * Kbuild is not very cooperative with respect to linking separately 64 + * compiled library objects into one module. So for now we won't use 65 + * separate compilation ... ensuring init/exit sections work to shrink 66 + * the runtime footprint, and giving us at least some parts of what 67 + * a "gcc --combine ... part1.c part2.c part3.c ... " build would. 68 + */ 69 + #include "composite.c" 70 + #include "usbstring.c" 71 + #include "config.c" 72 + #include "epautoconf.c" 73 + 74 + #include "f_sourcesink.c" 75 + #include "f_loopback.c" 76 + 77 + /*-------------------------------------------------------------------------*/ 78 + 62 79 #define DRIVER_VERSION "Cinco de Mayo 2008" 63 80 64 81 static const char longname[] = "Gadget Zero";
+8 -16
drivers/usb/host/uhci-q.c
··· 123 123 124 124 static void uhci_free_td(struct uhci_hcd *uhci, struct uhci_td *td) 125 125 { 126 - if (!list_empty(&td->list)) { 127 - dev_warn(uhci_dev(uhci), "td %p still in list!\n", td); 128 - WARN_ON(1); 129 - } 130 - if (!list_empty(&td->fl_list)) { 131 - dev_warn(uhci_dev(uhci), "td %p still in fl_list!\n", td); 132 - WARN_ON(1); 133 - } 126 + if (!list_empty(&td->list)) 127 + dev_WARN(uhci_dev(uhci), "td %p still in list!\n", td); 128 + if (!list_empty(&td->fl_list)) 129 + dev_WARN(uhci_dev(uhci), "td %p still in fl_list!\n", td); 134 130 135 131 dma_pool_free(uhci->td_pool, td, td->dma_handle); 136 132 } ··· 291 295 static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh) 292 296 { 293 297 WARN_ON(qh->state != QH_STATE_IDLE && qh->udev); 294 - if (!list_empty(&qh->queue)) { 295 - dev_warn(uhci_dev(uhci), "qh %p list not empty!\n", qh); 296 - WARN_ON(1); 297 - } 298 + if (!list_empty(&qh->queue)) 299 + dev_WARN(uhci_dev(uhci), "qh %p list not empty!\n", qh); 298 300 299 301 list_del(&qh->node); 300 302 if (qh->udev) { ··· 740 746 { 741 747 struct uhci_td *td, *tmp; 742 748 743 - if (!list_empty(&urbp->node)) { 744 - dev_warn(uhci_dev(uhci), "urb %p still on QH's list!\n", 749 + if (!list_empty(&urbp->node)) 750 + dev_WARN(uhci_dev(uhci), "urb %p still on QH's list!\n", 745 751 urbp->urb); 746 - WARN_ON(1); 747 - } 748 752 749 753 list_for_each_entry_safe(td, tmp, &urbp->td_list, list) { 750 754 uhci_remove_td_from_urbp(td);
+2 -3
drivers/usb/misc/phidgetkit.c
··· 595 595 } while(value); 596 596 kit->dev_no = bit; 597 597 598 - kit->dev = device_create_drvdata(phidget_class, &kit->udev->dev, 599 - MKDEV(0, 0), kit, 600 - "interfacekit%d", kit->dev_no); 598 + kit->dev = device_create(phidget_class, &kit->udev->dev, MKDEV(0, 0), 599 + kit, "interfacekit%d", kit->dev_no); 601 600 if (IS_ERR(kit->dev)) { 602 601 rc = PTR_ERR(kit->dev); 603 602 kit->dev = NULL;
+2 -3
drivers/usb/misc/phidgetmotorcontrol.c
··· 365 365 } while(value); 366 366 mc->dev_no = bit; 367 367 368 - mc->dev = device_create_drvdata(phidget_class, &mc->udev->dev, 369 - MKDEV(0, 0), mc, 370 - "motorcontrol%d", mc->dev_no); 368 + mc->dev = device_create(phidget_class, &mc->udev->dev, MKDEV(0, 0), mc, 369 + "motorcontrol%d", mc->dev_no); 371 370 if (IS_ERR(mc->dev)) { 372 371 rc = PTR_ERR(mc->dev); 373 372 mc->dev = NULL;
+2 -3
drivers/usb/misc/phidgetservo.c
··· 275 275 } while (value); 276 276 dev->dev_no = bit; 277 277 278 - dev->dev = device_create_drvdata(phidget_class, &dev->udev->dev, 279 - MKDEV(0, 0), dev, 280 - "servo%d", dev->dev_no); 278 + dev->dev = device_create(phidget_class, &dev->udev->dev, MKDEV(0, 0), 279 + dev, "servo%d", dev->dev_no); 281 280 if (IS_ERR(dev->dev)) { 282 281 rc = PTR_ERR(dev->dev); 283 282 dev->dev = NULL;
+3 -3
drivers/usb/mon/mon_bin.c
··· 1162 1162 if (minor >= MON_BIN_MAX_MINOR) 1163 1163 return 0; 1164 1164 1165 - dev = device_create_drvdata(mon_bin_class, ubus? ubus->controller: NULL, 1166 - MKDEV(MAJOR(mon_bin_dev0), minor), NULL, 1167 - "usbmon%d", minor); 1165 + dev = device_create(mon_bin_class, ubus ? ubus->controller : NULL, 1166 + MKDEV(MAJOR(mon_bin_dev0), minor), NULL, 1167 + "usbmon%d", minor); 1168 1168 if (IS_ERR(dev)) 1169 1169 return 0; 1170 1170
+2 -2
drivers/video/console/fbcon.c
··· 3573 3573 3574 3574 acquire_console_sem(); 3575 3575 fb_register_client(&fbcon_event_notifier); 3576 - fbcon_device = device_create_drvdata(fb_class, NULL, MKDEV(0, 0), 3577 - NULL, "fbcon"); 3576 + fbcon_device = device_create(fb_class, NULL, MKDEV(0, 0), NULL, 3577 + "fbcon"); 3578 3578 3579 3579 if (IS_ERR(fbcon_device)) { 3580 3580 printk(KERN_WARNING "Unable to create device "
+3 -6
drivers/video/display/display-sysfs.c
··· 153 153 mutex_unlock(&allocated_dsp_lock); 154 154 155 155 if (!ret) { 156 - new_dev->dev = device_create_drvdata(display_class, 157 - parent, 158 - MKDEV(0,0), 159 - new_dev, 160 - "display%d", 161 - new_dev->idx); 156 + new_dev->dev = device_create(display_class, parent, 157 + MKDEV(0, 0), new_dev, 158 + "display%d", new_dev->idx); 162 159 if (!IS_ERR(new_dev->dev)) { 163 160 new_dev->parent = parent; 164 161 new_dev->driver = driver;
+2 -3
drivers/video/fbmem.c
··· 1430 1430 break; 1431 1431 fb_info->node = i; 1432 1432 1433 - fb_info->dev = device_create_drvdata(fb_class, fb_info->device, 1434 - MKDEV(FB_MAJOR, i), NULL, 1435 - "fb%d", i); 1433 + fb_info->dev = device_create(fb_class, fb_info->device, 1434 + MKDEV(FB_MAJOR, i), NULL, "fb%d", i); 1436 1435 if (IS_ERR(fb_info->dev)) { 1437 1436 /* Not fatal */ 1438 1437 printk(KERN_WARNING "Unable to create device for framebuffer %d; errno = %ld\n", i, PTR_ERR(fb_info->dev));
+2 -3
fs/coda/psdev.c
··· 362 362 goto out_chrdev; 363 363 } 364 364 for (i = 0; i < MAX_CODADEVS; i++) 365 - device_create_drvdata(coda_psdev_class, NULL, 366 - MKDEV(CODA_PSDEV_MAJOR, i), 367 - NULL, "cfs%d", i); 365 + device_create(coda_psdev_class, NULL, 366 + MKDEV(CODA_PSDEV_MAJOR, i), NULL, "cfs%d", i); 368 367 coda_sysctl_init(); 369 368 goto out; 370 369
+31 -11
fs/sysfs/bin.c
··· 61 61 int size = dentry->d_inode->i_size; 62 62 loff_t offs = *off; 63 63 int count = min_t(size_t, bytes, PAGE_SIZE); 64 + char *temp; 64 65 65 66 if (size) { 66 67 if (offs > size) ··· 70 69 count = size - offs; 71 70 } 72 71 72 + temp = kmalloc(count, GFP_KERNEL); 73 + if (!temp) 74 + return -ENOMEM; 75 + 73 76 mutex_lock(&bb->mutex); 74 77 75 78 count = fill_read(dentry, bb->buffer, offs, count); 76 - if (count < 0) 77 - goto out_unlock; 79 + if (count < 0) { 80 + mutex_unlock(&bb->mutex); 81 + goto out_free; 82 + } 78 83 79 - if (copy_to_user(userbuf, bb->buffer, count)) { 84 + memcpy(temp, bb->buffer, count); 85 + 86 + mutex_unlock(&bb->mutex); 87 + 88 + if (copy_to_user(userbuf, temp, count)) { 80 89 count = -EFAULT; 81 - goto out_unlock; 90 + goto out_free; 82 91 } 83 92 84 93 pr_debug("offs = %lld, *off = %lld, count = %d\n", offs, *off, count); 85 94 86 95 *off = offs + count; 87 96 88 - out_unlock: 89 - mutex_unlock(&bb->mutex); 97 + out_free: 98 + kfree(temp); 90 99 return count; 91 100 } 92 101 ··· 129 118 int size = dentry->d_inode->i_size; 130 119 loff_t offs = *off; 131 120 int count = min_t(size_t, bytes, PAGE_SIZE); 121 + char *temp; 132 122 133 123 if (size) { 134 124 if (offs > size) ··· 138 126 count = size - offs; 139 127 } 140 128 141 - mutex_lock(&bb->mutex); 129 + temp = kmalloc(count, GFP_KERNEL); 130 + if (!temp) 131 + return -ENOMEM; 142 132 143 - if (copy_from_user(bb->buffer, userbuf, count)) { 133 + if (copy_from_user(temp, userbuf, count)) { 144 134 count = -EFAULT; 145 - goto out_unlock; 135 + goto out_free; 146 136 } 147 137 138 + mutex_lock(&bb->mutex); 139 + 140 + memcpy(bb->buffer, temp, count); 141 + 148 142 count = flush_write(dentry, bb->buffer, offs, count); 143 + mutex_unlock(&bb->mutex); 144 + 149 145 if (count > 0) 150 146 *off = offs + count; 151 147 152 - out_unlock: 153 - mutex_unlock(&bb->mutex); 148 + out_free: 149 + kfree(temp); 154 150 return count; 155 151 } 156 152
+10 -14
fs/sysfs/dir.c
··· 370 370 memset(acxt, 0, sizeof(*acxt)); 371 371 acxt->parent_sd = parent_sd; 372 372 373 - /* Lookup parent inode. inode initialization and I_NEW 374 - * clearing are protected by sysfs_mutex. By grabbing it and 375 - * looking up with _nowait variant, inode state can be 376 - * determined reliably. 373 + /* Lookup parent inode. inode initialization is protected by 374 + * sysfs_mutex, so inode existence can be determined by 375 + * looking up inode while holding sysfs_mutex. 377 376 */ 378 377 mutex_lock(&sysfs_mutex); 379 378 380 - inode = ilookup5_nowait(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test, 381 - parent_sd); 379 + inode = ilookup5(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test, 380 + parent_sd); 381 + if (inode) { 382 + WARN_ON(inode->i_state & I_NEW); 382 383 383 - if (inode && !(inode->i_state & I_NEW)) { 384 384 /* parent inode available */ 385 385 acxt->parent_inode = inode; 386 386 ··· 393 393 mutex_lock(&inode->i_mutex); 394 394 mutex_lock(&sysfs_mutex); 395 395 } 396 - } else 397 - iput(inode); 396 + } 398 397 } 399 398 400 399 /** ··· 635 636 636 637 return sd; 637 638 } 639 + EXPORT_SYMBOL_GPL(sysfs_get_dirent); 638 640 639 641 static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd, 640 642 const char *name, struct sysfs_dirent **p_sd) ··· 829 829 if (!new_dentry) 830 830 goto out_unlock; 831 831 832 - /* rename kobject and sysfs_dirent */ 832 + /* rename sysfs_dirent */ 833 833 error = -ENOMEM; 834 834 new_name = dup_name = kstrdup(new_name, GFP_KERNEL); 835 835 if (!new_name) 836 - goto out_unlock; 837 - 838 - error = kobject_set_name(kobj, "%s", new_name); 839 - if (error) 840 836 goto out_unlock; 841 837 842 838 dup_name = sd->s_name;
+32 -14
fs/sysfs/file.c
··· 19 19 #include <linux/poll.h> 20 20 #include <linux/list.h> 21 21 #include <linux/mutex.h> 22 + #include <linux/limits.h> 22 23 #include <asm/uaccess.h> 23 24 24 25 #include "sysfs.h" 26 + 27 + /* used in crash dumps to help with debugging */ 28 + static char last_sysfs_file[PATH_MAX]; 29 + void sysfs_printk_last_file(void) 30 + { 31 + printk(KERN_EMERG "last sysfs file: %s\n", last_sysfs_file); 32 + } 25 33 26 34 /* 27 35 * There's one sysfs_buffer for each open file and one ··· 336 328 struct sysfs_buffer *buffer; 337 329 struct sysfs_ops *ops; 338 330 int error = -EACCES; 331 + char *p; 332 + 333 + p = d_path(&file->f_path, last_sysfs_file, sizeof(last_sysfs_file)); 334 + if (p) 335 + memmove(last_sysfs_file, p, strlen(p) + 1); 339 336 340 337 /* need attr_sd for attr and ops, its parent for kobj */ 341 338 if (!sysfs_get_active_two(attr_sd)) ··· 453 440 return POLLERR|POLLPRI; 454 441 } 455 442 456 - void sysfs_notify(struct kobject *k, char *dir, char *attr) 443 + void sysfs_notify_dirent(struct sysfs_dirent *sd) 444 + { 445 + struct sysfs_open_dirent *od; 446 + 447 + spin_lock(&sysfs_open_dirent_lock); 448 + 449 + od = sd->s_attr.open; 450 + if (od) { 451 + atomic_inc(&od->event); 452 + wake_up_interruptible(&od->poll); 453 + } 454 + 455 + spin_unlock(&sysfs_open_dirent_lock); 456 + } 457 + EXPORT_SYMBOL_GPL(sysfs_notify_dirent); 458 + 459 + void sysfs_notify(struct kobject *k, const char *dir, const char *attr) 457 460 { 458 461 struct sysfs_dirent *sd = k->sd; 459 462 ··· 479 450 sd = sysfs_find_dirent(sd, dir); 480 451 if (sd && attr) 481 452 sd = sysfs_find_dirent(sd, attr); 482 - if (sd) { 483 - struct sysfs_open_dirent *od; 484 - 485 - spin_lock(&sysfs_open_dirent_lock); 486 - 487 - od = sd->s_attr.open; 488 - if (od) { 489 - atomic_inc(&od->event); 490 - wake_up_interruptible(&od->poll); 491 - } 492 - 493 - spin_unlock(&sysfs_open_dirent_lock); 494 - } 453 + if (sd) 454 + sysfs_notify_dirent(sd); 495 455 496 456 mutex_unlock(&sysfs_mutex); 497 457 }
+15
fs/sysfs/mount.c
··· 16 16 #include <linux/mount.h> 17 17 #include <linux/pagemap.h> 18 18 #include <linux/init.h> 19 + #include <linux/module.h> 19 20 20 21 #include "sysfs.h" 21 22 ··· 116 115 sysfs_dir_cachep = NULL; 117 116 goto out; 118 117 } 118 + 119 + #undef sysfs_get 120 + struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd) 121 + { 122 + return __sysfs_get(sd); 123 + } 124 + EXPORT_SYMBOL_GPL(sysfs_get); 125 + 126 + #undef sysfs_put 127 + void sysfs_put(struct sysfs_dirent *sd) 128 + { 129 + __sysfs_put(sd); 130 + } 131 + EXPORT_SYMBOL_GPL(sysfs_put);
+4 -2
fs/sysfs/sysfs.h
··· 124 124 struct sysfs_dirent **p_sd); 125 125 void sysfs_remove_subdir(struct sysfs_dirent *sd); 126 126 127 - static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd) 127 + static inline struct sysfs_dirent *__sysfs_get(struct sysfs_dirent *sd) 128 128 { 129 129 if (sd) { 130 130 WARN_ON(!atomic_read(&sd->s_count)); ··· 132 132 } 133 133 return sd; 134 134 } 135 + #define sysfs_get(sd) __sysfs_get(sd) 135 136 136 - static inline void sysfs_put(struct sysfs_dirent *sd) 137 + static inline void __sysfs_put(struct sysfs_dirent *sd) 137 138 { 138 139 if (sd && atomic_dec_and_test(&sd->s_count)) 139 140 release_sysfs_dirent(sd); 140 141 } 142 + #define sysfs_put(sd) __sysfs_put(sd) 141 143 142 144 /* 143 145 * inode.c
+9 -1
include/asm-generic/vmlinux.lds.h
··· 268 268 CPU_DISCARD(init.data) \ 269 269 CPU_DISCARD(init.rodata) \ 270 270 MEM_DISCARD(init.data) \ 271 - MEM_DISCARD(init.rodata) 271 + MEM_DISCARD(init.rodata) \ 272 + /* implement dynamic printk debug */ \ 273 + VMLINUX_SYMBOL(__start___verbose_strings) = .; \ 274 + *(__verbose_strings) \ 275 + VMLINUX_SYMBOL(__stop___verbose_strings) = .; \ 276 + . = ALIGN(8); \ 277 + VMLINUX_SYMBOL(__start___verbose) = .; \ 278 + *(__verbose) \ 279 + VMLINUX_SYMBOL(__stop___verbose) = .; 272 280 273 281 #define INIT_TEXT \ 274 282 *(.init.text) \
+16 -2
include/linux/device.h
··· 90 90 struct device_driver *start, void *data, 91 91 int (*fn)(struct device_driver *, void *)); 92 92 93 + void bus_sort_breadthfirst(struct bus_type *bus, 94 + int (*compare)(const struct device *a, 95 + const struct device *b)); 93 96 /* 94 97 * Bus notifiers: Get notified of addition/removal of devices 95 98 * and binding/unbinding of drivers to devices. ··· 505 502 dev_t devt, void *drvdata, 506 503 const char *fmt, ...) 507 504 __attribute__((format(printf, 5, 6))); 508 - #define device_create_drvdata device_create 509 505 extern void device_destroy(struct class *cls, dev_t devt); 510 506 511 507 /* ··· 553 551 #define dev_info(dev, format, arg...) \ 554 552 dev_printk(KERN_INFO , dev , format , ## arg) 555 553 556 - #ifdef DEBUG 554 + #if defined(CONFIG_DYNAMIC_PRINTK_DEBUG) 555 + #define dev_dbg(dev, format, ...) do { \ 556 + dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \ 557 + } while (0) 558 + #elif defined(DEBUG) 557 559 #define dev_dbg(dev, format, arg...) \ 558 560 dev_printk(KERN_DEBUG , dev , format , ## arg) 559 561 #else ··· 572 566 #define dev_vdbg(dev, format, arg...) \ 573 567 ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) 574 568 #endif 569 + 570 + /* 571 + * dev_WARN() acts like dev_printk(), but with the key difference 572 + * of using a WARN/WARN_ON to get the message out, including the 573 + * file/line information and a backtrace. 574 + */ 575 + #define dev_WARN(dev, format, arg...) \ 576 + WARN(1, "Device: %s\n" format, dev_driver_string(dev), ## arg); 575 577 576 578 /* Create alias, so I can be autoloaded. */ 577 579 #define MODULE_ALIAS_CHARDEV(major,minor) \
+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
+6 -1
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 20 #include <asm/byteorder.h> 20 21 #include <asm/bug.h> 21 22 ··· 305 304 #define pr_info(fmt, arg...) \ 306 305 printk(KERN_INFO fmt, ##arg) 307 306 308 - #ifdef DEBUG 309 307 /* If you are writing a driver, please use dev_dbg instead */ 308 + #if defined(CONFIG_DYNAMIC_PRINTK_DEBUG) 309 + #define pr_debug(fmt, ...) do { \ 310 + dynamic_pr_debug(fmt, ##__VA_ARGS__); \ 311 + } while (0) 312 + #elif defined(DEBUG) 310 313 #define pr_debug(fmt, arg...) \ 311 314 printk(KERN_DEBUG fmt, ##arg) 312 315 #else
-1
include/linux/module.h
··· 345 345 /* Reference counts */ 346 346 struct module_ref ref[NR_CPUS]; 347 347 #endif 348 - 349 348 }; 350 349 #ifndef MODULE_ARCH_INIT 351 350 #define MODULE_ARCH_INIT {}
+2
include/linux/platform_device.h
··· 37 37 38 38 extern struct platform_device *platform_device_register_simple(const char *, int id, 39 39 struct resource *, unsigned int); 40 + extern struct platform_device *platform_device_register_data(struct device *, 41 + const char *, int, const void *, size_t); 40 42 41 43 extern struct platform_device *platform_device_alloc(const char *name, int id); 42 44 extern int platform_device_add_resources(struct platform_device *pdev, struct resource *res, unsigned int num);
+32 -4
include/linux/sysfs.h
··· 78 78 ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); 79 79 }; 80 80 81 + struct sysfs_dirent; 82 + 81 83 #ifdef CONFIG_SYSFS 82 84 83 85 int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *), ··· 119 117 void sysfs_remove_file_from_group(struct kobject *kobj, 120 118 const struct attribute *attr, const char *group); 121 119 122 - void sysfs_notify(struct kobject *kobj, char *dir, char *attr); 123 - 124 - extern int __must_check sysfs_init(void); 120 + void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); 121 + void sysfs_notify_dirent(struct sysfs_dirent *sd); 122 + struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, 123 + const unsigned char *name); 124 + struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd); 125 + void sysfs_put(struct sysfs_dirent *sd); 126 + void sysfs_printk_last_file(void); 127 + int __must_check sysfs_init(void); 125 128 126 129 #else /* CONFIG_SYSFS */ 127 130 ··· 229 222 { 230 223 } 231 224 232 - static inline void sysfs_notify(struct kobject *kobj, char *dir, char *attr) 225 + static inline void sysfs_notify(struct kobject *kobj, const char *dir, 226 + const char *attr) 227 + { 228 + } 229 + static inline void sysfs_notify_dirent(struct sysfs_dirent *sd) 230 + { 231 + } 232 + static inline 233 + struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, 234 + const unsigned char *name) 235 + { 236 + return NULL; 237 + } 238 + static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd) 239 + { 240 + return NULL; 241 + } 242 + static inline void sysfs_put(struct sysfs_dirent *sd) 233 243 { 234 244 } 235 245 236 246 static inline int __must_check sysfs_init(void) 237 247 { 238 248 return 0; 249 + } 250 + 251 + static inline void sysfs_printk_last_file(void) 252 + { 239 253 } 240 254 241 255 #endif /* CONFIG_SYSFS */
+32 -1
kernel/module.c
··· 784 784 mutex_lock(&module_mutex); 785 785 /* Store the name of the last unloaded module for diagnostic purposes */ 786 786 strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); 787 + unregister_dynamic_debug_module(mod->name); 787 788 free_module(mod); 788 789 789 790 out: ··· 1174 1173 while (i-- > 0) 1175 1174 sysfs_remove_bin_file(notes_attrs->dir, 1176 1175 &notes_attrs->attrs[i]); 1177 - kobject_del(notes_attrs->dir); 1176 + kobject_put(notes_attrs->dir); 1178 1177 } 1179 1178 kfree(notes_attrs); 1180 1179 } ··· 1784 1783 } 1785 1784 #endif /* CONFIG_KALLSYMS */ 1786 1785 1786 + #ifdef CONFIG_DYNAMIC_PRINTK_DEBUG 1787 + static void dynamic_printk_setup(Elf_Shdr *sechdrs, unsigned int verboseindex) 1788 + { 1789 + struct mod_debug *debug_info; 1790 + unsigned long pos, end; 1791 + unsigned int num_verbose; 1792 + 1793 + pos = sechdrs[verboseindex].sh_addr; 1794 + num_verbose = sechdrs[verboseindex].sh_size / 1795 + sizeof(struct mod_debug); 1796 + end = pos + (num_verbose * sizeof(struct mod_debug)); 1797 + 1798 + for (; pos < end; pos += sizeof(struct mod_debug)) { 1799 + debug_info = (struct mod_debug *)pos; 1800 + register_dynamic_debug_module(debug_info->modname, 1801 + debug_info->type, debug_info->logical_modname, 1802 + debug_info->flag_names, debug_info->hash, 1803 + debug_info->hash2); 1804 + } 1805 + } 1806 + #else 1807 + static inline void dynamic_printk_setup(Elf_Shdr *sechdrs, 1808 + unsigned int verboseindex) 1809 + { 1810 + } 1811 + #endif /* CONFIG_DYNAMIC_PRINTK_DEBUG */ 1812 + 1787 1813 static void *module_alloc_update_bounds(unsigned long size) 1788 1814 { 1789 1815 void *ret = module_alloc(size); ··· 1859 1831 #endif 1860 1832 unsigned int markersindex; 1861 1833 unsigned int markersstringsindex; 1834 + unsigned int verboseindex; 1862 1835 struct module *mod; 1863 1836 long err = 0; 1864 1837 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */ ··· 2146 2117 markersindex = find_sec(hdr, sechdrs, secstrings, "__markers"); 2147 2118 markersstringsindex = find_sec(hdr, sechdrs, secstrings, 2148 2119 "__markers_strings"); 2120 + verboseindex = find_sec(hdr, sechdrs, secstrings, "__verbose"); 2149 2121 2150 2122 /* Now do relocations. */ 2151 2123 for (i = 1; i < hdr->e_shnum; i++) { ··· 2197 2167 marker_update_probe_range(mod->markers, 2198 2168 mod->markers + mod->num_markers); 2199 2169 #endif 2170 + dynamic_printk_setup(sechdrs, verboseindex); 2200 2171 err = module_finalize(hdr, sechdrs, mod); 2201 2172 if (err < 0) 2202 2173 goto cleanup;
+55
lib/Kconfig.debug
··· 807 807 808 808 Say N if you are unsure. 809 809 810 + config DYNAMIC_PRINTK_DEBUG 811 + bool "Enable dynamic printk() call support" 812 + default n 813 + depends on PRINTK 814 + select PRINTK_DEBUG 815 + help 816 + 817 + Compiles debug level messages into the kernel, which would not 818 + otherwise be available at runtime. These messages can then be 819 + enabled/disabled on a per module basis. This mechanism implicitly 820 + enables all pr_debug() and dev_dbg() calls. The impact of this 821 + compile option is a larger kernel text size of about 2%. 822 + 823 + Usage: 824 + 825 + Dynamic debugging is controlled by the debugfs file, 826 + dynamic_printk/modules. This file contains a list of the modules that 827 + can be enabled. The format of the file is the module name, followed 828 + by a set of flags that can be enabled. The first flag is always the 829 + 'enabled' flag. For example: 830 + 831 + <module_name> <enabled=0/1> 832 + . 833 + . 834 + . 835 + 836 + <module_name> : Name of the module in which the debug call resides 837 + <enabled=0/1> : whether the messages are enabled or not 838 + 839 + From a live system: 840 + 841 + snd_hda_intel enabled=0 842 + fixup enabled=0 843 + driver enabled=0 844 + 845 + Enable a module: 846 + 847 + $echo "set enabled=1 <module_name>" > dynamic_printk/modules 848 + 849 + Disable a module: 850 + 851 + $echo "set enabled=0 <module_name>" > dynamic_printk/modules 852 + 853 + Enable all modules: 854 + 855 + $echo "set enabled=1 all" > dynamic_printk/modules 856 + 857 + Disable all modules: 858 + 859 + $echo "set enabled=0 all" > dynamic_printk/modules 860 + 861 + Finally, passing "dynamic_printk" at the command line enables 862 + debugging for all modules. This mode can be turned off via the above 863 + disable command. 864 + 810 865 source "samples/Kconfig" 811 866 812 867 source "lib/Kconfig.kgdb"
+2
lib/Makefile
··· 81 81 82 82 obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o 83 83 84 + obj-$(CONFIG_DYNAMIC_PRINTK_DEBUG) += dynamic_printk.o 85 + 84 86 hostprogs-y := gen_crc32table 85 87 clean-files := crc32table.h 86 88
+418
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 0; 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 { 281 + if (elem) { 282 + if (value && (elem->enable == 0)) { 283 + dynamic_printk_enabled |= 284 + (1LL << elem->hash1); 285 + dynamic_printk_enabled2 |= 286 + (1LL << elem->hash2); 287 + elem->enable = 1; 288 + num_enabled++; 289 + dynamic_enabled = DYNAMIC_ENABLED_SOME; 290 + err = 0; 291 + printk(KERN_DEBUG 292 + "debugging enabled for module %s", 293 + elem->name); 294 + } else if (!value && (elem->enable == 1)) { 295 + elem->enable = 0; 296 + num_enabled--; 297 + if (disabled_hash(elem->hash1, true)) 298 + dynamic_printk_enabled &= 299 + ~(1LL << elem->hash1); 300 + if (disabled_hash(elem->hash2, false)) 301 + dynamic_printk_enabled2 &= 302 + ~(1LL << elem->hash2); 303 + if (num_enabled) 304 + dynamic_enabled = 305 + DYNAMIC_ENABLED_SOME; 306 + else 307 + dynamic_enabled = 308 + DYNAMIC_ENABLED_NONE; 309 + err = 0; 310 + printk(KERN_DEBUG 311 + "debugging disabled for module " 312 + "%s", elem->name); 313 + } 314 + } 315 + } 316 + } 317 + if (!err) 318 + err = length; 319 + out_up: 320 + up(&debug_list_mutex); 321 + out: 322 + free_page((unsigned long)buffer); 323 + return err; 324 + } 325 + 326 + static void *pr_debug_seq_start(struct seq_file *f, loff_t *pos) 327 + { 328 + return (*pos < DEBUG_HASH_TABLE_SIZE) ? pos : NULL; 329 + } 330 + 331 + static void *pr_debug_seq_next(struct seq_file *s, void *v, loff_t *pos) 332 + { 333 + (*pos)++; 334 + if (*pos >= DEBUG_HASH_TABLE_SIZE) 335 + return NULL; 336 + return pos; 337 + } 338 + 339 + static void pr_debug_seq_stop(struct seq_file *s, void *v) 340 + { 341 + /* Nothing to do */ 342 + } 343 + 344 + static int pr_debug_seq_show(struct seq_file *s, void *v) 345 + { 346 + struct hlist_head *head; 347 + struct hlist_node *node; 348 + struct debug_name *elem; 349 + unsigned int i = *(loff_t *) v; 350 + 351 + rcu_read_lock(); 352 + head = &module_table[i]; 353 + hlist_for_each_entry_rcu(elem, node, head, hlist) { 354 + seq_printf(s, "%s enabled=%d", elem->name, elem->enable); 355 + seq_printf(s, "\n"); 356 + } 357 + rcu_read_unlock(); 358 + return 0; 359 + } 360 + 361 + static struct seq_operations pr_debug_seq_ops = { 362 + .start = pr_debug_seq_start, 363 + .next = pr_debug_seq_next, 364 + .stop = pr_debug_seq_stop, 365 + .show = pr_debug_seq_show 366 + }; 367 + 368 + static int pr_debug_open(struct inode *inode, struct file *filp) 369 + { 370 + return seq_open(filp, &pr_debug_seq_ops); 371 + } 372 + 373 + static const struct file_operations pr_debug_operations = { 374 + .open = pr_debug_open, 375 + .read = seq_read, 376 + .write = pr_debug_write, 377 + .llseek = seq_lseek, 378 + .release = seq_release, 379 + }; 380 + 381 + static int __init dynamic_printk_init(void) 382 + { 383 + struct dentry *dir, *file; 384 + struct mod_debug *iter; 385 + unsigned long value; 386 + 387 + dir = debugfs_create_dir("dynamic_printk", NULL); 388 + if (!dir) 389 + return -ENOMEM; 390 + file = debugfs_create_file("modules", 0644, dir, NULL, 391 + &pr_debug_operations); 392 + if (!file) { 393 + debugfs_remove(dir); 394 + return -ENOMEM; 395 + } 396 + for (value = (unsigned long)__start___verbose; 397 + value < (unsigned long)__stop___verbose; 398 + value += sizeof(struct mod_debug)) { 399 + iter = (struct mod_debug *)value; 400 + register_dynamic_debug_module(iter->modname, 401 + iter->type, 402 + iter->logical_modname, 403 + iter->flag_names, iter->hash, iter->hash2); 404 + } 405 + return 0; 406 + } 407 + module_init(dynamic_printk_init); 408 + /* may want to move this earlier so we can get traces as early as possible */ 409 + 410 + static int __init dynamic_printk_setup(char *str) 411 + { 412 + if (str) 413 + return -ENOENT; 414 + set_all(true); 415 + return 0; 416 + } 417 + /* Use early_param(), so we can get debug output as early as possible */ 418 + early_param("dynamic_printk", dynamic_printk_setup);
+20 -15
lib/kobject.c
··· 387 387 * kobject_rename - change the name of an object 388 388 * @kobj: object in question. 389 389 * @new_name: object's new name 390 + * 391 + * It is the responsibility of the caller to provide mutual 392 + * exclusion between two different calls of kobject_rename 393 + * on the same kobject and to ensure that new_name is valid and 394 + * won't conflict with other kobjects. 390 395 */ 391 396 int kobject_rename(struct kobject *kobj, const char *new_name) 392 397 { 393 398 int error = 0; 394 399 const char *devpath = NULL; 400 + const char *dup_name = NULL, *name; 395 401 char *devpath_string = NULL; 396 402 char *envp[2]; 397 403 ··· 406 400 return -EINVAL; 407 401 if (!kobj->parent) 408 402 return -EINVAL; 409 - 410 - /* see if this name is already in use */ 411 - if (kobj->kset) { 412 - struct kobject *temp_kobj; 413 - temp_kobj = kset_find_obj(kobj->kset, new_name); 414 - if (temp_kobj) { 415 - printk(KERN_WARNING "kobject '%s' cannot be renamed " 416 - "to '%s' as '%s' is already in existence.\n", 417 - kobject_name(kobj), new_name, new_name); 418 - kobject_put(temp_kobj); 419 - return -EINVAL; 420 - } 421 - } 422 403 423 404 devpath = kobject_get_path(kobj, GFP_KERNEL); 424 405 if (!devpath) { ··· 421 428 envp[0] = devpath_string; 422 429 envp[1] = NULL; 423 430 431 + name = dup_name = kstrdup(new_name, GFP_KERNEL); 432 + if (!name) { 433 + error = -ENOMEM; 434 + goto out; 435 + } 436 + 424 437 error = sysfs_rename_dir(kobj, new_name); 438 + if (error) 439 + goto out; 440 + 441 + /* Install the new kobject name */ 442 + dup_name = kobj->name; 443 + kobj->name = name; 425 444 426 445 /* This function is mostly/only used for network interface. 427 446 * Some hotplug package track interfaces by their name and 428 447 * therefore want to know when the name is changed by the user. */ 429 - if (!error) 430 - kobject_uevent_env(kobj, KOBJ_MOVE, envp); 448 + kobject_uevent_env(kobj, KOBJ_MOVE, envp); 431 449 432 450 out: 451 + kfree(dup_name); 433 452 kfree(devpath_string); 434 453 kfree(devpath); 435 454 kobject_put(kobj);
+1 -1
net/netfilter/nf_conntrack_pptp.c
··· 65 65 struct nf_conntrack_expect *exp) __read_mostly; 66 66 EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn); 67 67 68 - #ifdef DEBUG 68 + #if defined(DEBUG) || defined(CONFIG_DYNAMIC_PRINTK_DEBUG) 69 69 /* PptpControlMessageType names */ 70 70 const char *const pptp_msg_name[] = { 71 71 "UNKNOWN_MESSAGE",
+10 -1
scripts/Makefile.lib
··· 96 96 modname_flags = $(if $(filter 1,$(words $(modname))),\ 97 97 -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))") 98 98 99 + #hash values 100 + ifdef CONFIG_DYNAMIC_PRINTK_DEBUG 101 + debug_flags = -D"DEBUG_HASH=$(shell ./scripts/basic/hash djb2 $(@D)$(modname))"\ 102 + -D"DEBUG_HASH2=$(shell ./scripts/basic/hash r5 $(@D)$(modname))" 103 + else 104 + debug_flags = 105 + endif 106 + 99 107 orig_c_flags = $(KBUILD_CFLAGS) $(ccflags-y) $(CFLAGS_$(basetarget).o) 100 108 _c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) 101 109 _a_flags = $(KBUILD_AFLAGS) $(asflags-y) $(AFLAGS_$(basetarget).o) ··· 129 121 130 122 c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ 131 123 $(__c_flags) $(modkern_cflags) \ 132 - -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) 124 + -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) \ 125 + $(debug_flags) 133 126 134 127 a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ 135 128 $(__a_flags) $(modkern_aflags)
+1 -1
scripts/basic/Makefile
··· 9 9 # fixdep: Used to generate dependency information during build process 10 10 # docproc: Used in Documentation/DocBook 11 11 12 - hostprogs-y := fixdep docproc 12 + hostprogs-y := fixdep docproc hash 13 13 always := $(hostprogs-y) 14 14 15 15 # fixdep is needed to compile other host programs
+64
scripts/basic/hash.c
··· 1 + /* 2 + * Copyright (C) 2008 Red Hat, Inc., Jason Baron <jbaron@redhat.com> 3 + * 4 + */ 5 + 6 + #include <stdio.h> 7 + #include <stdlib.h> 8 + #include <string.h> 9 + 10 + #define DYNAMIC_DEBUG_HASH_BITS 6 11 + 12 + static const char *program; 13 + 14 + static void usage(void) 15 + { 16 + printf("Usage: %s <djb2|r5> <modname>\n", program); 17 + exit(1); 18 + } 19 + 20 + /* djb2 hashing algorithm by Dan Bernstein. From: 21 + * http://www.cse.yorku.ca/~oz/hash.html 22 + */ 23 + 24 + unsigned int djb2_hash(char *str) 25 + { 26 + unsigned long hash = 5381; 27 + int c; 28 + 29 + c = *str; 30 + while (c) { 31 + hash = ((hash << 5) + hash) + c; 32 + c = *++str; 33 + } 34 + return (unsigned int)(hash & ((1 << DYNAMIC_DEBUG_HASH_BITS) - 1)); 35 + } 36 + 37 + unsigned int r5_hash(char *str) 38 + { 39 + unsigned long hash = 0; 40 + int c; 41 + 42 + c = *str; 43 + while (c) { 44 + hash = (hash + (c << 4) + (c >> 4)) * 11; 45 + c = *++str; 46 + } 47 + return (unsigned int)(hash & ((1 << DYNAMIC_DEBUG_HASH_BITS) - 1)); 48 + } 49 + 50 + int main(int argc, char *argv[]) 51 + { 52 + program = argv[0]; 53 + 54 + if (argc != 3) 55 + usage(); 56 + if (!strcmp(argv[1], "djb2")) 57 + printf("%d\n", djb2_hash(argv[2])); 58 + else if (!strcmp(argv[1], "r5")) 59 + printf("%d\n", r5_hash(argv[2])); 60 + else 61 + usage(); 62 + exit(0); 63 + } 64 +
+3 -3
sound/core/init.c
··· 549 549 return -EINVAL; 550 550 #ifndef CONFIG_SYSFS_DEPRECATED 551 551 if (!card->card_dev) { 552 - card->card_dev = device_create_drvdata(sound_class, card->dev, 553 - MKDEV(0, 0), NULL, 554 - "card%i", card->number); 552 + card->card_dev = device_create(sound_class, card->dev, 553 + MKDEV(0, 0), NULL, 554 + "card%i", card->number); 555 555 if (IS_ERR(card->card_dev)) 556 556 card->card_dev = NULL; 557 557 }
+2 -3
sound/core/sound.c
··· 274 274 return minor; 275 275 } 276 276 snd_minors[minor] = preg; 277 - preg->dev = device_create_drvdata(sound_class, device, 278 - MKDEV(major, minor), 279 - private_data, "%s", name); 277 + preg->dev = device_create(sound_class, device, MKDEV(major, minor), 278 + private_data, "%s", name); 280 279 if (IS_ERR(preg->dev)) { 281 280 snd_minors[minor] = NULL; 282 281 mutex_unlock(&sound_mutex);
+7 -8
sound/oss/soundcard.c
··· 560 560 sound_dmap_flag = (dmabuf > 0 ? 1 : 0); 561 561 562 562 for (i = 0; i < ARRAY_SIZE(dev_list); i++) { 563 - device_create_drvdata(sound_class, NULL, 564 - MKDEV(SOUND_MAJOR, dev_list[i].minor), 565 - NULL, "%s", dev_list[i].name); 563 + device_create(sound_class, NULL, 564 + MKDEV(SOUND_MAJOR, dev_list[i].minor), NULL, 565 + "%s", dev_list[i].name); 566 566 567 567 if (!dev_list[i].num) 568 568 continue; 569 569 570 570 for (j = 1; j < *dev_list[i].num; j++) 571 - device_create_drvdata(sound_class, NULL, 572 - MKDEV(SOUND_MAJOR, 573 - dev_list[i].minor + (j*0x10)), 574 - NULL, 575 - "%s%d", dev_list[i].name, j); 571 + device_create(sound_class, NULL, 572 + MKDEV(SOUND_MAJOR, 573 + dev_list[i].minor + (j*0x10)), 574 + NULL, "%s%d", dev_list[i].name, j); 576 575 } 577 576 578 577 if (sound_nblocks >= 1024)
+2 -3
sound/sound_core.c
··· 220 220 else 221 221 sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP); 222 222 223 - device_create_drvdata(sound_class, dev, 224 - MKDEV(SOUND_MAJOR, s->unit_minor), 225 - NULL, s->name+6); 223 + device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor), 224 + NULL, s->name+6); 226 225 return r; 227 226 228 227 fail: