diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Kconfig | 3 | ||||
| -rw-r--r-- | lib/Makefile | 2 | ||||
| -rw-r--r-- | lib/kobject.c | 9 | ||||
| -rw-r--r-- | lib/swiotlb.c | 19 | ||||
| -rw-r--r-- | lib/ucs2_string.c | 51 |
5 files changed, 79 insertions, 5 deletions
diff --git a/lib/Kconfig b/lib/Kconfig index 3958dc4389f9..fe01d418b09a 100644 --- a/lib/Kconfig +++ b/lib/Kconfig | |||
| @@ -404,4 +404,7 @@ config OID_REGISTRY | |||
| 404 | help | 404 | help |
| 405 | Enable fast lookup object identifier registry. | 405 | Enable fast lookup object identifier registry. |
| 406 | 406 | ||
| 407 | config UCS2_STRING | ||
| 408 | tristate | ||
| 409 | |||
| 407 | endmenu | 410 | endmenu |
diff --git a/lib/Makefile b/lib/Makefile index d7946ff75b2e..6e2cc561f761 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
| @@ -174,3 +174,5 @@ quiet_cmd_build_OID_registry = GEN $@ | |||
| 174 | cmd_build_OID_registry = perl $(srctree)/$(src)/build_OID_registry $< $@ | 174 | cmd_build_OID_registry = perl $(srctree)/$(src)/build_OID_registry $< $@ |
| 175 | 175 | ||
| 176 | clean-files += oid_registry_data.c | 176 | clean-files += oid_registry_data.c |
| 177 | |||
| 178 | obj-$(CONFIG_UCS2_STRING) += ucs2_string.o | ||
diff --git a/lib/kobject.c b/lib/kobject.c index e07ee1fcd6f1..a65486613d79 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
| @@ -529,6 +529,13 @@ struct kobject *kobject_get(struct kobject *kobj) | |||
| 529 | return kobj; | 529 | return kobj; |
| 530 | } | 530 | } |
| 531 | 531 | ||
| 532 | static struct kobject *kobject_get_unless_zero(struct kobject *kobj) | ||
| 533 | { | ||
| 534 | if (!kref_get_unless_zero(&kobj->kref)) | ||
| 535 | kobj = NULL; | ||
| 536 | return kobj; | ||
| 537 | } | ||
| 538 | |||
| 532 | /* | 539 | /* |
| 533 | * kobject_cleanup - free kobject resources. | 540 | * kobject_cleanup - free kobject resources. |
| 534 | * @kobj: object to cleanup | 541 | * @kobj: object to cleanup |
| @@ -751,7 +758,7 @@ struct kobject *kset_find_obj(struct kset *kset, const char *name) | |||
| 751 | 758 | ||
| 752 | list_for_each_entry(k, &kset->list, entry) { | 759 | list_for_each_entry(k, &kset->list, entry) { |
| 753 | if (kobject_name(k) && !strcmp(kobject_name(k), name)) { | 760 | if (kobject_name(k) && !strcmp(kobject_name(k), name)) { |
| 754 | ret = kobject_get(k); | 761 | ret = kobject_get_unless_zero(k); |
| 755 | break; | 762 | break; |
| 756 | } | 763 | } |
| 757 | } | 764 | } |
diff --git a/lib/swiotlb.c b/lib/swiotlb.c index bfe02b8fc55b..d23762e6652c 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c | |||
| @@ -105,9 +105,9 @@ setup_io_tlb_npages(char *str) | |||
| 105 | if (!strcmp(str, "force")) | 105 | if (!strcmp(str, "force")) |
| 106 | swiotlb_force = 1; | 106 | swiotlb_force = 1; |
| 107 | 107 | ||
| 108 | return 1; | 108 | return 0; |
| 109 | } | 109 | } |
| 110 | __setup("swiotlb=", setup_io_tlb_npages); | 110 | early_param("swiotlb", setup_io_tlb_npages); |
| 111 | /* make io_tlb_overflow tunable too? */ | 111 | /* make io_tlb_overflow tunable too? */ |
| 112 | 112 | ||
| 113 | unsigned long swiotlb_nr_tbl(void) | 113 | unsigned long swiotlb_nr_tbl(void) |
| @@ -115,6 +115,18 @@ unsigned long swiotlb_nr_tbl(void) | |||
| 115 | return io_tlb_nslabs; | 115 | return io_tlb_nslabs; |
| 116 | } | 116 | } |
| 117 | EXPORT_SYMBOL_GPL(swiotlb_nr_tbl); | 117 | EXPORT_SYMBOL_GPL(swiotlb_nr_tbl); |
| 118 | |||
| 119 | /* default to 64MB */ | ||
| 120 | #define IO_TLB_DEFAULT_SIZE (64UL<<20) | ||
| 121 | unsigned long swiotlb_size_or_default(void) | ||
| 122 | { | ||
| 123 | unsigned long size; | ||
| 124 | |||
| 125 | size = io_tlb_nslabs << IO_TLB_SHIFT; | ||
| 126 | |||
| 127 | return size ? size : (IO_TLB_DEFAULT_SIZE); | ||
| 128 | } | ||
| 129 | |||
| 118 | /* Note that this doesn't work with highmem page */ | 130 | /* Note that this doesn't work with highmem page */ |
| 119 | static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev, | 131 | static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev, |
| 120 | volatile void *address) | 132 | volatile void *address) |
| @@ -188,8 +200,7 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) | |||
| 188 | void __init | 200 | void __init |
| 189 | swiotlb_init(int verbose) | 201 | swiotlb_init(int verbose) |
| 190 | { | 202 | { |
| 191 | /* default to 64MB */ | 203 | size_t default_size = IO_TLB_DEFAULT_SIZE; |
| 192 | size_t default_size = 64UL<<20; | ||
| 193 | unsigned char *vstart; | 204 | unsigned char *vstart; |
| 194 | unsigned long bytes; | 205 | unsigned long bytes; |
| 195 | 206 | ||
diff --git a/lib/ucs2_string.c b/lib/ucs2_string.c new file mode 100644 index 000000000000..6f500ef2301d --- /dev/null +++ b/lib/ucs2_string.c | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | #include <linux/ucs2_string.h> | ||
| 2 | #include <linux/module.h> | ||
| 3 | |||
| 4 | /* Return the number of unicode characters in data */ | ||
| 5 | unsigned long | ||
| 6 | ucs2_strnlen(const ucs2_char_t *s, size_t maxlength) | ||
| 7 | { | ||
| 8 | unsigned long length = 0; | ||
| 9 | |||
| 10 | while (*s++ != 0 && length < maxlength) | ||
| 11 | length++; | ||
| 12 | return length; | ||
| 13 | } | ||
| 14 | EXPORT_SYMBOL(ucs2_strnlen); | ||
| 15 | |||
| 16 | unsigned long | ||
| 17 | ucs2_strlen(const ucs2_char_t *s) | ||
| 18 | { | ||
| 19 | return ucs2_strnlen(s, ~0UL); | ||
| 20 | } | ||
| 21 | EXPORT_SYMBOL(ucs2_strlen); | ||
| 22 | |||
| 23 | /* | ||
| 24 | * Return the number of bytes is the length of this string | ||
| 25 | * Note: this is NOT the same as the number of unicode characters | ||
| 26 | */ | ||
| 27 | unsigned long | ||
| 28 | ucs2_strsize(const ucs2_char_t *data, unsigned long maxlength) | ||
| 29 | { | ||
| 30 | return ucs2_strnlen(data, maxlength/sizeof(ucs2_char_t)) * sizeof(ucs2_char_t); | ||
| 31 | } | ||
| 32 | EXPORT_SYMBOL(ucs2_strsize); | ||
| 33 | |||
| 34 | int | ||
| 35 | ucs2_strncmp(const ucs2_char_t *a, const ucs2_char_t *b, size_t len) | ||
| 36 | { | ||
| 37 | while (1) { | ||
| 38 | if (len == 0) | ||
| 39 | return 0; | ||
| 40 | if (*a < *b) | ||
| 41 | return -1; | ||
| 42 | if (*a > *b) | ||
| 43 | return 1; | ||
| 44 | if (*a == 0) /* implies *b == 0 */ | ||
| 45 | return 0; | ||
| 46 | a++; | ||
| 47 | b++; | ||
| 48 | len--; | ||
| 49 | } | ||
| 50 | } | ||
| 51 | EXPORT_SYMBOL(ucs2_strncmp); | ||
