[PATCH] debug sysctl for acpi_ibm hiding the event printfs

Niki Denev nike_d at cytexbg.com
Sat Feb 11 19:03:06 PST 2006


Hello,

For some time i started using my IBM TP X31 with
the following sysctl enabled :

dev.acpi_ibm.0.events=1

and the following lines in devd.conf :

notify 10 {
         match "system"          "ACPI";
         match "subsystem"       "IBM";
         match "notify"          "0x05";
         action "/usr/local/sbin/wlan_toggle.sh";
};

With this stuff i am able to use the wireless/radio (Fn-F5) button on my
  laptop to enable/disable the wireless interface with the help of a
simple shell script.
But as annoying side effect of dev.acpi_ibm.0.events enabled now i get
printfs with the event codes each time i press a special combination.
So i decided to hide the printfs in acpi_ibm behind a debug sysctl,
in my case : dev.acpi_ibm.0.debug
The patch is attached. (it is for -CURRENT)

P.S.: As another side effect of dev.acpi_ibm.0.events enabled i can no
longer use the suspend (Fn-F4) and display output (Fn-F7) keys because
now they generate events to devd. This seems a little strange because
the brightness and think light combinations continue to work and do not 
generate events.


--niki
-------------- next part --------------
--- acpi_ibm.c.orig	Wed Feb  8 23:48:20 2006
+++ acpi_ibm.c	Sun Feb 12 04:41:43 2006
@@ -67,6 +67,7 @@
 #define ACPI_IBM_METHOD_FANLEVEL	11
 #define ACPI_IBM_METHOD_FANSTATUS	12
 #define ACPI_IBM_METHOD_THERMAL		13
+#define ACPI_IBM_METHOD_DEBUG		14
 
 /* Hotkeys/Buttons */
 #define IBM_RTC_HOTKEY1			0x64
@@ -172,6 +173,12 @@
 	int	access;
 } acpi_ibm_sysctls[] = {
 	{
+		.name		= "debug",
+		.method		= ACPI_IBM_METHOD_DEBUG,
+		.description	= "Show debug messages",
+		.access		= CTLTYPE_INT | CTLFLAG_RW
+	},
+	{
 		.name		= "events",
 		.method		= ACPI_IBM_METHOD_EVENTS,
 		.description	= "ACPI events enable",
@@ -249,6 +256,8 @@
 
 ACPI_SERIAL_DECL(ibm, "ACPI IBM extras");
 
+static int	acpi_ibm_debug = 0;
+
 static int	acpi_ibm_probe(device_t dev);
 static int	acpi_ibm_attach(device_t dev);
 static int	acpi_ibm_detach(device_t dev);
@@ -508,6 +517,9 @@
 	ACPI_SERIAL_ASSERT(ibm);
 
 	switch (method) {
+	case ACPI_IBM_METHOD_DEBUG:
+		val = acpi_ibm_debug;
+		break;
 	case ACPI_IBM_METHOD_EVENTS:
 		acpi_GetInteger(sc->handle, IBM_NAME_EVENTS_STATUS_GET, &val);
 		break;
@@ -641,6 +653,11 @@
 	ACPI_SERIAL_ASSERT(ibm);
 
 	switch (method) {
+	case ACPI_IBM_METHOD_DEBUG:
+		if (arg < 0 || arg > 1)
+			return (EINVAL);
+		acpi_ibm_debug = arg;
+		break;
 	case ACPI_IBM_METHOD_EVENTS:
 		if (arg < 0 || arg > 1)
 			return (EINVAL);
@@ -795,6 +812,7 @@
 	ACPI_HANDLE		ledb_handle;
 
 	switch (method) {
+	case ACPI_IBM_METHOD_DEBUG:
 	case ACPI_IBM_METHOD_EVENTS:
 		/* Events are disabled by default */
 		return (TRUE);
@@ -919,9 +937,11 @@
 
 	ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, notify);
 
-	printf("IBM:NOTIFY:%x\n", notify);
-	if (notify != 0x80)
-		printf("Unknown notify\n");
+	if (acpi_ibm_debug) {
+		printf("IBM:NOTIFY:%x\n", notify);
+		if (notify != 0x80)
+			printf("Unknown notify\n");
+	}
 
 	for (;;) {
 		acpi_GetInteger(acpi_get_handle(dev), IBM_NAME_EVENTS_GET, &event);
@@ -929,14 +949,16 @@
 		if (event == 0)
 			break;
 
-		printf("notify:%x\n", event);
+		if (acpi_ibm_debug)
+			printf("notify:%x\n", event);
 
 		type = (event >> 12) & 0xf;
 		arg = event & 0xfff;
 		switch (type) {
 		case 1:
 			if (!(sc->events_availmask & (1 << (arg - 1)))) {
-				printf("Unknown key %d\n", arg);
+				if (acpi_ibm_debug)
+					printf("Unknown key %d\n", arg);
 				break;
 			}
 


More information about the freebsd-acpi mailing list