public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@suse.cz>
To: Shem Multinymous <multinymous@gmail.com>
Cc: Robert Love <rlove@rlove.org>, Jean Delvare <khali@linux-fr.org>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	linux-kernel@vger.kernel.org, hdaps-devel@lists.sourceforge.net
Subject: Re: [PATCH 01/12] thinkpad_ec: New driver for ThinkPad embedded controller access
Date: Mon, 7 Aug 2006 13:44:41 +0000	[thread overview]
Message-ID: <20060807134440.GD4032@ucw.cz> (raw)
In-Reply-To: <11548492242899-git-send-email-multinymous@gmail.com>

Hi!

> The embedded controller on ThinkPad laptops has a non-standard interface
> at IO ports 0x1600-0x161F (mapped to LCP channel 3 of the H8S chip).
> The interface provides various system management services (currently 
> known: battery information and accelerometer readouts). This driver
> provides access and mutual exclusion for the EC interface.
> 
> The mainline hdaps driver already uses this hardware interface (in an 
> incorrect and unsafe way), and will be converted to use this module in
> the following patches. Another driver using this module, tp_smapi, will 
> be submitted later.
> 
> The Kconfig entry is set to tristate and will be selected by hdaps and
> (eventually) tp_smapi, since thinkpad_ec does nothing by itself.
> 
> Signed-off-by: Shem Multinymous <multinymous@gmail.com>

Signed-off-by: Pavel Machek <pavel@suse.cz>

> +/* Module parameters: */
> +static int tp_debug = 0;

Static variables do not need initializers.

> +module_param_named(debug, tp_debug, int, 0600);
> +MODULE_PARM_DESC(debug, "Debug level (0=off, 1=on)");
> +
> +/* A few macros for printk()ing: */
> +#define DPRINTK(fmt, args...) \
> +  do { if (tp_debug) printk(KERN_DEBUG fmt, ## args); } while (0)

Is not there generic function doing this?

> +/* thinkpad_ec_lock:
> + * Get exclusive lock for accesing the controller. May sleep.
> + * Returns 0 iff lock acquired .
> + */

Linuxdoc?

> +EXPORT_SYMBOL_GPL(thinkpad_ec_lock); 
> +EXPORT_SYMBOL_GPL(thinkpad_ec_try_lock); 
> +void thinkpad_ec_unlock(void) 
> +{
> + 	up(&thinkpad_ec_mutex);
> +}
> +

Do we need these wrappers? Perhaps just directly exporting the mutex?

> +	/* Wait until EC starts writing its reply (~60ns on average).
> +	 * Releasing locks before this happens may cause an EC hang
> +	 * due to firmware bug!
> +	 */
> +	for (i=0; i<TPC_REQUEST_RETRIES; ++i) {

I'd write i++ here (and in other loops)... just for consistency with
rest of kernel.

> +/*** Checking for EC hardware ***/
> +
> +/* thinkpad_ec_test:
> + * Ensure the EC LPC3 channel really works on this machine by making
> + * an arbitrary harmless EC request and seeing if the EC follows protocol.
> + * This test writes to IO ports, so execute only after checking DMI.
> + */
> +static int thinkpad_ec_test(void) {

{ on new line, please.


> +/* Search all DMI device names for a given type for a substrng */
> +static int __init dmi_find_substring(int type, const char *substr) {

same here.

> +	struct dmi_device *dev = NULL;

unneeded initializer.

> +static int __init thinkpad_ec_init(void)
> +{
> +	if (!check_dmi_for_ec()) {
> +		printk(KERN_ERR "thinkpad_ec: no ThinkPad embedded controller!\n");
> +		return -ENODEV;

KERN_ERR is little strong here, no?


> +	if (!request_region(TPC_BASE_PORT, TPC_NUM_PORTS,
> +	                    "thinkpad_ec")) 
> +	{

{ on same line, please.

							Pavel
-- 
Thanks for all the (sleeping) penguins.

  parent reply	other threads:[~2006-08-07 14:13 UTC|newest]

Thread overview: 86+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-06  7:26 [PATCH 00/12] ThinkPad embedded controller and hdaps drivers Shem Multinymous
2006-08-06  7:26 ` [PATCH 01/12] thinkpad_ec: New driver for ThinkPad embedded controller access Shem Multinymous
2006-08-06  7:56   ` Andrew Morton
2006-08-06  9:56     ` Shem Multinymous
2006-08-06 10:07       ` Andrew Morton
2006-08-06 10:44         ` Shem Multinymous
2006-08-06 14:55           ` Theodore Tso
2006-08-06 16:40             ` Olaf Hering
2006-08-06 16:55               ` Willy Tarreau
2006-08-06 18:40               ` Andrew Morton
2006-08-06 22:31                 ` Shem Multinymous
2006-08-06 22:08             ` Shem Multinymous
2006-08-07  0:56               ` [Hdaps-devel] " Shawn Starr
2006-08-07  3:40               ` Theodore Tso
2006-08-06 18:53           ` Arjan van de Ven
2006-08-06 22:41             ` Shem Multinymous
2006-08-06 22:56               ` Greg KH
2006-08-06 23:13               ` Arjan van de Ven
2006-08-07 13:26         ` Pavel Machek
2006-08-07 19:23           ` Andrew Morton
2006-08-07 23:20             ` Pavel Machek
2006-08-07 13:47     ` Pavel Machek
2006-08-07 13:44   ` Pavel Machek [this message]
2006-08-07 15:13     ` Shem Multinymous
2006-08-07 16:27       ` Björn Steinbrink
2006-08-07 16:41         ` Shem Multinymous
2006-08-07 16:54           ` Björn Steinbrink
2006-08-07 23:17             ` Pavel Machek
2006-08-07 23:15       ` Pavel Machek
2006-08-07 23:23         ` Greg KH
2006-08-07 23:25           ` Pavel Machek
2006-08-07 23:29             ` Greg KH
2006-08-07 23:37               ` [PATCH] pr_debug() should not be used in drivers Pavel Machek
2006-08-08  9:44           ` [PATCH 01/12] thinkpad_ec: New driver for ThinkPad embedded controller access Shem Multinymous
2006-08-08  9:23         ` Shem Multinymous
2006-08-08  9:39           ` Pavel Machek
2006-08-07 23:39     ` Randy.Dunlap
2006-08-06  7:26 ` [PATCH 02/12] hdaps: Use thinkpad_ec instead of direct port access Shem Multinymous
2006-08-07 13:55   ` Pavel Machek
2006-08-07 15:40     ` Shem Multinymous
2006-08-07 23:22       ` Pavel Machek
2006-08-06  7:26 ` [PATCH 03/12] hdaps: Unify and cache hdaps readouts Shem Multinymous
2006-08-07 14:02   ` Pavel Machek
2006-08-07 16:14     ` Shem Multinymous
2006-08-07 23:24       ` Pavel Machek
2006-08-08  9:16         ` Shem Multinymous
2006-08-08  9:21           ` Pavel Machek
2006-08-08 10:06             ` Shem Multinymous
2006-08-08 10:09               ` Pavel Machek
2006-08-06  7:26 ` [PATCH 04/12] hdaps: Correct readout and remove nonsensical attributes Shem Multinymous
2006-08-07 14:07   ` Pavel Machek
2006-08-07 16:30     ` Shem Multinymous
2006-08-07 18:20       ` Björn Steinbrink
2006-08-07 23:30         ` timeout nonsense [was Re: [PATCH 04/12] hdaps: Correct readout and remove nonsensical attributes] Pavel Machek
2006-08-08 12:22         ` [PATCH 04/12] hdaps: Correct readout and remove nonsensical attributes Muli Ben-Yehuda
2006-08-08 12:56           ` Pavel Machek
2006-08-08 13:17             ` Muli Ben-Yehuda
2006-08-08 13:35               ` Shem Multinymous
2006-08-08 13:43                 ` Muli Ben-Yehuda
2006-08-08 14:53                   ` Shem Multinymous
2006-08-08 15:19                     ` Alan Cox
2006-08-08 15:33                       ` Shem Multinymous
2006-08-09  3:44                         ` Muli Ben-Yehuda
2006-08-09  9:02                           ` Shem Multinymous
2006-08-09  9:56                             ` Muli Ben-Yehuda
2006-08-07 23:26       ` Pavel Machek
2006-08-06  7:26 ` [PATCH 05/12] hdaps: Remember keyboard and mouse activity Shem Multinymous
2006-08-07 14:11   ` Pavel Machek
2006-08-07 16:19     ` Shem Multinymous
2006-08-06  7:26 ` [PATCH 06/12] hdaps: Limit hardware query rate Shem Multinymous
2006-08-08 12:08   ` Pavel Machek
2006-08-06  7:26 ` [PATCH 07/12] hdaps: delay calibration to first hardware query Shem Multinymous
2006-08-08 12:10   ` Pavel Machek
2006-08-06  7:26 ` [PATCH 08/12] hdaps: Add explicit hardware configuration functions Shem Multinymous
2006-08-08 12:16   ` Pavel Machek
2006-08-08 13:17     ` Shem Multinymous
2006-08-06  7:26 ` [PATCH 09/12] hdaps: Add new sysfs attributes Shem Multinymous
2006-08-08 12:19   ` Pavel Machek
2006-08-06  7:26 ` [PATCH 10/12] hdaps: Power off accelerometer on suspend and unload Shem Multinymous
2006-08-08 12:45   ` Pavel Machek
2006-08-08 13:28     ` Shem Multinymous
2006-08-06  7:26 ` [PATCH 11/12] hdaps: Stop polling timer when suspended Shem Multinymous
2006-08-08 12:46   ` Pavel Machek
2006-08-06  7:26 ` [PATCH 12/12] hdaps: Simplify whitelist Shem Multinymous
2006-08-08 12:47   ` Pavel Machek
  -- strict thread matches above, loose matches on Subject: below --
2006-08-10  9:48 [PATCH 00/12] ThinkPad embedded controller and hdaps drivers (version 2) Shem Multinymous
2006-08-10  9:48 ` [PATCH 01/12] thinkpad_ec: New driver for ThinkPad embedded controller access Shem Multinymous

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060807134440.GD4032@ucw.cz \
    --to=pavel@suse.cz \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=gregkh@suse.de \
    --cc=hdaps-devel@lists.sourceforge.net \
    --cc=khali@linux-fr.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=multinymous@gmail.com \
    --cc=rlove@rlove.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox