diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/iomap.c | 27 | ||||
-rw-r--r-- | lib/kobject.c | 69 | ||||
-rw-r--r-- | lib/parser.c | 10 |
3 files changed, 33 insertions, 73 deletions
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 cecf2fbede3e..fc5f3f6e7329 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -582,22 +582,10 @@ void kset_init(struct kset * k) | |||
582 | /** | 582 | /** |
583 | * kset_add - add a kset object to the hierarchy. | 583 | * kset_add - add a kset object to the hierarchy. |
584 | * @k: kset. | 584 | * @k: kset. |
585 | * | ||
586 | * Simply, this adds the kset's embedded kobject to the | ||
587 | * hierarchy. | ||
588 | * We also try to make sure that the kset's embedded kobject | ||
589 | * has a parent before it is added. We only care if the embedded | ||
590 | * kobject is not part of a kset itself, since kobject_add() | ||
591 | * assigns a parent in that case. | ||
592 | * If that is the case, and the kset has a controlling subsystem, | ||
593 | * then we set the kset's parent to be said subsystem. | ||
594 | */ | 585 | */ |
595 | 586 | ||
596 | int kset_add(struct kset * k) | 587 | int kset_add(struct kset * k) |
597 | { | 588 | { |
598 | if (!k->kobj.parent && !k->kobj.kset && k->subsys) | ||
599 | k->kobj.parent = &k->subsys->kset.kobj; | ||
600 | |||
601 | return kobject_add(&k->kobj); | 589 | return kobject_add(&k->kobj); |
602 | } | 590 | } |
603 | 591 | ||
@@ -656,53 +644,28 @@ struct kobject * kset_find_obj(struct kset * kset, const char * name) | |||
656 | return ret; | 644 | return ret; |
657 | } | 645 | } |
658 | 646 | ||
659 | 647 | void subsystem_init(struct kset *s) | |
660 | void subsystem_init(struct subsystem * s) | ||
661 | { | 648 | { |
662 | kset_init(&s->kset); | 649 | kset_init(s); |
663 | } | 650 | } |
664 | 651 | ||
665 | /** | 652 | int subsystem_register(struct kset *s) |
666 | * subsystem_register - register a subsystem. | ||
667 | * @s: the subsystem we're registering. | ||
668 | * | ||
669 | * Once we register the subsystem, we want to make sure that | ||
670 | * the kset points back to this subsystem. | ||
671 | */ | ||
672 | |||
673 | int subsystem_register(struct subsystem * s) | ||
674 | { | 653 | { |
675 | int error; | 654 | return kset_register(s); |
676 | |||
677 | if (!s) | ||
678 | return -EINVAL; | ||
679 | |||
680 | subsystem_init(s); | ||
681 | pr_debug("subsystem %s: registering\n",s->kset.kobj.name); | ||
682 | |||
683 | if (!(error = kset_add(&s->kset))) { | ||
684 | if (!s->kset.subsys) | ||
685 | s->kset.subsys = s; | ||
686 | } | ||
687 | return error; | ||
688 | } | 655 | } |
689 | 656 | ||
690 | void subsystem_unregister(struct subsystem * s) | 657 | void subsystem_unregister(struct kset *s) |
691 | { | 658 | { |
692 | if (!s) | 659 | kset_unregister(s); |
693 | return; | ||
694 | pr_debug("subsystem %s: unregistering\n",s->kset.kobj.name); | ||
695 | kset_unregister(&s->kset); | ||
696 | } | 660 | } |
697 | 661 | ||
698 | |||
699 | /** | 662 | /** |
700 | * subsystem_create_file - export sysfs attribute file. | 663 | * subsystem_create_file - export sysfs attribute file. |
701 | * @s: subsystem. | 664 | * @s: subsystem. |
702 | * @a: subsystem attribute descriptor. | 665 | * @a: subsystem attribute descriptor. |
703 | */ | 666 | */ |
704 | 667 | ||
705 | int subsys_create_file(struct subsystem * s, struct subsys_attribute * a) | 668 | int subsys_create_file(struct kset *s, struct subsys_attribute *a) |
706 | { | 669 | { |
707 | int error = 0; | 670 | int error = 0; |
708 | 671 | ||
@@ -710,28 +673,12 @@ int subsys_create_file(struct subsystem * s, struct subsys_attribute * a) | |||
710 | return -EINVAL; | 673 | return -EINVAL; |
711 | 674 | ||
712 | if (subsys_get(s)) { | 675 | if (subsys_get(s)) { |
713 | error = sysfs_create_file(&s->kset.kobj,&a->attr); | 676 | error = sysfs_create_file(&s->kobj, &a->attr); |
714 | subsys_put(s); | 677 | subsys_put(s); |
715 | } | 678 | } |
716 | return error; | 679 | return error; |
717 | } | 680 | } |
718 | 681 | ||
719 | |||
720 | /** | ||
721 | * subsystem_remove_file - remove sysfs attribute file. | ||
722 | * @s: subsystem. | ||
723 | * @a: attribute desciptor. | ||
724 | */ | ||
725 | #if 0 | ||
726 | void subsys_remove_file(struct subsystem * s, struct subsys_attribute * a) | ||
727 | { | ||
728 | if (subsys_get(s)) { | ||
729 | sysfs_remove_file(&s->kset.kobj,&a->attr); | ||
730 | subsys_put(s); | ||
731 | } | ||
732 | } | ||
733 | #endif /* 0 */ | ||
734 | |||
735 | EXPORT_SYMBOL(kobject_init); | 682 | EXPORT_SYMBOL(kobject_init); |
736 | EXPORT_SYMBOL(kobject_register); | 683 | EXPORT_SYMBOL(kobject_register); |
737 | EXPORT_SYMBOL(kobject_unregister); | 684 | EXPORT_SYMBOL(kobject_unregister); |
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) |