Skip to contentSkip to conversation

ACPI patches for 2.6.22 merge window

PATCH In review Len Brown 4 participants 89 messages Apr 29, 2007 – May 10, 2007 21 messages not in the archive Page 2 of 2

Subsystems (7)
lore
Share & tools
lore
author
#81 lore raw

PATCH 81/105 ACPI: word-smith kconfig help

In reply to Len Brown

From: Borislav Petkov <[email protected]>

---
 drivers/acpi/Kconfig |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/acpi/Kconfig +2 -2
index e2ce4a9..2a18d4c 100644
@@ -85,8 +85,8 @@ config ACPI_PROCFS
 	depends on ACPI
 	default y
 	---help---
-	  Procfs interface for ACPI is made optional for back-compatible.
-	  As the same functions are duplicated in sysfs interface
+	  The Procfs interface for ACPI is made optional for backward compatibility.
+	  As the same functions are duplicated in the sysfs interface
 	  and this proc interface will be removed some time later,
 	  it's marked as deprecated.
 	  ( /proc/acpi/debug_layer && debug_level are deprecated by
Signature · 1 line
1.5.2.rc0.34.gda94
author
#82 lore raw

PATCH 82/105 ACPI: make /proc/acpi/wakeup more useful

From: David Brownell <[email protected]>

This updates /proc/acpi/wakeup to be more informative, primarily by showing the sysfs node associated with each wakeup-enabled device. Example:

	Device	S-state	  Status   Sysfs node
	PCI0	  S4	 disabled  no-bus:pci0000:00
	PS2M	  S4	 disabled  pnp:00:05
	PS2K	  S4	 disabled  pnp:00:06
	UAR1	  S4	 disabled  pnp:00:08
	USB1	  S3	 disabled  pci:0000:00:03.0
	USB2	  S3	 disabled  pci:0000:00:03.1
	USB3	  S3	 disabled
	USB4	  S3	 disabled  pci:0000:00:03.3
	S139	  S4	 disabled
	LAN	  S4	 disabled  pci:0000:00:04.0
	MDM	  S4	 disabled
	AUD	  S4	 disabled  pci:0000:00:02.7
	SLPB	  S4	*enabled

Eventually this file should be removed, but until then it's almost the only way we have to tell how the relevant ACPI tables are broken (and cope). In that example, two devices don't actually exist (USB3, S139), one can't issue wakeup events (PCI0), and two seem harmlessly (?) confused (MDM and AUD are the same PCI device, but it's the _modem_ that does wake-on-ring).

In particular, we need to be sure driver model nodes are properly hooked up before we can get rid of this ACPI-only interface for wakeup events.

---
 drivers/acpi/sleep/proc.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
drivers/acpi/sleep/proc.c +13 -3
index ccc11b3..2d912b7 100644
@@ -350,21 +350,31 @@ acpi_system_wakeup_device_seq_show(struct seq_file *seq, void *offset)
 {
 	struct list_head *node, *next;
 
-	seq_printf(seq, "Device	Sleep state	Status\n");
+	seq_printf(seq, "Device\tS-state\t  Status   Sysfs node\n");
 
 	spin_lock(&acpi_device_lock);
 	list_for_each_safe(node, next, &acpi_wakeup_device_list) {
 		struct acpi_device *dev =
 		    container_of(node, struct acpi_device, wakeup_list);
+		struct device *ldev;
 
 		if (!dev->wakeup.flags.valid)
 			continue;
 		spin_unlock(&acpi_device_lock);
-		seq_printf(seq, "%4s	%4d		%s%8s\n",
+
+		ldev = acpi_get_physical_device(dev->handle);
+		seq_printf(seq, "%s\t  S%d\t%c%-8s  ",
 			   dev->pnp.bus_id,
 			   (u32) dev->wakeup.sleep_state,
-			   dev->wakeup.flags.run_wake ? "*" : "",
+			   dev->wakeup.flags.run_wake ? '*' : ' ',
 			   dev->wakeup.state.enabled ? "enabled" : "disabled");
+		if (ldev)
+			seq_printf(seq, "%s:%s",
+				ldev->bus ? ldev->bus->name : "no-bus",
+				ldev->bus_id);
+		seq_printf(seq, "\n");
+		put_device(ldev);
+
 		spin_lock(&acpi_device_lock);
 	}
 	spin_unlock(&acpi_device_lock);
Signature · 1 line
1.5.2.rc0.34.gda94
author
#83 lore raw

PATCH 83/105 ACPI: prevent ACPI quirk warning mass spamming in logs

From: Thierry Vignaud <[email protected]>

The following patch prevent this warning to be displayed again & again (eg:
nine times on my NForce2 motherboard) and thus improve signal to noise ratio in logs.

The ATI quirk below probably needs a similar "fix" but I don't have the hardware to test.

Btw arch/x86_64/kernel/early-quirks.c::nvidia_bugs() would probably need to be synced (but I don't have an x86_64 NVidia motherboard to boot test it). Still it shows the usefullity of the recent x86 merge thread.

---
 arch/i386/kernel/acpi/earlyquirk.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
arch/i386/kernel/acpi/earlyquirk.c +4 -1
index a7d22d9..fa3255a 100644
@@ -22,11 +22,14 @@ static int __init nvidia_hpet_check(struct acpi_table_header *header)
 
 static int __init check_bridge(int vendor, int device)
 {
+	static int warned;
 #ifdef CONFIG_ACPI
 	/* According to Nvidia all timer overrides are bogus unless HPET
 	   is enabled. */
 	if (!acpi_use_timer_override && vendor == PCI_VENDOR_ID_NVIDIA) {
-		if (acpi_table_parse(ACPI_SIG_HPET, nvidia_hpet_check)) {
+		if (!warned && acpi_table_parse(ACPI_SIG_HPET,
+						nvidia_hpet_check)) {
+			warned = 1;
 			acpi_skip_timer_override = 1;
 			  printk(KERN_INFO "Nvidia board "
                        "detected. Ignoring ACPI "
Signature · 1 line
1.5.2.rc0.34.gda94
author
#84 lore raw

PATCH 84/105 ACPI: Remove a warning about unused variable in !CONFIG_ACPI compilation.

From: Zachary Amsden <[email protected]>

---
 arch/i386/kernel/acpi/earlyquirk.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/i386/kernel/acpi/earlyquirk.c +1 -1
index fa3255a..8f7efd3 100644
@@ -22,8 +22,8 @@ static int __init nvidia_hpet_check(struct acpi_table_header *header)
 
 static int __init check_bridge(int vendor, int device)
 {
-	static int warned;
 #ifdef CONFIG_ACPI
+	static int warned;
 	/* According to Nvidia all timer overrides are bogus unless HPET
 	   is enabled. */
 	if (!acpi_use_timer_override && vendor == PCI_VENDOR_ID_NVIDIA) {
Signature · 1 line
1.5.2.rc0.34.gda94
author
#85 lore raw

PATCH 85/105 ACPICA: clear fields reserved before FADT r3

From: Bob Moore <[email protected]>

Linux-2.6.21 stopped booting on a P4/HT because Linux wrote the FADT.CST_CNT value to the SMI_CMD. Apparently this stumbled over some SMM instability, such as confusing SMM when invoking it from cpu1.

Linux did this because even though the r2 FADT reserves the CST_CNT field, this BIOS set that field and Linux used it.

Turns out that up through 2.6.20 we explicitly cleared cst_control for r2 FADTs. So here we go back to doing that, plus also clear some additional fields that are reserved until FADT r3.

http://bugzilla.kernel.org/show_bug.cgi?id=8346

---
 drivers/acpi/tables/tbfadt.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
drivers/acpi/tables/tbfadt.c +12 -0
index 807c711..1db833e 100644
@@ -347,6 +347,18 @@ static void acpi_tb_convert_fadt(void)
 		acpi_gbl_xpm1b_enable.space_id = acpi_gbl_FADT.xpm1a_event_block.space_id;
 
 	}
+
+	/*
+	 * For ACPI 1.0 FADTs, ensure that reserved fields (which should be zero)
+	 * are indeed zero. This will workaround BIOSs that inadvertently placed
+	 * values in these fields.
+	 */
+	if (acpi_gbl_FADT.header.revision < 3) {
+		acpi_gbl_FADT.preferred_profile = 0;
+		acpi_gbl_FADT.pstate_control = 0;
+		acpi_gbl_FADT.cst_control = 0;
+		acpi_gbl_FADT.boot_flags = 0;
+	}
 }
 
 /******************************************************************************
Signature · 1 line
1.5.2.rc0.34.gda94
author
#86 lore raw

PATCH 86/105 ACPI: thinkpad-acpi: add a fan-control feature master toggle

From: Henrique de Moraes Holschuh <[email protected]>

Len Brown considers that an active by default fan control interface in laptops may be too close to giving users enough rope. There is a good chance he is quite correct on this, especially if someone decides to use that interface in applets and users are not aware of its risks.

This patch adds a master switch to thinkpad-acpi that enables or disables the entire fan-control feature as a module parameter: "fan_control". It defaults to disabled. Set it to non-zero to enable fan control.

Also, the patch removes the expermiental status from fan control, since it is stable enough to not be called experimental, and the master switch makes it safe enough to do so.

---
 Documentation/thinkpad-acpi.txt |   15 +++++++--------
 drivers/misc/thinkpad_acpi.c    |   30 +++++++++++++++++++++++++++++-
 drivers/misc/thinkpad_acpi.h    |    2 ++
 3 files changed, 38 insertions(+), 9 deletions(-)
Documentation/thinkpad-acpi.txt +7 -8
index eab4997..bca50d7 100644
@@ -38,7 +38,7 @@ detailed description):
 	- Experimental: embedded controller register dump
 	- LCD brightness control
 	- Volume control
-	- Experimental: fan speed, fan enable/disable
+	- Fan control and monitoring: fan speed, fan enable/disable
 	- Experimental: WAN enable and disable
 
 A compatibility table by model and feature is maintained on the web
@@ -681,21 +681,20 @@ distinct. The unmute the volume after the mute command, use either the
 up or down command (the level command will not unmute the volume).
 The current volume level and mute state is shown in the file.
 
-EXPERIMENTAL: fan speed, fan enable/disable
--------------------------------------------
+Fan control and monitoring: fan speed, fan enable/disable
+---------------------------------------------------------
 
 procfs: /proc/acpi/ibm/fan
 sysfs device attributes: (hwmon) fan_input, pwm1, pwm1_enable
 
-This feature is marked EXPERIMENTAL because the implementation
-directly accesses hardware registers and may not work as expected. USE
-WITH CAUTION! To use this feature, you need to supply the
-experimental=1 parameter when loading the module.
+NOTE NOTE NOTE: fan control operations are disabled by default for
+safety reasons.  To enable them, the module parameter "fan_control=1"
+must be given to thinkpad-acpi.
 
 This feature attempts to show the current fan speed, control mode and
 other fan data that might be available.  The speed is read directly
 from the hardware registers of the embedded controller.  This is known
-to work on later R, T and X series ThinkPads but may show a bogus
+to work on later R, T, X and Z series ThinkPads but may show a bogus
 value on other models.
 
 Fan levels:
drivers/misc/thinkpad_acpi.c +29 -1
index c0a023c..7dc3a22 100644
@@ -2935,6 +2935,9 @@ static ssize_t fan_fan_watchdog_store(struct device_driver *drv,
 	if (parse_strtoul(buf, 120, &t))
 		return -EINVAL;
 
+	if (!fan_control_allowed)
+		return -EPERM;
+
 	fan_watchdog_maxinterval = t;
 	fan_watchdog_reset();
 
@@ -3046,6 +3049,14 @@ static int __init fan_init(struct ibm_init_struct *iibm)
 		  fan_control_access_mode != TPACPI_FAN_WR_NONE),
 		fan_status_access_mode, fan_control_access_mode);
 
+	/* fan control master switch */
+	if (!fan_control_allowed) {
+		fan_control_access_mode = TPACPI_FAN_WR_NONE;
+		fan_control_commands = 0;
+		dbg_printk(TPACPI_DBG_INIT,
+			   "fan control features disabled by parameter\n");
+	}
+
 	/* update fan_control_desired_level */
 	if (fan_status_access_mode != TPACPI_FAN_NONE)
 		fan_get_status_safe(NULL);
@@ -3203,6 +3214,9 @@ static void fan_watchdog_reset(void)
 
 static int fan_set_level(int level)
 {
+	if (!fan_control_allowed)
+		return -EPERM;
+
 	switch (fan_control_access_mode) {
 	case TPACPI_FAN_WR_ACPI_SFAN:
 		if (level >= 0 && level <= 7) {
@@ -3242,6 +3256,9 @@ static int fan_set_level_safe(int level)
 {
 	int rc;
 
+	if (!fan_control_allowed)
+		return -EPERM;
+
 	rc = mutex_lock_interruptible(&fan_mutex);
 	if (rc < 0)
 		return rc;
@@ -3262,6 +3279,9 @@ static int fan_set_enable(void)
 	u8 s;
 	int rc;
 
+	if (!fan_control_allowed)
+		return -EPERM;
+
 	rc = mutex_lock_interruptible(&fan_mutex);
 	if (rc < 0)
 		return rc;
@@ -3315,6 +3335,9 @@ static int fan_set_disable(void)
 {
 	int rc;
 
+	if (!fan_control_allowed)
+		return -EPERM;
+
 	rc = mutex_lock_interruptible(&fan_mutex);
 	if (rc < 0)
 		return rc;
@@ -3351,6 +3374,9 @@ static int fan_set_speed(int speed)
 {
 	int rc;
 
+	if (!fan_control_allowed)
+		return -EPERM;
+
 	rc = mutex_lock_interruptible(&fan_mutex);
 	if (rc < 0)
 		return rc;
@@ -3558,7 +3584,6 @@ static struct ibm_struct fan_driver_data = {
 	.read = fan_read,
 	.write = fan_write,
 	.exit = fan_exit,
-	.flags.experimental = 1,
 };
 
 /****************************************************************************
@@ -3879,6 +3904,9 @@ module_param_named(debug, dbg_level, uint, 0);
 static int force_load;
 module_param(force_load, int, 0);
 
+static int fan_control_allowed;
+module_param_named(fan_control, fan_control_allowed, int, 0);
+
 #define IBM_PARAM(feature) \
 	module_param_call(feature, set_ibm_param, NULL, NULL, 0)
 
drivers/misc/thinkpad_acpi.h +2 -0
index 8348fc6..a9e7093 100644
@@ -375,6 +375,8 @@ enum fan_control_commands {
 						 * and also watchdog cmd */
 };
 
+static int fan_control_allowed;
+
 static enum fan_status_access_mode fan_status_access_mode;
 static enum fan_control_access_mode fan_control_access_mode;
 static enum fan_control_commands fan_control_commands;
Signature · 1 line
1.5.2.rc0.34.gda94
author
#87 lore raw

PATCH 87/105 ACPI: thinkpad-acpi: do not arm fan watchdog if it would not work

From: Henrique de Moraes Holschuh <[email protected]>

Do not enable/rearm the fan control safety watchdog if we would not be able to do anything to the fan anyway.

---
 drivers/misc/thinkpad_acpi.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/misc/thinkpad_acpi.c +3 -0
index 7dc3a22..f824259 100644
@@ -3197,6 +3197,9 @@ static void fan_watchdog_reset(void)
 {
 	static int fan_watchdog_active = 0;
 
+	if (fan_control_access_mode == TPACPI_FAN_WR_NONE)
+		return;
+
 	if (fan_watchdog_active)
 		cancel_delayed_work(&fan_watchdog_task);
 
Signature · 1 line
1.5.2.rc0.34.gda94
author
#88 lore raw

PATCH 88/105 ACPI: thinkpad-acpi: fix a fan watchdog invocation

From: Henrique de Moraes Holschuh <[email protected]>

The fan control watchdog was being called in one place even when the fan control operation had failed. Fix it.

---
 drivers/misc/thinkpad_acpi.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/misc/thinkpad_acpi.c +3 -2
index f824259..b85f096 100644
@@ -2888,9 +2888,10 @@ static ssize_t fan_pwm1_store(struct device *dev,
 	if (!rc && (status &
 		    (TP_EC_FAN_AUTO | TP_EC_FAN_FULLSPEED)) == 0) {
 		rc = fan_set_level(newlevel);
-		if (!rc)
+		if (!rc) {
 			fan_update_desired_level(newlevel);
-		fan_watchdog_reset();
+			fan_watchdog_reset();
+		}
 	}
 
 	mutex_unlock(&fan_mutex);
Signature · 1 line
1.5.2.rc0.34.gda94
author
#89 lore raw

PATCH 89/105 ACPI: thinkpad-acpi: map ENXIO to EINVAL for fan sysfs

From: Henrique de Moraes Holschuh <[email protected]>

Currently, all fan control operations return ENXIO if unsupported operations are requested, but return EINVAL if invalid fan modes are requested on a given ThinkPad.

This is not strictly correct for sysfs, so map ENXIO to EINVAL in the sysfs attribute store handlers, as we do benefit from the ENXIO in other parts of the driver code.

---
 drivers/misc/thinkpad_acpi.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/misc/thinkpad_acpi.c +6 -2
index b85f096..7aed118 100644
@@ -2824,7 +2824,9 @@ static ssize_t fan_pwm1_enable_store(struct device *dev,
 	}
 
 	res = fan_set_level_safe(level);
-	if (res < 0)
+	if (res == -ENXIO)
+		return -EINVAL;
+	else if (res < 0)
 		return res;
 
 	fan_watchdog_reset();
@@ -2888,7 +2890,9 @@ static ssize_t fan_pwm1_store(struct device *dev,
 	if (!rc && (status &
 		    (TP_EC_FAN_AUTO | TP_EC_FAN_FULLSPEED)) == 0) {
 		rc = fan_set_level(newlevel);
-		if (!rc) {
+		if (rc == -ENXIO)
+			rc = -EINVAL;
+		else if (!rc) {
 			fan_update_desired_level(newlevel);
 			fan_watchdog_reset();
 		}
Signature · 1 line
1.5.2.rc0.34.gda94
author
#90 lore raw

PATCH 90/105 ACPI: thinkpad-acpi: improve fan control documentation

From: Henrique de Moraes Holschuh <[email protected]>

Improve fan control documentation and fix one mistake.

---
 Documentation/thinkpad-acpi.txt |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
Documentation/thinkpad-acpi.txt +13 -5
index bca50d7..e3ad7a4 100644
@@ -795,15 +795,23 @@ Sysfs notes:
 The sysfs interface follows the hwmon subsystem guidelines for the most
 part, and the exception is the fan safety watchdog.
 
+Writes to any of the sysfs attributes may return the EINVAL error if
+that operation is not supported in a given ThinkPad or if the parameter
+is out-of-bounds, and EPERM if it is forbidden.  They may also return
+EINTR (interrupted system call), and EIO (I/O error while trying to talk
+to the firmware).
+
+Features not yet implemented by the driver return ENOSYS.
+
 hwmon device attribute pwm1_enable:
 	0: PWM offline (fan is set to full-speed mode)
 	1: Manual PWM control (use pwm1 to set fan level)
 	2: Hardware PWM control (EC "auto" mode)
 	3: reserved (Software PWM control, not implemented yet)
 
-	Modes 0 and 2 are not supported by all ThinkPads, and the driver
-	is not always able to detect this.  If it does know a mode is
-	unsupported, it will return -EINVAL.
+	Modes 0 and 2 are not supported by all ThinkPads, and the
+	driver is not always able to detect this.  If it does know a
+	mode is unsupported, it will return -EINVAL.
 
 hwmon device attribute pwm1:
 	Fan level, scaled from the firmware values of 0-7 to the hwmon
@@ -826,8 +834,8 @@ driver attribute fan_watchdog:
 To stop the fan: set pwm1 to zero, and pwm1_enable to 1.
 
 To start the fan in a safe mode: set pwm1_enable to 2.  If that fails
-with ENOTSUP, set it to 1 and set pwm1 to at least 128 (255 would be the
-safest choice, though).
+with EINVAL, try to set pwm1_enable to 1 and pwm1 to at least 128 (255
+would be the safest choice, though).
 
 
 EXPERIMENTAL: WAN -- /proc/acpi/ibm/wan
Signature · 1 line
1.5.2.rc0.34.gda94
author
#91 lore raw

PATCH 91/105 ACPI: thinkpad-acpi: improve debugging for acpi helpers

From: Henrique de Moraes Holschuh <[email protected]>

Some issues with the dock subdriver proved that a slightly improved debugging setup for ACPI notifiers and handler helpers would be useful.

---
 drivers/misc/thinkpad_acpi.c |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)
drivers/misc/thinkpad_acpi.c +20 -11
index 7aed118..68f1cc0 100644
@@ -296,14 +296,22 @@ static void drv_acpi_handle_init(char *name,
 	int i;
 	acpi_status status;
 
+	vdbg_printk(TPACPI_DBG_INIT, "trying to locate ACPI handle for %s\n",
+		name);
+
 	for (i = 0; i < num_paths; i++) {
 		status = acpi_get_handle(parent, paths[i], handle);
 		if (ACPI_SUCCESS(status)) {
 			*path = paths[i];
+			dbg_printk(TPACPI_DBG_INIT,
+				   "Found ACPI handle %s for %s\n",
+				   *path, name);
 			return;
 		}
 	}
 
+	vdbg_printk(TPACPI_DBG_INIT, "ACPI handle for %s not found\n",
+		    name);
 	*handle = NULL;
 }
 
@@ -320,19 +328,20 @@ static void dispatch_acpi_notify(acpi_handle handle, u32 event, void *data)
 static int __init setup_acpi_notify(struct ibm_struct *ibm)
 {
 	acpi_status status;
-	int ret;
+	int rc;
 
 	BUG_ON(!ibm->acpi);
 
 	if (!*ibm->acpi->handle)
 		return 0;
 
-	dbg_printk(TPACPI_DBG_INIT,
+	vdbg_printk(TPACPI_DBG_INIT,
 		"setting up ACPI notify for %s\n", ibm->name);
 
-	ret = acpi_bus_get_device(*ibm->acpi->handle, &ibm->acpi->device);
-	if (ret < 0) {
-		printk(IBM_ERR "%s device not present\n", ibm->name);
+	rc = acpi_bus_get_device(*ibm->acpi->handle, &ibm->acpi->device);
+	if (rc < 0) {
+		printk(IBM_ERR "acpi_bus_get_device(%s) failed: %d\n",
+			ibm->name, rc);
 		return -ENODEV;
 	}
 
@@ -364,7 +373,7 @@ static int __init tpacpi_device_add(struct acpi_device *device)
 
 static int __init register_tpacpi_subdriver(struct ibm_struct *ibm)
 {
-	int ret;
+	int rc;
 
 	dbg_printk(TPACPI_DBG_INIT,
 		"registering %s as an ACPI driver\n", ibm->name);
@@ -381,16 +390,16 @@ static int __init register_tpacpi_subdriver(struct ibm_struct *ibm)
 	ibm->acpi->driver->ids = ibm->acpi->hid;
 	ibm->acpi->driver->ops.add = &tpacpi_device_add;
 
-	ret = acpi_bus_register_driver(ibm->acpi->driver);
-	if (ret < 0) {
+	rc = acpi_bus_register_driver(ibm->acpi->driver);
+	if (rc < 0) {
 		printk(IBM_ERR "acpi_bus_register_driver(%s) failed: %d\n",
-		       ibm->acpi->hid, ret);
+		       ibm->acpi->hid, rc);
 		kfree(ibm->acpi->driver);
 		ibm->acpi->driver = NULL;
-	} else if (!ret)
+	} else if (!rc)
 		ibm->flags.acpi_driver_registered = 1;
 
-	return ret;
+	return rc;
 }
 
 
Signature · 1 line
1.5.2.rc0.34.gda94
author
#92 lore raw

PATCH 92/105 ACPI: thinkpad-acpi: improve dock subdriver initialization

From: Henrique de Moraes Holschuh <[email protected]>

The dock sub-driver has split-personality (two subdrivers), and it was doing some unoptimal things on init because of that. Fix it so that the second half of it will only init when necessary, and only if the first half initialized sucessfully in the first place.

---
 drivers/misc/thinkpad_acpi.c |   78 +++++++++++++++++++++++++++---------------
 1 files changed, 50 insertions(+), 28 deletions(-)
drivers/misc/thinkpad_acpi.c +50 -28
index 68f1cc0..a565265 100644
@@ -1519,6 +1519,33 @@ IBM_HANDLE(dock, root, "\\_SB.GDCK",	/* X30, X31, X40 */
 /* don't list other alternatives as we install a notify handler on the 570 */
 IBM_HANDLE(pci, root, "\\_SB.PCI");	/* 570 */
 
+static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = {
+	{
+	 .notify = dock_notify,
+	 .handle = &dock_handle,
+	 .type = ACPI_SYSTEM_NOTIFY,
+	},
+	{
+	 .hid = IBM_PCI_HID,
+	 .notify = dock_notify,
+	 .handle = &pci_handle,
+	 .type = ACPI_SYSTEM_NOTIFY,
+	},
+};
+
+static struct ibm_struct dock_driver_data[2] = {
+	{
+	 .name = "dock",
+	 .read = dock_read,
+	 .write = dock_write,
+	 .acpi = &ibm_dock_acpidriver[0],
+	},
+	{
+	 .name = "dock",
+	 .acpi = &ibm_dock_acpidriver[1],
+	},
+};
+
 #define dock_docked() (_sta(dock_handle) & 1)
 
 static int __init dock_init(struct ibm_init_struct *iibm)
@@ -1526,7 +1553,6 @@ static int __init dock_init(struct ibm_init_struct *iibm)
 	vdbg_printk(TPACPI_DBG_INIT, "initializing dock subdriver\n");
 
 	IBM_ACPIHANDLE_INIT(dock);
-	IBM_ACPIHANDLE_INIT(pci);
 
 	vdbg_printk(TPACPI_DBG_INIT, "dock is %s\n",
 		str_supported(dock_handle != NULL));
@@ -1534,6 +1560,28 @@ static int __init dock_init(struct ibm_init_struct *iibm)
 	return (dock_handle)? 0 : 1;
 }
 
+static int __init dock_init2(struct ibm_init_struct *iibm)
+{
+	int dock2_needed;
+
+	vdbg_printk(TPACPI_DBG_INIT, "initializing dock subdriver part 2\n");
+
+	if (dock_driver_data[0].flags.acpi_driver_registered &&
+	    dock_driver_data[0].flags.acpi_notify_installed) {
+		IBM_ACPIHANDLE_INIT(pci);
+		dock2_needed = (pci_handle != NULL);
+		vdbg_printk(TPACPI_DBG_INIT,
+			    "dock PCI handler for the TP 570 is %s\n",
+			    str_supported(dock2_needed));
+	} else {
+		vdbg_printk(TPACPI_DBG_INIT,
+		"dock subdriver part 2 not required\n");
+		dock2_needed = 0;
+	}
+
+	return (dock2_needed)? 0 : 1;
+}
+
 static void dock_notify(struct ibm_struct *ibm, u32 event)
 {
 	int docked = dock_docked();
@@ -1595,33 +1643,6 @@ static int dock_write(char *buf)
 	return 0;
 }
 
-static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = {
-	{
-	 .notify = dock_notify,
-	 .handle = &dock_handle,
-	 .type = ACPI_SYSTEM_NOTIFY,
-	},
-	{
-	 .hid = IBM_PCI_HID,
-	 .notify = dock_notify,
-	 .handle = &pci_handle,
-	 .type = ACPI_SYSTEM_NOTIFY,
-	},
-};
-
-static struct ibm_struct dock_driver_data[2] = {
-	{
-	 .name = "dock",
-	 .read = dock_read,
-	 .write = dock_write,
-	 .acpi = &ibm_dock_acpidriver[0],
-	},
-	{
-	 .name = "dock",
-	 .acpi = &ibm_dock_acpidriver[1],
-	},
-};
-
 #endif /* CONFIG_THINKPAD_ACPI_DOCK */
 
 /*************************************************************************
@@ -3850,6 +3871,7 @@ static struct ibm_init_struct ibms_init[] __initdata = {
 		.data = &dock_driver_data[0],
 	},
 	{
+		.init = dock_init2,
 		.data = &dock_driver_data[1],
 	},
 #endif
Signature · 1 line
1.5.2.rc0.34.gda94
author
#93 lore raw

PATCH 93/105 ACPI: thinkpad-acpi: add sysfs support to hotkey subdriver

From: Henrique de Moraes Holschuh <[email protected]>

Add the hotkey sysfs support.

---
 Documentation/thinkpad-acpi.txt |   58 ++++++++++++++----
 drivers/misc/thinkpad_acpi.c    |  127 +++++++++++++++++++++++++++++++++++++++
 drivers/misc/thinkpad_acpi.h    |    2 +
 3 files changed, 176 insertions(+), 11 deletions(-)
Documentation/thinkpad-acpi.txt +47 -11
index e3ad7a4..ebeed58 100644
@@ -134,8 +134,11 @@ end of this document.  Changes to the sysfs interface done by the kernel
 subsystems are not documented here, nor are they tracked by this
 attribute.
 
-Hot keys -- /proc/acpi/ibm/hotkey
----------------------------------
+Hot keys
+--------
+
+procfs: /proc/acpi/ibm/hotkey
+sysfs device attribute: hotkey/*
 
 Without this driver, only the Fn-F4 key (sleep button) generates an
 ACPI event. With the driver loaded, the hotkey feature enabled and the
@@ -149,15 +152,6 @@ All labeled Fn-Fx key combinations generate distinct events. In
 addition, the lid microswitch and some docking station buttons may
 also generate such events.
 
-The following commands can be written to this file:
-
-	echo enable > /proc/acpi/ibm/hotkey -- enable the hot keys feature
-	echo disable > /proc/acpi/ibm/hotkey -- disable the hot keys feature
-	echo 0xffff > /proc/acpi/ibm/hotkey -- enable all possible hot keys
-	echo 0x0000 > /proc/acpi/ibm/hotkey -- disable all possible hot keys
-	... any other 4-hex-digit mask ...
-	echo reset > /proc/acpi/ibm/hotkey -- restore the original mask
-
 The bit mask allows some control over which hot keys generate ACPI
 events. Not all bits in the mask can be modified. Not all bits that
 can be modified do anything. Not all hot keys can be individually
@@ -189,6 +183,48 @@ buttons do not generate ACPI events even with this driver. They *can*
 be used through the "ThinkPad Buttons" utility, see
 http://www.nongnu.org/tpb/
 
+procfs notes:
+
+The following commands can be written to the /proc/acpi/ibm/hotkey file:
+
+	echo enable > /proc/acpi/ibm/hotkey -- enable the hot keys feature
+	echo disable > /proc/acpi/ibm/hotkey -- disable the hot keys feature
+	echo 0xffff > /proc/acpi/ibm/hotkey -- enable all possible hot keys
+	echo 0x0000 > /proc/acpi/ibm/hotkey -- disable all possible hot keys
+	... any other 4-hex-digit mask ...
+	echo reset > /proc/acpi/ibm/hotkey -- restore the original mask
+
+sysfs notes:
+
+	The hot keys attributes are in a hotkey/ subdirectory off the
+	thinkpad device.
+
+	bios_enabled:
+		Returns the status of the hot keys feature when
+		thinkpad-acpi was loaded.  Upon module unload, the hot
+		key feature status will be restored to this value.
+
+		0: hot keys were disabled
+		1: hot keys were enabled
+
+	bios_mask:
+		Returns the hot keys mask when thinkpad-acpi was loaded.
+		Upon module unload, the hot keys mask will be restored
+		to this value.
+
+	enable:
+		Enables/disables the hot keys feature, and reports
+		current status of the hot keys feature.
+
+		0: disables the hot keys feature / feature disabled
+		1: enables the hot keys feature / feature enabled
+
+	mask:
+		bit mask to enable ACPI event generation for each hot
+		key (see above).  Returns the current status of the hot
+		keys mask, and allows one to modify it.
+
+
 Bluetooth -- /proc/acpi/ibm/bluetooth
 -------------------------------------
 
drivers/misc/thinkpad_acpi.c +127 -0

157 lines not on this page · raw message

drivers/misc/thinkpad_acpi.h +2 -0
index a9e7093..7615adb 100644
@@ -414,6 +414,8 @@ static int fan_write_cmd_watchdog(const char *cmd, int *rc);
  * Hotkey subdriver
  */
 
+#define TPACPI_HOTKEY_SYSFS_GROUP "hotkey"
+
 static int hotkey_orig_status;
 static int hotkey_orig_mask;
 
Signature · 1 line
1.5.2.rc0.34.gda94
author
#94 lore raw

PATCH 94/105 ACPI: thinkpad-acpi: add sysfs support to wan and bluetooth subdrivers

From: Henrique de Moraes Holschuh <[email protected]>

Add support to sysfs to the wan and bluetooth subdrivers.

---
 Documentation/thinkpad-acpi.txt |   61 ++++++++++++++---
 drivers/misc/thinkpad_acpi.c    |  144 +++++++++++++++++++++++++++++++++++---
 drivers/misc/thinkpad_acpi.h    |    4 +
 3 files changed, 186 insertions(+), 23 deletions(-)
Documentation/thinkpad-acpi.txt +50 -11
index ebeed58..2d48033 100644
@@ -225,15 +225,35 @@ sysfs notes:
 		keys mask, and allows one to modify it.
 
 
-Bluetooth -- /proc/acpi/ibm/bluetooth
--------------------------------------
+Bluetooth
+---------
 
-This feature shows the presence and current state of a Bluetooth
-device. If Bluetooth is installed, the following commands can be used:
+procfs: /proc/acpi/ibm/bluetooth
+sysfs device attribute: bluetooth/enable
+
+This feature shows the presence and current state of a ThinkPad
+Bluetooth device in the internal ThinkPad CDC slot.
+
+Procfs notes:
+
+If Bluetooth is installed, the following commands can be used:
 
 	echo enable > /proc/acpi/ibm/bluetooth
 	echo disable > /proc/acpi/ibm/bluetooth
 
+Sysfs notes:
+
+	If the Bluetooth CDC card is installed, it can be enabled /
+	disabled through the "bluetooth/enable" thinkpad-acpi device
+	attribute, and its current status can also be queried.
+
+	enable:
+		0: disables Bluetooth / Bluetooth is disabled
+		1: enables Bluetooth / Bluetooth is enabled.
+
+	Note: this interface will be probably be superseeded by the
+	generic rfkill class.
+
 Video output control -- /proc/acpi/ibm/video
 --------------------------------------------
 
@@ -874,23 +894,42 @@ with EINVAL, try to set pwm1_enable to 1 and pwm1 to at least 128 (255
 would be the safest choice, though).
 
 
-EXPERIMENTAL: WAN -- /proc/acpi/ibm/wan
----------------------------------------
+EXPERIMENTAL: WAN
+-----------------
+
+procfs: /proc/acpi/ibm/wan
+sysfs device attribute: wwan/enable
 
 This feature is marked EXPERIMENTAL because the implementation
 directly accesses hardware registers and may not work as expected. USE
 WITH CAUTION! To use this feature, you need to supply the
 experimental=1 parameter when loading the module.
 
-This feature shows the presence and current state of a WAN (Sierra
-Wireless EV-DO) device. If WAN is installed, the following commands can
-be used:
+This feature shows the presence and current state of a W-WAN (Sierra
+Wireless EV-DO) device.
+
+It was tested on a Lenovo Thinkpad X60. It should probably work on other
+Thinkpad models which come with this module installed.
+
+Procfs notes:
+
+If the W-WAN card is installed, the following commands can be used:
 
 	echo enable > /proc/acpi/ibm/wan
 	echo disable > /proc/acpi/ibm/wan
 
-It was tested on a Lenovo Thinkpad X60. It should probably work on other
-Thinkpad models which come with this module installed.
+Sysfs notes:
+
+	If the W-WAN card is installed, it can be enabled /
+	disabled through the "wwan/enable" thinkpad-acpi device
+	attribute, and its current status can also be queried.
+
+	enable:
+		0: disables WWAN card / WWAN card is disabled
+		1: enables WWAN card / WWAN card is enabled.
+
+	Note: this interface will be probably be superseeded by the
+	generic rfkill class.
 
 Multiple Commands, Module Parameters
 ------------------------------------
drivers/misc/thinkpad_acpi.c +132 -12

206 lines not on this page · raw message

drivers/misc/thinkpad_acpi.h +4 -0
index 7615adb..a6c2855 100644
@@ -278,6 +278,8 @@ static int beep_write(char *buf);
  * Bluetooth subdriver
  */
 
+#define TPACPI_BLUETH_SYSFS_GROUP "bluetooth"
+
 enum {
 	/* ACPI GBDC/SBDC bits */
 	TP_ACPI_BLUETOOTH_HWPRESENT	= 0x01,	/* Bluetooth hw available */
@@ -551,6 +553,8 @@ static int volume_write(char *buf);
  * Wan subdriver
  */
 
+#define TPACPI_WAN_SYSFS_GROUP "wwan"
+
 enum {
 	/* ACPI GWAN/SWAN bits */
 	TP_ACPI_WANCARD_HWPRESENT	= 0x01,	/* Wan hw available */
Signature · 1 line
1.5.2.rc0.34.gda94
author
#95 lore raw

PATCH 95/105 thinkpad-acpi: make drivers/misc/thinkpad_acpi:fan_mutex static

From: Adrian Bunk <[email protected]>

This patch makes the needlessly global fan_mutex static.

---
 drivers/misc/thinkpad_acpi.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/misc/thinkpad_acpi.h +1 -1
index a6c2855..440145a 100644
@@ -386,7 +386,7 @@ static u8 fan_control_initial_status;
 static u8 fan_control_desired_level;
 static int fan_watchdog_maxinterval;
 
-struct mutex fan_mutex;
+static struct mutex fan_mutex;
 
 static acpi_handle fans_handle, gfan_handle, sfan_handle;
 
Signature · 1 line
1.5.2.rc0.34.gda94

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#105 lore raw

PATCH 105/105 sonypi: use mutex instead of semaphore

From: Matthias Kaehlcke <[email protected]>

the Sony Programmable I/O Control driver uses a semaphore as mutex. use the mutex API instead of the (binary) semaphore

---
 drivers/char/sonypi.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
drivers/char/sonypi.c +10 -10
index b699890..3ef593a 100644
@@ -484,7 +484,7 @@ static struct sonypi_device {
 	u16 evtype_offset;
 	int camera_power;
 	int bluetooth_power;
-	struct semaphore lock;
+	struct mutex lock;
 	struct kfifo *fifo;
 	spinlock_t fifo_lock;
 	wait_queue_head_t fifo_proc_list;
@@ -891,7 +891,7 @@ int sonypi_camera_command(int command, u8 value)
 	if (!camera)
 		return -EIO;
 
-	down(&sonypi_device.lock);
+	mutex_lock(&sonypi_device.lock);
 
 	switch (command) {
 	case SONYPI_COMMAND_SETCAMERA:
@@ -926,7 +926,7 @@ int sonypi_camera_command(int command, u8 value)
 		       command);
 		break;
 	}
-	up(&sonypi_device.lock);
+	mutex_unlock(&sonypi_device.lock);
 	return 0;
 }
 
@@ -945,20 +945,20 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
 static int sonypi_misc_release(struct inode *inode, struct file *file)
 {
 	sonypi_misc_fasync(-1, file, 0);
-	down(&sonypi_device.lock);
+	mutex_lock(&sonypi_device.lock);
 	sonypi_device.open_count--;
-	up(&sonypi_device.lock);
+	mutex_unlock(&sonypi_device.lock);
 	return 0;
 }
 
 static int sonypi_misc_open(struct inode *inode, struct file *file)
 {
-	down(&sonypi_device.lock);
+	mutex_lock(&sonypi_device.lock);
 	/* Flush input queue on first open */
 	if (!sonypi_device.open_count)
 		kfifo_reset(sonypi_device.fifo);
 	sonypi_device.open_count++;
-	up(&sonypi_device.lock);
+	mutex_unlock(&sonypi_device.lock);
 	return 0;
 }
 
@@ -1008,7 +1008,7 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
 	u8 val8;
 	u16 val16;
 
-	down(&sonypi_device.lock);
+	mutex_lock(&sonypi_device.lock);
 	switch (cmd) {
 	case SONYPI_IOCGBRT:
 		if (sonypi_ec_read(SONYPI_LCD_LIGHT, &val8)) {
@@ -1108,7 +1108,7 @@ static int sonypi_misc_ioctl(struct inode *ip, struct file *fp,
 	default:
 		ret = -EINVAL;
 	}
-	up(&sonypi_device.lock);
+	mutex_unlock(&sonypi_device.lock);
 	return ret;
 }
 
@@ -1363,7 +1363,7 @@ static int __devinit sonypi_probe(struct platform_device *dev)
 	}
 
 	init_waitqueue_head(&sonypi_device.fifo_proc_list);
-	init_MUTEX(&sonypi_device.lock);
+	mutex_init(&sonypi_device.lock);
 	sonypi_device.bluetooth_power = -1;
 
 	if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL,
Signature · 1 line
1.5.2.rc0.34.gda94
#106 lore raw

Re: [PATCH 084/105] ACPI: Remove a warning about unused variable in !CONFIG_ACPI compilation.

In reply to Len Brown
Quoted 1 line · On Sunday 29 April 2007 06:51:24 Len Brown wrote:

From: Zachary Amsden <[email protected]>

Also got that one already

-Andi

#107 lore raw

Re: [PATCH 083/105] ACPI: prevent ACPI quirk warning mass spamming in logs

In reply to Len Brown
Quoted 5 lines · On Sunday 29 April 2007 06:51:23 Len Brown wrote:

From: Thierry Vignaud <[email protected]>

The following patch prevent this warning to be displayed again & again (eg:
nine times on my NForce2 motherboard) and thus improve signal to noise ratio in logs.

I already got that in my tree. Better let me submit it.

-Andi

maintainer
#108 lore raw
In reply to Len Brown

On Sun, Apr 29, 2007 at 12:50:00AM -0400, Len Brown wrote:
...

Quoted 2 lines

If I've missed something that you think is appropriate for 2.6.22 (I'm sure there are several) please let me know.

It's me who actually forgot to submit a trivial patch for 2.6.22, appended below.

mattia
---
Subject: rename SONY_LAPTOP_OLD to a more meaningful SONYPI_COMPAT

---

drivers/misc/Kconfig +1 -1
Index: linux-2.6/drivers/misc/Kconfig
===================================================================
@@ -121,7 +121,7 @@ config SONY_LAPTOP
 
 	  Read <file:Documentation/sony-laptop.txt> for more information.
 
-config SONY_LAPTOP_OLD
+config SONYPI_COMPAT
 	bool "Sonypi compatibility"
 	depends on SONY_LAPTOP
 	  ---help---
drivers/misc/sony-laptop.c +4 -4
Index: linux-2.6/drivers/misc/sony-laptop.c
===================================================================
@@ -63,7 +63,7 @@
 #include <asm/uaccess.h>
 #include <linux/sonypi.h>
 #include <linux/sony-laptop.h>
-#ifdef CONFIG_SONY_LAPTOP_OLD
+#ifdef CONFIG_SONYPI_COMPAT
 #include <linux/poll.h>
 #include <linux/miscdevice.h>
 #endif
@@ -114,7 +114,7 @@ MODULE_PARM_DESC(camera,
 		 "set this to 1 to enable Motion Eye camera controls "
 		 "(only use it if you have a C1VE or C1VN model)");
 
-#ifdef CONFIG_SONY_LAPTOP_OLD
+#ifdef CONFIG_SONYPI_COMPAT
 static int minor = -1;
 module_param(minor, int, 0);
 MODULE_PARM_DESC(minor,
@@ -1504,7 +1504,7 @@ static struct attribute_group spic_attri
 };
 
 /******** SONYPI compatibility **********/
-#ifdef CONFIG_SONY_LAPTOP_OLD
+#ifdef CONFIG_SONYPI_COMPAT
 
 /* battery / brightness / temperature  addresses */
 #define SONYPI_BAT_FLAGS	0x81
@@ -1798,7 +1798,7 @@ static void sonypi_compat_exit(void)
 static int sonypi_compat_init(void) { return 0; }
 static void sonypi_compat_exit(void) { }
 static void sonypi_compat_report_event(u8 event) { }
-#endif /* CONFIG_SONY_LAPTOP_OLD */
+#endif /* CONFIG_SONYPI_COMPAT */
 
 /*
  * ACPI callbacks
reviewer Applied
#109 lore raw

Applied.

thanks,
-Len

Quoted 72 lines · Mattia Dongili

On Sun, Apr 29, 2007 at 12:50:00AM -0400, Len Brown wrote:
...

Quoted 2 lines

If I've missed something that you think is appropriate for 2.6.22 (I'm sure there are several) please let me know.

It's me who actually forgot to submit a trivial patch for 2.6.22, appended below.

mattia
---
Subject: rename SONY_LAPTOP_OLD to a more meaningful SONYPI_COMPAT

---
Index: linux-2.6/drivers/misc/Kconfig
===================================================================

drivers/misc/Kconfig +1 -1
@@ -121,7 +121,7 @@ config SONY_LAPTOP
 
 	  Read <file:Documentation/sony-laptop.txt> for more information.
 
-config SONY_LAPTOP_OLD
+config SONYPI_COMPAT
 	bool "Sonypi compatibility"
 	depends on SONY_LAPTOP
 	  ---help---

Index: linux-2.6/drivers/misc/sony-laptop.c
===================================================================

drivers/misc/sony-laptop.c +4 -5
@@ -63,7 +63,7 @@
 #include <asm/uaccess.h>
 #include <linux/sonypi.h>
 #include <linux/sony-laptop.h>
-#ifdef CONFIG_SONY_LAPTOP_OLD
+#ifdef CONFIG_SONYPI_COMPAT
 #include <linux/poll.h>
 #include <linux/miscdevice.h>
 #endif
@@ -114,7 +114,7 @@ MODULE_PARM_DESC(camera,
 		 "set this to 1 to enable Motion Eye camera controls "
 		 "(only use it if you have a C1VE or C1VN model)");
 
-#ifdef CONFIG_SONY_LAPTOP_OLD
+#ifdef CONFIG_SONYPI_COMPAT
 static int minor = -1;
 module_param(minor, int, 0);
 MODULE_PARM_DESC(minor,
@@ -1504,7 +1504,7 @@ static struct attribute_group spic_attri
 };
 
 /******** SONYPI compatibility **********/
-#ifdef CONFIG_SONY_LAPTOP_OLD
+#ifdef CONFIG_SONYPI_COMPAT
 
 /* battery / brightness / temperature  addresses */
 #define SONYPI_BAT_FLAGS	0x81
@@ -1798,7 +1798,7 @@ static void sonypi_compat_exit(void)
 static int sonypi_compat_init(void) { return 0; }
 static void sonypi_compat_exit(void) { }
 static void sonypi_compat_report_event(u8 event) { }
-#endif /* CONFIG_SONY_LAPTOP_OLD */
+#endif /* CONFIG_SONYPI_COMPAT */
 
 /*
  * ACPI callbacks
-

To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html