Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k:
m68k/math-emu: Remove unnecessary code
m68k/math-emu: Remove commented out old code
m68k: Kill warning in setup_arch() when compiling for Sun3
m68k/atari: Prefix GPIO_{IN,OUT} with CODEC_
sparc: iounmap() and *_free_coherent() - Use lookup_resource()
m68k/atari: Reserve some ST-RAM early on for device buffer use
m68k/amiga: Chip RAM - Use lookup_resource()
resources: Add lookup_resource()
sparc: _sparc_find_resource() should check for exact matches
m68k/amiga: Chip RAM - Offset resource end by CHIP_PHYSADDR
m68k/amiga: Chip RAM - Use resource_size() to fix off-by-one error
m68k/amiga: Chip RAM - Change chipavail to an atomic_t
m68k/amiga: Chip RAM - Always allocate from the start of memory
m68k/amiga: Chip RAM - Convert from printk() to pr_*()
m68k/amiga: Chip RAM - Use tabs for indentation

+161 -926
-6
arch/m68k/Kconfig.mmu
··· 372 372 Include support in the kernel for pcmcia on Amiga 1200 and Amiga 373 373 600. If you intend to use pcmcia cards say Y; otherwise say N. 374 374 375 - config STRAM_PROC 376 - bool "ST-RAM statistics in /proc" 377 - depends on ATARI 378 - help 379 - Say Y here to report ST-RAM usage statistics in /proc/stram. 380 - 381 375 config HEARTBEAT 382 376 bool "Use power LED as a heartbeat" if AMIGA || APOLLO || ATARI || MAC ||Q40 383 377 default y if !AMIGA && !APOLLO && !ATARI && !MAC && !Q40 && HP300
+60 -70
arch/m68k/amiga/chipram.c
··· 16 16 #include <linux/string.h> 17 17 #include <linux/module.h> 18 18 19 + #include <asm/atomic.h> 19 20 #include <asm/page.h> 20 21 #include <asm/amigahw.h> 21 22 ··· 24 23 EXPORT_SYMBOL(amiga_chip_size); 25 24 26 25 static struct resource chipram_res = { 27 - .name = "Chip RAM", .start = CHIP_PHYSADDR 26 + .name = "Chip RAM", .start = CHIP_PHYSADDR 28 27 }; 29 - static unsigned long chipavail; 28 + static atomic_t chipavail; 30 29 31 30 32 31 void __init amiga_chip_init(void) 33 32 { 34 - if (!AMIGAHW_PRESENT(CHIP_RAM)) 35 - return; 33 + if (!AMIGAHW_PRESENT(CHIP_RAM)) 34 + return; 36 35 37 - chipram_res.end = amiga_chip_size-1; 38 - request_resource(&iomem_resource, &chipram_res); 36 + chipram_res.end = CHIP_PHYSADDR + amiga_chip_size - 1; 37 + request_resource(&iomem_resource, &chipram_res); 39 38 40 - chipavail = amiga_chip_size; 39 + atomic_set(&chipavail, amiga_chip_size); 41 40 } 42 41 43 42 44 43 void *amiga_chip_alloc(unsigned long size, const char *name) 45 44 { 46 - struct resource *res; 45 + struct resource *res; 46 + void *p; 47 47 48 - /* round up */ 49 - size = PAGE_ALIGN(size); 48 + res = kzalloc(sizeof(struct resource), GFP_KERNEL); 49 + if (!res) 50 + return NULL; 50 51 51 - #ifdef DEBUG 52 - printk("amiga_chip_alloc: allocate %ld bytes\n", size); 53 - #endif 54 - res = kzalloc(sizeof(struct resource), GFP_KERNEL); 55 - if (!res) 56 - return NULL; 57 - res->name = name; 52 + res->name = name; 53 + p = amiga_chip_alloc_res(size, res); 54 + if (!p) { 55 + kfree(res); 56 + return NULL; 57 + } 58 58 59 - if (allocate_resource(&chipram_res, res, size, 0, UINT_MAX, PAGE_SIZE, NULL, NULL) < 0) { 60 - kfree(res); 61 - return NULL; 62 - } 63 - chipavail -= size; 64 - #ifdef DEBUG 65 - printk("amiga_chip_alloc: returning %lx\n", res->start); 66 - #endif 67 - return (void *)ZTWO_VADDR(res->start); 59 + return p; 68 60 } 69 61 EXPORT_SYMBOL(amiga_chip_alloc); 70 62 71 63 72 - /* 73 - * Warning: 74 - * amiga_chip_alloc_res is meant only for drivers that need to allocate 75 - * Chip RAM before kmalloc() is functional. As a consequence, those 76 - * drivers must not free that Chip RAM afterwards. 77 - */ 64 + /* 65 + * Warning: 66 + * amiga_chip_alloc_res is meant only for drivers that need to 67 + * allocate Chip RAM before kmalloc() is functional. As a consequence, 68 + * those drivers must not free that Chip RAM afterwards. 69 + */ 78 70 79 - void * __init amiga_chip_alloc_res(unsigned long size, struct resource *res) 71 + void *amiga_chip_alloc_res(unsigned long size, struct resource *res) 80 72 { 81 - unsigned long start; 73 + int error; 82 74 83 - /* round up */ 84 - size = PAGE_ALIGN(size); 85 - /* dmesg into chipmem prefers memory at the safe end */ 86 - start = CHIP_PHYSADDR + chipavail - size; 75 + /* round up */ 76 + size = PAGE_ALIGN(size); 87 77 88 - #ifdef DEBUG 89 - printk("amiga_chip_alloc_res: allocate %ld bytes\n", size); 90 - #endif 91 - if (allocate_resource(&chipram_res, res, size, start, UINT_MAX, PAGE_SIZE, NULL, NULL) < 0) { 92 - printk("amiga_chip_alloc_res: first alloc failed!\n"); 93 - if (allocate_resource(&chipram_res, res, size, 0, UINT_MAX, PAGE_SIZE, NULL, NULL) < 0) 94 - return NULL; 95 - } 96 - chipavail -= size; 97 - #ifdef DEBUG 98 - printk("amiga_chip_alloc_res: returning %lx\n", res->start); 99 - #endif 100 - return (void *)ZTWO_VADDR(res->start); 78 + pr_debug("amiga_chip_alloc_res: allocate %lu bytes\n", size); 79 + error = allocate_resource(&chipram_res, res, size, 0, UINT_MAX, 80 + PAGE_SIZE, NULL, NULL); 81 + if (error < 0) { 82 + pr_err("amiga_chip_alloc_res: allocate_resource() failed %d!\n", 83 + error); 84 + return NULL; 85 + } 86 + 87 + atomic_sub(size, &chipavail); 88 + pr_debug("amiga_chip_alloc_res: returning %pR\n", res); 89 + return (void *)ZTWO_VADDR(res->start); 101 90 } 102 91 103 92 void amiga_chip_free(void *ptr) 104 93 { 105 - unsigned long start = ZTWO_PADDR(ptr); 106 - struct resource **p, *res; 107 - unsigned long size; 94 + unsigned long start = ZTWO_PADDR(ptr); 95 + struct resource *res; 96 + unsigned long size; 108 97 109 - for (p = &chipram_res.child; (res = *p); p = &res->sibling) { 110 - if (res->start != start) 111 - continue; 112 - *p = res->sibling; 113 - size = res->end-start; 114 - #ifdef DEBUG 115 - printk("amiga_chip_free: free %ld bytes at %p\n", size, ptr); 116 - #endif 117 - chipavail += size; 98 + res = lookup_resource(&chipram_res, start); 99 + if (!res) { 100 + pr_err("amiga_chip_free: trying to free nonexistent region at " 101 + "%p\n", ptr); 102 + return; 103 + } 104 + 105 + size = resource_size(res); 106 + pr_debug("amiga_chip_free: free %lu bytes at %p\n", size, ptr); 107 + atomic_add(size, &chipavail); 108 + release_resource(res); 118 109 kfree(res); 119 - return; 120 - } 121 - printk("amiga_chip_free: trying to free nonexistent region at %p\n", ptr); 122 110 } 123 111 EXPORT_SYMBOL(amiga_chip_free); 124 112 125 113 126 114 unsigned long amiga_chip_avail(void) 127 115 { 128 - #ifdef DEBUG 129 - printk("amiga_chip_avail : %ld bytes\n", chipavail); 130 - #endif 131 - return chipavail; 116 + unsigned long n = atomic_read(&chipavail); 117 + 118 + pr_debug("amiga_chip_avail : %lu bytes\n", n); 119 + return n; 132 120 } 133 121 EXPORT_SYMBOL(amiga_chip_avail); 134 122
+67 -283
arch/m68k/atari/stram.c
··· 1 1 /* 2 - * arch/m68k/atari/stram.c: Functions for ST-RAM allocations 2 + * Functions for ST-RAM allocations 3 3 * 4 4 * Copyright 1994-97 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de> 5 5 * ··· 30 30 #include <asm/atari_stram.h> 31 31 #include <asm/io.h> 32 32 33 - #undef DEBUG 34 - 35 - #ifdef DEBUG 36 - #define DPRINTK(fmt,args...) printk( fmt, ##args ) 37 - #else 38 - #define DPRINTK(fmt,args...) 39 - #endif 40 - 41 - #if defined(CONFIG_PROC_FS) && defined(CONFIG_STRAM_PROC) 42 - /* abbrev for the && above... */ 43 - #define DO_PROC 44 - #include <linux/proc_fs.h> 45 - #include <linux/seq_file.h> 46 - #endif 47 33 48 34 /* 49 - * ++roman: 50 - * 51 - * New version of ST-Ram buffer allocation. Instead of using the 52 - * 1 MB - 4 KB that remain when the ST-Ram chunk starts at $1000 53 - * (1 MB granularity!), such buffers are reserved like this: 54 - * 55 - * - If the kernel resides in ST-Ram anyway, we can take the buffer 56 - * from behind the current kernel data space the normal way 57 - * (incrementing start_mem). 58 - * 59 - * - If the kernel is in TT-Ram, stram_init() initializes start and 60 - * end of the available region. Buffers are allocated from there 61 - * and mem_init() later marks the such used pages as reserved. 62 - * Since each TT-Ram chunk is at least 4 MB in size, I hope there 63 - * won't be an overrun of the ST-Ram region by normal kernel data 64 - * space. 65 - * 66 - * For that, ST-Ram may only be allocated while kernel initialization 67 - * is going on, or exactly: before mem_init() is called. There is also 68 - * no provision now for freeing ST-Ram buffers. It seems that isn't 69 - * really needed. 70 - * 35 + * The ST-RAM allocator allocates memory from a pool of reserved ST-RAM of 36 + * configurable size, set aside on ST-RAM init. 37 + * As long as this pool is not exhausted, allocation of real ST-RAM can be 38 + * guaranteed. 71 39 */ 72 - 73 - /* Start and end (virtual) of ST-RAM */ 74 - static void *stram_start, *stram_end; 75 - 76 - /* set after memory_init() executed and allocations via start_mem aren't 77 - * possible anymore */ 78 - static int mem_init_done; 79 40 80 41 /* set if kernel is in ST-RAM */ 81 42 static int kernel_in_stram; 82 43 83 - typedef struct stram_block { 84 - struct stram_block *next; 85 - void *start; 86 - unsigned long size; 87 - unsigned flags; 88 - const char *owner; 89 - } BLOCK; 44 + static struct resource stram_pool = { 45 + .name = "ST-RAM Pool" 46 + }; 90 47 91 - /* values for flags field */ 92 - #define BLOCK_FREE 0x01 /* free structure in the BLOCKs pool */ 93 - #define BLOCK_KMALLOCED 0x02 /* structure allocated by kmalloc() */ 94 - #define BLOCK_GFP 0x08 /* block allocated with __get_dma_pages() */ 48 + static unsigned long pool_size = 1024*1024; 95 49 96 - /* list of allocated blocks */ 97 - static BLOCK *alloc_list; 98 50 99 - /* We can't always use kmalloc() to allocate BLOCK structures, since 100 - * stram_alloc() can be called rather early. So we need some pool of 101 - * statically allocated structures. 20 of them is more than enough, so in most 102 - * cases we never should need to call kmalloc(). */ 103 - #define N_STATIC_BLOCKS 20 104 - static BLOCK static_blocks[N_STATIC_BLOCKS]; 51 + static int __init atari_stram_setup(char *arg) 52 + { 53 + if (!MACH_IS_ATARI) 54 + return 0; 105 55 106 - /***************************** Prototypes *****************************/ 56 + pool_size = memparse(arg, NULL); 57 + return 0; 58 + } 107 59 108 - static BLOCK *add_region( void *addr, unsigned long size ); 109 - static BLOCK *find_region( void *addr ); 110 - static int remove_region( BLOCK *block ); 60 + early_param("stram_pool", atari_stram_setup); 111 61 112 - /************************* End of Prototypes **************************/ 113 - 114 - 115 - /* ------------------------------------------------------------------------ */ 116 - /* Public Interface */ 117 - /* ------------------------------------------------------------------------ */ 118 62 119 63 /* 120 64 * This init function is called very early by atari/config.c ··· 67 123 void __init atari_stram_init(void) 68 124 { 69 125 int i; 126 + void *stram_start; 70 127 71 - /* initialize static blocks */ 72 - for( i = 0; i < N_STATIC_BLOCKS; ++i ) 73 - static_blocks[i].flags = BLOCK_FREE; 74 - 75 - /* determine whether kernel code resides in ST-RAM (then ST-RAM is the 76 - * first memory block at virtual 0x0) */ 128 + /* 129 + * determine whether kernel code resides in ST-RAM 130 + * (then ST-RAM is the first memory block at virtual 0x0) 131 + */ 77 132 stram_start = phys_to_virt(0); 78 133 kernel_in_stram = (stram_start == 0); 79 134 80 - for( i = 0; i < m68k_num_memory; ++i ) { 135 + for (i = 0; i < m68k_num_memory; ++i) { 81 136 if (m68k_memory[i].addr == 0) { 82 - /* skip first 2kB or page (supervisor-only!) */ 83 - stram_end = stram_start + m68k_memory[i].size; 84 137 return; 85 138 } 86 139 } 140 + 87 141 /* Should never come here! (There is always ST-Ram!) */ 88 - panic( "atari_stram_init: no ST-RAM found!" ); 142 + panic("atari_stram_init: no ST-RAM found!"); 89 143 } 90 144 91 145 ··· 93 151 */ 94 152 void __init atari_stram_reserve_pages(void *start_mem) 95 153 { 96 - /* always reserve first page of ST-RAM, the first 2 kB are 97 - * supervisor-only! */ 154 + /* 155 + * always reserve first page of ST-RAM, the first 2 KiB are 156 + * supervisor-only! 157 + */ 98 158 if (!kernel_in_stram) 99 159 reserve_bootmem(0, PAGE_SIZE, BOOTMEM_DEFAULT); 100 160 161 + stram_pool.start = (resource_size_t)alloc_bootmem_low_pages(pool_size); 162 + stram_pool.end = stram_pool.start + pool_size - 1; 163 + request_resource(&iomem_resource, &stram_pool); 164 + 165 + pr_debug("atari_stram pool: size = %lu bytes, resource = %pR\n", 166 + pool_size, &stram_pool); 101 167 } 102 168 103 - void atari_stram_mem_init_hook (void) 169 + 170 + void *atari_stram_alloc(unsigned long size, const char *owner) 104 171 { 105 - mem_init_done = 1; 106 - } 172 + struct resource *res; 173 + int error; 107 174 175 + pr_debug("atari_stram_alloc: allocate %lu bytes\n", size); 108 176 109 - /* 110 - * This is main public interface: somehow allocate a ST-RAM block 111 - * 112 - * - If we're before mem_init(), we have to make a static allocation. The 113 - * region is taken in the kernel data area (if the kernel is in ST-RAM) or 114 - * from the start of ST-RAM (if the kernel is in TT-RAM) and added to the 115 - * rsvd_stram_* region. The ST-RAM is somewhere in the middle of kernel 116 - * address space in the latter case. 117 - * 118 - * - If mem_init() already has been called, try with __get_dma_pages(). 119 - * This has the disadvantage that it's very hard to get more than 1 page, 120 - * and it is likely to fail :-( 121 - * 122 - */ 123 - void *atari_stram_alloc(long size, const char *owner) 124 - { 125 - void *addr = NULL; 126 - BLOCK *block; 127 - int flags; 177 + /* round up */ 178 + size = PAGE_ALIGN(size); 128 179 129 - DPRINTK("atari_stram_alloc(size=%08lx,owner=%s)\n", size, owner); 180 + res = kzalloc(sizeof(struct resource), GFP_KERNEL); 181 + if (!res) 182 + return NULL; 130 183 131 - if (!mem_init_done) 132 - return alloc_bootmem_low(size); 133 - else { 134 - /* After mem_init(): can only resort to __get_dma_pages() */ 135 - addr = (void *)__get_dma_pages(GFP_KERNEL, get_order(size)); 136 - flags = BLOCK_GFP; 137 - DPRINTK( "atari_stram_alloc: after mem_init, " 138 - "get_pages=%p\n", addr ); 184 + res->name = owner; 185 + error = allocate_resource(&stram_pool, res, size, 0, UINT_MAX, 186 + PAGE_SIZE, NULL, NULL); 187 + if (error < 0) { 188 + pr_err("atari_stram_alloc: allocate_resource() failed %d!\n", 189 + error); 190 + kfree(res); 191 + return NULL; 139 192 } 140 193 141 - if (addr) { 142 - if (!(block = add_region( addr, size ))) { 143 - /* out of memory for BLOCK structure :-( */ 144 - DPRINTK( "atari_stram_alloc: out of mem for BLOCK -- " 145 - "freeing again\n" ); 146 - free_pages((unsigned long)addr, get_order(size)); 147 - return( NULL ); 148 - } 149 - block->owner = owner; 150 - block->flags |= flags; 151 - } 152 - return( addr ); 194 + pr_debug("atari_stram_alloc: returning %pR\n", res); 195 + return (void *)res->start; 153 196 } 154 197 EXPORT_SYMBOL(atari_stram_alloc); 155 198 156 - void atari_stram_free( void *addr ) 157 199 200 + void atari_stram_free(void *addr) 158 201 { 159 - BLOCK *block; 202 + unsigned long start = (unsigned long)addr; 203 + struct resource *res; 204 + unsigned long size; 160 205 161 - DPRINTK( "atari_stram_free(addr=%p)\n", addr ); 162 - 163 - if (!(block = find_region( addr ))) { 164 - printk( KERN_ERR "Attempt to free non-allocated ST-RAM block at %p " 165 - "from %p\n", addr, __builtin_return_address(0) ); 206 + res = lookup_resource(&stram_pool, start); 207 + if (!res) { 208 + pr_err("atari_stram_free: trying to free nonexistent region " 209 + "at %p\n", addr); 166 210 return; 167 211 } 168 - DPRINTK( "atari_stram_free: found block (%p): size=%08lx, owner=%s, " 169 - "flags=%02x\n", block, block->size, block->owner, block->flags ); 170 212 171 - if (!(block->flags & BLOCK_GFP)) 172 - goto fail; 173 - 174 - DPRINTK("atari_stram_free: is kmalloced, order_size=%d\n", 175 - get_order(block->size)); 176 - free_pages((unsigned long)addr, get_order(block->size)); 177 - remove_region( block ); 178 - return; 179 - 180 - fail: 181 - printk( KERN_ERR "atari_stram_free: cannot free block at %p " 182 - "(called from %p)\n", addr, __builtin_return_address(0) ); 213 + size = resource_size(res); 214 + pr_debug("atari_stram_free: free %lu bytes at %p\n", size, addr); 215 + release_resource(res); 216 + kfree(res); 183 217 } 184 218 EXPORT_SYMBOL(atari_stram_free); 185 - 186 - 187 - /* ------------------------------------------------------------------------ */ 188 - /* Region Management */ 189 - /* ------------------------------------------------------------------------ */ 190 - 191 - 192 - /* insert a region into the alloced list (sorted) */ 193 - static BLOCK *add_region( void *addr, unsigned long size ) 194 - { 195 - BLOCK **p, *n = NULL; 196 - int i; 197 - 198 - for( i = 0; i < N_STATIC_BLOCKS; ++i ) { 199 - if (static_blocks[i].flags & BLOCK_FREE) { 200 - n = &static_blocks[i]; 201 - n->flags = 0; 202 - break; 203 - } 204 - } 205 - if (!n && mem_init_done) { 206 - /* if statics block pool exhausted and we can call kmalloc() already 207 - * (after mem_init()), try that */ 208 - n = kmalloc( sizeof(BLOCK), GFP_KERNEL ); 209 - if (n) 210 - n->flags = BLOCK_KMALLOCED; 211 - } 212 - if (!n) { 213 - printk( KERN_ERR "Out of memory for ST-RAM descriptor blocks\n" ); 214 - return( NULL ); 215 - } 216 - n->start = addr; 217 - n->size = size; 218 - 219 - for( p = &alloc_list; *p; p = &((*p)->next) ) 220 - if ((*p)->start > addr) break; 221 - n->next = *p; 222 - *p = n; 223 - 224 - return( n ); 225 - } 226 - 227 - 228 - /* find a region (by start addr) in the alloced list */ 229 - static BLOCK *find_region( void *addr ) 230 - { 231 - BLOCK *p; 232 - 233 - for( p = alloc_list; p; p = p->next ) { 234 - if (p->start == addr) 235 - return( p ); 236 - if (p->start > addr) 237 - break; 238 - } 239 - return( NULL ); 240 - } 241 - 242 - 243 - /* remove a block from the alloced list */ 244 - static int remove_region( BLOCK *block ) 245 - { 246 - BLOCK **p; 247 - 248 - for( p = &alloc_list; *p; p = &((*p)->next) ) 249 - if (*p == block) break; 250 - if (!*p) 251 - return( 0 ); 252 - 253 - *p = block->next; 254 - if (block->flags & BLOCK_KMALLOCED) 255 - kfree( block ); 256 - else 257 - block->flags |= BLOCK_FREE; 258 - return( 1 ); 259 - } 260 - 261 - 262 - 263 - /* ------------------------------------------------------------------------ */ 264 - /* /proc statistics file stuff */ 265 - /* ------------------------------------------------------------------------ */ 266 - 267 - #ifdef DO_PROC 268 - 269 - #define PRINT_PROC(fmt,args...) seq_printf( m, fmt, ##args ) 270 - 271 - static int stram_proc_show(struct seq_file *m, void *v) 272 - { 273 - BLOCK *p; 274 - 275 - PRINT_PROC("Total ST-RAM: %8u kB\n", 276 - (stram_end - stram_start) >> 10); 277 - PRINT_PROC( "Allocated regions:\n" ); 278 - for( p = alloc_list; p; p = p->next ) { 279 - PRINT_PROC("0x%08lx-0x%08lx: %s (", 280 - virt_to_phys(p->start), 281 - virt_to_phys(p->start+p->size-1), 282 - p->owner); 283 - if (p->flags & BLOCK_GFP) 284 - PRINT_PROC( "page-alloced)\n" ); 285 - else 286 - PRINT_PROC( "??)\n" ); 287 - } 288 - 289 - return 0; 290 - } 291 - 292 - static int stram_proc_open(struct inode *inode, struct file *file) 293 - { 294 - return single_open(file, stram_proc_show, NULL); 295 - } 296 - 297 - static const struct file_operations stram_proc_fops = { 298 - .open = stram_proc_open, 299 - .read = seq_read, 300 - .llseek = seq_lseek, 301 - .release = single_release, 302 - }; 303 - 304 - static int __init proc_stram_init(void) 305 - { 306 - proc_create("stram", 0, NULL, &stram_proc_fops); 307 - return 0; 308 - } 309 - module_init(proc_stram_init); 310 - #endif 311 - 312 - 313 - /* 314 - * Local variables: 315 - * c-indent-level: 4 316 - * tab-width: 4 317 - * End: 318 - */
+1 -2
arch/m68k/include/asm/atari_stram.h
··· 6 6 */ 7 7 8 8 /* public interface */ 9 - void *atari_stram_alloc(long size, const char *owner); 9 + void *atari_stram_alloc(unsigned long size, const char *owner); 10 10 void atari_stram_free(void *); 11 11 12 12 /* functions called internally by other parts of the kernel */ 13 13 void atari_stram_init(void); 14 14 void atari_stram_reserve_pages(void *start_mem); 15 - void atari_stram_mem_init_hook (void); 16 15 17 16 #endif /*_M68K_ATARI_STRAM_H */
+2 -2
arch/m68k/include/asm/atarihw.h
··· 399 399 #define CODEC_OVERFLOW_LEFT 2 400 400 u_char unused2, unused3, unused4, unused5; 401 401 u_char gpio_directions; 402 - #define GPIO_IN 0 403 - #define GPIO_OUT 1 402 + #define CODEC_GPIO_IN 0 403 + #define CODEC_GPIO_OUT 1 404 404 u_char unused6; 405 405 u_char gpio_data; 406 406 };
+2
arch/m68k/kernel/setup_mm.c
··· 216 216 217 217 void __init setup_arch(char **cmdline_p) 218 218 { 219 + #ifndef CONFIG_SUN3 219 220 int i; 221 + #endif 220 222 221 223 /* The bootinfo is located right after the kernel bss */ 222 224 m68k_parse_bootinfo((const struct bi_record *)_end);
-3
arch/m68k/math-emu/fp_log.c
··· 105 105 106 106 fp_monadic_check(dest, src); 107 107 108 - if (IS_ZERO(dest)) 109 - return dest; 110 - 111 108 return dest; 112 109 } 113 110
-530
arch/m68k/math-emu/multi_arith.h
··· 19 19 #ifndef MULTI_ARITH_H 20 20 #define MULTI_ARITH_H 21 21 22 - #if 0 /* old code... */ 23 - 24 - /* Unsigned only, because we don't need signs to multiply and divide. */ 25 - typedef unsigned int int128[4]; 26 - 27 - /* Word order */ 28 - enum { 29 - MSW128, 30 - NMSW128, 31 - NLSW128, 32 - LSW128 33 - }; 34 - 35 - /* big-endian */ 36 - #define LO_WORD(ll) (((unsigned int *) &ll)[1]) 37 - #define HI_WORD(ll) (((unsigned int *) &ll)[0]) 38 - 39 - /* Convenience functions to stuff various integer values into int128s */ 40 - 41 - static inline void zero128(int128 a) 42 - { 43 - a[LSW128] = a[NLSW128] = a[NMSW128] = a[MSW128] = 0; 44 - } 45 - 46 - /* Human-readable word order in the arguments */ 47 - static inline void set128(unsigned int i3, unsigned int i2, unsigned int i1, 48 - unsigned int i0, int128 a) 49 - { 50 - a[LSW128] = i0; 51 - a[NLSW128] = i1; 52 - a[NMSW128] = i2; 53 - a[MSW128] = i3; 54 - } 55 - 56 - /* Convenience functions (for testing as well) */ 57 - static inline void int64_to_128(unsigned long long src, int128 dest) 58 - { 59 - dest[LSW128] = (unsigned int) src; 60 - dest[NLSW128] = src >> 32; 61 - dest[NMSW128] = dest[MSW128] = 0; 62 - } 63 - 64 - static inline void int128_to_64(const int128 src, unsigned long long *dest) 65 - { 66 - *dest = src[LSW128] | (long long) src[NLSW128] << 32; 67 - } 68 - 69 - static inline void put_i128(const int128 a) 70 - { 71 - printk("%08x %08x %08x %08x\n", a[MSW128], a[NMSW128], 72 - a[NLSW128], a[LSW128]); 73 - } 74 - 75 - /* Internal shifters: 76 - 77 - Note that these are only good for 0 < count < 32. 78 - */ 79 - 80 - static inline void _lsl128(unsigned int count, int128 a) 81 - { 82 - a[MSW128] = (a[MSW128] << count) | (a[NMSW128] >> (32 - count)); 83 - a[NMSW128] = (a[NMSW128] << count) | (a[NLSW128] >> (32 - count)); 84 - a[NLSW128] = (a[NLSW128] << count) | (a[LSW128] >> (32 - count)); 85 - a[LSW128] <<= count; 86 - } 87 - 88 - static inline void _lsr128(unsigned int count, int128 a) 89 - { 90 - a[LSW128] = (a[LSW128] >> count) | (a[NLSW128] << (32 - count)); 91 - a[NLSW128] = (a[NLSW128] >> count) | (a[NMSW128] << (32 - count)); 92 - a[NMSW128] = (a[NMSW128] >> count) | (a[MSW128] << (32 - count)); 93 - a[MSW128] >>= count; 94 - } 95 - 96 - /* Should be faster, one would hope */ 97 - 98 - static inline void lslone128(int128 a) 99 - { 100 - asm volatile ("lsl.l #1,%0\n" 101 - "roxl.l #1,%1\n" 102 - "roxl.l #1,%2\n" 103 - "roxl.l #1,%3\n" 104 - : 105 - "=d" (a[LSW128]), 106 - "=d"(a[NLSW128]), 107 - "=d"(a[NMSW128]), 108 - "=d"(a[MSW128]) 109 - : 110 - "0"(a[LSW128]), 111 - "1"(a[NLSW128]), 112 - "2"(a[NMSW128]), 113 - "3"(a[MSW128])); 114 - } 115 - 116 - static inline void lsrone128(int128 a) 117 - { 118 - asm volatile ("lsr.l #1,%0\n" 119 - "roxr.l #1,%1\n" 120 - "roxr.l #1,%2\n" 121 - "roxr.l #1,%3\n" 122 - : 123 - "=d" (a[MSW128]), 124 - "=d"(a[NMSW128]), 125 - "=d"(a[NLSW128]), 126 - "=d"(a[LSW128]) 127 - : 128 - "0"(a[MSW128]), 129 - "1"(a[NMSW128]), 130 - "2"(a[NLSW128]), 131 - "3"(a[LSW128])); 132 - } 133 - 134 - /* Generalized 128-bit shifters: 135 - 136 - These bit-shift to a multiple of 32, then move whole longwords. */ 137 - 138 - static inline void lsl128(unsigned int count, int128 a) 139 - { 140 - int wordcount, i; 141 - 142 - if (count % 32) 143 - _lsl128(count % 32, a); 144 - 145 - if (0 == (wordcount = count / 32)) 146 - return; 147 - 148 - /* argh, gak, endian-sensitive */ 149 - for (i = 0; i < 4 - wordcount; i++) { 150 - a[i] = a[i + wordcount]; 151 - } 152 - for (i = 3; i >= 4 - wordcount; --i) { 153 - a[i] = 0; 154 - } 155 - } 156 - 157 - static inline void lsr128(unsigned int count, int128 a) 158 - { 159 - int wordcount, i; 160 - 161 - if (count % 32) 162 - _lsr128(count % 32, a); 163 - 164 - if (0 == (wordcount = count / 32)) 165 - return; 166 - 167 - for (i = 3; i >= wordcount; --i) { 168 - a[i] = a[i - wordcount]; 169 - } 170 - for (i = 0; i < wordcount; i++) { 171 - a[i] = 0; 172 - } 173 - } 174 - 175 - static inline int orl128(int a, int128 b) 176 - { 177 - b[LSW128] |= a; 178 - } 179 - 180 - static inline int btsthi128(const int128 a) 181 - { 182 - return a[MSW128] & 0x80000000; 183 - } 184 - 185 - /* test bits (numbered from 0 = LSB) up to and including "top" */ 186 - static inline int bftestlo128(int top, const int128 a) 187 - { 188 - int r = 0; 189 - 190 - if (top > 31) 191 - r |= a[LSW128]; 192 - if (top > 63) 193 - r |= a[NLSW128]; 194 - if (top > 95) 195 - r |= a[NMSW128]; 196 - 197 - r |= a[3 - (top / 32)] & ((1 << (top % 32 + 1)) - 1); 198 - 199 - return (r != 0); 200 - } 201 - 202 - /* Aargh. We need these because GCC is broken */ 203 - /* FIXME: do them in assembly, for goodness' sake! */ 204 - static inline void mask64(int pos, unsigned long long *mask) 205 - { 206 - *mask = 0; 207 - 208 - if (pos < 32) { 209 - LO_WORD(*mask) = (1 << pos) - 1; 210 - return; 211 - } 212 - LO_WORD(*mask) = -1; 213 - HI_WORD(*mask) = (1 << (pos - 32)) - 1; 214 - } 215 - 216 - static inline void bset64(int pos, unsigned long long *dest) 217 - { 218 - /* This conditional will be optimized away. Thanks, GCC! */ 219 - if (pos < 32) 220 - asm volatile ("bset %1,%0":"=m" 221 - (LO_WORD(*dest)):"id"(pos)); 222 - else 223 - asm volatile ("bset %1,%0":"=m" 224 - (HI_WORD(*dest)):"id"(pos - 32)); 225 - } 226 - 227 - static inline int btst64(int pos, unsigned long long dest) 228 - { 229 - if (pos < 32) 230 - return (0 != (LO_WORD(dest) & (1 << pos))); 231 - else 232 - return (0 != (HI_WORD(dest) & (1 << (pos - 32)))); 233 - } 234 - 235 - static inline void lsl64(int count, unsigned long long *dest) 236 - { 237 - if (count < 32) { 238 - HI_WORD(*dest) = (HI_WORD(*dest) << count) 239 - | (LO_WORD(*dest) >> count); 240 - LO_WORD(*dest) <<= count; 241 - return; 242 - } 243 - count -= 32; 244 - HI_WORD(*dest) = LO_WORD(*dest) << count; 245 - LO_WORD(*dest) = 0; 246 - } 247 - 248 - static inline void lsr64(int count, unsigned long long *dest) 249 - { 250 - if (count < 32) { 251 - LO_WORD(*dest) = (LO_WORD(*dest) >> count) 252 - | (HI_WORD(*dest) << (32 - count)); 253 - HI_WORD(*dest) >>= count; 254 - return; 255 - } 256 - count -= 32; 257 - LO_WORD(*dest) = HI_WORD(*dest) >> count; 258 - HI_WORD(*dest) = 0; 259 - } 260 - #endif 261 - 262 22 static inline void fp_denormalize(struct fp_ext *reg, unsigned int cnt) 263 23 { 264 24 reg->exp += cnt; ··· 241 481 } 242 482 } 243 483 244 - #if 0 245 - static inline unsigned int fp_fls128(union fp_mant128 *src) 246 - { 247 - unsigned long data; 248 - unsigned int res, off; 249 - 250 - if ((data = src->m32[0])) 251 - off = 0; 252 - else if ((data = src->m32[1])) 253 - off = 32; 254 - else if ((data = src->m32[2])) 255 - off = 64; 256 - else if ((data = src->m32[3])) 257 - off = 96; 258 - else 259 - return 128; 260 - 261 - asm ("bfffo %1{#0,#32},%0" : "=d" (res) : "dm" (data)); 262 - return res + off; 263 - } 264 - 265 - static inline void fp_shiftmant128(union fp_mant128 *src, int shift) 266 - { 267 - unsigned long sticky; 268 - 269 - switch (shift) { 270 - case 0: 271 - return; 272 - case 1: 273 - asm volatile ("lsl.l #1,%0" 274 - : "=d" (src->m32[3]) : "0" (src->m32[3])); 275 - asm volatile ("roxl.l #1,%0" 276 - : "=d" (src->m32[2]) : "0" (src->m32[2])); 277 - asm volatile ("roxl.l #1,%0" 278 - : "=d" (src->m32[1]) : "0" (src->m32[1])); 279 - asm volatile ("roxl.l #1,%0" 280 - : "=d" (src->m32[0]) : "0" (src->m32[0])); 281 - return; 282 - case 2 ... 31: 283 - src->m32[0] = (src->m32[0] << shift) | (src->m32[1] >> (32 - shift)); 284 - src->m32[1] = (src->m32[1] << shift) | (src->m32[2] >> (32 - shift)); 285 - src->m32[2] = (src->m32[2] << shift) | (src->m32[3] >> (32 - shift)); 286 - src->m32[3] = (src->m32[3] << shift); 287 - return; 288 - case 32 ... 63: 289 - shift -= 32; 290 - src->m32[0] = (src->m32[1] << shift) | (src->m32[2] >> (32 - shift)); 291 - src->m32[1] = (src->m32[2] << shift) | (src->m32[3] >> (32 - shift)); 292 - src->m32[2] = (src->m32[3] << shift); 293 - src->m32[3] = 0; 294 - return; 295 - case 64 ... 95: 296 - shift -= 64; 297 - src->m32[0] = (src->m32[2] << shift) | (src->m32[3] >> (32 - shift)); 298 - src->m32[1] = (src->m32[3] << shift); 299 - src->m32[2] = src->m32[3] = 0; 300 - return; 301 - case 96 ... 127: 302 - shift -= 96; 303 - src->m32[0] = (src->m32[3] << shift); 304 - src->m32[1] = src->m32[2] = src->m32[3] = 0; 305 - return; 306 - case -31 ... -1: 307 - shift = -shift; 308 - sticky = 0; 309 - if (src->m32[3] << (32 - shift)) 310 - sticky = 1; 311 - src->m32[3] = (src->m32[3] >> shift) | (src->m32[2] << (32 - shift)) | sticky; 312 - src->m32[2] = (src->m32[2] >> shift) | (src->m32[1] << (32 - shift)); 313 - src->m32[1] = (src->m32[1] >> shift) | (src->m32[0] << (32 - shift)); 314 - src->m32[0] = (src->m32[0] >> shift); 315 - return; 316 - case -63 ... -32: 317 - shift = -shift - 32; 318 - sticky = 0; 319 - if ((src->m32[2] << (32 - shift)) || src->m32[3]) 320 - sticky = 1; 321 - src->m32[3] = (src->m32[2] >> shift) | (src->m32[1] << (32 - shift)) | sticky; 322 - src->m32[2] = (src->m32[1] >> shift) | (src->m32[0] << (32 - shift)); 323 - src->m32[1] = (src->m32[0] >> shift); 324 - src->m32[0] = 0; 325 - return; 326 - case -95 ... -64: 327 - shift = -shift - 64; 328 - sticky = 0; 329 - if ((src->m32[1] << (32 - shift)) || src->m32[2] || src->m32[3]) 330 - sticky = 1; 331 - src->m32[3] = (src->m32[1] >> shift) | (src->m32[0] << (32 - shift)) | sticky; 332 - src->m32[2] = (src->m32[0] >> shift); 333 - src->m32[1] = src->m32[0] = 0; 334 - return; 335 - case -127 ... -96: 336 - shift = -shift - 96; 337 - sticky = 0; 338 - if ((src->m32[0] << (32 - shift)) || src->m32[1] || src->m32[2] || src->m32[3]) 339 - sticky = 1; 340 - src->m32[3] = (src->m32[0] >> shift) | sticky; 341 - src->m32[2] = src->m32[1] = src->m32[0] = 0; 342 - return; 343 - } 344 - 345 - if (shift < 0 && (src->m32[0] || src->m32[1] || src->m32[2] || src->m32[3])) 346 - src->m32[3] = 1; 347 - else 348 - src->m32[3] = 0; 349 - src->m32[2] = 0; 350 - src->m32[1] = 0; 351 - src->m32[0] = 0; 352 - } 353 - #endif 354 - 355 484 static inline void fp_putmant128(struct fp_ext *dest, union fp_mant128 *src, 356 485 int shift) 357 486 { ··· 285 636 break; 286 637 } 287 638 } 288 - 289 - #if 0 /* old code... */ 290 - static inline int fls(unsigned int a) 291 - { 292 - int r; 293 - 294 - asm volatile ("bfffo %1{#0,#32},%0" 295 - : "=d" (r) : "md" (a)); 296 - return r; 297 - } 298 - 299 - /* fls = "find last set" (cf. ffs(3)) */ 300 - static inline int fls128(const int128 a) 301 - { 302 - if (a[MSW128]) 303 - return fls(a[MSW128]); 304 - if (a[NMSW128]) 305 - return fls(a[NMSW128]) + 32; 306 - /* XXX: it probably never gets beyond this point in actual 307 - use, but that's indicative of a more general problem in the 308 - algorithm (i.e. as per the actual 68881 implementation, we 309 - really only need at most 67 bits of precision [plus 310 - overflow]) so I'm not going to fix it. */ 311 - if (a[NLSW128]) 312 - return fls(a[NLSW128]) + 64; 313 - if (a[LSW128]) 314 - return fls(a[LSW128]) + 96; 315 - else 316 - return -1; 317 - } 318 - 319 - static inline int zerop128(const int128 a) 320 - { 321 - return !(a[LSW128] | a[NLSW128] | a[NMSW128] | a[MSW128]); 322 - } 323 - 324 - static inline int nonzerop128(const int128 a) 325 - { 326 - return (a[LSW128] | a[NLSW128] | a[NMSW128] | a[MSW128]); 327 - } 328 - 329 - /* Addition and subtraction */ 330 - /* Do these in "pure" assembly, because "extended" asm is unmanageable 331 - here */ 332 - static inline void add128(const int128 a, int128 b) 333 - { 334 - /* rotating carry flags */ 335 - unsigned int carry[2]; 336 - 337 - carry[0] = a[LSW128] > (0xffffffff - b[LSW128]); 338 - b[LSW128] += a[LSW128]; 339 - 340 - carry[1] = a[NLSW128] > (0xffffffff - b[NLSW128] - carry[0]); 341 - b[NLSW128] = a[NLSW128] + b[NLSW128] + carry[0]; 342 - 343 - carry[0] = a[NMSW128] > (0xffffffff - b[NMSW128] - carry[1]); 344 - b[NMSW128] = a[NMSW128] + b[NMSW128] + carry[1]; 345 - 346 - b[MSW128] = a[MSW128] + b[MSW128] + carry[0]; 347 - } 348 - 349 - /* Note: assembler semantics: "b -= a" */ 350 - static inline void sub128(const int128 a, int128 b) 351 - { 352 - /* rotating borrow flags */ 353 - unsigned int borrow[2]; 354 - 355 - borrow[0] = b[LSW128] < a[LSW128]; 356 - b[LSW128] -= a[LSW128]; 357 - 358 - borrow[1] = b[NLSW128] < a[NLSW128] + borrow[0]; 359 - b[NLSW128] = b[NLSW128] - a[NLSW128] - borrow[0]; 360 - 361 - borrow[0] = b[NMSW128] < a[NMSW128] + borrow[1]; 362 - b[NMSW128] = b[NMSW128] - a[NMSW128] - borrow[1]; 363 - 364 - b[MSW128] = b[MSW128] - a[MSW128] - borrow[0]; 365 - } 366 - 367 - /* Poor man's 64-bit expanding multiply */ 368 - static inline void mul64(unsigned long long a, unsigned long long b, int128 c) 369 - { 370 - unsigned long long acc; 371 - int128 acc128; 372 - 373 - zero128(acc128); 374 - zero128(c); 375 - 376 - /* first the low words */ 377 - if (LO_WORD(a) && LO_WORD(b)) { 378 - acc = (long long) LO_WORD(a) * LO_WORD(b); 379 - c[NLSW128] = HI_WORD(acc); 380 - c[LSW128] = LO_WORD(acc); 381 - } 382 - /* Next the high words */ 383 - if (HI_WORD(a) && HI_WORD(b)) { 384 - acc = (long long) HI_WORD(a) * HI_WORD(b); 385 - c[MSW128] = HI_WORD(acc); 386 - c[NMSW128] = LO_WORD(acc); 387 - } 388 - /* The middle words */ 389 - if (LO_WORD(a) && HI_WORD(b)) { 390 - acc = (long long) LO_WORD(a) * HI_WORD(b); 391 - acc128[NMSW128] = HI_WORD(acc); 392 - acc128[NLSW128] = LO_WORD(acc); 393 - add128(acc128, c); 394 - } 395 - /* The first and last words */ 396 - if (HI_WORD(a) && LO_WORD(b)) { 397 - acc = (long long) HI_WORD(a) * LO_WORD(b); 398 - acc128[NMSW128] = HI_WORD(acc); 399 - acc128[NLSW128] = LO_WORD(acc); 400 - add128(acc128, c); 401 - } 402 - } 403 - 404 - /* Note: unsigned */ 405 - static inline int cmp128(int128 a, int128 b) 406 - { 407 - if (a[MSW128] < b[MSW128]) 408 - return -1; 409 - if (a[MSW128] > b[MSW128]) 410 - return 1; 411 - if (a[NMSW128] < b[NMSW128]) 412 - return -1; 413 - if (a[NMSW128] > b[NMSW128]) 414 - return 1; 415 - if (a[NLSW128] < b[NLSW128]) 416 - return -1; 417 - if (a[NLSW128] > b[NLSW128]) 418 - return 1; 419 - 420 - return (signed) a[LSW128] - b[LSW128]; 421 - } 422 - 423 - inline void div128(int128 a, int128 b, int128 c) 424 - { 425 - int128 mask; 426 - 427 - /* Algorithm: 428 - 429 - Shift the divisor until it's at least as big as the 430 - dividend, keeping track of the position to which we've 431 - shifted it, i.e. the power of 2 which we've multiplied it 432 - by. 433 - 434 - Then, for this power of 2 (the mask), and every one smaller 435 - than it, subtract the mask from the dividend and add it to 436 - the quotient until the dividend is smaller than the raised 437 - divisor. At this point, divide the dividend and the mask 438 - by 2 (i.e. shift one place to the right). Lather, rinse, 439 - and repeat, until there are no more powers of 2 left. */ 440 - 441 - /* FIXME: needless to say, there's room for improvement here too. */ 442 - 443 - /* Shift up */ 444 - /* XXX: since it just has to be "at least as big", we can 445 - probably eliminate this horribly wasteful loop. I will 446 - have to prove this first, though */ 447 - set128(0, 0, 0, 1, mask); 448 - while (cmp128(b, a) < 0 && !btsthi128(b)) { 449 - lslone128(b); 450 - lslone128(mask); 451 - } 452 - 453 - /* Shift down */ 454 - zero128(c); 455 - do { 456 - if (cmp128(a, b) >= 0) { 457 - sub128(b, a); 458 - add128(mask, c); 459 - } 460 - lsrone128(mask); 461 - lsrone128(b); 462 - } while (nonzerop128(mask)); 463 - 464 - /* The remainder is in a... */ 465 - } 466 - #endif 467 639 468 640 #endif /* MULTI_ARITH_H */
-5
arch/m68k/mm/init_mm.c
··· 83 83 int initpages = 0; 84 84 int i; 85 85 86 - #ifdef CONFIG_ATARI 87 - if (MACH_IS_ATARI) 88 - atari_stram_mem_init_hook(); 89 - #endif 90 - 91 86 /* this will put all memory onto the freelists */ 92 87 totalram_pages = num_physpages = 0; 93 88 for_each_online_pgdat(pgdat) {
+7 -25
arch/sparc/kernel/ioport.c
··· 65 65 } 66 66 #endif 67 67 68 - static struct resource *_sparc_find_resource(struct resource *r, 69 - unsigned long); 70 - 71 68 static void __iomem *_sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz); 72 69 static void __iomem *_sparc_alloc_io(unsigned int busno, unsigned long phys, 73 70 unsigned long size, char *name); ··· 140 143 unsigned long vaddr = (unsigned long) virtual & PAGE_MASK; 141 144 struct resource *res; 142 145 143 - if ((res = _sparc_find_resource(&sparc_iomap, vaddr)) == NULL) { 146 + /* 147 + * XXX Too slow. Can have 8192 DVMA pages on sun4m in the worst case. 148 + * This probably warrants some sort of hashing. 149 + */ 150 + if ((res = lookup_resource(&sparc_iomap, vaddr)) == NULL) { 144 151 printk("free_io/iounmap: cannot free %lx\n", vaddr); 145 152 return; 146 153 } ··· 320 319 struct resource *res; 321 320 struct page *pgv; 322 321 323 - if ((res = _sparc_find_resource(&_sparc_dvma, 322 + if ((res = lookup_resource(&_sparc_dvma, 324 323 (unsigned long)p)) == NULL) { 325 324 printk("sbus_free_consistent: cannot free %p\n", p); 326 325 return; ··· 493 492 { 494 493 struct resource *res; 495 494 496 - if ((res = _sparc_find_resource(&_sparc_dvma, 495 + if ((res = lookup_resource(&_sparc_dvma, 497 496 (unsigned long)p)) == NULL) { 498 497 printk("pci_free_consistent: cannot free %p\n", p); 499 498 return; ··· 715 714 .release = single_release, 716 715 }; 717 716 #endif /* CONFIG_PROC_FS */ 718 - 719 - /* 720 - * This is a version of find_resource and it belongs to kernel/resource.c. 721 - * Until we have agreement with Linus and Martin, it lingers here. 722 - * 723 - * XXX Too slow. Can have 8192 DVMA pages on sun4m in the worst case. 724 - * This probably warrants some sort of hashing. 725 - */ 726 - static struct resource *_sparc_find_resource(struct resource *root, 727 - unsigned long hit) 728 - { 729 - struct resource *tmp; 730 - 731 - for (tmp = root->child; tmp != 0; tmp = tmp->sibling) { 732 - if (tmp->start <= hit && tmp->end >= hit) 733 - return tmp; 734 - } 735 - return NULL; 736 - } 737 717 738 718 static void register_proc_sparc_ioport(void) 739 719 {
+1
include/linux/ioport.h
··· 162 162 resource_size_t, 163 163 resource_size_t), 164 164 void *alignf_data); 165 + struct resource *lookup_resource(struct resource *root, resource_size_t start); 165 166 int adjust_resource(struct resource *res, resource_size_t start, 166 167 resource_size_t size); 167 168 resource_size_t resource_alignment(struct resource *res);
+21
kernel/resource.c
··· 553 553 554 554 EXPORT_SYMBOL(allocate_resource); 555 555 556 + /** 557 + * lookup_resource - find an existing resource by a resource start address 558 + * @root: root resource descriptor 559 + * @start: resource start address 560 + * 561 + * Returns a pointer to the resource if found, NULL otherwise 562 + */ 563 + struct resource *lookup_resource(struct resource *root, resource_size_t start) 564 + { 565 + struct resource *res; 566 + 567 + read_lock(&resource_lock); 568 + for (res = root->child; res; res = res->sibling) { 569 + if (res->start == start) 570 + break; 571 + } 572 + read_unlock(&resource_lock); 573 + 574 + return res; 575 + } 576 + 556 577 /* 557 578 * Insert a resource into the resource tree. If successful, return NULL, 558 579 * otherwise return the conflicting resource (compare to __request_resource())