Re: [PATCH] Acer Aspire One Fan Control

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Borislav Petkov
Date: Sunday, May 24, 2009 - 12:22 pm

Hi,

On Mon, May 18, 2009 at 08:04:40PM +0200, Peter Feuerer wrote:



There's an excellent manual explaining all that at length:
<Documentation/development-process/> and especially
<Documentation/development-process/5.Posting> and
<Documentation/SubmittingPatches, Section 14> which answers the
particular question you have. I could try to rephrase that here but
those documents explain it much better and extensively than I could.


Ok, minor nitpicks below but it starting to shape up quite ok. You could
send it for inclusion upstream.

Reviewed-by: Borislav Petkov <petkovbb@gmail.com>
Tested-by: Borislav Petkov <petkovbb@gmail.com>


				    the BIOS is still in control of the fan

is better english, IMHO.


s/kernelmodule/driver/


s/kernelmode/kernel mode/g


* define the following:
*/
#undef START_IN_KERNEL_MODE

is better


let's make all those module parameters unsigned just in case because you
can write negative values to them and acerhdf_check_param() won't catch
invalid values:

diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c
index 99ae2e6..d4fc5d3 100644
--- a/drivers/platform/x86/acerhdf.c
+++ b/drivers/platform/x86/acerhdf.c
@@ -83,32 +83,32 @@
 
 
 #ifdef START_IN_KERNEL_MODE
-static int kernelmode = 1;
+static unsigned int kernelmode = 1;
 #else
-static int kernelmode;
+static unsigned int kernelmode;
 #endif
 
-static int interval = 10;
-static int fanon = 65;
-static int fanoff = 60;
-static int verbose;
-static int fanstate = ACERHDF_FAN_AUTO;
+static unsigned int interval = 10;
+static unsigned int fanon = 65;
+static unsigned int fanoff = 60;
+static unsigned int verbose;
+static unsigned int fanstate = ACERHDF_FAN_AUTO;
 static int disable_kernelmode;
 static int bios_version = -1;
 static char force_bios[16];
-static int prev_interval;
+static unsigned int prev_interval;
 struct thermal_zone_device *acerhdf_thz_dev;
 struct thermal_cooling_device *acerhdf_cool_dev;
 
-module_param(kernelmode, int, 0);
+module_param(kernelmode, uint, 0);
 MODULE_PARM_DESC(kernelmode, "Kernel mode on / off");
-module_param(interval, int, 0600);
+module_param(interval, uint, 0600);
 MODULE_PARM_DESC(interval, "Polling interval of temperature check");
-module_param(fanon, int, 0600);
+module_param(fanon, uint, 0600);
 MODULE_PARM_DESC(fanon, "Turn the fan on above this temperature");
-module_param(fanoff, int, 0600);
+module_param(fanoff, uint, 0600);
 MODULE_PARM_DESC(fanoff, "Turn the fan off below this temperature");
-module_param(verbose, int, 0600);
+module_param(verbose, uint, 0600);
 MODULE_PARM_DESC(verbose, "Enable verbose dmesg outputs");
 module_param_string(force_bios, force_bios, 16, 0);
 MODULE_PARM_DESC(force_bios, "Force BIOS version and omit BIOS check");


s/outputs/output/


you need to check the error status here before printing the temperature
since it might be invalid if the ec_read has failed:

	u8 temp;
	int err;

	err = ec_read(bios_settings[bios_version].tempreg, &temp);

	if (err)
		return ACERHDF_ERROR;

	if (verbose)
		acerhdf_notice("temp %d\n", temp);

	return temp;
}


need a new line here.


you can save an indentation level here by exiting early:

	if (cdev != acerhdf_cool_dev)
		return 0;

	if (thermal_zone_bind_cooling_device(thermal, 0, cdev)) {
		acerhdf_error("error binding cooling dev\n");
		return -EINVAL;
	}

	return 0;
}


same as above.


s/kernelmode/kernel mode/


ditto.


ditto.


well, this variable should be called current_state or similar but not
old since it is written through acerhdf_get_fanstate(), which returns
the current state.


s/kernelmode/kernel mode/


it might be cool to tell the user why you're not turning off the fan.

		if (verbose)
			acerhdf_notice("Not turning off fan due to current temp "
				       "exceeding fanoff value\n");


let's split that line:

	acerhdf_notice("version %s\n", VERSION);
	acerhdf_notice("BIOS vendor: \"%s\", version: \"%s\"\n",
		       vendor, version);


s/Fancontrol/Fan control/


let's make that function even one more readable:

static int __init acerhdf_init(void)
{

	if (acerhdf_check_hardware() == ACERHDF_ERROR)
		goto err;

	if (acerhdf_register_thermal() == ACERHDF_ERROR)
		goto err_unreg;

	return 0;

err_unreg:
	acerhdf_unregister_thermal();

err:
	return -EINVAL;
}


no need for that comment


-- 
Regards/Gruss,
    Boris.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Fri Apr 24, 6:45 pm)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Sat Apr 25, 1:42 am)
Re: [PATCH] Acer Aspire One Fan Control, Matthew Garrett, (Sun Apr 26, 8:31 am)
Re: [PATCH] Acer Aspire One Fan Control, Borislav Petkov, (Sun Apr 26, 10:29 am)
Re: [PATCH] Acer Aspire One Fan Control, Joe Perches, (Sun Apr 26, 3:20 pm)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Mon Apr 27, 11:25 am)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Mon Apr 27, 11:57 am)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Mon Apr 27, 12:03 pm)
Re: [PATCH] Acer Aspire One Fan Control, Borislav Petkov, (Tue Apr 28, 12:25 am)
Re: [PATCH] Acer Aspire One Fan Control, Maxim Levitsky, (Tue Apr 28, 3:04 am)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Tue Apr 28, 1:17 pm)
Re: [PATCH] Acer Aspire One Fan Control, Maxim Levitsky, (Tue Apr 28, 1:31 pm)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Sat May 2, 2:21 pm)
Re: [PATCH] Acer Aspire One Fan Control, Borislav Petkov, (Sun May 3, 11:46 am)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Wed May 6, 12:41 pm)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Wed May 6, 3:17 pm)
Re: [PATCH] Acer Aspire One Fan Control, Borislav Petkov, (Sat May 9, 10:14 am)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Mon May 11, 11:05 am)
Re: [PATCH] Acer Aspire One Fan Control, Borislav Petkov, (Mon May 11, 11:02 pm)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Mon May 18, 11:04 am)
Re: [PATCH] Acer Aspire One Fan Control, Joe Perches, (Mon May 18, 1:20 pm)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Mon May 18, 11:47 pm)
Re: [PATCH] Acer Aspire One Fan Control, Joe Perches, (Tue May 19, 12:06 am)
Re: [PATCH] Acer Aspire One Fan Control, Pavel Machek, (Tue May 19, 1:30 pm)
Re: [PATCH] Acer Aspire One Fan Control, Borislav Petkov, (Fri May 22, 4:50 am)
Re: [PATCH] Acer Aspire One Fan Control, Pavel Machek, (Fri May 22, 7:09 am)
Re: [PATCH] Acer Aspire One Fan Control, Borislav Petkov, (Fri May 22, 7:53 am)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Sun May 24, 4:13 am)
Re: [PATCH] Acer Aspire One Fan Control, Borislav Petkov, (Sun May 24, 12:22 pm)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Mon Jun 1, 7:12 am)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Mon Jun 1, 7:18 am)
Re: [PATCH] Acer Aspire One Fan Control, Borislav Petkov, (Wed Jun 3, 12:35 am)
Re: [PATCH] Acer Aspire One Fan Control, Borislav Petkov, (Wed Jun 3, 12:39 am)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Wed Jun 3, 12:52 am)
Re: [PATCH] Acer Aspire One Fan Control, Borislav Petkov, (Wed Jun 3, 1:00 am)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Wed Jun 3, 1:10 am)
Re: [PATCH] Acer Aspire One Fan Control, Borislav Petkov, (Wed Jun 3, 3:52 am)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Wed Jun 3, 4:29 am)
Re: [PATCH] Acer Aspire One Fan Control, Peter Feuerer, (Wed Jun 3, 6:07 am)
Re: [PATCH] Acer Aspire One Fan Control, Borislav Petkov, (Wed Jun 3, 7:49 am)