* 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. ...
Unified · Split
| @@ -1714,6 +1714,11 @@ and is between 256 and 4096 characters. It is defined in the file · 1713 unmodified lines | ||
| 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 |
| @@ -118,6 +118,10 @@ the name of the kobject, call kobject_rename(): · 117 unmodified lines | ||
| 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. |
| @@ -522,8 +522,8 @@ static int __init rtlx_module_init(void) · 521 unmodified lines | ||
| 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; |
| @@ -576,8 +576,7 @@ static int __init sbprof_tb_init(void) · 575 unmodified lines | ||
| 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; |
| @@ -147,8 +147,8 @@ static __cpuinit int cpuid_device_create(int cpu) · 146 unmodified lines | ||
| 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 | |
| @@ -13,6 +13,7 @@ · 12 unmodified lines | ||
| 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 | |
| @@ -343,6 +344,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err) · 324 unmodified lines | ||
| 343 | 344 | printk("DEBUG_PAGEALLOC"); |
| 344 | 345 | #endif |
| 345 | 346 | printk("\n"); |
| 347 | + sysfs_printk_last_file(); | |
| 346 | 348 | if (notify_die(DIE_OOPS, str, regs, err, |
| 347 | 349 | current->thread.trap_no, SIGSEGV) == NOTIFY_STOP) |
| 348 | 350 | return 1; |
| @@ -13,6 +13,7 @@ · 12 unmodified lines | ||
| 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 | |
| @@ -489,6 +490,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err) · 470 unmodified lines | ||
| 489 | 490 | printk("DEBUG_PAGEALLOC"); |
| 490 | 491 | #endif |
| 491 | 492 | printk("\n"); |
| 493 | + sysfs_printk_last_file(); | |
| 492 | 494 | if (notify_die(DIE_OOPS, str, regs, err, |
| 493 | 495 | current->thread.trap_no, SIGSEGV) == NOTIFY_STOP) |
| 494 | 496 | return 1; |
| @@ -163,8 +163,8 @@ static int __cpuinit msr_device_create(int cpu) · 162 unmodified lines | ||
| 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 | |
| @@ -1024,8 +1024,7 @@ int bsg_register_queue(struct request_queue *q, struct device *parent, · 1023 unmodified lines | ||
| 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; |
| @@ -333,9 +333,7 @@ static int match_name(struct device *dev, void *data) · 332 unmodified lines | ||
| 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 | /** |
| @@ -982,6 +980,56 @@ struct klist *bus_get_device_klist(struct bus_type *bus) · 640 unmodified lines | ||
| 982 | 980 | } |
| 983 | 981 | EXPORT_SYMBOL_GPL(bus_get_device_klist); |
| 984 | 982 | |
| 983 | +/* | |
| 984 | + * Yes, this forcably breaks the klist abstraction temporarily. It | |
| 985 | + * just wants to sort the klist, not change reference counts and | |
| 986 | + * take/drop locks rapidly in the process. It does all this while | |
| 987 | + * holding the lock for the list, so objects can't otherwise be | |
| 988 | + * added/removed while we're swizzling. | |
| 989 | + */ | |
| 990 | +static void device_insertion_sort_klist(struct device *a, struct list_head *list, | |
| 991 | + int (*compare)(const struct device *a, | |
| 992 | + const struct device *b)) | |
| 993 | +{ | |
| 994 | + struct list_head *pos; | |
| 995 | + struct klist_node *n; | |
| 996 | + struct device *b; | |
| 997 | + | |
| 998 | + list_for_each(pos, list) { | |
| 999 | + n = container_of(pos, struct klist_node, n_node); | |
| 1000 | + b = container_of(n, struct device, knode_bus); | |
| 1001 | + if (compare(a, b) <= 0) { | |
| 1002 | + list_move_tail(&a->knode_bus.n_node, | |
| 1003 | + &b->knode_bus.n_node); | |
| 1004 | + return; | |
| 1005 | + } | |
| 1006 | + } | |
| 1007 | + list_move_tail(&a->knode_bus.n_node, list); | |
| 1008 | +} | |
| 1009 | + | |
| 1010 | +void bus_sort_breadthfirst(struct bus_type *bus, | |
| 1011 | + int (*compare)(const struct device *a, | |
| 1012 | + const struct device *b)) | |
| 1013 | +{ | |
| 1014 | + LIST_HEAD(sorted_devices); | |
| 1015 | + struct list_head *pos, *tmp; | |
| 1016 | + struct klist_node *n; | |
| 1017 | + struct device *dev; | |
| 1018 | + struct klist *device_klist; | |
| 1019 | + | |
| 1020 | + device_klist = bus_get_device_klist(bus); | |
| 1021 | + | |
| 1022 | + spin_lock(&device_klist->k_lock); | |
| 1023 | + list_for_each_safe(pos, tmp, &device_klist->k_list) { | |
| 1024 | + n = container_of(pos, struct klist_node, n_node); | |
| 1025 | + dev = container_of(n, struct device, knode_bus); | |
| 1026 | + device_insertion_sort_klist(dev, &sorted_devices, compare); | |
| 1027 | + } | |
| 1028 | + list_splice(&sorted_devices, &device_klist->k_list); | |
| 1029 | + spin_unlock(&device_klist->k_lock); | |
| 1030 | +} | |
| 1031 | +EXPORT_SYMBOL_GPL(bus_sort_breadthfirst); | |
| 1032 | + | |
| 985 | 1033 | int __init buses_init(void) |
| 986 | 1034 | { |
| 987 | 1035 | bus_kset = kset_create_and_add("bus", &bus_uevent_ops, NULL); |
| @@ -523,11 +523,16 @@ static void klist_children_put(struct klist_node *n) · 522 unmodified lines | ||
| 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 | { |
| @@ -835,9 +840,13 @@ static void device_remove_sys_dev_entry(struct device *dev) · 301 unmodified lines | ||
| 835 | 840 | * This is part 2 of device_register(), though may be called |
| 836 | 841 | * separately _iff_ device_initialize() has been called separately. |
| 837 | 842 | * |
| 838 | − * This adds it to the kobject hierarchy via kobject_add(), adds it | |
| 843 | + * This adds @dev to the kobject hierarchy via kobject_add(), adds it | |
| 839 | 844 | * to the global and sibling lists for the device, then |
| 840 | 845 | * adds it to the other relevant subsystems of the driver model. |
| 846 | + * | |
| 847 | + * NOTE: _Never_ directly free @dev after calling this function, even | |
| 848 | + * if it returned an error! Always use put_device() to give up your | |
| 849 | + * reference instead. | |
| 841 | 850 | */ |
| 842 | 851 | int device_add(struct device *dev) |
| 843 | 852 | { |
| @@ -965,6 +974,10 @@ done: · 121 unmodified lines | ||
| 965 | 974 | * I.e. you should only call the two helpers separately if |
| 966 | 975 | * have a clearly defined need to use and refcount the device |
| 967 | 976 | * before it is added to the hierarchy. |
| 977 | + * | |
| 978 | + * NOTE: _Never_ directly free @dev after calling this function, even | |
| 979 | + * if it returned an error! Always use put_device() to give up the | |
| 980 | + * reference initialized in this function instead. | |
| 968 | 981 | */ |
| 969 | 982 | int device_register(struct device *dev) |
| 970 | 983 | { |
| @@ -1243,7 +1256,7 @@ struct device *device_create_vargs(struct class *class, struct device *parent, · 272 unmodified lines | ||
| 1243 | 1256 | return dev; |
| 1244 | 1257 | |
| 1245 | 1258 | error: |
| 1246 | − kfree(dev); | |
| 1259 | + put_device(dev); | |
| 1247 | 1260 | return ERR_PTR(retval); |
| 1248 | 1261 | } |
| 1249 | 1262 | EXPORT_SYMBOL_GPL(device_create_vargs); |
| @@ -1314,6 +1327,11 @@ EXPORT_SYMBOL_GPL(device_destroy); · 64 unmodified lines | ||
| 1314 | 1327 | * device_rename - renames a device |
| 1315 | 1328 | * @dev: the pointer to the struct device to be renamed |
| 1316 | 1329 | * @new_name: the new name of the device |
| 1330 | + * | |
| 1331 | + * It is the responsibility of the caller to provide mutual | |
| 1332 | + * exclusion between two different calls of device_rename | |
| 1333 | + * on the same device to ensure that new_name is valid and | |
| 1334 | + * won't conflict with other devices. | |
| 1317 | 1335 | */ |
| 1318 | 1336 | int device_rename(struct device *dev, char *new_name) |
| 1319 | 1337 | { |
| @@ -257,6 +257,9 @@ static int __driver_attach(struct device *dev, void *data) · 256 unmodified lines | ||
| 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); |
| @@ -394,6 +394,53 @@ error: · 393 unmodified lines | ||
| 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); |
| @@ -865,7 +912,7 @@ static int platform_pm_restore_noirq(struct device *dev) · 465 unmodified lines | ||
| 865 | 912 | |
| 866 | 913 | #endif /* !CONFIG_HIBERNATION */ |
| 867 | 914 | |
| 868 | −struct pm_ext_ops platform_pm_ops = { | |
| 915 | +static struct pm_ext_ops platform_pm_ops = { | |
| 869 | 916 | .base = { |
| 870 | 917 | .prepare = platform_pm_prepare, |
| 871 | 918 | .complete = platform_pm_complete, |
| @@ -83,7 +83,7 @@ void device_pm_add(struct device *dev) · 82 unmodified lines | ||
| 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); |
| @@ -284,9 +284,9 @@ aoechr_init(void) · 283 unmodified lines | ||
| 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 | } |
| @@ -686,9 +686,8 @@ static int __init pg_init(void) · 685 unmodified lines | ||
| 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; |
| @@ -979,12 +979,10 @@ static int __init pt_init(void) · 978 unmodified lines | ||
| 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 | |
| @@ -302,9 +302,8 @@ static struct kobj_type kobj_pkt_type_wqueue = { · 301 unmodified lines | ||
| 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 | } |
| @@ -229,9 +229,8 @@ static int bsr_create_devs(struct device_node *bn) · 228 unmodified lines | ||
| 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); |
| @@ -508,8 +508,8 @@ static int __init dsp56k_init_driver(void) · 507 unmodified lines | ||
| 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; |
| @@ -745,12 +745,12 @@ static int __init ip2_loadmain(void) · 744 unmodified lines | ||
| 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++) |
| @@ -871,7 +871,7 @@ static void ipmi_new_smi(int if_num, struct device *device) · 870 unmodified lines | ||
| 871 | 871 | entry->dev = dev; |
| 872 | 872 | |
| 873 | 873 | mutex_lock(®_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, ®_list); |
| 876 | 876 | mutex_unlock(®_list_mutex); |
| 877 | 877 | } |
| @@ -4600,9 +4600,8 @@ static int __init istallion_module_init(void) · 4599 unmodified lines | ||
| 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: |
| @@ -813,8 +813,8 @@ static int lp_register(int nr, struct parport *port) · 812 unmodified lines | ||
| 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"); |
| @@ -992,9 +992,9 @@ static int __init chr_dev_init(void) · 991 unmodified lines | ||
| 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 | } |
| @@ -217,8 +217,8 @@ int misc_register(struct miscdevice * misc) · 216 unmodified lines | ||
| 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; |
| @@ -1871,7 +1871,7 @@ static int cm4000_probe(struct pcmcia_device *link) · 1870 unmodified lines | ||
| 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 | } |
| @@ -637,8 +637,7 @@ static int reader_probe(struct pcmcia_device *link) · 636 unmodified lines | ||
| 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 | } |
| @@ -760,9 +760,8 @@ static const struct file_operations pp_fops = { · 759 unmodified lines | ||
| 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) |
| @@ -131,8 +131,8 @@ raw_ioctl(struct inode *inode, struct file *filp, · 130 unmodified lines | ||
| 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,8 +283,7 @@ static int __init raw_init(void) · 144 unmodified lines | ||
| 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 | |
| @@ -444,8 +444,8 @@ scdrv_init(void) · 443 unmodified lines | ||
| 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 */ , |
| @@ -4743,8 +4743,8 @@ static int __init stallion_module_init(void) · 4742 unmodified lines | ||
| 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: |
| @@ -2850,7 +2850,7 @@ struct device *tty_register_device(struct tty_driver *driver, unsigned index, · 2849 unmodified lines | ||
| 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 | |
| @@ -481,10 +481,10 @@ static struct class *vc_class; · 480 unmodified lines | ||
| 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,7 +499,7 @@ int __init vcs_init(void) · 8 unmodified lines | ||
| 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 | } |
| @@ -886,10 +886,10 @@ static int viotape_probe(struct vio_dev *vdev, const struct vio_device_id *id) · 885 unmodified lines | ||
| 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, |
| @@ -657,8 +657,7 @@ static int __devinit hwicap_setup(struct device *dev, int id, · 656 unmodified lines | ||
| 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: |
| @@ -15,9 +15,8 @@ int dca_sysfs_add_req(struct dca_provider *dca, struct device *dev, int slot) · 14 unmodified lines | ||
| 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; |
| @@ -48,8 +47,7 @@ idr_try_again: · 24 unmodified lines | ||
| 48 | 47 | return err; |
| 49 | 48 | } |
| 50 | 49 | |
| 51 | − cd = device_create_drvdata(dca_class, dev, MKDEV(0, 0), NULL, | |
| 52 | − "dca%d", dca->id); | |
| 50 | + cd = device_create(dca_class, dev, MKDEV(0, 0), NULL, "dca%d", dca->id); | |
| 53 | 51 | if (IS_ERR(cd)) { |
| 54 | 52 | spin_lock(&dca_idr_lock); |
| 55 | 53 | idr_remove(&dca_idr, dca->id); |
| @@ -334,9 +334,9 @@ static void ibft_release(struct kobject *kobj) · 333 unmodified lines | ||
| 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,9 +376,9 @@ ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry, · 33 unmodified lines | ||
| 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,9 +440,9 @@ ssize_t ibft_attr_show_nic(struct ibft_kobject *entry, · 55 unmodified lines | ||
| 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; |
| @@ -326,9 +326,8 @@ int hidraw_connect(struct hid_device *hid) · 325 unmodified lines | ||
| 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); |
| @@ -55,8 +55,8 @@ again: · 54 unmodified lines | ||
| 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); |
| @@ -521,9 +521,9 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap) · 520 unmodified lines | ||
| 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; |
| @@ -657,8 +657,8 @@ static int ide_register_port(ide_hwif_t *hwif) · 656 unmodified lines | ||
| 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); |
| @@ -2420,12 +2420,11 @@ static int ide_tape_probe(ide_drive_t *drive) · 2419 unmodified lines | ||
| 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); |
| @@ -2296,10 +2296,10 @@ static void dv1394_add_host(struct hpsb_host *host) · 2295 unmodified lines | ||
| 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); |
| @@ -3010,10 +3010,10 @@ static int __init init_raw1394(void) · 3009 unmodified lines | ||
| 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 | } |
| @@ -1341,9 +1341,8 @@ static void video1394_add_host (struct hpsb_host *host) · 1340 unmodified lines | ||
| 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 | |
| @@ -3691,9 +3691,9 @@ static void cm_add_one(struct ib_device *ib_device) · 3690 unmodified lines | ||
| 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; |
| @@ -1016,9 +1016,9 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, · 1015 unmodified lines | ||
| 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,9 +1036,9 @@ static int ib_umad_init_port(struct ib_device *device, int port_num, · 11 unmodified lines | ||
| 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 | |
| @@ -764,12 +764,9 @@ static void ib_uverbs_add_one(struct ib_device *device) · 763 unmodified lines | ||
| 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 | |
| @@ -2455,7 +2455,7 @@ static int init_cdev(int minor, char *name, const struct file_operations *fops, · 2454 unmodified lines | ||
| 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); |
| @@ -1553,8 +1553,7 @@ static int __init capi_init(void) · 1552 unmodified lines | ||
| 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) { |
| @@ -103,8 +103,8 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev) · 102 unmodified lines | ||
| 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 | |
| @@ -862,8 +862,7 @@ adbdev_init(void) · 861 unmodified lines | ||
| 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); |
| @@ -233,7 +233,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, · 232 unmodified lines | ||
| 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)) { |
| @@ -399,9 +399,9 @@ static int __devinit phantom_probe(struct pci_dev *pdev, · 398 unmodified lines | ||
| 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); |
| @@ -26,13 +26,11 @@ static void mtd_notify_add(struct mtd_info* mtd) · 25 unmodified lines | ||
| 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) |
| @@ -309,11 +309,6 @@ void phy_disconnect(struct phy_device *phydev) · 308 unmodified lines | ||
| 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 |
| @@ -337,8 +332,7 @@ struct phy_device *phy_attach(struct net_device *dev, · 17 unmodified lines | ||
| 337 | 332 | |
| 338 | 333 | /* Search the list of PHY devices on the mdio bus for the |
| 339 | 334 | * PHY with the requested name */ |
| 340 | − d = bus_find_device(bus, NULL, (void *)bus_id, phy_compare_id); | |
| 341 | − | |
| 335 | + d = bus_find_device_by_name(bus, NULL, bus_id); | |
| 342 | 336 | if (d) { |
| 343 | 337 | phydev = to_phy_device(d); |
| 344 | 338 | } else { |
| @@ -866,8 +866,8 @@ static int __init ppp_init(void) · 865 unmodified lines | ||
| 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: |
| @@ -388,8 +388,8 @@ static int __init cosa_init(void) · 387 unmodified lines | ||
| 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 | |
| @@ -533,11 +533,11 @@ static int __init init_mac80211_hwsim(void) · 532 unmodified lines | ||
| 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; |
| @@ -1237,8 +1237,11 @@ EXPORT_SYMBOL(pci_scan_bridge); · 1236 unmodified lines | ||
| 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 | |
| @@ -1251,50 +1254,7 @@ static int __init pci_sort_bf_cmp(const struct pci_dev *a, const struct pci_dev · 6 unmodified lines | ||
| 1251 | 1254 | return 0; |
| 1252 | 1255 | } |
| 1253 | 1256 | |
| 1254 | −/* | |
| 1255 | − * Yes, this forcably breaks the klist abstraction temporarily. It | |
| 1256 | − * just wants to sort the klist, not change reference counts and | |
| 1257 | − * take/drop locks rapidly in the process. It does all this while | |
| 1258 | − * holding the lock for the list, so objects can't otherwise be | |
| 1259 | − * added/removed while we're swizzling. | |
| 1260 | − */ | |
| 1261 | −static void __init pci_insertion_sort_klist(struct pci_dev *a, struct list_head *list) | |
| 1262 | −{ | |
| 1263 | − struct list_head *pos; | |
| 1264 | − struct klist_node *n; | |
| 1265 | − struct device *dev; | |
| 1266 | − struct pci_dev *b; | |
| 1267 | − | |
| 1268 | − list_for_each(pos, list) { | |
| 1269 | − n = container_of(pos, struct klist_node, n_node); | |
| 1270 | − dev = container_of(n, struct device, knode_bus); | |
| 1271 | − b = to_pci_dev(dev); | |
| 1272 | − if (pci_sort_bf_cmp(a, b) <= 0) { | |
| 1273 | − list_move_tail(&a->dev.knode_bus.n_node, &b->dev.knode_bus.n_node); | |
| 1274 | − return; | |
| 1275 | − } | |
| 1276 | − } | |
| 1277 | − list_move_tail(&a->dev.knode_bus.n_node, list); | |
| 1278 | −} | |
| 1279 | − | |
| 1280 | 1257 | void __init pci_sort_breadthfirst(void) |
| 1281 | 1258 | { |
| 1282 | − LIST_HEAD(sorted_devices); | |
| 1283 | − struct list_head *pos, *tmp; | |
| 1284 | − struct klist_node *n; | |
| 1285 | − struct device *dev; | |
| 1286 | − struct pci_dev *pdev; | |
| 1287 | − struct klist *device_klist; | |
| 1288 | − | |
| 1289 | − device_klist = bus_get_device_klist(&pci_bus_type); | |
| 1290 | − | |
| 1291 | − spin_lock(&device_klist->k_lock); | |
| 1292 | − list_for_each_safe(pos, tmp, &device_klist->k_list) { | |
| 1293 | − n = container_of(pos, struct klist_node, n_node); | |
| 1294 | − dev = container_of(n, struct device, knode_bus); | |
| 1295 | − pdev = to_pci_dev(dev); | |
| 1296 | − pci_insertion_sort_klist(pdev, &sorted_devices); | |
| 1297 | − } | |
| 1298 | − list_splice(&sorted_devices, &device_klist->k_list); | |
| 1299 | − spin_unlock(&device_klist->k_lock); | |
| 1259 | + bus_sort_breadthfirst(&pci_bus_type, &pci_sort_bf_cmp); | |
| 1300 | 1260 | } |
| @@ -4,6 +4,7 @@ · 3 unmodified lines | ||
| 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); |
| @@ -16,7 +17,6 @@ struct pnp_card *pnp_alloc_card(struct pnp_protocol *, int id, char *pnpid); · 6 unmodified lines | ||
| 16 | 17 | |
| 17 | 18 | int pnp_add_device(struct pnp_dev *dev); |
| 18 | 19 | struct pnp_id *pnp_add_id(struct pnp_dev *dev, char *id); |
| 19 | −int pnp_interface_attach_device(struct pnp_dev *dev); | |
| 20 | 20 | |
| 21 | 21 | int pnp_add_card(struct pnp_card *card); |
| 22 | 22 | void pnp_remove_card(struct pnp_card *card); |
| @@ -159,21 +159,13 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid · 158 unmodified lines | ||
| 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 | /* |
| @@ -206,6 +206,7 @@ struct bus_type pnp_bus_type = { · 205 unmodified lines | ||
| 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) |
| @@ -243,8 +243,6 @@ static ssize_t pnp_show_options(struct device *dmdev, · 242 unmodified lines | ||
| 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) |
| @@ -420,9 +418,6 @@ done: · 169 unmodified lines | ||
| 420 | 418 | return count; |
| 421 | 419 | } |
| 422 | 420 | |
| 423 | −static DEVICE_ATTR(resources, S_IRUGO | S_IWUSR, | |
| 424 | − pnp_show_current_resources, pnp_set_current_resources); | |
| 425 | − | |
| 426 | 421 | static ssize_t pnp_show_current_ids(struct device *dmdev, |
| 427 | 422 | struct device_attribute *attr, char *buf) |
| 428 | 423 | { |
| @@ -437,27 +432,11 @@ static ssize_t pnp_show_current_ids(struct device *dmdev, · 8 unmodified lines | ||
| 437 | 432 | return (str - buf); |
| 438 | 433 | } |
| 439 | 434 | |
| 440 | −static DEVICE_ATTR(id, S_IRUGO, pnp_show_current_ids, NULL); | |
| 441 | − | |
| 442 | −int pnp_interface_attach_device(struct pnp_dev *dev) | |
| 443 | −{ | |
| 444 | − int rc = device_create_file(&dev->dev, &dev_attr_options); | |
| 445 | − | |
| 446 | − if (rc) | |
| 447 | − goto err; | |
| 448 | − rc = device_create_file(&dev->dev, &dev_attr_resources); | |
| 449 | − if (rc) | |
| 450 | − goto err_opt; | |
| 451 | − rc = device_create_file(&dev->dev, &dev_attr_id); | |
| 452 | − if (rc) | |
| 453 | − goto err_res; | |
| 454 | − | |
| 455 | − return 0; | |
| 456 | − | |
| 457 | −err_res: | |
| 458 | − device_remove_file(&dev->dev, &dev_attr_resources); | |
| 459 | −err_opt: | |
| 460 | − device_remove_file(&dev->dev, &dev_attr_options); | |
| 461 | −err: | |
| 462 | − return rc; | |
| 463 | −} | |
| 435 | +struct device_attribute pnp_interface_attrs[] = { | |
| 436 | + __ATTR(resources, S_IRUGO | S_IWUSR, | |
| 437 | + pnp_show_current_resources, | |
| 438 | + pnp_set_current_resources), | |
| 439 | + __ATTR(options, S_IRUGO, pnp_show_options, NULL), | |
| 440 | + __ATTR(id, S_IRUGO, pnp_show_current_ids, NULL), | |
| 441 | + __ATTR_NULL, | |
| 442 | +}; | |
| @@ -91,8 +91,8 @@ int power_supply_register(struct device *parent, struct power_supply *psy) · 90 unmodified lines | ||
| 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; |
| @@ -1168,19 +1168,17 @@ static int raw3270_create_attributes(struct raw3270 *rp) · 1167 unmodified lines | ||
| 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 | |
| @@ -69,9 +69,9 @@ struct tape_class_device *register_tape_dev( · 68 unmodified lines | ||
| 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; |
| @@ -747,10 +747,10 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv) · 746 unmodified lines | ||
| 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; |
| @@ -896,9 +896,8 @@ static int ur_set_online(struct ccw_device *cdev) · 895 unmodified lines | ||
| 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); |
| @@ -914,9 +914,9 @@ static int ch_probe(struct device *dev) · 913 unmodified lines | ||
| 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); |
| @@ -271,7 +271,7 @@ rebuild_sys_tab: · 270 unmodified lines | ||
| 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)) { |
| @@ -5708,7 +5708,8 @@ static int osst_sysfs_add(dev_t dev, struct device *device, struct osst_tape * S · 5707 unmodified lines | ||
| 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); |
| @@ -1450,12 +1450,10 @@ sg_add(struct device *cl_dev, struct class_interface *cl_intf) · 1449 unmodified lines | ||
| 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"); |
| @@ -4428,13 +4428,10 @@ static int do_create_class_files(struct scsi_tape *STp, int dev_num, int mode) · 4427 unmodified lines | ||
| 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); |
| @@ -583,10 +583,9 @@ static int spidev_probe(struct spi_device *spi) · 582 unmodified lines | ||
| 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"); |
| @@ -58,4 +58,17 @@ config UIO_SMX · 57 unmodified lines | ||
| 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 |
| @@ -3,3 +3,4 @@ obj-$(CONFIG_UIO_CIF) += uio_cif.o · 2 unmodified lines | ||
| 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 | |
| @@ -67,6 +67,11 @@ static ssize_t map_size_show(struct uio_mem *mem, char *buf) · 66 unmodified lines | ||
| 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 *); |
| @@ -77,10 +82,13 @@ static struct uio_sysfs_entry addr_attribute = · 4 unmodified lines | ||
| 77 | 82 | __ATTR(addr, S_IRUGO, map_addr_show, NULL); |
| 78 | 83 | static struct uio_sysfs_entry size_attribute = |
| 79 | 84 | __ATTR(size, S_IRUGO, map_size_show, NULL); |
| 85 | +static struct uio_sysfs_entry offset_attribute = | |
| 86 | + __ATTR(offset, S_IRUGO, map_offset_show, NULL); | |
| 80 | 87 | |
| 81 | 88 | static struct attribute *attrs[] = { |
| 82 | 89 | &addr_attribute.attr, |
| 83 | 90 | &size_attribute.attr, |
| 91 | + &offset_attribute.attr, | |
| 84 | 92 | NULL, /* need to NULL terminate the list of attributes */ |
| 85 | 93 | }; |
| 86 | 94 | |
| @@ -482,15 +490,23 @@ static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) · 395 unmodified lines | ||
| 482 | 490 | { |
| 483 | 491 | struct uio_device *idev = vma->vm_private_data; |
| 484 | 492 | struct page *page; |
| 493 | + unsigned long offset; | |
| 485 | 494 | |
| 486 | 495 | int mi = uio_find_mem_index(vma); |
| 487 | 496 | if (mi < 0) |
| 488 | 497 | return VM_FAULT_SIGBUS; |
| 489 | 498 | |
| 499 | + /* | |
| 500 | + * We need to subtract mi because userspace uses offset = N*PAGE_SIZE | |
| 501 | + * to use mem[N]. | |
| 502 | + */ | |
| 503 | + offset = (vmf->pgoff - mi) << PAGE_SHIFT; | |
| 504 | + | |
| 490 | 505 | if (idev->info->mem[mi].memtype == UIO_MEM_LOGICAL) |
| 491 | − page = virt_to_page(idev->info->mem[mi].addr); | |
| 506 | + page = virt_to_page(idev->info->mem[mi].addr + offset); | |
| 492 | 507 | else |
| 493 | − page = vmalloc_to_page((void*)idev->info->mem[mi].addr); | |
| 508 | + page = vmalloc_to_page((void *)idev->info->mem[mi].addr | |
| 509 | + + offset); | |
| 494 | 510 | get_page(page); |
| 495 | 511 | vmf->page = page; |
| 496 | 512 | return 0; |
| @@ -682,9 +698,9 @@ int __uio_register_device(struct module *owner, · 185 unmodified lines | ||
| 682 | 698 | if (ret) |
| 683 | 699 | goto err_get_minor; |
| 684 | 700 | |
| 685 | − idev->dev = device_create_drvdata(uio_class->class, parent, | |
| 686 | − MKDEV(uio_major, idev->minor), idev, | |
| 687 | − "uio%d", idev->minor); | |
| 701 | + idev->dev = device_create(uio_class->class, parent, | |
| 702 | + MKDEV(uio_major, idev->minor), idev, | |
| 703 | + "uio%d", idev->minor); | |
| 688 | 704 | if (IS_ERR(idev->dev)) { |
| 689 | 705 | printk(KERN_ERR "UIO: device register failed\n"); |
| 690 | 706 | ret = PTR_ERR(idev->dev); |
| @@ -12,7 +12,7 @@ · 11 unmodified lines | ||
| 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; |
| @@ -0,0 +1,243 @@ | ||
| 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"); | |
| @@ -1729,9 +1729,9 @@ static int usb_classdev_add(struct usb_device *dev) · 1728 unmodified lines | ||
| 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; |
| @@ -196,9 +196,9 @@ int usb_register_dev(struct usb_interface *intf, · 195 unmodified lines | ||
| 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; |
| @@ -818,9 +818,8 @@ static int usb_register_bus(struct usb_bus *bus) · 817 unmodified lines | ||
| 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; |
| @@ -22,24 +22,15 @@ obj-$(CONFIG_USB_M66592) += m66592-udc.o · 21 unmodified lines | ||
| 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 |
| @@ -43,6 +43,25 @@ · 42 unmodified lines | ||
| 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, |
| @@ -148,7 +167,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) · 99 unmodified lines | ||
| 148 | 167 | int status; |
| 149 | 168 | |
| 150 | 169 | if (!can_support_ecm(cdev->gadget)) { |
| 151 | − ERROR(cdev, "controller '%s' not usable\n", gadget->name); | |
| 170 | + dev_err(&gadget->dev, "controller '%s' not usable\n", | |
| 171 | + gadget->name); | |
| 152 | 172 | return -EINVAL; |
| 153 | 173 | } |
| 154 | 174 | |
| @@ -203,7 +223,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) · 48 unmodified lines | ||
| 203 | 223 | if (status < 0) |
| 204 | 224 | goto fail1; |
| 205 | 225 | |
| 206 | − INFO(cdev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC); | |
| 226 | + dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", | |
| 227 | + DRIVER_DESC); | |
| 207 | 228 | |
| 208 | 229 | return 0; |
| 209 | 230 | |
| @@ -96,6 +96,28 @@ static inline bool has_rndis(void) · 95 unmodified lines | ||
| 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 | */ |
| @@ -293,7 +315,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev) · 191 unmodified lines | ||
| 293 | 315 | * but if the controller isn't recognized at all then |
| 294 | 316 | * that assumption is a bit more likely to be wrong. |
| 295 | 317 | */ |
| 296 | − WARNING(cdev, "controller '%s' not recognized; trying %s\n", | |
| 318 | + dev_warn(&gadget->dev, | |
| 319 | + "controller '%s' not recognized; trying %s\n", | |
| 297 | 320 | gadget->name, |
| 298 | 321 | eth_config_driver.label); |
| 299 | 322 | device_desc.bcdDevice = |
| @@ -332,7 +355,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev) · 32 unmodified lines | ||
| 332 | 355 | if (status < 0) |
| 333 | 356 | goto fail; |
| 334 | 357 | |
| 335 | − INFO(cdev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC); | |
| 358 | + dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", | |
| 359 | + DRIVER_DESC); | |
| 336 | 360 | |
| 337 | 361 | return 0; |
| 338 | 362 | |
| @@ -83,7 +83,7 @@ static inline struct f_ecm *func_to_ecm(struct usb_function *f) · 82 unmodified lines | ||
| 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,7 +107,7 @@ static inline unsigned bitrate(struct usb_gadget *g) · 17 unmodified lines | ||
| 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,8 +125,8 @@ static struct usb_interface_descriptor ecm_control_intf __initdata = { · 11 unmodified lines | ||
| 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,8 +141,8 @@ static struct usb_cdc_union_desc ecm_union_desc __initdata = { · 8 unmodified lines | ||
| 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,17 +186,17 @@ static struct usb_interface_descriptor ecm_data_intf __initdata = { · 37 unmodified lines | ||
| 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,7 +204,7 @@ static struct usb_endpoint_descriptor fs_in_desc __initdata = { · 1 unmodified line | ||
| 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,34 +212,34 @@ static struct usb_endpoint_descriptor fs_out_desc __initdata = { · 1 unmodified line | ||
| 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 *) ðer_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,7 +248,7 @@ static struct usb_endpoint_descriptor hs_in_desc __initdata = { · 2 unmodified lines | ||
| 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,19 +257,19 @@ static struct usb_endpoint_descriptor hs_out_desc __initdata = { · 2 unmodified lines | ||
| 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 *) ðer_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,14 +329,14 @@ static void ecm_do_notify(struct f_ecm *ecm) · 53 unmodified lines | ||
| 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,13 +628,13 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) · 285 unmodified lines | ||
| 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,7 +644,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) · 3 unmodified lines | ||
| 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,47 +656,47 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) · 5 unmodified lines | ||
| 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,7 +795,7 @@ int __init ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]) · 92 unmodified lines | ||
| 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 */ |
| @@ -70,7 +70,7 @@ static struct usb_interface_descriptor loopback_intf = { · 69 unmodified lines | ||
| 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,7 +78,7 @@ static struct usb_endpoint_descriptor fs_source_desc = { · 1 unmodified line | ||
| 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,14 +88,14 @@ static struct usb_endpoint_descriptor fs_sink_desc = { · 3 unmodified lines | ||
| 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,7 +103,7 @@ static struct usb_endpoint_descriptor hs_source_desc = { · 1 unmodified line | ||
| 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,8 +113,8 @@ static struct usb_endpoint_descriptor hs_sink_desc = { · 3 unmodified lines | ||
| 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,7 +152,7 @@ loopback_bind(struct usb_configuration *c, struct usb_function *f) · 31 unmodified lines | ||
| 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,17 +161,17 @@ autoconf_fail: · 2 unmodified lines | ||
| 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,8 +255,10 @@ enable_loopback(struct usb_composite_dev *cdev, struct f_loopback *loop) · 77 unmodified lines | ||
| 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; |
| @@ -103,8 +103,8 @@ static struct usb_interface_descriptor subset_data_intf __initdata = { · 102 unmodified lines | ||
| 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,7 +152,7 @@ static struct usb_cdc_ether_desc ether_desc __initdata = { · 41 unmodified lines | ||
| 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,7 +160,7 @@ static struct usb_endpoint_descriptor fs_in_desc __initdata = { · 1 unmodified line | ||
| 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,18 +170,18 @@ static struct usb_endpoint_descriptor fs_out_desc __initdata = { · 3 unmodified lines | ||
| 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 *) ðer_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,7 +189,7 @@ static struct usb_endpoint_descriptor hs_in_desc __initdata = { · 1 unmodified line | ||
| 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,12 +199,12 @@ static struct usb_endpoint_descriptor hs_out_desc __initdata = { · 3 unmodified lines | ||
| 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 *) ðer_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,13 +281,13 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) · 70 unmodified lines | ||
| 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,9 +297,9 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) · 3 unmodified lines | ||
| 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,18 +307,18 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) · 1 unmodified line | ||
| 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 |
| @@ -245,6 +245,18 @@ · 244 unmodified lines | ||
| 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" |
| @@ -35,6 +35,21 @@ · 34 unmodified lines | ||
| 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 | |
| @@ -53,6 +53,20 @@ · 52 unmodified lines | ||
| 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 | |
| @@ -1360,8 +1374,8 @@ printer_bind(struct usb_gadget *gadget) · 1301 unmodified lines | ||
| 1360 | 1374 | |
| 1361 | 1375 | |
| 1362 | 1376 | /* Setup the sysfs files for the printer gadget. */ |
| 1363 | − dev->pdev = device_create_drvdata(usb_gadget_class, NULL, | |
| 1364 | − g_printer_devno, NULL, "g_printer"); | |
| 1377 | + dev->pdev = device_create(usb_gadget_class, NULL, g_printer_devno, | |
| 1378 | + NULL, "g_printer"); | |
| 1365 | 1379 | if (IS_ERR(dev->pdev)) { |
| 1366 | 1380 | ERROR(dev, "Failed to create device: g_printer\n"); |
| 1367 | 1381 | goto fail; |
| @@ -57,11 +57,6 @@ MODULE_PARM_DESC (rndis_debug, "enable debugging"); · 56 unmodified lines | ||
| 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 | |
| @@ -183,9 +178,9 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 115 unmodified lines | ||
| 183 | 178 | if (!resp) return -ENOMEM; |
| 184 | 179 | |
| 185 | 180 | if (buf_len && rndis_debug > 1) { |
| 186 | − DBG("query OID %08x value, len %d:\n", OID, buf_len); | |
| 181 | + pr_debug("query OID %08x value, len %d:\n", OID, buf_len); | |
| 187 | 182 | for (i = 0; i < buf_len; i += 16) { |
| 188 | − DBG("%03d: %08x %08x %08x %08x\n", i, | |
| 183 | + pr_debug("%03d: %08x %08x %08x %08x\n", i, | |
| 189 | 184 | get_unaligned_le32(&buf[i]), |
| 190 | 185 | get_unaligned_le32(&buf[i + 4]), |
| 191 | 186 | get_unaligned_le32(&buf[i + 8]), |
| @@ -209,7 +204,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 17 unmodified lines | ||
| 209 | 204 | |
| 210 | 205 | /* mandatory */ |
| 211 | 206 | case OID_GEN_SUPPORTED_LIST: |
| 212 | − DBG("%s: OID_GEN_SUPPORTED_LIST\n", __func__); | |
| 207 | + pr_debug("%s: OID_GEN_SUPPORTED_LIST\n", __func__); | |
| 213 | 208 | length = sizeof (oid_supported_list); |
| 214 | 209 | count = length / sizeof (u32); |
| 215 | 210 | for (i = 0; i < count; i++) |
| @@ -219,7 +214,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 3 unmodified lines | ||
| 219 | 214 | |
| 220 | 215 | /* mandatory */ |
| 221 | 216 | case OID_GEN_HARDWARE_STATUS: |
| 222 | − DBG("%s: OID_GEN_HARDWARE_STATUS\n", __func__); | |
| 217 | + pr_debug("%s: OID_GEN_HARDWARE_STATUS\n", __func__); | |
| 223 | 218 | /* Bogus question! |
| 224 | 219 | * Hardware must be ready to receive high level protocols. |
| 225 | 220 | * BTW: |
| @@ -232,14 +227,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 6 unmodified lines | ||
| 232 | 227 | |
| 233 | 228 | /* mandatory */ |
| 234 | 229 | case OID_GEN_MEDIA_SUPPORTED: |
| 235 | − DBG("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__); | |
| 230 | + pr_debug("%s: OID_GEN_MEDIA_SUPPORTED\n", __func__); | |
| 236 | 231 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); |
| 237 | 232 | retval = 0; |
| 238 | 233 | break; |
| 239 | 234 | |
| 240 | 235 | /* mandatory */ |
| 241 | 236 | case OID_GEN_MEDIA_IN_USE: |
| 242 | − DBG("%s: OID_GEN_MEDIA_IN_USE\n", __func__); | |
| 237 | + pr_debug("%s: OID_GEN_MEDIA_IN_USE\n", __func__); | |
| 243 | 238 | /* one medium, one transport... (maybe you do it better) */ |
| 244 | 239 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr].medium); |
| 245 | 240 | retval = 0; |
| @@ -247,7 +242,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 1 unmodified line | ||
| 247 | 242 | |
| 248 | 243 | /* mandatory */ |
| 249 | 244 | case OID_GEN_MAXIMUM_FRAME_SIZE: |
| 250 | − DBG("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__); | |
| 245 | + pr_debug("%s: OID_GEN_MAXIMUM_FRAME_SIZE\n", __func__); | |
| 251 | 246 | if (rndis_per_dev_params [configNr].dev) { |
| 252 | 247 | *outbuf = cpu_to_le32 ( |
| 253 | 248 | rndis_per_dev_params [configNr].dev->mtu); |
| @@ -258,7 +253,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 4 unmodified lines | ||
| 258 | 253 | /* mandatory */ |
| 259 | 254 | case OID_GEN_LINK_SPEED: |
| 260 | 255 | if (rndis_debug > 1) |
| 261 | − DBG("%s: OID_GEN_LINK_SPEED\n", __func__); | |
| 256 | + pr_debug("%s: OID_GEN_LINK_SPEED\n", __func__); | |
| 262 | 257 | if (rndis_per_dev_params [configNr].media_state |
| 263 | 258 | == NDIS_MEDIA_STATE_DISCONNECTED) |
| 264 | 259 | *outbuf = __constant_cpu_to_le32 (0); |
| @@ -270,7 +265,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 5 unmodified lines | ||
| 270 | 265 | |
| 271 | 266 | /* mandatory */ |
| 272 | 267 | case OID_GEN_TRANSMIT_BLOCK_SIZE: |
| 273 | − DBG("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__); | |
| 268 | + pr_debug("%s: OID_GEN_TRANSMIT_BLOCK_SIZE\n", __func__); | |
| 274 | 269 | if (rndis_per_dev_params [configNr].dev) { |
| 275 | 270 | *outbuf = cpu_to_le32 ( |
| 276 | 271 | rndis_per_dev_params [configNr].dev->mtu); |
| @@ -280,7 +275,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 3 unmodified lines | ||
| 280 | 275 | |
| 281 | 276 | /* mandatory */ |
| 282 | 277 | case OID_GEN_RECEIVE_BLOCK_SIZE: |
| 283 | − DBG("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__); | |
| 278 | + pr_debug("%s: OID_GEN_RECEIVE_BLOCK_SIZE\n", __func__); | |
| 284 | 279 | if (rndis_per_dev_params [configNr].dev) { |
| 285 | 280 | *outbuf = cpu_to_le32 ( |
| 286 | 281 | rndis_per_dev_params [configNr].dev->mtu); |
| @@ -290,7 +285,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 3 unmodified lines | ||
| 290 | 285 | |
| 291 | 286 | /* mandatory */ |
| 292 | 287 | case OID_GEN_VENDOR_ID: |
| 293 | − DBG("%s: OID_GEN_VENDOR_ID\n", __func__); | |
| 288 | + pr_debug("%s: OID_GEN_VENDOR_ID\n", __func__); | |
| 294 | 289 | *outbuf = cpu_to_le32 ( |
| 295 | 290 | rndis_per_dev_params [configNr].vendorID); |
| 296 | 291 | retval = 0; |
| @@ -298,7 +293,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 1 unmodified line | ||
| 298 | 293 | |
| 299 | 294 | /* mandatory */ |
| 300 | 295 | case OID_GEN_VENDOR_DESCRIPTION: |
| 301 | − DBG("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__); | |
| 296 | + pr_debug("%s: OID_GEN_VENDOR_DESCRIPTION\n", __func__); | |
| 302 | 297 | length = strlen (rndis_per_dev_params [configNr].vendorDescr); |
| 303 | 298 | memcpy (outbuf, |
| 304 | 299 | rndis_per_dev_params [configNr].vendorDescr, length); |
| @@ -306,7 +301,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 1 unmodified line | ||
| 306 | 301 | break; |
| 307 | 302 | |
| 308 | 303 | case OID_GEN_VENDOR_DRIVER_VERSION: |
| 309 | − DBG("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __func__); | |
| 304 | + pr_debug("%s: OID_GEN_VENDOR_DRIVER_VERSION\n", __func__); | |
| 310 | 305 | /* Created as LE */ |
| 311 | 306 | *outbuf = rndis_driver_version; |
| 312 | 307 | retval = 0; |
| @@ -314,14 +309,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 1 unmodified line | ||
| 314 | 309 | |
| 315 | 310 | /* mandatory */ |
| 316 | 311 | case OID_GEN_CURRENT_PACKET_FILTER: |
| 317 | − DBG("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__); | |
| 312 | + pr_debug("%s: OID_GEN_CURRENT_PACKET_FILTER\n", __func__); | |
| 318 | 313 | *outbuf = cpu_to_le32 (*rndis_per_dev_params[configNr].filter); |
| 319 | 314 | retval = 0; |
| 320 | 315 | break; |
| 321 | 316 | |
| 322 | 317 | /* mandatory */ |
| 323 | 318 | case OID_GEN_MAXIMUM_TOTAL_SIZE: |
| 324 | − DBG("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__); | |
| 319 | + pr_debug("%s: OID_GEN_MAXIMUM_TOTAL_SIZE\n", __func__); | |
| 325 | 320 | *outbuf = __constant_cpu_to_le32(RNDIS_MAX_TOTAL_SIZE); |
| 326 | 321 | retval = 0; |
| 327 | 322 | break; |
| @@ -329,14 +324,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 1 unmodified line | ||
| 329 | 324 | /* mandatory */ |
| 330 | 325 | case OID_GEN_MEDIA_CONNECT_STATUS: |
| 331 | 326 | if (rndis_debug > 1) |
| 332 | − DBG("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__); | |
| 327 | + pr_debug("%s: OID_GEN_MEDIA_CONNECT_STATUS\n", __func__); | |
| 333 | 328 | *outbuf = cpu_to_le32 (rndis_per_dev_params [configNr] |
| 334 | 329 | .media_state); |
| 335 | 330 | retval = 0; |
| 336 | 331 | break; |
| 337 | 332 | |
| 338 | 333 | case OID_GEN_PHYSICAL_MEDIUM: |
| 339 | − DBG("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__); | |
| 334 | + pr_debug("%s: OID_GEN_PHYSICAL_MEDIUM\n", __func__); | |
| 340 | 335 | *outbuf = __constant_cpu_to_le32 (0); |
| 341 | 336 | retval = 0; |
| 342 | 337 | break; |
| @@ -346,7 +341,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 3 unmodified lines | ||
| 346 | 341 | * versions emit undefined RNDIS messages. DOCUMENT ALL THESE! |
| 347 | 342 | */ |
| 348 | 343 | case OID_GEN_MAC_OPTIONS: /* from WinME */ |
| 349 | − DBG("%s: OID_GEN_MAC_OPTIONS\n", __func__); | |
| 344 | + pr_debug("%s: OID_GEN_MAC_OPTIONS\n", __func__); | |
| 350 | 345 | *outbuf = __constant_cpu_to_le32( |
| 351 | 346 | NDIS_MAC_OPTION_RECEIVE_SERIALIZED |
| 352 | 347 | | NDIS_MAC_OPTION_FULL_DUPLEX); |
| @@ -358,7 +353,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 5 unmodified lines | ||
| 358 | 353 | /* mandatory */ |
| 359 | 354 | case OID_GEN_XMIT_OK: |
| 360 | 355 | if (rndis_debug > 1) |
| 361 | − DBG("%s: OID_GEN_XMIT_OK\n", __func__); | |
| 356 | + pr_debug("%s: OID_GEN_XMIT_OK\n", __func__); | |
| 362 | 357 | if (stats) { |
| 363 | 358 | *outbuf = cpu_to_le32(stats->tx_packets |
| 364 | 359 | - stats->tx_errors - stats->tx_dropped); |
| @@ -369,7 +364,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 4 unmodified lines | ||
| 369 | 364 | /* mandatory */ |
| 370 | 365 | case OID_GEN_RCV_OK: |
| 371 | 366 | if (rndis_debug > 1) |
| 372 | − DBG("%s: OID_GEN_RCV_OK\n", __func__); | |
| 367 | + pr_debug("%s: OID_GEN_RCV_OK\n", __func__); | |
| 373 | 368 | if (stats) { |
| 374 | 369 | *outbuf = cpu_to_le32(stats->rx_packets |
| 375 | 370 | - stats->rx_errors - stats->rx_dropped); |
| @@ -380,7 +375,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 4 unmodified lines | ||
| 380 | 375 | /* mandatory */ |
| 381 | 376 | case OID_GEN_XMIT_ERROR: |
| 382 | 377 | if (rndis_debug > 1) |
| 383 | − DBG("%s: OID_GEN_XMIT_ERROR\n", __func__); | |
| 378 | + pr_debug("%s: OID_GEN_XMIT_ERROR\n", __func__); | |
| 384 | 379 | if (stats) { |
| 385 | 380 | *outbuf = cpu_to_le32(stats->tx_errors); |
| 386 | 381 | retval = 0; |
| @@ -390,7 +385,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 3 unmodified lines | ||
| 390 | 385 | /* mandatory */ |
| 391 | 386 | case OID_GEN_RCV_ERROR: |
| 392 | 387 | if (rndis_debug > 1) |
| 393 | − DBG("%s: OID_GEN_RCV_ERROR\n", __func__); | |
| 388 | + pr_debug("%s: OID_GEN_RCV_ERROR\n", __func__); | |
| 394 | 389 | if (stats) { |
| 395 | 390 | *outbuf = cpu_to_le32(stats->rx_errors); |
| 396 | 391 | retval = 0; |
| @@ -399,7 +394,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 2 unmodified lines | ||
| 399 | 394 | |
| 400 | 395 | /* mandatory */ |
| 401 | 396 | case OID_GEN_RCV_NO_BUFFER: |
| 402 | − DBG("%s: OID_GEN_RCV_NO_BUFFER\n", __func__); | |
| 397 | + pr_debug("%s: OID_GEN_RCV_NO_BUFFER\n", __func__); | |
| 403 | 398 | if (stats) { |
| 404 | 399 | *outbuf = cpu_to_le32(stats->rx_dropped); |
| 405 | 400 | retval = 0; |
| @@ -410,7 +405,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 4 unmodified lines | ||
| 410 | 405 | |
| 411 | 406 | /* mandatory */ |
| 412 | 407 | case OID_802_3_PERMANENT_ADDRESS: |
| 413 | − DBG("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__); | |
| 408 | + pr_debug("%s: OID_802_3_PERMANENT_ADDRESS\n", __func__); | |
| 414 | 409 | if (rndis_per_dev_params [configNr].dev) { |
| 415 | 410 | length = ETH_ALEN; |
| 416 | 411 | memcpy (outbuf, |
| @@ -422,7 +417,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 5 unmodified lines | ||
| 422 | 417 | |
| 423 | 418 | /* mandatory */ |
| 424 | 419 | case OID_802_3_CURRENT_ADDRESS: |
| 425 | − DBG("%s: OID_802_3_CURRENT_ADDRESS\n", __func__); | |
| 420 | + pr_debug("%s: OID_802_3_CURRENT_ADDRESS\n", __func__); | |
| 426 | 421 | if (rndis_per_dev_params [configNr].dev) { |
| 427 | 422 | length = ETH_ALEN; |
| 428 | 423 | memcpy (outbuf, |
| @@ -434,7 +429,7 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 5 unmodified lines | ||
| 434 | 429 | |
| 435 | 430 | /* mandatory */ |
| 436 | 431 | case OID_802_3_MULTICAST_LIST: |
| 437 | − DBG("%s: OID_802_3_MULTICAST_LIST\n", __func__); | |
| 432 | + pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__); | |
| 438 | 433 | /* Multicast base address only */ |
| 439 | 434 | *outbuf = __constant_cpu_to_le32 (0xE0000000); |
| 440 | 435 | retval = 0; |
| @@ -442,21 +437,21 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 1 unmodified line | ||
| 442 | 437 | |
| 443 | 438 | /* mandatory */ |
| 444 | 439 | case OID_802_3_MAXIMUM_LIST_SIZE: |
| 445 | − DBG("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__); | |
| 440 | + pr_debug("%s: OID_802_3_MAXIMUM_LIST_SIZE\n", __func__); | |
| 446 | 441 | /* Multicast base address only */ |
| 447 | 442 | *outbuf = __constant_cpu_to_le32 (1); |
| 448 | 443 | retval = 0; |
| 449 | 444 | break; |
| 450 | 445 | |
| 451 | 446 | case OID_802_3_MAC_OPTIONS: |
| 452 | − DBG("%s: OID_802_3_MAC_OPTIONS\n", __func__); | |
| 447 | + pr_debug("%s: OID_802_3_MAC_OPTIONS\n", __func__); | |
| 453 | 448 | break; |
| 454 | 449 | |
| 455 | 450 | /* ieee802.3 statistics OIDs (table 4-4) */ |
| 456 | 451 | |
| 457 | 452 | /* mandatory */ |
| 458 | 453 | case OID_802_3_RCV_ERROR_ALIGNMENT: |
| 459 | − DBG("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __func__); | |
| 454 | + pr_debug("%s: OID_802_3_RCV_ERROR_ALIGNMENT\n", __func__); | |
| 460 | 455 | if (stats) { |
| 461 | 456 | *outbuf = cpu_to_le32(stats->rx_frame_errors); |
| 462 | 457 | retval = 0; |
| @@ -465,14 +460,14 @@ gen_ndis_query_resp (int configNr, u32 OID, u8 *buf, unsigned buf_len, · 2 unmodified lines | ||
| 465 | 460 | |
| 466 | 461 | /* mandatory */ |
| 467 | 462 | case OID_802_3_XMIT_ONE_COLLISION: |
| 468 | − DBG("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__); | |
| 463 | + pr_debug("%s: OID_802_3_XMIT_ONE_COLLISION\n", __func__); | |
| 469 | 464 | *outbuf = __constant_cpu_to_le32 (0); |
| 470 | 465 | retval = 0; |
| 471 | 466 | break; |
| 472 | 467 | |
| 473 | 468 | /* mandatory */ |
| 474 | 469 | case OID_802_3_XMIT_MORE_COLLISIONS: |
| 475 | − DBG("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__); | |
| 470 | + pr_debug("%s: OID_802_3_XMIT_MORE_COLLISIONS\n", __func__); | |
| 476 | 471 | *outbuf = __constant_cpu_to_le32 (0); |
| 477 | 472 | retval = 0; |
| 478 | 473 | break; |
| @@ -504,9 +499,9 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, · 25 unmodified lines | ||
| 504 | 499 | return -ENOMEM; |
| 505 | 500 | |
| 506 | 501 | if (buf_len && rndis_debug > 1) { |
| 507 | − DBG("set OID %08x value, len %d:\n", OID, buf_len); | |
| 502 | + pr_debug("set OID %08x value, len %d:\n", OID, buf_len); | |
| 508 | 503 | for (i = 0; i < buf_len; i += 16) { |
| 509 | − DBG("%03d: %08x %08x %08x %08x\n", i, | |
| 504 | + pr_debug("%03d: %08x %08x %08x %08x\n", i, | |
| 510 | 505 | get_unaligned_le32(&buf[i]), |
| 511 | 506 | get_unaligned_le32(&buf[i + 4]), |
| 512 | 507 | get_unaligned_le32(&buf[i + 8]), |
| @@ -525,7 +520,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, · 12 unmodified lines | ||
| 525 | 520 | * MULTICAST, ALL_MULTICAST, BROADCAST |
| 526 | 521 | */ |
| 527 | 522 | *params->filter = (u16)get_unaligned_le32(buf); |
| 528 | − DBG("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n", | |
| 523 | + pr_debug("%s: OID_GEN_CURRENT_PACKET_FILTER %08x\n", | |
| 529 | 524 | __func__, *params->filter); |
| 530 | 525 | |
| 531 | 526 | /* this call has a significant side effect: it's |
| @@ -547,7 +542,7 @@ static int gen_ndis_set_resp (u8 configNr, u32 OID, u8 *buf, u32 buf_len, · 15 unmodified lines | ||
| 547 | 542 | |
| 548 | 543 | case OID_802_3_MULTICAST_LIST: |
| 549 | 544 | /* I think we can ignore this */ |
| 550 | − DBG("%s: OID_802_3_MULTICAST_LIST\n", __func__); | |
| 545 | + pr_debug("%s: OID_802_3_MULTICAST_LIST\n", __func__); | |
| 551 | 546 | retval = 0; |
| 552 | 547 | break; |
| 553 | 548 | |
| @@ -606,7 +601,7 @@ static int rndis_query_response (int configNr, rndis_query_msg_type *buf) · 52 unmodified lines | ||
| 606 | 601 | rndis_resp_t *r; |
| 607 | 602 | struct rndis_params *params = rndis_per_dev_params + configNr; |
| 608 | 603 | |
| 609 | − // DBG("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); | |
| 604 | + /* pr_debug("%s: OID = %08X\n", __func__, cpu_to_le32(buf->OID)); */ | |
| 610 | 605 | if (!params->dev) |
| 611 | 606 | return -ENOTSUPP; |
| 612 | 607 | |
| @@ -659,15 +654,15 @@ static int rndis_set_response (int configNr, rndis_set_msg_type *buf) · 46 unmodified lines | ||
| 659 | 654 | BufOffset = le32_to_cpu (buf->InformationBufferOffset); |
| 660 | 655 | |
| 661 | 656 | #ifdef VERBOSE_DEBUG |
| 662 | − DBG("%s: Length: %d\n", __func__, BufLength); | |
| 663 | − DBG("%s: Offset: %d\n", __func__, BufOffset); | |
| 664 | − DBG("%s: InfoBuffer: ", __func__); | |
| 657 | + pr_debug("%s: Length: %d\n", __func__, BufLength); | |
| 658 | + pr_debug("%s: Offset: %d\n", __func__, BufOffset); | |
| 659 | + pr_debug("%s: InfoBuffer: ", __func__); | |
| 665 | 660 | |
| 666 | 661 | for (i = 0; i < BufLength; i++) { |
| 667 | − DBG("%02x ", *(((u8 *) buf) + i + 8 + BufOffset)); | |
| 662 | + pr_debug("%02x ", *(((u8 *) buf) + i + 8 + BufOffset)); | |
| 668 | 663 | } |
| 669 | 664 | |
| 670 | − DBG("\n"); | |
| 665 | + pr_debug("\n"); | |
| 671 | 666 | #endif |
| 672 | 667 | |
| 673 | 668 | resp->MessageType = __constant_cpu_to_le32 (REMOTE_NDIS_SET_CMPLT); |
| @@ -821,14 +816,14 @@ int rndis_msg_parser (u8 configNr, u8 *buf) · 147 unmodified lines | ||
| 821 | 816 | /* For USB: responses may take up to 10 seconds */ |
| 822 | 817 | switch (MsgType) { |
| 823 | 818 | case REMOTE_NDIS_INITIALIZE_MSG: |
| 824 | − DBG("%s: REMOTE_NDIS_INITIALIZE_MSG\n", | |
| 819 | + pr_debug("%s: REMOTE_NDIS_INITIALIZE_MSG\n", | |
| 825 | 820 | __func__ ); |
| 826 | 821 | params->state = RNDIS_INITIALIZED; |
| 827 | 822 | return rndis_init_response (configNr, |
| 828 | 823 | (rndis_init_msg_type *) buf); |
| 829 | 824 | |
| 830 | 825 | case REMOTE_NDIS_HALT_MSG: |
| 831 | − DBG("%s: REMOTE_NDIS_HALT_MSG\n", | |
| 826 | + pr_debug("%s: REMOTE_NDIS_HALT_MSG\n", | |
| 832 | 827 | __func__ ); |
| 833 | 828 | params->state = RNDIS_UNINITIALIZED; |
| 834 | 829 | if (params->dev) { |
| @@ -846,7 +841,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf) · 11 unmodified lines | ||
| 846 | 841 | (rndis_set_msg_type *) buf); |
| 847 | 842 | |
| 848 | 843 | case REMOTE_NDIS_RESET_MSG: |
| 849 | − DBG("%s: REMOTE_NDIS_RESET_MSG\n", | |
| 844 | + pr_debug("%s: REMOTE_NDIS_RESET_MSG\n", | |
| 850 | 845 | __func__ ); |
| 851 | 846 | return rndis_reset_response (configNr, |
| 852 | 847 | (rndis_reset_msg_type *) buf); |
| @@ -854,7 +849,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf) · 1 unmodified line | ||
| 854 | 849 | case REMOTE_NDIS_KEEPALIVE_MSG: |
| 855 | 850 | /* For USB: host does this every 5 seconds */ |
| 856 | 851 | if (rndis_debug > 1) |
| 857 | − DBG("%s: REMOTE_NDIS_KEEPALIVE_MSG\n", | |
| 852 | + pr_debug("%s: REMOTE_NDIS_KEEPALIVE_MSG\n", | |
| 858 | 853 | __func__ ); |
| 859 | 854 | return rndis_keepalive_response (configNr, |
| 860 | 855 | (rndis_keepalive_msg_type *) |
| @@ -870,7 +865,7 @@ int rndis_msg_parser (u8 configNr, u8 *buf) · 9 unmodified lines | ||
| 870 | 865 | { |
| 871 | 866 | unsigned i; |
| 872 | 867 | for (i = 0; i < MsgLength; i += 16) { |
| 873 | − DBG("%03d: " | |
| 868 | + pr_debug("%03d: " | |
| 874 | 869 | " %02x %02x %02x %02x" |
| 875 | 870 | " %02x %02x %02x %02x" |
| 876 | 871 | " %02x %02x %02x %02x" |
| @@ -905,18 +900,18 @@ int rndis_register(void (*resp_avail)(void *v), void *v) · 28 unmodified lines | ||
| 905 | 900 | rndis_per_dev_params [i].used = 1; |
| 906 | 901 | rndis_per_dev_params [i].resp_avail = resp_avail; |
| 907 | 902 | rndis_per_dev_params [i].v = v; |
| 908 | − DBG("%s: configNr = %d\n", __func__, i); | |
| 903 | + pr_debug("%s: configNr = %d\n", __func__, i); | |
| 909 | 904 | return i; |
| 910 | 905 | } |
| 911 | 906 | } |
| 912 | − DBG("failed\n"); | |
| 907 | + pr_debug("failed\n"); | |
| 913 | 908 | |
| 914 | 909 | return -ENODEV; |
| 915 | 910 | } |
| 916 | 911 | |
| 917 | 912 | void rndis_deregister (int configNr) |
| 918 | 913 | { |
| 919 | − DBG("%s: \n", __func__ ); | |
| 914 | + pr_debug("%s: \n", __func__); | |
| 920 | 915 | |
| 921 | 916 | if (configNr >= RNDIS_MAX_CONFIGS) return; |
| 922 | 917 | rndis_per_dev_params [configNr].used = 0; |
| @@ -926,7 +921,7 @@ void rndis_deregister (int configNr) · 3 unmodified lines | ||
| 926 | 921 | |
| 927 | 922 | int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter) |
| 928 | 923 | { |
| 929 | − DBG("%s:\n", __func__ ); | |
| 924 | + pr_debug("%s:\n", __func__); | |
| 930 | 925 | if (!dev) |
| 931 | 926 | return -EINVAL; |
| 932 | 927 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; |
| @@ -939,7 +934,7 @@ int rndis_set_param_dev(u8 configNr, struct net_device *dev, u16 *cdc_filter) · 6 unmodified lines | ||
| 939 | 934 | |
| 940 | 935 | int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr) |
| 941 | 936 | { |
| 942 | − DBG("%s:\n", __func__ ); | |
| 937 | + pr_debug("%s:\n", __func__); | |
| 943 | 938 | if (!vendorDescr) return -1; |
| 944 | 939 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; |
| 945 | 940 | |
| @@ -951,7 +946,7 @@ int rndis_set_param_vendor (u8 configNr, u32 vendorID, const char *vendorDescr) · 5 unmodified lines | ||
| 951 | 946 | |
| 952 | 947 | int rndis_set_param_medium (u8 configNr, u32 medium, u32 speed) |
| 953 | 948 | { |
| 954 | − DBG("%s: %u %u\n", __func__, medium, speed); | |
| 949 | + pr_debug("%s: %u %u\n", __func__, medium, speed); | |
| 955 | 950 | if (configNr >= RNDIS_MAX_CONFIGS) return -1; |
| 956 | 951 | |
| 957 | 952 | rndis_per_dev_params [configNr].medium = medium; |
| @@ -1114,7 +1109,7 @@ static ssize_t rndis_proc_write(struct file *file, const char __user *buffer, · 156 unmodified lines | ||
| 1114 | 1109 | break; |
| 1115 | 1110 | default: |
| 1116 | 1111 | if (fl_speed) p->speed = speed; |
| 1117 | − else DBG("%c is not valid\n", c); | |
| 1112 | + else pr_debug("%c is not valid\n", c); | |
| 1118 | 1113 | break; |
| 1119 | 1114 | } |
| 1120 | 1115 | |
| @@ -1159,12 +1154,12 @@ int __init rndis_init (void) · 38 unmodified lines | ||
| 1159 | 1154 | &rndis_proc_fops, |
| 1160 | 1155 | (void *)(rndis_per_dev_params + i)))) |
| 1161 | 1156 | { |
| 1162 | − DBG("%s :remove entries", __func__); | |
| 1157 | + pr_debug("%s :remove entries", __func__); | |
| 1163 | 1158 | while (i) { |
| 1164 | 1159 | sprintf (name, NAME_TEMPLATE, --i); |
| 1165 | 1160 | remove_proc_entry (name, NULL); |
| 1166 | 1161 | } |
| 1167 | − DBG("\n"); | |
| 1162 | + pr_debug("\n"); | |
| 1168 | 1163 | return -EIO; |
| 1169 | 1164 | } |
| 1170 | 1165 | #endif |
| @@ -30,6 +30,24 @@ · 29 unmodified lines | ||
| 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!! |
| @@ -52,7 +52,7 @@ · 51 unmodified lines | ||
| 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,7 +170,7 @@ static void eth_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *p) · 111 unmodified lines | ||
| 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 | } |
| @@ -57,6 +57,23 @@ · 56 unmodified lines | ||
| 57 | 57 | #include "gadget_chips.h" |
| 58 | 58 | |
| 59 | 59 | |
| 60 | +/*-------------------------------------------------------------------------*/ | |
| 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 | + | |
| 60 | 77 | /*-------------------------------------------------------------------------*/ |
| 61 | 78 | |
| 62 | 79 | #define DRIVER_VERSION "Cinco de Mayo 2008" |
| @@ -123,14 +123,10 @@ static struct uhci_td *uhci_alloc_td(struct uhci_hcd *uhci) · 122 unmodified lines | ||
| 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 | } |
| @@ -295,10 +291,8 @@ static struct uhci_qh *uhci_alloc_qh(struct uhci_hcd *uhci, · 158 unmodified lines | ||
| 295 | 291 | static void uhci_free_qh(struct uhci_hcd *uhci, struct uhci_qh *qh) |
| 296 | 292 | { |
| 297 | 293 | WARN_ON(qh->state != QH_STATE_IDLE && qh->udev); |
| 298 | − if (!list_empty(&qh->queue)) { | |
| 299 | − dev_warn(uhci_dev(uhci), "qh %p list not empty!\n", qh); | |
| 300 | − WARN_ON(1); | |
| 301 | − } | |
| 294 | + if (!list_empty(&qh->queue)) | |
| 295 | + dev_WARN(uhci_dev(uhci), "qh %p list not empty!\n", qh); | |
| 302 | 296 | |
| 303 | 297 | list_del(&qh->node); |
| 304 | 298 | if (qh->udev) { |
| @@ -746,11 +740,9 @@ static void uhci_free_urb_priv(struct uhci_hcd *uhci, · 441 unmodified lines | ||
| 746 | 740 | { |
| 747 | 741 | struct uhci_td *td, *tmp; |
| 748 | 742 | |
| 749 | − if (!list_empty(&urbp->node)) { | |
| 750 | − dev_warn(uhci_dev(uhci), "urb %p still on QH's list!\n", | |
| 743 | + if (!list_empty(&urbp->node)) | |
| 744 | + dev_WARN(uhci_dev(uhci), "urb %p still on QH's list!\n", | |
| 751 | 745 | urbp->urb); |
| 752 | − WARN_ON(1); | |
| 753 | − } | |
| 754 | 746 | |
| 755 | 747 | list_for_each_entry_safe(td, tmp, &urbp->td_list, list) { |
| 756 | 748 | uhci_remove_td_from_urbp(td); |
| @@ -595,9 +595,8 @@ static int interfacekit_probe(struct usb_interface *intf, const struct usb_devic · 594 unmodified lines | ||
| 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; |
| @@ -365,9 +365,8 @@ static int motorcontrol_probe(struct usb_interface *intf, const struct usb_devic · 364 unmodified lines | ||
| 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; |
| @@ -275,9 +275,8 @@ servo_probe(struct usb_interface *interface, const struct usb_device_id *id) · 274 unmodified lines | ||
| 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; |
| @@ -1162,9 +1162,9 @@ int mon_bin_add(struct mon_bus *mbus, const struct usb_bus *ubus) · 1161 unmodified lines | ||
| 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 | |
| @@ -3573,8 +3573,8 @@ static int __init fb_console_init(void) · 3572 unmodified lines | ||
| 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 " |
| @@ -153,12 +153,9 @@ struct display_device *display_device_register(struct display_driver *driver, · 152 unmodified lines | ||
| 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; |
| @@ -1430,9 +1430,8 @@ register_framebuffer(struct fb_info *fb_info) · 1429 unmodified lines | ||
| 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)); |
| @@ -362,9 +362,8 @@ static int init_coda_psdev(void) · 361 unmodified lines | ||
| 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 | |
| @@ -61,6 +61,7 @@ read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off) · 60 unmodified lines | ||
| 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) |
| @@ -69,23 +70,33 @@ read(struct file *file, char __user *userbuf, size_t bytes, loff_t *off) · 2 unmodified lines | ||
| 69 | 70 | count = size - offs; |
| 70 | 71 | } |
| 71 | 72 | |
| 73 | + temp = kmalloc(count, GFP_KERNEL); | |
| 74 | + if (!temp) | |
| 75 | + return -ENOMEM; | |
| 76 | + | |
| 72 | 77 | mutex_lock(&bb->mutex); |
| 73 | 78 | |
| 74 | 79 | count = fill_read(dentry, bb->buffer, offs, count); |
| 75 | − if (count < 0) | |
| 76 | − goto out_unlock; | |
| 80 | + if (count < 0) { | |
| 81 | + mutex_unlock(&bb->mutex); | |
| 82 | + goto out_free; | |
| 83 | + } | |
| 77 | 84 | |
| 78 | − if (copy_to_user(userbuf, bb->buffer, count)) { | |
| 85 | + memcpy(temp, bb->buffer, count); | |
| 86 | + | |
| 87 | + mutex_unlock(&bb->mutex); | |
| 88 | + | |
| 89 | + if (copy_to_user(userbuf, temp, count)) { | |
| 79 | 90 | count = -EFAULT; |
| 80 | − goto out_unlock; | |
| 91 | + goto out_free; | |
| 81 | 92 | } |
| 82 | 93 | |
| 83 | 94 | pr_debug("offs = %lld, *off = %lld, count = %d\n", offs, *off, count); |
| 84 | 95 | |
| 85 | 96 | *off = offs + count; |
| 86 | 97 | |
| 87 | − out_unlock: | |
| 88 | − mutex_unlock(&bb->mutex); | |
| 98 | + out_free: | |
| 99 | + kfree(temp); | |
| 89 | 100 | return count; |
| 90 | 101 | } |
| 91 | 102 | |
| @@ -118,6 +129,7 @@ static ssize_t write(struct file *file, const char __user *userbuf, · 26 unmodified lines | ||
| 118 | 129 | int size = dentry->d_inode->i_size; |
| 119 | 130 | loff_t offs = *off; |
| 120 | 131 | int count = min_t(size_t, bytes, PAGE_SIZE); |
| 132 | + char *temp; | |
| 121 | 133 | |
| 122 | 134 | if (size) { |
| 123 | 135 | if (offs > size) |
| @@ -126,19 +138,27 @@ static ssize_t write(struct file *file, const char __user *userbuf, · 2 unmodified lines | ||
| 126 | 138 | count = size - offs; |
| 127 | 139 | } |
| 128 | 140 | |
| 129 | − mutex_lock(&bb->mutex); | |
| 141 | + temp = kmalloc(count, GFP_KERNEL); | |
| 142 | + if (!temp) | |
| 143 | + return -ENOMEM; | |
| 130 | 144 | |
| 131 | − if (copy_from_user(bb->buffer, userbuf, count)) { | |
| 145 | + if (copy_from_user(temp, userbuf, count)) { | |
| 132 | 146 | count = -EFAULT; |
| 133 | − goto out_unlock; | |
| 147 | + goto out_free; | |
| 134 | 148 | } |
| 135 | 149 | |
| 150 | + mutex_lock(&bb->mutex); | |
| 151 | + | |
| 152 | + memcpy(bb->buffer, temp, count); | |
| 153 | + | |
| 136 | 154 | count = flush_write(dentry, bb->buffer, offs, count); |
| 155 | + mutex_unlock(&bb->mutex); | |
| 156 | + | |
| 137 | 157 | if (count > 0) |
| 138 | 158 | *off = offs + count; |
| 139 | 159 | |
| 140 | − out_unlock: | |
| 141 | − mutex_unlock(&bb->mutex); | |
| 160 | +out_free: | |
| 161 | + kfree(temp); | |
| 142 | 162 | return count; |
| 143 | 163 | } |
| 144 | 164 | |
| @@ -370,17 +370,17 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, · 369 unmodified lines | ||
| 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,8 +393,7 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt, · 6 unmodified lines | ||
| 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 | /** |
| @@ -636,6 +635,7 @@ struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, · 235 unmodified lines | ||
| 636 | 635 | |
| 637 | 636 | return sd; |
| 638 | 637 | } |
| 638 | +EXPORT_SYMBOL_GPL(sysfs_get_dirent); | |
| 639 | 639 | |
| 640 | 640 | static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd, |
| 641 | 641 | const char *name, struct sysfs_dirent **p_sd) |
| @@ -829,16 +829,12 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name) · 187 unmodified lines | ||
| 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 | 836 | goto out_unlock; |
| 837 | 837 | |
| 838 | − error = kobject_set_name(kobj, "%s", new_name); | |
| 839 | − if (error) | |
| 840 | − goto out_unlock; | |
| 841 | − | |
| 842 | 838 | dup_name = sd->s_name; |
| 843 | 839 | sd->s_name = new_name; |
| 844 | 840 | |
| @@ -19,10 +19,18 @@ · 18 unmodified lines | ||
| 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" |
| 25 | 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 | +} | |
| 33 | + | |
| 26 | 34 | /* |
| 27 | 35 | * There's one sysfs_buffer for each open file and one |
| 28 | 36 | * sysfs_open_dirent for each sysfs_dirent with one or more open |
| @@ -328,6 +336,11 @@ static int sysfs_open_file(struct inode *inode, struct file *file) · 299 unmodified lines | ||
| 328 | 336 | struct sysfs_buffer *buffer; |
| 329 | 337 | struct sysfs_ops *ops; |
| 330 | 338 | int error = -EACCES; |
| 339 | + char *p; | |
| 340 | + | |
| 341 | + p = d_path(&file->f_path, last_sysfs_file, sizeof(last_sysfs_file)); | |
| 342 | + if (p) | |
| 343 | + memmove(last_sysfs_file, p, strlen(p) + 1); | |
| 331 | 344 | |
| 332 | 345 | /* need attr_sd for attr and ops, its parent for kobj */ |
| 333 | 346 | if (!sysfs_get_active_two(attr_sd)) |
| @@ -440,7 +453,23 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait) · 106 unmodified lines | ||
| 440 | 453 | return POLLERR|POLLPRI; |
| 441 | 454 | } |
| 442 | 455 | |
| 443 | −void sysfs_notify(struct kobject *k, char *dir, char *attr) | |
| 456 | +void sysfs_notify_dirent(struct sysfs_dirent *sd) | |
| 457 | +{ | |
| 458 | + struct sysfs_open_dirent *od; | |
| 459 | + | |
| 460 | + spin_lock(&sysfs_open_dirent_lock); | |
| 461 | + | |
| 462 | + od = sd->s_attr.open; | |
| 463 | + if (od) { | |
| 464 | + atomic_inc(&od->event); | |
| 465 | + wake_up_interruptible(&od->poll); | |
| 466 | + } | |
| 467 | + | |
| 468 | + spin_unlock(&sysfs_open_dirent_lock); | |
| 469 | +} | |
| 470 | +EXPORT_SYMBOL_GPL(sysfs_notify_dirent); | |
| 471 | + | |
| 472 | +void sysfs_notify(struct kobject *k, const char *dir, const char *attr) | |
| 444 | 473 | { |
| 445 | 474 | struct sysfs_dirent *sd = k->sd; |
| 446 | 475 | |
| @@ -450,19 +479,8 @@ void sysfs_notify(struct kobject *k, char *dir, char *attr) · 3 unmodified lines | ||
| 450 | 479 | sd = sysfs_find_dirent(sd, dir); |
| 451 | 480 | if (sd && attr) |
| 452 | 481 | sd = sysfs_find_dirent(sd, attr); |
| 453 | − if (sd) { | |
| 454 | − struct sysfs_open_dirent *od; | |
| 455 | − | |
| 456 | − spin_lock(&sysfs_open_dirent_lock); | |
| 457 | − | |
| 458 | − od = sd->s_attr.open; | |
| 459 | − if (od) { | |
| 460 | − atomic_inc(&od->event); | |
| 461 | − wake_up_interruptible(&od->poll); | |
| 462 | − } | |
| 463 | − | |
| 464 | − spin_unlock(&sysfs_open_dirent_lock); | |
| 465 | − } | |
| 482 | + if (sd) | |
| 483 | + sysfs_notify_dirent(sd); | |
| 466 | 484 | |
| 467 | 485 | mutex_unlock(&sysfs_mutex); |
| 468 | 486 | } |
| @@ -16,6 +16,7 @@ · 15 unmodified lines | ||
| 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 | |
| @@ -115,3 +116,17 @@ out_err: · 93 unmodified lines | ||
| 115 | 116 | sysfs_dir_cachep = NULL; |
| 116 | 117 | goto out; |
| 117 | 118 | } |
| 119 | + | |
| 120 | +#undef sysfs_get | |
| 121 | +struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd) | |
| 122 | +{ | |
| 123 | + return __sysfs_get(sd); | |
| 124 | +} | |
| 125 | +EXPORT_SYMBOL_GPL(sysfs_get); | |
| 126 | + | |
| 127 | +#undef sysfs_put | |
| 128 | +void sysfs_put(struct sysfs_dirent *sd) | |
| 129 | +{ | |
| 130 | + __sysfs_put(sd); | |
| 131 | +} | |
| 132 | +EXPORT_SYMBOL_GPL(sysfs_put); | |
| @@ -124,7 +124,7 @@ int sysfs_create_subdir(struct kobject *kobj, const char *name, · 123 unmodified lines | ||
| 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,12 +132,14 @@ static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd) · 1 unmodified line | ||
| 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 |
| @@ -268,7 +268,15 @@ · 267 unmodified lines | ||
| 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) \ |
| @@ -90,6 +90,9 @@ int __must_check bus_for_each_drv(struct bus_type *bus, · 89 unmodified lines | ||
| 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. |
| @@ -502,7 +505,6 @@ extern struct device *device_create(struct class *cls, struct device *parent, · 406 unmodified lines | ||
| 502 | 505 | dev_t devt, void *drvdata, |
| 503 | 506 | const char *fmt, ...) |
| 504 | 507 | __attribute__((format(printf, 5, 6))); |
| 505 | −#define device_create_drvdata device_create | |
| 506 | 508 | extern void device_destroy(struct class *cls, dev_t devt); |
| 507 | 509 | |
| 508 | 510 | /* |
| @@ -551,7 +553,11 @@ extern const char *dev_driver_string(const struct device *dev); · 42 unmodified lines | ||
| 551 | 553 | #define dev_info(dev, format, arg...) \ |
| 552 | 554 | dev_printk(KERN_INFO , dev , format , ## arg) |
| 553 | 555 | |
| 554 | −#ifdef DEBUG | |
| 556 | +#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG) | |
| 557 | +#define dev_dbg(dev, format, ...) do { \ | |
| 558 | + dynamic_dev_dbg(dev, format, ##__VA_ARGS__); \ | |
| 559 | + } while (0) | |
| 560 | +#elif defined(DEBUG) | |
| 555 | 561 | #define dev_dbg(dev, format, arg...) \ |
| 556 | 562 | dev_printk(KERN_DEBUG , dev , format , ## arg) |
| 557 | 563 | #else |
| @@ -567,6 +573,14 @@ extern const char *dev_driver_string(const struct device *dev); · 9 unmodified lines | ||
| 567 | 573 | ({ if (0) dev_printk(KERN_DEBUG, dev, format, ##arg); 0; }) |
| 568 | 574 | #endif |
| 569 | 575 | |
| 576 | +/* | |
| 577 | + * dev_WARN() acts like dev_printk(), but with the key difference | |
| 578 | + * of using a WARN/WARN_ON to get the message out, including the | |
| 579 | + * file/line information and a backtrace. | |
| 580 | + */ | |
| 581 | +#define dev_WARN(dev, format, arg...) \ | |
| 582 | + WARN(1, "Device: %s\n" format, dev_driver_string(dev), ## arg); | |
| 583 | + | |
| 570 | 584 | /* Create alias, so I can be autoloaded. */ |
| 571 | 585 | #define MODULE_ALIAS_CHARDEV(major,minor) \ |
| 572 | 586 | MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor)) |
| @@ -0,0 +1,93 @@ | ||
| 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 | |
| @@ -16,6 +16,7 @@ · 15 unmodified lines | ||
| 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 | |
| @@ -304,8 +305,12 @@ static inline char *pack_hex_byte(char *buf, u8 byte) · 282 unmodified lines | ||
| 304 | 305 | #define pr_info(fmt, arg...) \ |
| 305 | 306 | printk(KERN_INFO fmt, ##arg) |
| 306 | 307 | |
| 307 | −#ifdef DEBUG | |
| 308 | 308 | /* If you are writing a driver, please use dev_dbg instead */ |
| 309 | +#if defined(CONFIG_DYNAMIC_PRINTK_DEBUG) | |
| 310 | +#define pr_debug(fmt, ...) do { \ | |
| 311 | + dynamic_pr_debug(fmt, ##__VA_ARGS__); \ | |
| 312 | + } while (0) | |
| 313 | +#elif defined(DEBUG) | |
| 309 | 314 | #define pr_debug(fmt, arg...) \ |
| 310 | 315 | printk(KERN_DEBUG fmt, ##arg) |
| 311 | 316 | #else |
| @@ -345,7 +345,6 @@ struct module · 344 unmodified lines | ||
| 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 {} |
| @@ -37,6 +37,8 @@ extern int platform_add_devices(struct platform_device **, int); · 36 unmodified lines | ||
| 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); |
| @@ -78,6 +78,8 @@ struct sysfs_ops { · 77 unmodified lines | ||
| 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 *), |
| @@ -117,9 +119,14 @@ int sysfs_add_file_to_group(struct kobject *kobj, · 33 unmodified lines | ||
| 117 | 119 | void sysfs_remove_file_from_group(struct kobject *kobj, |
| 118 | 120 | const struct attribute *attr, const char *group); |
| 119 | 121 | |
| 120 | −void sysfs_notify(struct kobject *kobj, char *dir, char *attr); | |
| 121 | − | |
| 122 | −extern int __must_check sysfs_init(void); | |
| 122 | +void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr); | |
| 123 | +void sysfs_notify_dirent(struct sysfs_dirent *sd); | |
| 124 | +struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, | |
| 125 | + const unsigned char *name); | |
| 126 | +struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd); | |
| 127 | +void sysfs_put(struct sysfs_dirent *sd); | |
| 128 | +void sysfs_printk_last_file(void); | |
| 129 | +int __must_check sysfs_init(void); | |
| 123 | 130 | |
| 124 | 131 | #else /* CONFIG_SYSFS */ |
| 125 | 132 | |
| @@ -222,7 +229,24 @@ static inline void sysfs_remove_file_from_group(struct kobject *kobj, · 96 unmodified lines | ||
| 222 | 229 | { |
| 223 | 230 | } |
| 224 | 231 | |
| 225 | −static inline void sysfs_notify(struct kobject *kobj, char *dir, char *attr) | |
| 232 | +static inline void sysfs_notify(struct kobject *kobj, const char *dir, | |
| 233 | + const char *attr) | |
| 234 | +{ | |
| 235 | +} | |
| 236 | +static inline void sysfs_notify_dirent(struct sysfs_dirent *sd) | |
| 237 | +{ | |
| 238 | +} | |
| 239 | +static inline | |
| 240 | +struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd, | |
| 241 | + const unsigned char *name) | |
| 242 | +{ | |
| 243 | + return NULL; | |
| 244 | +} | |
| 245 | +static inline struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd) | |
| 246 | +{ | |
| 247 | + return NULL; | |
| 248 | +} | |
| 249 | +static inline void sysfs_put(struct sysfs_dirent *sd) | |
| 226 | 250 | { |
| 227 | 251 | } |
| 228 | 252 | |
| @@ -231,6 +255,10 @@ static inline int __must_check sysfs_init(void) · 2 unmodified lines | ||
| 231 | 255 | return 0; |
| 232 | 256 | } |
| 233 | 257 | |
| 258 | +static inline void sysfs_printk_last_file(void) | |
| 259 | +{ | |
| 260 | +} | |
| 261 | + | |
| 234 | 262 | #endif /* CONFIG_SYSFS */ |
| 235 | 263 | |
| 236 | 264 | #endif /* _SYSFS_H_ */ |
| @@ -784,6 +784,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags) · 783 unmodified lines | ||
| 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: |
| @@ -1173,7 +1174,7 @@ static void free_notes_attrs(struct module_notes_attrs *notes_attrs, · 383 unmodified lines | ||
| 1173 | 1174 | while (i-- > 0) |
| 1174 | 1175 | sysfs_remove_bin_file(notes_attrs->dir, |
| 1175 | 1176 | ¬es_attrs->attrs[i]); |
| 1176 | − kobject_del(notes_attrs->dir); | |
| 1177 | + kobject_put(notes_attrs->dir); | |
| 1177 | 1178 | } |
| 1178 | 1179 | kfree(notes_attrs); |
| 1179 | 1180 | } |
| @@ -1783,6 +1784,33 @@ static inline void add_kallsyms(struct module *mod, · 603 unmodified lines | ||
| 1783 | 1784 | } |
| 1784 | 1785 | #endif /* CONFIG_KALLSYMS */ |
| 1785 | 1786 | |
| 1787 | +#ifdef CONFIG_DYNAMIC_PRINTK_DEBUG | |
| 1788 | +static void dynamic_printk_setup(Elf_Shdr *sechdrs, unsigned int verboseindex) | |
| 1789 | +{ | |
| 1790 | + struct mod_debug *debug_info; | |
| 1791 | + unsigned long pos, end; | |
| 1792 | + unsigned int num_verbose; | |
| 1793 | + | |
| 1794 | + pos = sechdrs[verboseindex].sh_addr; | |
| 1795 | + num_verbose = sechdrs[verboseindex].sh_size / | |
| 1796 | + sizeof(struct mod_debug); | |
| 1797 | + end = pos + (num_verbose * sizeof(struct mod_debug)); | |
| 1798 | + | |
| 1799 | + for (; pos < end; pos += sizeof(struct mod_debug)) { | |
| 1800 | + debug_info = (struct mod_debug *)pos; | |
| 1801 | + register_dynamic_debug_module(debug_info->modname, | |
| 1802 | + debug_info->type, debug_info->logical_modname, | |
| 1803 | + debug_info->flag_names, debug_info->hash, | |
| 1804 | + debug_info->hash2); | |
| 1805 | + } | |
| 1806 | +} | |
| 1807 | +#else | |
| 1808 | +static inline void dynamic_printk_setup(Elf_Shdr *sechdrs, | |
| 1809 | + unsigned int verboseindex) | |
| 1810 | +{ | |
| 1811 | +} | |
| 1812 | +#endif /* CONFIG_DYNAMIC_PRINTK_DEBUG */ | |
| 1813 | + | |
| 1786 | 1814 | static void *module_alloc_update_bounds(unsigned long size) |
| 1787 | 1815 | { |
| 1788 | 1816 | void *ret = module_alloc(size); |
| @@ -1831,6 +1859,7 @@ static noinline struct module *load_module(void __user *umod, · 42 unmodified lines | ||
| 1831 | 1859 | #endif |
| 1832 | 1860 | unsigned int markersindex; |
| 1833 | 1861 | unsigned int markersstringsindex; |
| 1862 | + unsigned int verboseindex; | |
| 1834 | 1863 | struct module *mod; |
| 1835 | 1864 | long err = 0; |
| 1836 | 1865 | void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */ |
| @@ -2117,6 +2146,7 @@ static noinline struct module *load_module(void __user *umod, · 280 unmodified lines | ||
| 2117 | 2146 | markersindex = find_sec(hdr, sechdrs, secstrings, "__markers"); |
| 2118 | 2147 | markersstringsindex = find_sec(hdr, sechdrs, secstrings, |
| 2119 | 2148 | "__markers_strings"); |
| 2149 | + verboseindex = find_sec(hdr, sechdrs, secstrings, "__verbose"); | |
| 2120 | 2150 | |
| 2121 | 2151 | /* Now do relocations. */ |
| 2122 | 2152 | for (i = 1; i < hdr->e_shnum; i++) { |
| @@ -2167,6 +2197,7 @@ static noinline struct module *load_module(void __user *umod, · 44 unmodified lines | ||
| 2167 | 2197 | marker_update_probe_range(mod->markers, |
| 2168 | 2198 | mod->markers + mod->num_markers); |
| 2169 | 2199 | #endif |
| 2200 | + dynamic_printk_setup(sechdrs, verboseindex); | |
| 2170 | 2201 | err = module_finalize(hdr, sechdrs, mod); |
| 2171 | 2202 | if (err < 0) |
| 2172 | 2203 | goto cleanup; |
| @@ -807,6 +807,61 @@ menuconfig BUILD_DOCSRC · 806 unmodified lines | ||
| 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" |
| @@ -81,6 +81,8 @@ obj-$(CONFIG_HAVE_LMB) += lmb.o · 80 unmodified lines | ||
| 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 | |
| @@ -0,0 +1,418 @@ | ||
| 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); | |
| @@ -387,11 +387,17 @@ EXPORT_SYMBOL_GPL(kobject_init_and_add); · 386 unmodified lines | ||
| 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 | |
| @@ -401,19 +407,6 @@ int kobject_rename(struct kobject *kobj, const char *new_name) · 3 unmodified lines | ||
| 401 | 407 | if (!kobj->parent) |
| 402 | 408 | return -EINVAL; |
| 403 | 409 | |
| 404 | − /* see if this name is already in use */ | |
| 405 | − if (kobj->kset) { | |
| 406 | − struct kobject *temp_kobj; | |
| 407 | − temp_kobj = kset_find_obj(kobj->kset, new_name); | |
| 408 | − if (temp_kobj) { | |
| 409 | − printk(KERN_WARNING "kobject '%s' cannot be renamed " | |
| 410 | − "to '%s' as '%s' is already in existence.\n", | |
| 411 | − kobject_name(kobj), new_name, new_name); | |
| 412 | − kobject_put(temp_kobj); | |
| 413 | − return -EINVAL; | |
| 414 | − } | |
| 415 | − } | |
| 416 | − | |
| 417 | 410 | devpath = kobject_get_path(kobj, GFP_KERNEL); |
| 418 | 411 | if (!devpath) { |
| 419 | 412 | error = -ENOMEM; |
| @@ -428,15 +421,27 @@ int kobject_rename(struct kobject *kobj, const char *new_name) · 8 unmodified lines | ||
| 428 | 421 | envp[0] = devpath_string; |
| 429 | 422 | envp[1] = NULL; |
| 430 | 423 | |
| 424 | + name = dup_name = kstrdup(new_name, GFP_KERNEL); | |
| 425 | + if (!name) { | |
| 426 | + error = -ENOMEM; | |
| 427 | + goto out; | |
| 428 | + } | |
| 429 | + | |
| 431 | 430 | error = sysfs_rename_dir(kobj, new_name); |
| 431 | + if (error) | |
| 432 | + goto out; | |
| 433 | + | |
| 434 | + /* Install the new kobject name */ | |
| 435 | + dup_name = kobj->name; | |
| 436 | + kobj->name = name; | |
| 432 | 437 | |
| 433 | 438 | /* This function is mostly/only used for network interface. |
| 434 | 439 | * Some hotplug package track interfaces by their name and |
| 435 | 440 | * therefore want to know when the name is changed by the user. */ |
| 436 | − if (!error) | |
| 437 | − kobject_uevent_env(kobj, KOBJ_MOVE, envp); | |
| 441 | + kobject_uevent_env(kobj, KOBJ_MOVE, envp); | |
| 438 | 442 | |
| 439 | 443 | out: |
| 444 | + kfree(dup_name); | |
| 440 | 445 | kfree(devpath_string); |
| 441 | 446 | kfree(devpath); |
| 442 | 447 | kobject_put(kobj); |
| @@ -65,7 +65,7 @@ void · 64 unmodified lines | ||
| 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", |
| @@ -96,6 +96,14 @@ basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))" · 95 unmodified lines | ||
| 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) |
| @@ -121,7 +129,8 @@ endif · 19 unmodified lines | ||
| 121 | 129 | |
| 122 | 130 | c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ |
| 123 | 131 | $(__c_flags) $(modkern_cflags) \ |
| 124 | − -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) | |
| 132 | + -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) \ | |
| 133 | + $(debug_flags) | |
| 125 | 134 | |
| 126 | 135 | a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ |
| 127 | 136 | $(__a_flags) $(modkern_aflags) |
| @@ -9,7 +9,7 @@ · 8 unmodified lines | ||
| 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 |
| @@ -0,0 +1,64 @@ | ||
| 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 | + | |
| @@ -549,9 +549,9 @@ int snd_card_register(struct snd_card *card) · 548 unmodified lines | ||
| 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 | } |
| @@ -274,9 +274,8 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev, · 273 unmodified lines | ||
| 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); |
| @@ -560,19 +560,18 @@ static int __init oss_init(void) · 559 unmodified lines | ||
| 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) |
| @@ -220,9 +220,8 @@ static int sound_insert_unit(struct sound_unit **list, const struct file_operati · 219 unmodified lines | ||
| 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: |