* if CPU is heating and GPU/power is not */ 
* if sensor1 is heating and sensor2 is not */ 
static void update_fans_speed (struct thermostat *th){	int lastvar = 0; /* last variation, for iBook */	int i = 0;	/* we don't care about local sensor, so we start at sensor 1 */	for (i = 1; i < 3; i++) {		int started = 0;		int fan_number = (therm_type == ADT7460 && i == 2);		int var = th->temps[i] - th->limits[i];		if (var > -1) {			int step = (255 - fan_speed) / 7;			int new_speed = 0;			/* hysteresis : change fan speed only if variation is			 * more than two degrees */			if (abs(var - th->last_var[fan_number]) < 2)				continue;			started = 1;			new_speed = fan_speed + ((var-1)*step);			if (new_speed < fan_speed)				new_speed = fan_speed;			if (new_speed > 255)				new_speed = 255;			printk(KERN_DEBUG "adt746x: setting fans speed to %d "					 "(limit exceeded by %d on %s) \n",					new_speed, var,					fan_number?"GPU/pwr":"CPU");			write_both_fan_speed(th, new_speed);			th->last_var[fan_number] = var;		} else if (var < -2) {			/* don't stop fan if GPU/power is cold and CPU is not			 * so cold (lastvar >= -1) */			if (i == 2 && lastvar < -1) {				if (th->last_speed[fan_number] != 0)					printk(KERN_DEBUG "adt746x: Stopping "						"fans.\n");				write_both_fan_speed(th, 0);			}		}		lastvar = var;		if (started)			return; /* we don't want to re-stop the fan				* if CPU is heating and GPU/power is not */	}}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/d20c507f28dbee33086e8212b98f9ddc5372cd81/therm_adt746x.c/clean/drivers/macintosh/therm_adt746x.c