Re: [PATCH v2 1/2] i8k: Autodetect maximal fan speed and fan RPM multiplier

From: Guenter Roeck
Date: Sun Dec 21 2014 - 06:47:53 EST


On 12/21/2014 01:13 AM, Pali RohÃr wrote:
On Saturday 20 December 2014 19:38:32 Guenter Roeck wrote:
+ if (fan_mult <= 0) {

Wonder what to do in the < 0 case. It might be better to make
the variable and the module parameter an unsigned int to
cover that case, since a negative multiplier doesn't really
make sense. Same for fan_max.


In some other kernel modules negative value means autodetect. I
think we can do that too.

But 0 already implies autodetect, so that would be redundant.

+ /*
+ * Autodetect fan multiplier for each fan based on
nominal rpm + * First set default fan multiplier for each
fan + * And if it reports rpm value too high then set
multiplier to 1 + *
+ * Try also setting multiplier from current rpm, but
this
will + * work only in case when fan is not turned off. It
is better + * then nothing for machines which does not
support nominal rpm + * SMM function.
+ */
+ for (fan = 0; fan < ARRAY_SIZE(i8k_fan_mult); ++fan) {
+ i8k_fan_mult[fan] = I8K_FAN_DEFAULT_MULT;
+ if (i8k_get_fan_speed(fan) > I8K_FAN_MAX_RPM) {
+ i8k_fan_mult[fan] = 1;
+ continue;
+ }

What if i8k_get_fan_speed(fan) returns an error ? Doesn't that
imply that the fan does not exist, and that you would not
need the second loop in the first place ?


See my other email "[PATCH] i8k: Add support for fan labels". DOS
binary check for fan presence by another function. I bet it is
because fan could have same problem as temperature sensors. If
fan is on GPU and GPU is turned off reading fan rpm will fail.
But my laptop (with GPU which can be turned on/off) does not have
GPU fan so this is just my assumption.

Good point.

Guenter

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/