diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Kconfig.debug | 2 | ||||
| -rw-r--r-- | lib/Makefile | 5 | ||||
| -rw-r--r-- | lib/devres.c | 26 | ||||
| -rw-r--r-- | lib/div64.c | 22 | ||||
| -rw-r--r-- | lib/iomap.c | 27 | ||||
| -rw-r--r-- | lib/kobject.c | 129 | ||||
| -rw-r--r-- | lib/kobject_uevent.c | 28 | ||||
| -rw-r--r-- | lib/kref.c | 2 | ||||
| -rw-r--r-- | lib/parser.c | 10 | ||||
| -rw-r--r-- | lib/string.c | 28 | ||||
| -rw-r--r-- | lib/vsprintf.c | 26 |
11 files changed, 198 insertions, 107 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 3f3e7403dcac..79afd00bbe5f 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
| @@ -261,7 +261,7 @@ config LOCKDEP | |||
| 261 | bool | 261 | bool |
| 262 | depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT | 262 | depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT |
| 263 | select STACKTRACE | 263 | select STACKTRACE |
| 264 | select FRAME_POINTER if !X86 | 264 | select FRAME_POINTER if !X86 && !MIPS |
| 265 | select KALLSYMS | 265 | select KALLSYMS |
| 266 | select KALLSYMS_ALL | 266 | select KALLSYMS_ALL |
| 267 | 267 | ||
diff --git a/lib/Makefile b/lib/Makefile index 992a39ef9ffd..ae57f357fec0 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | lib-y := ctype.o string.o vsprintf.o cmdline.o \ | 5 | lib-y := ctype.o string.o vsprintf.o cmdline.o \ |
| 6 | rbtree.o radix-tree.o dump_stack.o \ | 6 | rbtree.o radix-tree.o dump_stack.o \ |
| 7 | idr.o div64.o int_sqrt.o bitmap.o extable.o prio_tree.o \ | 7 | idr.o int_sqrt.o bitmap.o extable.o prio_tree.o \ |
| 8 | sha1.o irq_regs.o reciprocal_div.o | 8 | sha1.o irq_regs.o reciprocal_div.o |
| 9 | 9 | ||
| 10 | lib-$(CONFIG_MMU) += ioremap.o | 10 | lib-$(CONFIG_MMU) += ioremap.o |
| @@ -12,7 +12,8 @@ lib-$(CONFIG_SMP) += cpumask.o | |||
| 12 | 12 | ||
| 13 | lib-y += kobject.o kref.o kobject_uevent.o klist.o | 13 | lib-y += kobject.o kref.o kobject_uevent.o klist.o |
| 14 | 14 | ||
| 15 | obj-y += sort.o parser.o halfmd4.o debug_locks.o random32.o bust_spinlocks.o | 15 | obj-y += div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ |
| 16 | bust_spinlocks.o | ||
| 16 | 17 | ||
| 17 | ifeq ($(CONFIG_DEBUG_KOBJECT),y) | 18 | ifeq ($(CONFIG_DEBUG_KOBJECT),y) |
| 18 | CFLAGS_kobject.o += -DDEBUG | 19 | CFLAGS_kobject.o += -DDEBUG |
diff --git a/lib/devres.c b/lib/devres.c index eb38849aa717..b1d336ce7f3d 100644 --- a/lib/devres.c +++ b/lib/devres.c | |||
| @@ -296,5 +296,31 @@ int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name) | |||
| 296 | return rc; | 296 | return rc; |
| 297 | } | 297 | } |
| 298 | EXPORT_SYMBOL(pcim_iomap_regions); | 298 | EXPORT_SYMBOL(pcim_iomap_regions); |
| 299 | |||
| 300 | /** | ||
| 301 | * pcim_iounmap_regions - Unmap and release PCI BARs | ||
| 302 | * @pdev: PCI device to map IO resources for | ||
| 303 | * @mask: Mask of BARs to unmap and release | ||
| 304 | * | ||
| 305 | * Unamp and release regions specified by @mask. | ||
| 306 | */ | ||
| 307 | void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask) | ||
| 308 | { | ||
| 309 | void __iomem * const *iomap; | ||
| 310 | int i; | ||
| 311 | |||
| 312 | iomap = pcim_iomap_table(pdev); | ||
| 313 | if (!iomap) | ||
| 314 | return; | ||
| 315 | |||
| 316 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { | ||
| 317 | if (!(mask & (1 << i))) | ||
| 318 | continue; | ||
| 319 | |||
| 320 | pcim_iounmap(pdev, iomap[i]); | ||
| 321 | pci_release_region(pdev, i); | ||
| 322 | } | ||
| 323 | } | ||
| 324 | EXPORT_SYMBOL(pcim_iounmap_regions); | ||
| 299 | #endif | 325 | #endif |
| 300 | #endif | 326 | #endif |
diff --git a/lib/div64.c b/lib/div64.c index 365719f84832..b71cf93c529a 100644 --- a/lib/div64.c +++ b/lib/div64.c | |||
| @@ -23,7 +23,7 @@ | |||
| 23 | /* Not needed on 64bit architectures */ | 23 | /* Not needed on 64bit architectures */ |
| 24 | #if BITS_PER_LONG == 32 | 24 | #if BITS_PER_LONG == 32 |
| 25 | 25 | ||
| 26 | uint32_t __div64_32(uint64_t *n, uint32_t base) | 26 | uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base) |
| 27 | { | 27 | { |
| 28 | uint64_t rem = *n; | 28 | uint64_t rem = *n; |
| 29 | uint64_t b = base; | 29 | uint64_t b = base; |
| @@ -58,4 +58,24 @@ uint32_t __div64_32(uint64_t *n, uint32_t base) | |||
| 58 | 58 | ||
| 59 | EXPORT_SYMBOL(__div64_32); | 59 | EXPORT_SYMBOL(__div64_32); |
| 60 | 60 | ||
| 61 | /* 64bit divisor, dividend and result. dynamic precision */ | ||
| 62 | uint64_t div64_64(uint64_t dividend, uint64_t divisor) | ||
| 63 | { | ||
| 64 | uint32_t high, d; | ||
| 65 | |||
| 66 | high = divisor >> 32; | ||
| 67 | if (high) { | ||
| 68 | unsigned int shift = fls(high); | ||
| 69 | |||
| 70 | d = divisor >> shift; | ||
| 71 | dividend >>= shift; | ||
| 72 | } else | ||
| 73 | d = divisor; | ||
| 74 | |||
| 75 | do_div(dividend, d); | ||
| 76 | |||
| 77 | return dividend; | ||
| 78 | } | ||
| 79 | EXPORT_SYMBOL(div64_64); | ||
| 80 | |||
| 61 | #endif /* BITS_PER_LONG == 32 */ | 81 | #endif /* BITS_PER_LONG == 32 */ |
diff --git a/lib/iomap.c b/lib/iomap.c index 4d43f37c0154..a57d262a5ed9 100644 --- a/lib/iomap.c +++ b/lib/iomap.c | |||
| @@ -35,20 +35,28 @@ | |||
| 35 | #define PIO_RESERVED 0x40000UL | 35 | #define PIO_RESERVED 0x40000UL |
| 36 | #endif | 36 | #endif |
| 37 | 37 | ||
| 38 | static void bad_io_access(unsigned long port, const char *access) | ||
| 39 | { | ||
| 40 | static int count = 10; | ||
| 41 | if (count) { | ||
| 42 | count--; | ||
| 43 | printk(KERN_ERR "Bad IO access at port %lx (%s)\n", port, access); | ||
| 44 | WARN_ON(1); | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 38 | /* | 48 | /* |
| 39 | * Ugly macros are a way of life. | 49 | * Ugly macros are a way of life. |
| 40 | */ | 50 | */ |
| 41 | #define VERIFY_PIO(port) BUG_ON((port & ~PIO_MASK) != PIO_OFFSET) | ||
| 42 | |||
| 43 | #define IO_COND(addr, is_pio, is_mmio) do { \ | 51 | #define IO_COND(addr, is_pio, is_mmio) do { \ |
| 44 | unsigned long port = (unsigned long __force)addr; \ | 52 | unsigned long port = (unsigned long __force)addr; \ |
| 45 | if (port < PIO_RESERVED) { \ | 53 | if (port >= PIO_RESERVED) { \ |
| 46 | VERIFY_PIO(port); \ | 54 | is_mmio; \ |
| 55 | } else if (port > PIO_OFFSET) { \ | ||
| 47 | port &= PIO_MASK; \ | 56 | port &= PIO_MASK; \ |
| 48 | is_pio; \ | 57 | is_pio; \ |
| 49 | } else { \ | 58 | } else \ |
| 50 | is_mmio; \ | 59 | bad_io_access(port, #is_pio ); \ |
| 51 | } \ | ||
| 52 | } while (0) | 60 | } while (0) |
| 53 | 61 | ||
| 54 | #ifndef pio_read16be | 62 | #ifndef pio_read16be |
| @@ -64,22 +72,27 @@ | |||
| 64 | unsigned int fastcall ioread8(void __iomem *addr) | 72 | unsigned int fastcall ioread8(void __iomem *addr) |
| 65 | { | 73 | { |
| 66 | IO_COND(addr, return inb(port), return readb(addr)); | 74 | IO_COND(addr, return inb(port), return readb(addr)); |
| 75 | return 0xff; | ||
| 67 | } | 76 | } |
| 68 | unsigned int fastcall ioread16(void __iomem *addr) | 77 | unsigned int fastcall ioread16(void __iomem *addr) |
| 69 | { | 78 | { |
| 70 | IO_COND(addr, return inw(port), return readw(addr)); | 79 | IO_COND(addr, return inw(port), return readw(addr)); |
| 80 | return 0xffff; | ||
| 71 | } | 81 | } |
| 72 | unsigned int fastcall ioread16be(void __iomem *addr) | 82 | unsigned int fastcall ioread16be(void __iomem *addr) |
| 73 | { | 83 | { |
| 74 | IO_COND(addr, return pio_read16be(port), return mmio_read16be(addr)); | 84 | IO_COND(addr, return pio_read16be(port), return mmio_read16be(addr)); |
| 85 | return 0xffff; | ||
| 75 | } | 86 | } |
| 76 | unsigned int fastcall ioread32(void __iomem *addr) | 87 | unsigned int fastcall ioread32(void __iomem *addr) |
| 77 | { | 88 | { |
| 78 | IO_COND(addr, return inl(port), return readl(addr)); | 89 | IO_COND(addr, return inl(port), return readl(addr)); |
| 90 | return 0xffffffff; | ||
| 79 | } | 91 | } |
| 80 | unsigned int fastcall ioread32be(void __iomem *addr) | 92 | unsigned int fastcall ioread32be(void __iomem *addr) |
| 81 | { | 93 | { |
| 82 | IO_COND(addr, return pio_read32be(port), return mmio_read32be(addr)); | 94 | IO_COND(addr, return pio_read32be(port), return mmio_read32be(addr)); |
| 95 | return 0xffffffff; | ||
| 83 | } | 96 | } |
| 84 | EXPORT_SYMBOL(ioread8); | 97 | EXPORT_SYMBOL(ioread8); |
| 85 | EXPORT_SYMBOL(ioread16); | 98 | EXPORT_SYMBOL(ioread16); |
diff --git a/lib/kobject.c b/lib/kobject.c index 057921c5945a..fc5f3f6e7329 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
| @@ -157,7 +157,7 @@ static void unlink(struct kobject * kobj) | |||
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | /** | 159 | /** |
| 160 | * kobject_add - add an object to the hierarchy. | 160 | * kobject_shadow_add - add an object to the hierarchy. |
| 161 | * @kobj: object. | 161 | * @kobj: object. |
| 162 | * @shadow_parent: sysfs directory to add to. | 162 | * @shadow_parent: sysfs directory to add to. |
| 163 | */ | 163 | */ |
| @@ -174,6 +174,7 @@ int kobject_shadow_add(struct kobject * kobj, struct dentry *shadow_parent) | |||
| 174 | if (!*kobj->k_name) { | 174 | if (!*kobj->k_name) { |
| 175 | pr_debug("kobject attempted to be registered with no name!\n"); | 175 | pr_debug("kobject attempted to be registered with no name!\n"); |
| 176 | WARN_ON(1); | 176 | WARN_ON(1); |
| 177 | kobject_put(kobj); | ||
| 177 | return -EINVAL; | 178 | return -EINVAL; |
| 178 | } | 179 | } |
| 179 | parent = kobject_get(kobj->parent); | 180 | parent = kobject_get(kobj->parent); |
| @@ -190,8 +191,8 @@ int kobject_shadow_add(struct kobject * kobj, struct dentry *shadow_parent) | |||
| 190 | 191 | ||
| 191 | list_add_tail(&kobj->entry,&kobj->kset->list); | 192 | list_add_tail(&kobj->entry,&kobj->kset->list); |
| 192 | spin_unlock(&kobj->kset->list_lock); | 193 | spin_unlock(&kobj->kset->list_lock); |
| 194 | kobj->parent = parent; | ||
| 193 | } | 195 | } |
| 194 | kobj->parent = parent; | ||
| 195 | 196 | ||
| 196 | error = create_dir(kobj, shadow_parent); | 197 | error = create_dir(kobj, shadow_parent); |
| 197 | if (error) { | 198 | if (error) { |
| @@ -311,13 +312,43 @@ EXPORT_SYMBOL(kobject_set_name); | |||
| 311 | int kobject_rename(struct kobject * kobj, const char *new_name) | 312 | int kobject_rename(struct kobject * kobj, const char *new_name) |
| 312 | { | 313 | { |
| 313 | int error = 0; | 314 | int error = 0; |
| 315 | const char *devpath = NULL; | ||
| 316 | char *devpath_string = NULL; | ||
| 317 | char *envp[2]; | ||
| 314 | 318 | ||
| 315 | kobj = kobject_get(kobj); | 319 | kobj = kobject_get(kobj); |
| 316 | if (!kobj) | 320 | if (!kobj) |
| 317 | return -EINVAL; | 321 | return -EINVAL; |
| 318 | if (!kobj->parent) | 322 | if (!kobj->parent) |
| 319 | return -EINVAL; | 323 | return -EINVAL; |
| 324 | |||
| 325 | devpath = kobject_get_path(kobj, GFP_KERNEL); | ||
| 326 | if (!devpath) { | ||
| 327 | error = -ENOMEM; | ||
| 328 | goto out; | ||
| 329 | } | ||
| 330 | devpath_string = kmalloc(strlen(devpath) + 15, GFP_KERNEL); | ||
| 331 | if (!devpath_string) { | ||
| 332 | error = -ENOMEM; | ||
| 333 | goto out; | ||
| 334 | } | ||
| 335 | sprintf(devpath_string, "DEVPATH_OLD=%s", devpath); | ||
| 336 | envp[0] = devpath_string; | ||
| 337 | envp[1] = NULL; | ||
| 338 | /* Note : if we want to send the new name alone, not the full path, | ||
| 339 | * we could probably use kobject_name(kobj); */ | ||
| 340 | |||
| 320 | error = sysfs_rename_dir(kobj, kobj->parent->dentry, new_name); | 341 | error = sysfs_rename_dir(kobj, kobj->parent->dentry, new_name); |
| 342 | |||
| 343 | /* This function is mostly/only used for network interface. | ||
| 344 | * Some hotplug package track interfaces by their name and | ||
| 345 | * therefore want to know when the name is changed by the user. */ | ||
| 346 | if (!error) | ||
| 347 | kobject_uevent_env(kobj, KOBJ_MOVE, envp); | ||
| 348 | |||
| 349 | out: | ||
| 350 | kfree(devpath_string); | ||
| 351 | kfree(devpath); | ||
| 321 | kobject_put(kobj); | 352 | kobject_put(kobj); |
| 322 | 353 | ||
| 323 | return error; | 354 | return error; |
| @@ -488,13 +519,15 @@ static struct kobj_type dir_ktype = { | |||
| 488 | }; | 519 | }; |
| 489 | 520 | ||
| 490 | /** | 521 | /** |
| 491 | * kobject_add_dir - add sub directory of object. | 522 | * kobject_kset_add_dir - add sub directory of object. |
| 523 | * @kset: kset the directory is belongs to. | ||
| 492 | * @parent: object in which a directory is created. | 524 | * @parent: object in which a directory is created. |
| 493 | * @name: directory name. | 525 | * @name: directory name. |
| 494 | * | 526 | * |
| 495 | * Add a plain directory object as child of given object. | 527 | * Add a plain directory object as child of given object. |
| 496 | */ | 528 | */ |
| 497 | struct kobject *kobject_add_dir(struct kobject *parent, const char *name) | 529 | struct kobject *kobject_kset_add_dir(struct kset *kset, |
| 530 | struct kobject *parent, const char *name) | ||
| 498 | { | 531 | { |
| 499 | struct kobject *k; | 532 | struct kobject *k; |
| 500 | int ret; | 533 | int ret; |
| @@ -506,13 +539,14 @@ struct kobject *kobject_add_dir(struct kobject *parent, const char *name) | |||
| 506 | if (!k) | 539 | if (!k) |
| 507 | return NULL; | 540 | return NULL; |
| 508 | 541 | ||
| 542 | k->kset = kset; | ||
| 509 | k->parent = parent; | 543 | k->parent = parent; |
| 510 | k->ktype = &dir_ktype; | 544 | k->ktype = &dir_ktype; |
| 511 | kobject_set_name(k, name); | 545 | kobject_set_name(k, name); |
| 512 | ret = kobject_register(k); | 546 | ret = kobject_register(k); |
| 513 | if (ret < 0) { | 547 | if (ret < 0) { |
| 514 | printk(KERN_WARNING "kobject_add_dir: " | 548 | printk(KERN_WARNING "%s: kobject_register error: %d\n", |
| 515 | "kobject_register error: %d\n", ret); | 549 | __func__, ret); |
| 516 | kobject_del(k); | 550 | kobject_del(k); |
| 517 | return NULL; | 551 | return NULL; |
| 518 | } | 552 | } |
| @@ -521,6 +555,18 @@ struct kobject *kobject_add_dir(struct kobject *parent, const char *name) | |||
| 521 | } | 555 | } |
| 522 | 556 | ||
| 523 | /** | 557 | /** |
| 558 | * kobject_add_dir - add sub directory of object. | ||
| 559 | * @parent: object in which a directory is created. | ||
| 560 | * @name: directory name. | ||
| 561 | * | ||
| 562 | * Add a plain directory object as child of given object. | ||
| 563 | */ | ||
| 564 | struct kobject *kobject_add_dir(struct kobject *parent, const char *name) | ||
| 565 | { | ||
| 566 | return kobject_kset_add_dir(NULL, parent, name); | ||
| 567 | } | ||
| 568 | |||
| 569 | /** | ||
| 524 | * kset_init - initialize a kset for use | 570 | * kset_init - initialize a kset for use |
| 525 | * @k: kset | 571 | * @k: kset |
| 526 | */ | 572 | */ |
| @@ -536,22 +582,10 @@ void kset_init(struct kset * k) | |||
| 536 | /** | 582 | /** |
| 537 | * kset_add - add a kset object to the hierarchy. | 583 | * kset_add - add a kset object to the hierarchy. |
| 538 | * @k: kset. | 584 | * @k: kset. |
| 539 | * | ||
| 540 | * Simply, this adds the kset's embedded kobject to the | ||
| 541 | * hierarchy. | ||
| 542 | * We also try to make sure that the kset's embedded kobject | ||
| 543 | * has a parent before it is added. We only care if the embedded | ||
| 544 | * kobject is not part of a kset itself, since kobject_add() | ||
| 545 | * assigns a parent in that case. | ||
| 546 | * If that is the case, and the kset has a controlling subsystem, | ||
| 547 | * then we set the kset's parent to be said subsystem. | ||
| 548 | */ | 585 | */ |
| 549 | 586 | ||
| 550 | int kset_add(struct kset * k) | 587 | int kset_add(struct kset * k) |
| 551 | { | 588 | { |
| 552 | if (!k->kobj.parent && !k->kobj.kset && k->subsys) | ||
| 553 | k->kobj.parent = &k->subsys->kset.kobj; | ||
| 554 | |||
| 555 | return kobject_add(&k->kobj); | 589 | return kobject_add(&k->kobj); |
| 556 | } | 590 | } |
| 557 | 591 | ||
| @@ -610,55 +644,28 @@ struct kobject * kset_find_obj(struct kset * kset, const char * name) | |||
| 610 | return ret; | 644 | return ret; |
| 611 | } | 645 | } |
| 612 | 646 | ||
| 613 | 647 | void subsystem_init(struct kset *s) | |
| 614 | void subsystem_init(struct subsystem * s) | ||
| 615 | { | 648 | { |
| 616 | init_rwsem(&s->rwsem); | 649 | kset_init(s); |
| 617 | kset_init(&s->kset); | ||
| 618 | } | 650 | } |
| 619 | 651 | ||
| 620 | /** | 652 | int subsystem_register(struct kset *s) |
| 621 | * subsystem_register - register a subsystem. | ||
| 622 | * @s: the subsystem we're registering. | ||
| 623 | * | ||
| 624 | * Once we register the subsystem, we want to make sure that | ||
| 625 | * the kset points back to this subsystem for correct usage of | ||
| 626 | * the rwsem. | ||
| 627 | */ | ||
| 628 | |||
| 629 | int subsystem_register(struct subsystem * s) | ||
| 630 | { | 653 | { |
| 631 | int error; | 654 | return kset_register(s); |
| 632 | |||
| 633 | if (!s) | ||
| 634 | return -EINVAL; | ||
| 635 | |||
| 636 | subsystem_init(s); | ||
| 637 | pr_debug("subsystem %s: registering\n",s->kset.kobj.name); | ||
| 638 | |||
| 639 | if (!(error = kset_add(&s->kset))) { | ||
| 640 | if (!s->kset.subsys) | ||
| 641 | s->kset.subsys = s; | ||
| 642 | } | ||
| 643 | return error; | ||
| 644 | } | 655 | } |
| 645 | 656 | ||
| 646 | void subsystem_unregister(struct subsystem * s) | 657 | void subsystem_unregister(struct kset *s) |
| 647 | { | 658 | { |
| 648 | if (!s) | 659 | kset_unregister(s); |
| 649 | return; | ||
| 650 | pr_debug("subsystem %s: unregistering\n",s->kset.kobj.name); | ||
| 651 | kset_unregister(&s->kset); | ||
| 652 | } | 660 | } |
| 653 | 661 | ||
| 654 | |||
| 655 | /** | 662 | /** |
| 656 | * subsystem_create_file - export sysfs attribute file. | 663 | * subsystem_create_file - export sysfs attribute file. |
| 657 | * @s: subsystem. | 664 | * @s: subsystem. |
| 658 | * @a: subsystem attribute descriptor. | 665 | * @a: subsystem attribute descriptor. |
| 659 | */ | 666 | */ |
| 660 | 667 | ||
| 661 | int subsys_create_file(struct subsystem * s, struct subsys_attribute * a) | 668 | int subsys_create_file(struct kset *s, struct subsys_attribute *a) |
| 662 | { | 669 | { |
| 663 | int error = 0; | 670 | int error = 0; |
| 664 | 671 | ||
| @@ -666,28 +673,12 @@ int subsys_create_file(struct subsystem * s, struct subsys_attribute * a) | |||
| 666 | return -EINVAL; | 673 | return -EINVAL; |
| 667 | 674 | ||
| 668 | if (subsys_get(s)) { | 675 | if (subsys_get(s)) { |
| 669 | error = sysfs_create_file(&s->kset.kobj,&a->attr); | 676 | error = sysfs_create_file(&s->kobj, &a->attr); |
| 670 | subsys_put(s); | 677 | subsys_put(s); |
| 671 | } | 678 | } |
| 672 | return error; | 679 | return error; |
| 673 | } | 680 | } |
| 674 | 681 | ||
| 675 | |||
| 676 | /** | ||
| 677 | * subsystem_remove_file - remove sysfs attribute file. | ||
| 678 | * @s: subsystem. | ||
| 679 | * @a: attribute desciptor. | ||
| 680 | */ | ||
| 681 | #if 0 | ||
| 682 | void subsys_remove_file(struct subsystem * s, struct subsys_attribute * a) | ||
| 683 | { | ||
| 684 | if (subsys_get(s)) { | ||
| 685 | sysfs_remove_file(&s->kset.kobj,&a->attr); | ||
| 686 | subsys_put(s); | ||
| 687 | } | ||
| 688 | } | ||
| 689 | #endif /* 0 */ | ||
| 690 | |||
| 691 | EXPORT_SYMBOL(kobject_init); | 682 | EXPORT_SYMBOL(kobject_init); |
| 692 | EXPORT_SYMBOL(kobject_register); | 683 | EXPORT_SYMBOL(kobject_register); |
| 693 | EXPORT_SYMBOL(kobject_unregister); | 684 | EXPORT_SYMBOL(kobject_unregister); |
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index 84272ed77f03..12e311dc664c 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c | |||
| @@ -42,10 +42,6 @@ static char *action_to_string(enum kobject_action action) | |||
| 42 | return "remove"; | 42 | return "remove"; |
| 43 | case KOBJ_CHANGE: | 43 | case KOBJ_CHANGE: |
| 44 | return "change"; | 44 | return "change"; |
| 45 | case KOBJ_MOUNT: | ||
| 46 | return "mount"; | ||
| 47 | case KOBJ_UMOUNT: | ||
| 48 | return "umount"; | ||
| 49 | case KOBJ_OFFLINE: | 45 | case KOBJ_OFFLINE: |
| 50 | return "offline"; | 46 | return "offline"; |
| 51 | case KOBJ_ONLINE: | 47 | case KOBJ_ONLINE: |
| @@ -95,10 +91,8 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
| 95 | 91 | ||
| 96 | /* search the kset we belong to */ | 92 | /* search the kset we belong to */ |
| 97 | top_kobj = kobj; | 93 | top_kobj = kobj; |
| 98 | if (!top_kobj->kset && top_kobj->parent) { | 94 | while (!top_kobj->kset && top_kobj->parent) { |
| 99 | do { | 95 | top_kobj = top_kobj->parent; |
| 100 | top_kobj = top_kobj->parent; | ||
| 101 | } while (!top_kobj->kset && top_kobj->parent); | ||
| 102 | } | 96 | } |
| 103 | if (!top_kobj->kset) { | 97 | if (!top_kobj->kset) { |
| 104 | pr_debug("kobject attempted to send uevent without kset!\n"); | 98 | pr_debug("kobject attempted to send uevent without kset!\n"); |
| @@ -115,6 +109,16 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
| 115 | return 0; | 109 | return 0; |
| 116 | } | 110 | } |
| 117 | 111 | ||
| 112 | /* originating subsystem */ | ||
| 113 | if (uevent_ops && uevent_ops->name) | ||
| 114 | subsystem = uevent_ops->name(kset, kobj); | ||
| 115 | else | ||
| 116 | subsystem = kobject_name(&kset->kobj); | ||
| 117 | if (!subsystem) { | ||
| 118 | pr_debug("unset subsytem caused the event to drop!\n"); | ||
| 119 | return 0; | ||
| 120 | } | ||
| 121 | |||
| 118 | /* environment index */ | 122 | /* environment index */ |
| 119 | envp = kzalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL); | 123 | envp = kzalloc(NUM_ENVP * sizeof (char *), GFP_KERNEL); |
| 120 | if (!envp) | 124 | if (!envp) |
| @@ -134,12 +138,6 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
| 134 | goto exit; | 138 | goto exit; |
| 135 | } | 139 | } |
| 136 | 140 | ||
| 137 | /* originating subsystem */ | ||
| 138 | if (uevent_ops && uevent_ops->name) | ||
| 139 | subsystem = uevent_ops->name(kset, kobj); | ||
| 140 | else | ||
| 141 | subsystem = kobject_name(&kset->kobj); | ||
| 142 | |||
| 143 | /* event environemnt for helper process only */ | 141 | /* event environemnt for helper process only */ |
| 144 | envp[i++] = "HOME=/"; | 142 | envp[i++] = "HOME=/"; |
| 145 | envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; | 143 | envp[i++] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin"; |
| @@ -293,7 +291,7 @@ EXPORT_SYMBOL_GPL(add_uevent_var); | |||
| 293 | static int __init kobject_uevent_init(void) | 291 | static int __init kobject_uevent_init(void) |
| 294 | { | 292 | { |
| 295 | uevent_sock = netlink_kernel_create(NETLINK_KOBJECT_UEVENT, 1, NULL, | 293 | uevent_sock = netlink_kernel_create(NETLINK_KOBJECT_UEVENT, 1, NULL, |
| 296 | THIS_MODULE); | 294 | NULL, THIS_MODULE); |
| 297 | 295 | ||
| 298 | if (!uevent_sock) { | 296 | if (!uevent_sock) { |
| 299 | printk(KERN_ERR | 297 | printk(KERN_ERR |
diff --git a/lib/kref.c b/lib/kref.c index 0d07cc31c818..a6dc3ec328e0 100644 --- a/lib/kref.c +++ b/lib/kref.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | void kref_init(struct kref *kref) | 21 | void kref_init(struct kref *kref) |
| 22 | { | 22 | { |
| 23 | atomic_set(&kref->refcount,1); | 23 | atomic_set(&kref->refcount,1); |
| 24 | smp_mb(); | ||
| 24 | } | 25 | } |
| 25 | 26 | ||
| 26 | /** | 27 | /** |
| @@ -31,6 +32,7 @@ void kref_get(struct kref *kref) | |||
| 31 | { | 32 | { |
| 32 | WARN_ON(!atomic_read(&kref->refcount)); | 33 | WARN_ON(!atomic_read(&kref->refcount)); |
| 33 | atomic_inc(&kref->refcount); | 34 | atomic_inc(&kref->refcount); |
| 35 | smp_mb__after_atomic_inc(); | ||
| 34 | } | 36 | } |
| 35 | 37 | ||
| 36 | /** | 38 | /** |
diff --git a/lib/parser.c b/lib/parser.c index 7ad2a48abc5e..703c8c13b346 100644 --- a/lib/parser.c +++ b/lib/parser.c | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | * match extremely simple token=arg style patterns. If the pattern is found, | 22 | * match extremely simple token=arg style patterns. If the pattern is found, |
| 23 | * the location(s) of the arguments will be returned in the @args array. | 23 | * the location(s) of the arguments will be returned in the @args array. |
| 24 | */ | 24 | */ |
| 25 | static int match_one(char *s, char *p, substring_t args[]) | 25 | static int match_one(char *s, const char *p, substring_t args[]) |
| 26 | { | 26 | { |
| 27 | char *meta; | 27 | char *meta; |
| 28 | int argc = 0; | 28 | int argc = 0; |
| @@ -43,7 +43,7 @@ static int match_one(char *s, char *p, substring_t args[]) | |||
| 43 | p = meta + 1; | 43 | p = meta + 1; |
| 44 | 44 | ||
| 45 | if (isdigit(*p)) | 45 | if (isdigit(*p)) |
| 46 | len = simple_strtoul(p, &p, 10); | 46 | len = simple_strtoul(p, (char **) &p, 10); |
| 47 | else if (*p == '%') { | 47 | else if (*p == '%') { |
| 48 | if (*s++ != '%') | 48 | if (*s++ != '%') |
| 49 | return 0; | 49 | return 0; |
| @@ -102,7 +102,7 @@ static int match_one(char *s, char *p, substring_t args[]) | |||
| 102 | */ | 102 | */ |
| 103 | int match_token(char *s, match_table_t table, substring_t args[]) | 103 | int match_token(char *s, match_table_t table, substring_t args[]) |
| 104 | { | 104 | { |
| 105 | struct match_token *p; | 105 | const struct match_token *p; |
| 106 | 106 | ||
| 107 | for (p = table; !match_one(s, p->pattern, args) ; p++) | 107 | for (p = table; !match_one(s, p->pattern, args) ; p++) |
| 108 | ; | 108 | ; |
| @@ -190,7 +190,7 @@ int match_hex(substring_t *s, int *result) | |||
| 190 | * &substring_t @s to the c-style string @to. Caller guarantees that @to is | 190 | * &substring_t @s to the c-style string @to. Caller guarantees that @to is |
| 191 | * large enough to hold the characters of @s. | 191 | * large enough to hold the characters of @s. |
| 192 | */ | 192 | */ |
| 193 | void match_strcpy(char *to, substring_t *s) | 193 | void match_strcpy(char *to, const substring_t *s) |
| 194 | { | 194 | { |
| 195 | memcpy(to, s->from, s->to - s->from); | 195 | memcpy(to, s->from, s->to - s->from); |
| 196 | to[s->to - s->from] = '\0'; | 196 | to[s->to - s->from] = '\0'; |
| @@ -204,7 +204,7 @@ void match_strcpy(char *to, substring_t *s) | |||
| 204 | * the &substring_t @s. The caller is responsible for freeing the returned | 204 | * the &substring_t @s. The caller is responsible for freeing the returned |
| 205 | * string with kfree(). | 205 | * string with kfree(). |
| 206 | */ | 206 | */ |
| 207 | char *match_strdup(substring_t *s) | 207 | char *match_strdup(const substring_t *s) |
| 208 | { | 208 | { |
| 209 | char *p = kmalloc(s->to - s->from + 1, GFP_KERNEL); | 209 | char *p = kmalloc(s->to - s->from + 1, GFP_KERNEL); |
| 210 | if (p) | 210 | if (p) |
diff --git a/lib/string.c b/lib/string.c index bab440fb0dfc..5efafed3d6b6 100644 --- a/lib/string.c +++ b/lib/string.c | |||
| @@ -60,6 +60,34 @@ int strnicmp(const char *s1, const char *s2, size_t len) | |||
| 60 | EXPORT_SYMBOL(strnicmp); | 60 | EXPORT_SYMBOL(strnicmp); |
| 61 | #endif | 61 | #endif |
| 62 | 62 | ||
| 63 | #ifndef __HAVE_ARCH_STRCASECMP | ||
| 64 | int strcasecmp(const char *s1, const char *s2) | ||
| 65 | { | ||
| 66 | int c1, c2; | ||
| 67 | |||
| 68 | do { | ||
| 69 | c1 = tolower(*s1++); | ||
| 70 | c2 = tolower(*s2++); | ||
| 71 | } while (c1 == c2 && c1 != 0); | ||
| 72 | return c1 - c2; | ||
| 73 | } | ||
| 74 | EXPORT_SYMBOL(strcasecmp); | ||
| 75 | #endif | ||
| 76 | |||
| 77 | #ifndef __HAVE_ARCH_STRNCASECMP | ||
| 78 | int strncasecmp(const char *s1, const char *s2, size_t n) | ||
| 79 | { | ||
| 80 | int c1, c2; | ||
| 81 | |||
| 82 | do { | ||
| 83 | c1 = tolower(*s1++); | ||
| 84 | c2 = tolower(*s2++); | ||
| 85 | } while ((--n > 0) && c1 == c2 && c1 != 0); | ||
| 86 | return c1 - c2; | ||
| 87 | } | ||
| 88 | EXPORT_SYMBOL(strncasecmp); | ||
| 89 | #endif | ||
| 90 | |||
| 63 | #ifndef __HAVE_ARCH_STRCPY | 91 | #ifndef __HAVE_ARCH_STRCPY |
| 64 | /** | 92 | /** |
| 65 | * strcpy - Copy a %NUL terminated string | 93 | * strcpy - Copy a %NUL terminated string |
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index b025864d2e43..cbab1df150cf 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
| @@ -851,23 +851,35 @@ EXPORT_SYMBOL(sscanf); | |||
| 851 | 851 | ||
| 852 | 852 | ||
| 853 | /* Simplified asprintf. */ | 853 | /* Simplified asprintf. */ |
| 854 | char *kasprintf(gfp_t gfp, const char *fmt, ...) | 854 | char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap) |
| 855 | { | 855 | { |
| 856 | va_list ap; | ||
| 857 | unsigned int len; | 856 | unsigned int len; |
| 858 | char *p; | 857 | char *p; |
| 858 | va_list aq; | ||
| 859 | 859 | ||
| 860 | va_start(ap, fmt); | 860 | va_copy(aq, ap); |
| 861 | len = vsnprintf(NULL, 0, fmt, ap); | 861 | len = vsnprintf(NULL, 0, fmt, aq); |
| 862 | va_end(ap); | 862 | va_end(aq); |
| 863 | 863 | ||
| 864 | p = kmalloc(len+1, gfp); | 864 | p = kmalloc(len+1, gfp); |
| 865 | if (!p) | 865 | if (!p) |
| 866 | return NULL; | 866 | return NULL; |
| 867 | va_start(ap, fmt); | 867 | |
| 868 | vsnprintf(p, len+1, fmt, ap); | 868 | vsnprintf(p, len+1, fmt, ap); |
| 869 | va_end(ap); | 869 | |
| 870 | return p; | 870 | return p; |
| 871 | } | 871 | } |
| 872 | EXPORT_SYMBOL(kvasprintf); | ||
| 873 | |||
| 874 | char *kasprintf(gfp_t gfp, const char *fmt, ...) | ||
| 875 | { | ||
| 876 | va_list ap; | ||
| 877 | char *p; | ||
| 872 | 878 | ||
| 879 | va_start(ap, fmt); | ||
| 880 | p = kvasprintf(gfp, fmt, ap); | ||
| 881 | va_end(ap); | ||
| 882 | |||
| 883 | return p; | ||
| 884 | } | ||
| 873 | EXPORT_SYMBOL(kasprintf); | 885 | EXPORT_SYMBOL(kasprintf); |
