diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Kconfig | 30 | ||||
| -rw-r--r-- | lib/Kconfig.debug | 11 | ||||
| -rw-r--r-- | lib/lockref.c | 36 | ||||
| -rw-r--r-- | lib/pci_iomap.c | 35 |
4 files changed, 84 insertions, 28 deletions
diff --git a/lib/Kconfig b/lib/Kconfig index cb9758e0ba0c..87da53bb1fef 100644 --- a/lib/Kconfig +++ b/lib/Kconfig | |||
| @@ -23,7 +23,7 @@ config HAVE_ARCH_BITREVERSE | |||
| 23 | have this capability. | 23 | have this capability. |
| 24 | 24 | ||
| 25 | config RATIONAL | 25 | config RATIONAL |
| 26 | boolean | 26 | bool |
| 27 | 27 | ||
| 28 | config GENERIC_STRNCPY_FROM_USER | 28 | config GENERIC_STRNCPY_FROM_USER |
| 29 | bool | 29 | bool |
| @@ -48,14 +48,14 @@ config GENERIC_IOMAP | |||
| 48 | select GENERIC_PCI_IOMAP | 48 | select GENERIC_PCI_IOMAP |
| 49 | 49 | ||
| 50 | config GENERIC_IO | 50 | config GENERIC_IO |
| 51 | boolean | 51 | bool |
| 52 | default n | 52 | default n |
| 53 | 53 | ||
| 54 | config STMP_DEVICE | 54 | config STMP_DEVICE |
| 55 | bool | 55 | bool |
| 56 | 56 | ||
| 57 | config PERCPU_RWSEM | 57 | config PERCPU_RWSEM |
| 58 | boolean | 58 | bool |
| 59 | 59 | ||
| 60 | config ARCH_USE_CMPXCHG_LOCKREF | 60 | config ARCH_USE_CMPXCHG_LOCKREF |
| 61 | bool | 61 | bool |
| @@ -266,7 +266,7 @@ config DECOMPRESS_LZ4 | |||
| 266 | # Generic allocator support is selected if needed | 266 | # Generic allocator support is selected if needed |
| 267 | # | 267 | # |
| 268 | config GENERIC_ALLOCATOR | 268 | config GENERIC_ALLOCATOR |
| 269 | boolean | 269 | bool |
| 270 | 270 | ||
| 271 | # | 271 | # |
| 272 | # reed solomon support is select'ed if needed | 272 | # reed solomon support is select'ed if needed |
| @@ -275,16 +275,16 @@ config REED_SOLOMON | |||
| 275 | tristate | 275 | tristate |
| 276 | 276 | ||
| 277 | config REED_SOLOMON_ENC8 | 277 | config REED_SOLOMON_ENC8 |
| 278 | boolean | 278 | bool |
| 279 | 279 | ||
| 280 | config REED_SOLOMON_DEC8 | 280 | config REED_SOLOMON_DEC8 |
| 281 | boolean | 281 | bool |
| 282 | 282 | ||
| 283 | config REED_SOLOMON_ENC16 | 283 | config REED_SOLOMON_ENC16 |
| 284 | boolean | 284 | bool |
| 285 | 285 | ||
| 286 | config REED_SOLOMON_DEC16 | 286 | config REED_SOLOMON_DEC16 |
| 287 | boolean | 287 | bool |
| 288 | 288 | ||
| 289 | # | 289 | # |
| 290 | # BCH support is selected if needed | 290 | # BCH support is selected if needed |
| @@ -293,7 +293,7 @@ config BCH | |||
| 293 | tristate | 293 | tristate |
| 294 | 294 | ||
| 295 | config BCH_CONST_PARAMS | 295 | config BCH_CONST_PARAMS |
| 296 | boolean | 296 | bool |
| 297 | help | 297 | help |
| 298 | Drivers may select this option to force specific constant | 298 | Drivers may select this option to force specific constant |
| 299 | values for parameters 'm' (Galois field order) and 't' | 299 | values for parameters 'm' (Galois field order) and 't' |
| @@ -329,7 +329,7 @@ config BCH_CONST_T | |||
| 329 | # Textsearch support is select'ed if needed | 329 | # Textsearch support is select'ed if needed |
| 330 | # | 330 | # |
| 331 | config TEXTSEARCH | 331 | config TEXTSEARCH |
| 332 | boolean | 332 | bool |
| 333 | 333 | ||
| 334 | config TEXTSEARCH_KMP | 334 | config TEXTSEARCH_KMP |
| 335 | tristate | 335 | tristate |
| @@ -341,10 +341,10 @@ config TEXTSEARCH_FSM | |||
| 341 | tristate | 341 | tristate |
| 342 | 342 | ||
| 343 | config BTREE | 343 | config BTREE |
| 344 | boolean | 344 | bool |
| 345 | 345 | ||
| 346 | config INTERVAL_TREE | 346 | config INTERVAL_TREE |
| 347 | boolean | 347 | bool |
| 348 | help | 348 | help |
| 349 | Simple, embeddable, interval-tree. Can find the start of an | 349 | Simple, embeddable, interval-tree. Can find the start of an |
| 350 | overlapping range in log(n) time and then iterate over all | 350 | overlapping range in log(n) time and then iterate over all |
| @@ -372,18 +372,18 @@ config ASSOCIATIVE_ARRAY | |||
| 372 | for more information. | 372 | for more information. |
| 373 | 373 | ||
| 374 | config HAS_IOMEM | 374 | config HAS_IOMEM |
| 375 | boolean | 375 | bool |
| 376 | depends on !NO_IOMEM | 376 | depends on !NO_IOMEM |
| 377 | select GENERIC_IO | 377 | select GENERIC_IO |
| 378 | default y | 378 | default y |
| 379 | 379 | ||
| 380 | config HAS_IOPORT_MAP | 380 | config HAS_IOPORT_MAP |
| 381 | boolean | 381 | bool |
| 382 | depends on HAS_IOMEM && !NO_IOPORT_MAP | 382 | depends on HAS_IOMEM && !NO_IOPORT_MAP |
| 383 | default y | 383 | default y |
| 384 | 384 | ||
| 385 | config HAS_DMA | 385 | config HAS_DMA |
| 386 | boolean | 386 | bool |
| 387 | depends on !NO_DMA | 387 | depends on !NO_DMA |
| 388 | default y | 388 | default y |
| 389 | 389 | ||
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index ecb3516f6546..c5cefb3c009c 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
| @@ -167,6 +167,17 @@ config DEBUG_INFO_DWARF4 | |||
| 167 | But it significantly improves the success of resolving | 167 | But it significantly improves the success of resolving |
| 168 | variables in gdb on optimized code. | 168 | variables in gdb on optimized code. |
| 169 | 169 | ||
| 170 | config GDB_SCRIPTS | ||
| 171 | bool "Provide GDB scripts for kernel debugging" | ||
| 172 | depends on DEBUG_INFO | ||
| 173 | help | ||
| 174 | This creates the required links to GDB helper scripts in the | ||
| 175 | build directory. If you load vmlinux into gdb, the helper | ||
| 176 | scripts will be automatically imported by gdb as well, and | ||
| 177 | additional functions are available to analyze a Linux kernel | ||
| 178 | instance. See Documentation/gdb-kernel-debugging.txt for further | ||
| 179 | details. | ||
| 180 | |||
| 170 | config ENABLE_WARN_DEPRECATED | 181 | config ENABLE_WARN_DEPRECATED |
| 171 | bool "Enable __deprecated logic" | 182 | bool "Enable __deprecated logic" |
| 172 | default y | 183 | default y |
diff --git a/lib/lockref.c b/lib/lockref.c index d2233de9a86e..ecb9a665ec19 100644 --- a/lib/lockref.c +++ b/lib/lockref.c | |||
| @@ -60,7 +60,7 @@ void lockref_get(struct lockref *lockref) | |||
| 60 | EXPORT_SYMBOL(lockref_get); | 60 | EXPORT_SYMBOL(lockref_get); |
| 61 | 61 | ||
| 62 | /** | 62 | /** |
| 63 | * lockref_get_not_zero - Increments count unless the count is 0 | 63 | * lockref_get_not_zero - Increments count unless the count is 0 or dead |
| 64 | * @lockref: pointer to lockref structure | 64 | * @lockref: pointer to lockref structure |
| 65 | * Return: 1 if count updated successfully or 0 if count was zero | 65 | * Return: 1 if count updated successfully or 0 if count was zero |
| 66 | */ | 66 | */ |
| @@ -70,7 +70,7 @@ int lockref_get_not_zero(struct lockref *lockref) | |||
| 70 | 70 | ||
| 71 | CMPXCHG_LOOP( | 71 | CMPXCHG_LOOP( |
| 72 | new.count++; | 72 | new.count++; |
| 73 | if (!old.count) | 73 | if (old.count <= 0) |
| 74 | return 0; | 74 | return 0; |
| 75 | , | 75 | , |
| 76 | return 1; | 76 | return 1; |
| @@ -78,7 +78,7 @@ int lockref_get_not_zero(struct lockref *lockref) | |||
| 78 | 78 | ||
| 79 | spin_lock(&lockref->lock); | 79 | spin_lock(&lockref->lock); |
| 80 | retval = 0; | 80 | retval = 0; |
| 81 | if (lockref->count) { | 81 | if (lockref->count > 0) { |
| 82 | lockref->count++; | 82 | lockref->count++; |
| 83 | retval = 1; | 83 | retval = 1; |
| 84 | } | 84 | } |
| @@ -88,7 +88,7 @@ int lockref_get_not_zero(struct lockref *lockref) | |||
| 88 | EXPORT_SYMBOL(lockref_get_not_zero); | 88 | EXPORT_SYMBOL(lockref_get_not_zero); |
| 89 | 89 | ||
| 90 | /** | 90 | /** |
| 91 | * lockref_get_or_lock - Increments count unless the count is 0 | 91 | * lockref_get_or_lock - Increments count unless the count is 0 or dead |
| 92 | * @lockref: pointer to lockref structure | 92 | * @lockref: pointer to lockref structure |
| 93 | * Return: 1 if count updated successfully or 0 if count was zero | 93 | * Return: 1 if count updated successfully or 0 if count was zero |
| 94 | * and we got the lock instead. | 94 | * and we got the lock instead. |
| @@ -97,14 +97,14 @@ int lockref_get_or_lock(struct lockref *lockref) | |||
| 97 | { | 97 | { |
| 98 | CMPXCHG_LOOP( | 98 | CMPXCHG_LOOP( |
| 99 | new.count++; | 99 | new.count++; |
| 100 | if (!old.count) | 100 | if (old.count <= 0) |
| 101 | break; | 101 | break; |
| 102 | , | 102 | , |
| 103 | return 1; | 103 | return 1; |
| 104 | ); | 104 | ); |
| 105 | 105 | ||
| 106 | spin_lock(&lockref->lock); | 106 | spin_lock(&lockref->lock); |
| 107 | if (!lockref->count) | 107 | if (lockref->count <= 0) |
| 108 | return 0; | 108 | return 0; |
| 109 | lockref->count++; | 109 | lockref->count++; |
| 110 | spin_unlock(&lockref->lock); | 110 | spin_unlock(&lockref->lock); |
| @@ -113,6 +113,26 @@ int lockref_get_or_lock(struct lockref *lockref) | |||
| 113 | EXPORT_SYMBOL(lockref_get_or_lock); | 113 | EXPORT_SYMBOL(lockref_get_or_lock); |
| 114 | 114 | ||
| 115 | /** | 115 | /** |
| 116 | * lockref_put_return - Decrement reference count if possible | ||
| 117 | * @lockref: pointer to lockref structure | ||
| 118 | * | ||
| 119 | * Decrement the reference count and return the new value. | ||
| 120 | * If the lockref was dead or locked, return an error. | ||
| 121 | */ | ||
| 122 | int lockref_put_return(struct lockref *lockref) | ||
| 123 | { | ||
| 124 | CMPXCHG_LOOP( | ||
| 125 | new.count--; | ||
| 126 | if (old.count <= 0) | ||
| 127 | return -1; | ||
| 128 | , | ||
| 129 | return new.count; | ||
| 130 | ); | ||
| 131 | return -1; | ||
| 132 | } | ||
| 133 | EXPORT_SYMBOL(lockref_put_return); | ||
| 134 | |||
| 135 | /** | ||
| 116 | * lockref_put_or_lock - decrements count unless count <= 1 before decrement | 136 | * lockref_put_or_lock - decrements count unless count <= 1 before decrement |
| 117 | * @lockref: pointer to lockref structure | 137 | * @lockref: pointer to lockref structure |
| 118 | * Return: 1 if count updated successfully or 0 if count <= 1 and lock taken | 138 | * Return: 1 if count updated successfully or 0 if count <= 1 and lock taken |
| @@ -158,7 +178,7 @@ int lockref_get_not_dead(struct lockref *lockref) | |||
| 158 | 178 | ||
| 159 | CMPXCHG_LOOP( | 179 | CMPXCHG_LOOP( |
| 160 | new.count++; | 180 | new.count++; |
| 161 | if ((int)old.count < 0) | 181 | if (old.count < 0) |
| 162 | return 0; | 182 | return 0; |
| 163 | , | 183 | , |
| 164 | return 1; | 184 | return 1; |
| @@ -166,7 +186,7 @@ int lockref_get_not_dead(struct lockref *lockref) | |||
| 166 | 186 | ||
| 167 | spin_lock(&lockref->lock); | 187 | spin_lock(&lockref->lock); |
| 168 | retval = 0; | 188 | retval = 0; |
| 169 | if ((int) lockref->count >= 0) { | 189 | if (lockref->count >= 0) { |
| 170 | lockref->count++; | 190 | lockref->count++; |
| 171 | retval = 1; | 191 | retval = 1; |
| 172 | } | 192 | } |
diff --git a/lib/pci_iomap.c b/lib/pci_iomap.c index 0d83ea8a9605..bcce5f149310 100644 --- a/lib/pci_iomap.c +++ b/lib/pci_iomap.c | |||
| @@ -10,10 +10,11 @@ | |||
| 10 | 10 | ||
| 11 | #ifdef CONFIG_PCI | 11 | #ifdef CONFIG_PCI |
| 12 | /** | 12 | /** |
| 13 | * pci_iomap - create a virtual mapping cookie for a PCI BAR | 13 | * pci_iomap_range - create a virtual mapping cookie for a PCI BAR |
| 14 | * @dev: PCI device that owns the BAR | 14 | * @dev: PCI device that owns the BAR |
| 15 | * @bar: BAR number | 15 | * @bar: BAR number |
| 16 | * @maxlen: length of the memory to map | 16 | * @offset: map memory at the given offset in BAR |
| 17 | * @maxlen: max length of the memory to map | ||
| 17 | * | 18 | * |
| 18 | * Using this function you will get a __iomem address to your device BAR. | 19 | * Using this function you will get a __iomem address to your device BAR. |
| 19 | * You can access it using ioread*() and iowrite*(). These functions hide | 20 | * You can access it using ioread*() and iowrite*(). These functions hide |
| @@ -21,16 +22,21 @@ | |||
| 21 | * you expect from them in the correct way. | 22 | * you expect from them in the correct way. |
| 22 | * | 23 | * |
| 23 | * @maxlen specifies the maximum length to map. If you want to get access to | 24 | * @maxlen specifies the maximum length to map. If you want to get access to |
| 24 | * the complete BAR without checking for its length first, pass %0 here. | 25 | * the complete BAR from offset to the end, pass %0 here. |
| 25 | * */ | 26 | * */ |
| 26 | void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) | 27 | void __iomem *pci_iomap_range(struct pci_dev *dev, |
| 28 | int bar, | ||
| 29 | unsigned long offset, | ||
| 30 | unsigned long maxlen) | ||
| 27 | { | 31 | { |
| 28 | resource_size_t start = pci_resource_start(dev, bar); | 32 | resource_size_t start = pci_resource_start(dev, bar); |
| 29 | resource_size_t len = pci_resource_len(dev, bar); | 33 | resource_size_t len = pci_resource_len(dev, bar); |
| 30 | unsigned long flags = pci_resource_flags(dev, bar); | 34 | unsigned long flags = pci_resource_flags(dev, bar); |
| 31 | 35 | ||
| 32 | if (!len || !start) | 36 | if (len <= offset || !start) |
| 33 | return NULL; | 37 | return NULL; |
| 38 | len -= offset; | ||
| 39 | start += offset; | ||
| 34 | if (maxlen && len > maxlen) | 40 | if (maxlen && len > maxlen) |
| 35 | len = maxlen; | 41 | len = maxlen; |
| 36 | if (flags & IORESOURCE_IO) | 42 | if (flags & IORESOURCE_IO) |
| @@ -43,6 +49,25 @@ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) | |||
| 43 | /* What? */ | 49 | /* What? */ |
| 44 | return NULL; | 50 | return NULL; |
| 45 | } | 51 | } |
| 52 | EXPORT_SYMBOL(pci_iomap_range); | ||
| 46 | 53 | ||
| 54 | /** | ||
| 55 | * pci_iomap - create a virtual mapping cookie for a PCI BAR | ||
| 56 | * @dev: PCI device that owns the BAR | ||
| 57 | * @bar: BAR number | ||
| 58 | * @maxlen: length of the memory to map | ||
| 59 | * | ||
| 60 | * Using this function you will get a __iomem address to your device BAR. | ||
| 61 | * You can access it using ioread*() and iowrite*(). These functions hide | ||
| 62 | * the details if this is a MMIO or PIO address space and will just do what | ||
| 63 | * you expect from them in the correct way. | ||
| 64 | * | ||
| 65 | * @maxlen specifies the maximum length to map. If you want to get access to | ||
| 66 | * the complete BAR without checking for its length first, pass %0 here. | ||
| 67 | * */ | ||
| 68 | void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) | ||
| 69 | { | ||
| 70 | return pci_iomap_range(dev, bar, 0, maxlen); | ||
| 71 | } | ||
| 47 | EXPORT_SYMBOL(pci_iomap); | 72 | EXPORT_SYMBOL(pci_iomap); |
| 48 | #endif /* CONFIG_PCI */ | 73 | #endif /* CONFIG_PCI */ |
