diff options
| author | Keith Packard <keithp@keithp.com> | 2011-01-06 23:35:31 -0800 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2011-01-06 23:35:31 -0800 | 
| commit | e991f52276248fa08d96fbecc458bc478e98d299 (patch) | |
| tree | 1d2825ddbeb2b8b3efbcf41ea475472ec7983c8f /src | |
| parent | 569a1dac55b70c30f01afa7bcb74442ecdd85d85 (diff) | |
altos: Rip out 'optimization' in ao_log_scan
Remove premature optimization to avoid re-scanning the flight logs for
the best empty entry.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/ao_log.c | 29 | 
1 files changed, 9 insertions, 20 deletions
| diff --git a/src/ao_log.c b/src/ao_log.c index 9ca033e1..00bb46d3 100644 --- a/src/ao_log.c +++ b/src/ao_log.c @@ -234,9 +234,10 @@ ao_log_flight(uint8_t slot)  }  static void -ao_log_scan(void) +ao_log_scan(void) __reentrant  {  	uint8_t		log_slot; +	uint8_t		log_slots;  	uint8_t		log_avail = 0;  	uint16_t	log_flight; @@ -244,7 +245,7 @@ ao_log_scan(void)  	ao_flight_number = 0; -	/* Scan the log space looking for an empty one, and find the biggest flight number */ +	/* Scan the log space looking for the biggest flight number */  	log_slot = 0;  	{  		log_flight = ao_log_flight(log_slot); @@ -256,8 +257,9 @@ ao_log_scan(void)  				ao_flight_number = log_flight;  			}  		} else -			log_avail |= 1 << log_slot; +			log_avail = 1;  	} +	log_slots = log_slot + 1;  	/* Now look through the log of flight numbers from erase operations and  	 * see if the last one is bigger than what we found above @@ -279,25 +281,12 @@ ao_log_scan(void)  	 * that we write logs to each spot about the same number of times.  	 */ -	/* If there are no log slots available, then -	 * do not log the next flight -	 */ -	if (!log_avail) { -		ao_log_current_pos = 0; -		ao_log_end_pos = 0; -	} else { -		log_slot = ao_flight_number % log_slot; -		while (!((log_avail & (1 << log_slot)))) { -			if ((1 << log_slot) > log_avail) -				log_slot = 0; -			else -				log_slot++; -		} -//		ao_log_current_pos = log_slot * ao_config.flight_log_max; -//		ao_log_end_pos = ao_log_current_pos + ao_config.flight_log_max; +	/* Find a log slot for the next flight, if available */ +	if (log_avail) {  		ao_log_current_pos = 0;  		ao_log_end_pos = ao_storage_config; -	} +	} else +		ao_log_current_pos = ao_log_end_pos = 0;  	ao_wakeup(&ao_flight_number);  } | 
