[SPARC64]: Simplify read_obp_memory().
Kick out empty entries as soon as we spot them, and use memmove() instead of a silly loop to make the operation more clear. Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
					parent
					
						
							
								d78d0891d3
							
						
					
				
			
			
				commit
				
					
						0015d3d68c
					
				
			
		
					 1 changed files with 11 additions and 16 deletions
				
			
		| 
						 | 
				
			
			@ -122,26 +122,21 @@ static void __init read_obp_memory(const char *property,
 | 
			
		|||
				size = 0UL;
 | 
			
		||||
			base = new_base;
 | 
			
		||||
		}
 | 
			
		||||
		if (size == 0UL) {
 | 
			
		||||
			/* If it is empty, simply get rid of it.
 | 
			
		||||
			 * This simplifies the logic of the other
 | 
			
		||||
			 * functions that process these arrays.
 | 
			
		||||
			 */
 | 
			
		||||
			memmove(®s[i], ®s[i + 1],
 | 
			
		||||
				(ents - i - 1) * sizeof(regs[0]));
 | 
			
		||||
			i--;
 | 
			
		||||
			ents--;
 | 
			
		||||
			continue;
 | 
			
		||||
		}
 | 
			
		||||
		regs[i].phys_addr = base;
 | 
			
		||||
		regs[i].reg_size = size;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < ents; i++) {
 | 
			
		||||
		if (regs[i].reg_size == 0UL) {
 | 
			
		||||
			int j;
 | 
			
		||||
 | 
			
		||||
			for (j = i; j < ents - 1; j++) {
 | 
			
		||||
				regs[j].phys_addr =
 | 
			
		||||
					regs[j+1].phys_addr;
 | 
			
		||||
				regs[j].reg_size =
 | 
			
		||||
					regs[j+1].reg_size;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			ents--;
 | 
			
		||||
			i--;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	*num_ents = ents;
 | 
			
		||||
 | 
			
		||||
	sort(regs, ents, sizeof(struct linux_prom64_registers),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue