 -	opt_avalon2_fan_max = AVA2_PWM_MAX - val2 * AVA2_PWM_MAX / 100;
 +	opt_avalon2_fan_min = get_fan_pwm(val1);
 +	opt_avalon2_fan_max = get_fan_pwm(val2);
-+
-+	return NULL;
-+}
+ 
+ 	return NULL;
+ }
  
 +char *set_avalon2_fixed_speed(enum avalon2_fan_fixed *f)
 +{
 +	*f = FAN_FIXED;
- 	return NULL;
- }
- 
++	return NULL;
++}
++
+ char *set_avalon2_freq(char *arg)
+ {
+ 	int val1, val2, ret;
 @@ -147,12 +158,24 @@ static int avalon2_init_pkg(struct avalon2_pkg *pkg, uint8_t type, uint8_t idx,
  
  static int job_idcmp(uint8_t *job_id, char *pool_job_id)

 
 	return true;
 }
@@ -668,12 +732,25 @@ static int polling(struct thr_info *thr)
 	struct cgpu_info *avalon2 = thr->cgpu;
 	struct avalon2_info *info = avalon2->device_data;
 

 	h = 0;
 	for (i = 0; i < AVA2_DEFAULT_MODULARS; i++) {
-		h += info->local_work[i];
+		h += info->enable[i] ? (info->local_work[i] - info->hw_works[i]) : 0;
 	}
 	return h * 0xffffffff;
 }
@@ -783,18 +915,11 @@ static struct api_data *avalon2_api_stats(struct cgpu_info *cgpu)
 	int i, j, a, b;
 	char buf[24];
 	double hwp;
