diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-07 15:03:30 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-07 15:03:30 -0500 |
commit | 7affca3537d74365128e477b40c529d6f2fe86c8 (patch) | |
tree | 20be92bd240029182fc89c2c4f25401b7715dcae /lib | |
parent | 356b95424cfb456e14a59eaa579422ce014c424b (diff) | |
parent | ff4b8a57f0aaa2882d444ca44b2b9b333d22a4df (diff) |
Merge branch 'driver-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
* 'driver-core-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (73 commits)
arm: fix up some samsung merge sysdev conversion problems
firmware: Fix an oops on reading fw_priv->fw in sysfs loading file
Drivers:hv: Fix a bug in vmbus_driver_unregister()
driver core: remove __must_check from device_create_file
debugfs: add missing #ifdef HAS_IOMEM
arm: time.h: remove device.h #include
driver-core: remove sysdev.h usage.
clockevents: remove sysdev.h
arm: convert sysdev_class to a regular subsystem
arm: leds: convert sysdev_class to a regular subsystem
kobject: remove kset_find_obj_hinted()
m86k: gpio - convert sysdev_class to a regular subsystem
mips: txx9_sram - convert sysdev_class to a regular subsystem
mips: 7segled - convert sysdev_class to a regular subsystem
sh: dma - convert sysdev_class to a regular subsystem
sh: intc - convert sysdev_class to a regular subsystem
power: suspend - convert sysdev_class to a regular subsystem
power: qe_ic - convert sysdev_class to a regular subsystem
power: cmm - convert sysdev_class to a regular subsystem
s390: time - convert sysdev_class to a regular subsystem
...
Fix up conflicts with 'struct sysdev' removal from various platform
drivers that got changed:
- arch/arm/mach-exynos/cpu.c
- arch/arm/mach-exynos/irq-eint.c
- arch/arm/mach-s3c64xx/common.c
- arch/arm/mach-s3c64xx/cpu.c
- arch/arm/mach-s5p64x0/cpu.c
- arch/arm/mach-s5pv210/common.c
- arch/arm/plat-samsung/include/plat/cpu.h
- arch/powerpc/kernel/sysfs.c
and fix up cpu_is_hotpluggable() as per Greg in include/linux/cpu.h
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Makefile | 2 | ||||
-rw-r--r-- | lib/devres.c | 55 | ||||
-rw-r--r-- | lib/kobject.c | 37 | ||||
-rw-r--r-- | lib/kobject_uevent.c | 3 | ||||
-rw-r--r-- | lib/kref.c | 97 |
5 files changed, 57 insertions, 137 deletions
diff --git a/lib/Makefile b/lib/Makefile index ff00d4dcb7ed..c0ffaaff6534 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
@@ -17,7 +17,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \ | |||
17 | lib-$(CONFIG_MMU) += ioremap.o | 17 | lib-$(CONFIG_MMU) += ioremap.o |
18 | lib-$(CONFIG_SMP) += cpumask.o | 18 | lib-$(CONFIG_SMP) += cpumask.o |
19 | 19 | ||
20 | lib-y += kobject.o kref.o klist.o | 20 | lib-y += kobject.o klist.o |
21 | 21 | ||
22 | obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ | 22 | obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ |
23 | bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ | 23 | bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ |
diff --git a/lib/devres.c b/lib/devres.c index 7c0e953a7486..4fbc09e6e9e6 100644 --- a/lib/devres.c +++ b/lib/devres.c | |||
@@ -85,6 +85,57 @@ void devm_iounmap(struct device *dev, void __iomem *addr) | |||
85 | } | 85 | } |
86 | EXPORT_SYMBOL(devm_iounmap); | 86 | EXPORT_SYMBOL(devm_iounmap); |
87 | 87 | ||
88 | /** | ||
89 | * devm_request_and_ioremap() - Check, request region, and ioremap resource | ||
90 | * @dev: Generic device to handle the resource for | ||
91 | * @res: resource to be handled | ||
92 | * | ||
93 | * Takes all necessary steps to ioremap a mem resource. Uses managed device, so | ||
94 | * everything is undone on driver detach. Checks arguments, so you can feed | ||
95 | * it the result from e.g. platform_get_resource() directly. Returns the | ||
96 | * remapped pointer or NULL on error. Usage example: | ||
97 | * | ||
98 | * res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
99 | * base = devm_request_and_ioremap(&pdev->dev, res); | ||
100 | * if (!base) | ||
101 | * return -EADDRNOTAVAIL; | ||
102 | */ | ||
103 | void __iomem *devm_request_and_ioremap(struct device *dev, | ||
104 | struct resource *res) | ||
105 | { | ||
106 | resource_size_t size; | ||
107 | const char *name; | ||
108 | void __iomem *dest_ptr; | ||
109 | |||
110 | BUG_ON(!dev); | ||
111 | |||
112 | if (!res || resource_type(res) != IORESOURCE_MEM) { | ||
113 | dev_err(dev, "invalid resource\n"); | ||
114 | return NULL; | ||
115 | } | ||
116 | |||
117 | size = resource_size(res); | ||
118 | name = res->name ?: dev_name(dev); | ||
119 | |||
120 | if (!devm_request_mem_region(dev, res->start, size, name)) { | ||
121 | dev_err(dev, "can't request region for resource %pR\n", res); | ||
122 | return NULL; | ||
123 | } | ||
124 | |||
125 | if (res->flags & IORESOURCE_CACHEABLE) | ||
126 | dest_ptr = devm_ioremap(dev, res->start, size); | ||
127 | else | ||
128 | dest_ptr = devm_ioremap_nocache(dev, res->start, size); | ||
129 | |||
130 | if (!dest_ptr) { | ||
131 | dev_err(dev, "ioremap failed for resource %pR\n", res); | ||
132 | devm_release_mem_region(dev, res->start, size); | ||
133 | } | ||
134 | |||
135 | return dest_ptr; | ||
136 | } | ||
137 | EXPORT_SYMBOL(devm_request_and_ioremap); | ||
138 | |||
88 | #ifdef CONFIG_HAS_IOPORT | 139 | #ifdef CONFIG_HAS_IOPORT |
89 | /* | 140 | /* |
90 | * Generic iomap devres | 141 | * Generic iomap devres |
@@ -348,5 +399,5 @@ void pcim_iounmap_regions(struct pci_dev *pdev, u16 mask) | |||
348 | } | 399 | } |
349 | } | 400 | } |
350 | EXPORT_SYMBOL(pcim_iounmap_regions); | 401 | EXPORT_SYMBOL(pcim_iounmap_regions); |
351 | #endif | 402 | #endif /* CONFIG_PCI */ |
352 | #endif | 403 | #endif /* CONFIG_HAS_IOPORT */ |
diff --git a/lib/kobject.c b/lib/kobject.c index 640bd98a4c8a..c33d7a18d635 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
@@ -746,43 +746,11 @@ void kset_unregister(struct kset *k) | |||
746 | */ | 746 | */ |
747 | struct kobject *kset_find_obj(struct kset *kset, const char *name) | 747 | struct kobject *kset_find_obj(struct kset *kset, const char *name) |
748 | { | 748 | { |
749 | return kset_find_obj_hinted(kset, name, NULL); | ||
750 | } | ||
751 | |||
752 | /** | ||
753 | * kset_find_obj_hinted - search for object in kset given a predecessor hint. | ||
754 | * @kset: kset we're looking in. | ||
755 | * @name: object's name. | ||
756 | * @hint: hint to possible object's predecessor. | ||
757 | * | ||
758 | * Check the hint's next object and if it is a match return it directly, | ||
759 | * otherwise, fall back to the behavior of kset_find_obj(). Either way | ||
760 | * a reference for the returned object is held and the reference on the | ||
761 | * hinted object is released. | ||
762 | */ | ||
763 | struct kobject *kset_find_obj_hinted(struct kset *kset, const char *name, | ||
764 | struct kobject *hint) | ||
765 | { | ||
766 | struct kobject *k; | 749 | struct kobject *k; |
767 | struct kobject *ret = NULL; | 750 | struct kobject *ret = NULL; |
768 | 751 | ||
769 | spin_lock(&kset->list_lock); | 752 | spin_lock(&kset->list_lock); |
770 | 753 | ||
771 | if (!hint) | ||
772 | goto slow_search; | ||
773 | |||
774 | /* end of list detection */ | ||
775 | if (hint->entry.next == kset->list.next) | ||
776 | goto slow_search; | ||
777 | |||
778 | k = container_of(hint->entry.next, struct kobject, entry); | ||
779 | if (!kobject_name(k) || strcmp(kobject_name(k), name)) | ||
780 | goto slow_search; | ||
781 | |||
782 | ret = kobject_get(k); | ||
783 | goto unlock_exit; | ||
784 | |||
785 | slow_search: | ||
786 | list_for_each_entry(k, &kset->list, entry) { | 754 | list_for_each_entry(k, &kset->list, entry) { |
787 | if (kobject_name(k) && !strcmp(kobject_name(k), name)) { | 755 | if (kobject_name(k) && !strcmp(kobject_name(k), name)) { |
788 | ret = kobject_get(k); | 756 | ret = kobject_get(k); |
@@ -790,12 +758,7 @@ slow_search: | |||
790 | } | 758 | } |
791 | } | 759 | } |
792 | 760 | ||
793 | unlock_exit: | ||
794 | spin_unlock(&kset->list_lock); | 761 | spin_unlock(&kset->list_lock); |
795 | |||
796 | if (hint) | ||
797 | kobject_put(hint); | ||
798 | |||
799 | return ret; | 762 | return ret; |
800 | } | 763 | } |
801 | 764 | ||
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index ad72a03ce5e9..e66e9b632617 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c | |||
@@ -259,6 +259,9 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
259 | struct sk_buff *skb; | 259 | struct sk_buff *skb; |
260 | size_t len; | 260 | size_t len; |
261 | 261 | ||
262 | if (!netlink_has_listeners(uevent_sock, 1)) | ||
263 | continue; | ||
264 | |||
262 | /* allocate message with the maximum possible size */ | 265 | /* allocate message with the maximum possible size */ |
263 | len = strlen(action_string) + strlen(devpath) + 2; | 266 | len = strlen(action_string) + strlen(devpath) + 2; |
264 | skb = alloc_skb(len + env->buflen, GFP_KERNEL); | 267 | skb = alloc_skb(len + env->buflen, GFP_KERNEL); |
diff --git a/lib/kref.c b/lib/kref.c deleted file mode 100644 index 3efb882b11db..000000000000 --- a/lib/kref.c +++ /dev/null | |||
@@ -1,97 +0,0 @@ | |||
1 | /* | ||
2 | * kref.c - library routines for handling generic reference counted objects | ||
3 | * | ||
4 | * Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com> | ||
5 | * Copyright (C) 2004 IBM Corp. | ||
6 | * | ||
7 | * based on lib/kobject.c which was: | ||
8 | * Copyright (C) 2002-2003 Patrick Mochel <mochel@osdl.org> | ||
9 | * | ||
10 | * This file is released under the GPLv2. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/kref.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/slab.h> | ||
17 | |||
18 | /** | ||
19 | * kref_init - initialize object. | ||
20 | * @kref: object in question. | ||
21 | */ | ||
22 | void kref_init(struct kref *kref) | ||
23 | { | ||
24 | atomic_set(&kref->refcount, 1); | ||
25 | smp_mb(); | ||
26 | } | ||
27 | |||
28 | /** | ||
29 | * kref_get - increment refcount for object. | ||
30 | * @kref: object. | ||
31 | */ | ||
32 | void kref_get(struct kref *kref) | ||
33 | { | ||
34 | WARN_ON(!atomic_read(&kref->refcount)); | ||
35 | atomic_inc(&kref->refcount); | ||
36 | smp_mb__after_atomic_inc(); | ||
37 | } | ||
38 | |||
39 | /** | ||
40 | * kref_put - decrement refcount for object. | ||
41 | * @kref: object. | ||
42 | * @release: pointer to the function that will clean up the object when the | ||
43 | * last reference to the object is released. | ||
44 | * This pointer is required, and it is not acceptable to pass kfree | ||
45 | * in as this function. | ||
46 | * | ||
47 | * Decrement the refcount, and if 0, call release(). | ||
48 | * Return 1 if the object was removed, otherwise return 0. Beware, if this | ||
49 | * function returns 0, you still can not count on the kref from remaining in | ||
50 | * memory. Only use the return value if you want to see if the kref is now | ||
51 | * gone, not present. | ||
52 | */ | ||
53 | int kref_put(struct kref *kref, void (*release)(struct kref *kref)) | ||
54 | { | ||
55 | WARN_ON(release == NULL); | ||
56 | WARN_ON(release == (void (*)(struct kref *))kfree); | ||
57 | |||
58 | if (atomic_dec_and_test(&kref->refcount)) { | ||
59 | release(kref); | ||
60 | return 1; | ||
61 | } | ||
62 | return 0; | ||
63 | } | ||
64 | |||
65 | |||
66 | /** | ||
67 | * kref_sub - subtract a number of refcounts for object. | ||
68 | * @kref: object. | ||
69 | * @count: Number of recounts to subtract. | ||
70 | * @release: pointer to the function that will clean up the object when the | ||
71 | * last reference to the object is released. | ||
72 | * This pointer is required, and it is not acceptable to pass kfree | ||
73 | * in as this function. | ||
74 | * | ||
75 | * Subtract @count from the refcount, and if 0, call release(). | ||
76 | * Return 1 if the object was removed, otherwise return 0. Beware, if this | ||
77 | * function returns 0, you still can not count on the kref from remaining in | ||
78 | * memory. Only use the return value if you want to see if the kref is now | ||
79 | * gone, not present. | ||
80 | */ | ||
81 | int kref_sub(struct kref *kref, unsigned int count, | ||
82 | void (*release)(struct kref *kref)) | ||
83 | { | ||
84 | WARN_ON(release == NULL); | ||
85 | WARN_ON(release == (void (*)(struct kref *))kfree); | ||
86 | |||
87 | if (atomic_sub_and_test((int) count, &kref->refcount)) { | ||
88 | release(kref); | ||
89 | return 1; | ||
90 | } | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | EXPORT_SYMBOL(kref_init); | ||
95 | EXPORT_SYMBOL(kref_get); | ||
96 | EXPORT_SYMBOL(kref_put); | ||
97 | EXPORT_SYMBOL(kref_sub); | ||