Skip to contentSkip to conversation

platform: x86: ACPI: Get rid of ACPICA message printing

PATCH In review Rafael J. Wysocki 3 participants 5 messages Feb 24, 2021 – Mar 4, 2021

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform: x86: ACPI: Get rid of ACPICA message printing

From: Rafael J. Wysocki <[email protected]>

A few x86 platform drivers use ACPI_DEBUG_PRINT() or ACPI_EXCEPTION() for printing messages, but that is questionable, because those macros belong to ACPICA and they should not be used elsewhere. In addition, ACPI_DEBUG_PRINT() requires special enabling to allow it to actually print the message, which is a nuisance, and the _COMPONENT symbol generally needed for that is not defined in any of the files in question.

For this reason, replace the ACPI_DEBUG_PRINT() in lg-laptop.c with pr_debug() and the one in xo15-ebook.c with acpi_handle_debug() (with the additional benefit that the source object can be identified more easily after this change), and replace the ACPI_EXCEPTION() in acer-wmi.c with pr_warn().

Also drop the ACPI_MODULE_NAME() definitions that are only used by the ACPICA message printing macros from those files and from wmi.c and surfacepro3_button.c (while at it).

---
 drivers/platform/surface/surfacepro3_button.c |    2 --
 drivers/platform/x86/acer-wmi.c               |    4 ++--
 drivers/platform/x86/lg-laptop.c              |    2 +-
 drivers/platform/x86/wmi.c                    |    1 -
 drivers/platform/x86/xo15-ebook.c             |    6 ++----
 5 files changed, 5 insertions(+), 10 deletions(-)
drivers/platform/x86/lg-laptop.c +1 -1
Index: linux-pm/drivers/platform/x86/lg-laptop.c
===================================================================
@@ -678,7 +678,7 @@ static int __init acpi_init(void)
 
 	result = acpi_bus_register_driver(&acpi_driver);
 	if (result < 0) {
-		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error registering driver\n"));
+		pr_debug("Error registering driver\n");
 		return -ENODEV;
 	}
 
drivers/platform/x86/xo15-ebook.c +2 -4
Index: linux-pm/drivers/platform/x86/xo15-ebook.c
===================================================================
@@ -26,8 +26,6 @@
 #define XO15_EBOOK_HID			"XO15EBK"
 #define XO15_EBOOK_DEVICE_NAME		"EBook Switch"
 
-ACPI_MODULE_NAME(MODULE_NAME);
-
 MODULE_DESCRIPTION("OLPC XO-1.5 ebook switch driver");
 MODULE_LICENSE("GPL");
 
@@ -66,8 +64,8 @@ static void ebook_switch_notify(struct a
 		ebook_send_state(device);
 		break;
 	default:
-		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
-				  "Unsupported event [0x%x]\n", event));
+		acpi_handle_debug(device->handle,
+				  "Unsupported event [0x%x]\n", event);
 		break;
 	}
 }
drivers/platform/x86/acer-wmi.c +2 -2
Index: linux-pm/drivers/platform/x86/acer-wmi.c
===================================================================
@@ -30,7 +30,6 @@
 #include <linux/input/sparse-keymap.h>
 #include <acpi/video.h>
 
-ACPI_MODULE_NAME(KBUILD_MODNAME);
 MODULE_AUTHOR("Carlos Corbacho");
 MODULE_DESCRIPTION("Acer Laptop WMI Extras Driver");
 MODULE_LICENSE("GPL");
@@ -1605,7 +1604,8 @@ static void acer_kbd_dock_get_initial_st
 
 	status = wmi_evaluate_method(WMID_GUID3, 0, 0x2, &input_buf, &output_buf);
 	if (ACPI_FAILURE(status)) {
-		ACPI_EXCEPTION((AE_INFO, status, "Error getting keyboard-dock initial status"));
+		pr_warn("Error getting keyboard-dock initial status: %s\n",
+			acpi_format_exception(status));
 		return;
 	}
 
drivers/platform/surface/surfacepro3_button.c +0 -2
Index: linux-pm/drivers/platform/surface/surfacepro3_button.c
===================================================================
@@ -40,8 +40,6 @@ static const guid_t MSHW0040_DSM_UUID =
 #define SURFACE_BUTTON_NOTIFY_PRESS_VOLUME_DOWN		0xc2
 #define SURFACE_BUTTON_NOTIFY_RELEASE_VOLUME_DOWN	0xc3
 
-ACPI_MODULE_NAME("surface pro 3 button");
-
 MODULE_AUTHOR("Chen Yu");
 MODULE_DESCRIPTION("Surface Pro3 Button Driver");
 MODULE_LICENSE("GPL v2");
drivers/platform/x86/wmi.c +0 -1
Index: linux-pm/drivers/platform/x86/wmi.c
===================================================================
@@ -32,7 +32,6 @@
 #include <linux/fs.h>
 #include <uapi/linux/wmi.h>
 
-ACPI_MODULE_NAME("wmi");
 MODULE_AUTHOR("Carlos Corbacho");
 MODULE_DESCRIPTION("ACPI-WMI Mapping Driver");
 MODULE_LICENSE("GPL");
Reviewed-by on v1 1/1
#1 lore raw

Hi Rafael,

Quoted 16 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

A few x86 platform drivers use ACPI_DEBUG_PRINT() or ACPI_EXCEPTION() for printing messages, but that is questionable, because those macros belong to ACPICA and they should not be used elsewhere. In addition, ACPI_DEBUG_PRINT() requires special enabling to allow it to actually print the message, which is a nuisance, and the _COMPONENT symbol generally needed for that is not defined in any of the files in question.

For this reason, replace the ACPI_DEBUG_PRINT() in lg-laptop.c with pr_debug() and the one in xo15-ebook.c with acpi_handle_debug() (with the additional benefit that the source object can be identified more easily after this change), and replace the ACPI_EXCEPTION() in acer-wmi.c with pr_warn().

Quoted 5 lines

Also drop the ACPI_MODULE_NAME() definitions that are only used by the ACPICA message printing macros from those files and from wmi.c and surfacepro3_button.c (while at it).

Thank you for your patch for this.

This looks good to me, except that I already fixed the acer-wmi.c case a couple of weeks ago, and that fiox was merged into Linus' tree already:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ef14f0e82c9b225ae19476fa5bed89d55b2a96d5

I can drop the acer-wmi.c chunks when I merge this, so there is no need to send out a new version.

Regards,

Hans

Quoted 95 lines
---
 drivers/platform/surface/surfacepro3_button.c |    2 --
 drivers/platform/x86/acer-wmi.c               |    4 ++--
 drivers/platform/x86/lg-laptop.c              |    2 +-
 drivers/platform/x86/wmi.c                    |    1 -
 drivers/platform/x86/xo15-ebook.c             |    6 ++----
 5 files changed, 5 insertions(+), 10 deletions(-)

Index: linux-pm/drivers/platform/x86/lg-laptop.c
===================================================================

drivers/platform/x86/lg-laptop.c +1 -1
@@ -678,7 +678,7 @@ static int __init acpi_init(void)
 
 	result = acpi_bus_register_driver(&acpi_driver);
 	if (result < 0) {
-		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error registering driver\n"));
+		pr_debug("Error registering driver\n");
 		return -ENODEV;
 	}
 

Index: linux-pm/drivers/platform/x86/xo15-ebook.c
===================================================================

drivers/platform/x86/xo15-ebook.c +2 -4
@@ -26,8 +26,6 @@
 #define XO15_EBOOK_HID			"XO15EBK"
 #define XO15_EBOOK_DEVICE_NAME		"EBook Switch"
 
-ACPI_MODULE_NAME(MODULE_NAME);
-
 MODULE_DESCRIPTION("OLPC XO-1.5 ebook switch driver");
 MODULE_LICENSE("GPL");
 
@@ -66,8 +64,8 @@ static void ebook_switch_notify(struct a
 		ebook_send_state(device);
 		break;
 	default:
-		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
-				  "Unsupported event [0x%x]\n", event));
+		acpi_handle_debug(device->handle,
+				  "Unsupported event [0x%x]\n", event);
 		break;
 	}
 }

Index: linux-pm/drivers/platform/x86/acer-wmi.c
===================================================================

drivers/platform/x86/acer-wmi.c +2 -2
@@ -30,7 +30,6 @@
 #include <linux/input/sparse-keymap.h>
 #include <acpi/video.h>
 
-ACPI_MODULE_NAME(KBUILD_MODNAME);
 MODULE_AUTHOR("Carlos Corbacho");
 MODULE_DESCRIPTION("Acer Laptop WMI Extras Driver");
 MODULE_LICENSE("GPL");
@@ -1605,7 +1604,8 @@ static void acer_kbd_dock_get_initial_st
 
 	status = wmi_evaluate_method(WMID_GUID3, 0, 0x2, &input_buf, &output_buf);
 	if (ACPI_FAILURE(status)) {
-		ACPI_EXCEPTION((AE_INFO, status, "Error getting keyboard-dock initial status"));
+		pr_warn("Error getting keyboard-dock initial status: %s\n",
+			acpi_format_exception(status));
 		return;
 	}
 

Index: linux-pm/drivers/platform/surface/surfacepro3_button.c
===================================================================

drivers/platform/surface/surfacepro3_button.c +0 -2
@@ -40,8 +40,6 @@ static const guid_t MSHW0040_DSM_UUID =
 #define SURFACE_BUTTON_NOTIFY_PRESS_VOLUME_DOWN		0xc2
 #define SURFACE_BUTTON_NOTIFY_RELEASE_VOLUME_DOWN	0xc3
 
-ACPI_MODULE_NAME("surface pro 3 button");
-
 MODULE_AUTHOR("Chen Yu");
 MODULE_DESCRIPTION("Surface Pro3 Button Driver");
 MODULE_LICENSE("GPL v2");

Index: linux-pm/drivers/platform/x86/wmi.c
===================================================================

drivers/platform/x86/wmi.c +0 -1
@@ -32,7 +32,6 @@
 #include <linux/fs.h>
 #include <uapi/linux/wmi.h>
 
-ACPI_MODULE_NAME("wmi");
 MODULE_AUTHOR("Carlos Corbacho");
 MODULE_DESCRIPTION("ACPI-WMI Mapping Driver");
 MODULE_LICENSE("GPL");
#2 lore raw
Quoted 28 lines · Hans de Goede

Hi Rafael,

Quoted 16 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

A few x86 platform drivers use ACPI_DEBUG_PRINT() or ACPI_EXCEPTION() for printing messages, but that is questionable, because those macros belong to ACPICA and they should not be used elsewhere. In addition, ACPI_DEBUG_PRINT() requires special enabling to allow it to actually print the message, which is a nuisance, and the _COMPONENT symbol generally needed for that is not defined in any of the files in question.

For this reason, replace the ACPI_DEBUG_PRINT() in lg-laptop.c with pr_debug() and the one in xo15-ebook.c with acpi_handle_debug() (with the additional benefit that the source object can be identified more easily after this change), and replace the ACPI_EXCEPTION() in acer-wmi.c with pr_warn().

Quoted 5 lines

Also drop the ACPI_MODULE_NAME() definitions that are only used by the ACPICA message printing macros from those files and from wmi.c and surfacepro3_button.c (while at it).

Thank you for your patch for this.

Quoted 7 lines

This looks good to me, except that I already fixed the acer-wmi.c case a couple of weeks ago, and that fiox was merged into Linus' tree already:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ef14f0e82c9b225ae19476fa5bed89d55b2a96d5

I can drop the acer-wmi.c chunks when I merge this, so there is no need to send out a new version.

OK, thanks!

I will be assuming that you will pick up this patch and adjust it as needed.

Quoted 104 lines

Regards,

Hans

Quoted 95 lines
---
 drivers/platform/surface/surfacepro3_button.c |    2 --
 drivers/platform/x86/acer-wmi.c               |    4 ++--
 drivers/platform/x86/lg-laptop.c              |    2 +-
 drivers/platform/x86/wmi.c                    |    1 -
 drivers/platform/x86/xo15-ebook.c             |    6 ++----
 5 files changed, 5 insertions(+), 10 deletions(-)

Index: linux-pm/drivers/platform/x86/lg-laptop.c
===================================================================

drivers/platform/x86/lg-laptop.c +1 -1
@@ -678,7 +678,7 @@ static int __init acpi_init(void)
 
      result = acpi_bus_register_driver(&acpi_driver);
      if (result < 0) {
-             ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error registering driver\n"));
+             pr_debug("Error registering driver\n");
              return -ENODEV;
      }
 

Index: linux-pm/drivers/platform/x86/xo15-ebook.c
===================================================================

drivers/platform/x86/xo15-ebook.c +2 -4
@@ -26,8 +26,6 @@
 #define XO15_EBOOK_HID                       "XO15EBK"
 #define XO15_EBOOK_DEVICE_NAME               "EBook Switch"
 
-ACPI_MODULE_NAME(MODULE_NAME);
-
 MODULE_DESCRIPTION("OLPC XO-1.5 ebook switch driver");
 MODULE_LICENSE("GPL");
 
@@ -66,8 +64,8 @@ static void ebook_switch_notify(struct a
              ebook_send_state(device);
              break;
      default:
-             ACPI_DEBUG_PRINT((ACPI_DB_INFO,
-                               "Unsupported event [0x%x]\n", event));
+             acpi_handle_debug(device->handle,
+                               "Unsupported event [0x%x]\n", event);
              break;
      }
 }

Index: linux-pm/drivers/platform/x86/acer-wmi.c
===================================================================

drivers/platform/x86/acer-wmi.c +2 -2
@@ -30,7 +30,6 @@
 #include <linux/input/sparse-keymap.h>
 #include <acpi/video.h>
 
-ACPI_MODULE_NAME(KBUILD_MODNAME);
 MODULE_AUTHOR("Carlos Corbacho");
 MODULE_DESCRIPTION("Acer Laptop WMI Extras Driver");
 MODULE_LICENSE("GPL");
@@ -1605,7 +1604,8 @@ static void acer_kbd_dock_get_initial_st
 
      status = wmi_evaluate_method(WMID_GUID3, 0, 0x2, &input_buf, &output_buf);
      if (ACPI_FAILURE(status)) {
-             ACPI_EXCEPTION((AE_INFO, status, "Error getting keyboard-dock initial status"));
+             pr_warn("Error getting keyboard-dock initial status: %s\n",
+                     acpi_format_exception(status));
              return;
      }
 

Index: linux-pm/drivers/platform/surface/surfacepro3_button.c
===================================================================

drivers/platform/surface/surfacepro3_button.c +0 -2
@@ -40,8 +40,6 @@ static const guid_t MSHW0040_DSM_UUID =
 #define SURFACE_BUTTON_NOTIFY_PRESS_VOLUME_DOWN              0xc2
 #define SURFACE_BUTTON_NOTIFY_RELEASE_VOLUME_DOWN    0xc3
 
-ACPI_MODULE_NAME("surface pro 3 button");
-
 MODULE_AUTHOR("Chen Yu");
 MODULE_DESCRIPTION("Surface Pro3 Button Driver");
 MODULE_LICENSE("GPL v2");

Index: linux-pm/drivers/platform/x86/wmi.c
===================================================================

drivers/platform/x86/wmi.c +0 -1
@@ -32,7 +32,6 @@
 #include <linux/fs.h>
 #include <uapi/linux/wmi.h>
 
-ACPI_MODULE_NAME("wmi");
 MODULE_AUTHOR("Carlos Corbacho");
 MODULE_DESCRIPTION("ACPI-WMI Mapping Driver");
 MODULE_LICENSE("GPL");
#3 lore raw
In reply to Rafael J. Wysocki

Hi,

Quoted 16 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

A few x86 platform drivers use ACPI_DEBUG_PRINT() or ACPI_EXCEPTION() for printing messages, but that is questionable, because those macros belong to ACPICA and they should not be used elsewhere. In addition, ACPI_DEBUG_PRINT() requires special enabling to allow it to actually print the message, which is a nuisance, and the _COMPONENT symbol generally needed for that is not defined in any of the files in question.

For this reason, replace the ACPI_DEBUG_PRINT() in lg-laptop.c with pr_debug() and the one in xo15-ebook.c with acpi_handle_debug() (with the additional benefit that the source object can be identified more easily after this change), and replace the ACPI_EXCEPTION() in acer-wmi.c with pr_warn().

Quoted 5 lines

Also drop the ACPI_MODULE_NAME() definitions that are only used by the ACPICA message printing macros from those files and from wmi.c and surfacepro3_button.c (while at it).

Thank you.

I've merged this into my review-hans branch now, minus the acer-wmi.c changes because a similar patch was already merged for those.

Regards,

Hans

Quoted 95 lines
---
 drivers/platform/surface/surfacepro3_button.c |    2 --
 drivers/platform/x86/acer-wmi.c               |    4 ++--
 drivers/platform/x86/lg-laptop.c              |    2 +-
 drivers/platform/x86/wmi.c                    |    1 -
 drivers/platform/x86/xo15-ebook.c             |    6 ++----
 5 files changed, 5 insertions(+), 10 deletions(-)

Index: linux-pm/drivers/platform/x86/lg-laptop.c
===================================================================

drivers/platform/x86/lg-laptop.c +1 -1
@@ -678,7 +678,7 @@ static int __init acpi_init(void)
 
 	result = acpi_bus_register_driver(&acpi_driver);
 	if (result < 0) {
-		ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error registering driver\n"));
+		pr_debug("Error registering driver\n");
 		return -ENODEV;
 	}
 

Index: linux-pm/drivers/platform/x86/xo15-ebook.c
===================================================================

drivers/platform/x86/xo15-ebook.c +2 -4
@@ -26,8 +26,6 @@
 #define XO15_EBOOK_HID			"XO15EBK"
 #define XO15_EBOOK_DEVICE_NAME		"EBook Switch"
 
-ACPI_MODULE_NAME(MODULE_NAME);
-
 MODULE_DESCRIPTION("OLPC XO-1.5 ebook switch driver");
 MODULE_LICENSE("GPL");
 
@@ -66,8 +64,8 @@ static void ebook_switch_notify(struct a
 		ebook_send_state(device);
 		break;
 	default:
-		ACPI_DEBUG_PRINT((ACPI_DB_INFO,
-				  "Unsupported event [0x%x]\n", event));
+		acpi_handle_debug(device->handle,
+				  "Unsupported event [0x%x]\n", event);
 		break;
 	}
 }

Index: linux-pm/drivers/platform/x86/acer-wmi.c
===================================================================

drivers/platform/x86/acer-wmi.c +2 -2
@@ -30,7 +30,6 @@
 #include <linux/input/sparse-keymap.h>
 #include <acpi/video.h>
 
-ACPI_MODULE_NAME(KBUILD_MODNAME);
 MODULE_AUTHOR("Carlos Corbacho");
 MODULE_DESCRIPTION("Acer Laptop WMI Extras Driver");
 MODULE_LICENSE("GPL");
@@ -1605,7 +1604,8 @@ static void acer_kbd_dock_get_initial_st
 
 	status = wmi_evaluate_method(WMID_GUID3, 0, 0x2, &input_buf, &output_buf);
 	if (ACPI_FAILURE(status)) {
-		ACPI_EXCEPTION((AE_INFO, status, "Error getting keyboard-dock initial status"));
+		pr_warn("Error getting keyboard-dock initial status: %s\n",
+			acpi_format_exception(status));
 		return;
 	}
 

Index: linux-pm/drivers/platform/surface/surfacepro3_button.c
===================================================================

drivers/platform/surface/surfacepro3_button.c +0 -2
@@ -40,8 +40,6 @@ static const guid_t MSHW0040_DSM_UUID =
 #define SURFACE_BUTTON_NOTIFY_PRESS_VOLUME_DOWN		0xc2
 #define SURFACE_BUTTON_NOTIFY_RELEASE_VOLUME_DOWN	0xc3
 
-ACPI_MODULE_NAME("surface pro 3 button");
-
 MODULE_AUTHOR("Chen Yu");
 MODULE_DESCRIPTION("Surface Pro3 Button Driver");
 MODULE_LICENSE("GPL v2");

Index: linux-pm/drivers/platform/x86/wmi.c
===================================================================

drivers/platform/x86/wmi.c +0 -1
@@ -32,7 +32,6 @@
 #include <linux/fs.h>
 #include <uapi/linux/wmi.h>
 
-ACPI_MODULE_NAME("wmi");
 MODULE_AUTHOR("Carlos Corbacho");
 MODULE_DESCRIPTION("ACPI-WMI Mapping Driver");
 MODULE_LICENSE("GPL");
#4 lore raw
Quoted 24 lines · Hans de Goede

Hi,

Quoted 20 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

A few x86 platform drivers use ACPI_DEBUG_PRINT() or ACPI_EXCEPTION() for printing messages, but that is questionable, because those macros belong to ACPICA and they should not be used elsewhere. In addition, ACPI_DEBUG_PRINT() requires special enabling to allow it to actually print the message, which is a nuisance, and the _COMPONENT symbol generally needed for that is not defined in any of the files in question.

For this reason, replace the ACPI_DEBUG_PRINT() in lg-laptop.c with pr_debug() and the one in xo15-ebook.c with acpi_handle_debug() (with the additional benefit that the source object can be identified more easily after this change), and replace the ACPI_EXCEPTION() in acer-wmi.c with pr_warn().

Also drop the ACPI_MODULE_NAME() definitions that are only used by the ACPICA message printing macros from those files and from wmi.c and surfacepro3_button.c (while at it).

Quoted 6 lines
Quoted 1 line

Thank you.

I've merged this into my review-hans branch now, minus the acer-wmi.c changes because a similar patch was already merged for those.

Thanks!