diff mbox series

[v1,09/34] acpi/tiny-power-button: Move handler installing logic to driver

Message ID 20230512140222.124868-10-michal.wilczynski@intel.com
State New
Headers show
Series Remove .notify callback in acpi_device_ops | expand

Commit Message

Michal Wilczynski May 12, 2023, 2:01 p.m. UTC
Currently logic for installing notifications from ACPI devices is
implemented using notify callback in struct acpi_driver. Preparations
are being made to replace acpi_driver with more generic struct
platform_driver, which doesn't contain notify callback. Furthermore
as of now handlers are being called indirectly through
acpi_notify_device(), which decreases performance.

Call acpi_device_install_event_handler() at the end of .add() callback.
Call acpi_device_remove_event_handler() at the beginning of .remove()
callback. Change arguments passed to the notify callback to match with
what's required by acpi_device_install_event_handler().

Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
---
 drivers/acpi/tiny-power-button.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

kernel test robot May 12, 2023, 8:09 p.m. UTC | #1
Hi Michal,

kernel test robot noticed the following build errors:

[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on chrome-platform/for-next groeck-staging/hwmon-next linus/master v6.4-rc1 next-20230512]
[cannot apply to jic23-iio/togreg nvdimm/libnvdimm-for-next nvdimm/dax-misc crng-random/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Michal-Wilczynski/acpi-Adjust-functions-installing-bus-event-handlers/20230512-220607
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link:    https://lore.kernel.org/r/20230512140222.124868-10-michal.wilczynski%40intel.com
patch subject: [PATCH v1 09/34] acpi/tiny-power-button: Move handler installing logic to driver
config: ia64-allmodconfig (https://download.01.org/0day-ci/archive/20230513/202305130350.ZEskVtFO-lkp@intel.com/config)
compiler: ia64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/e12cdb4ace4a523a569590ecc95f782f3d6fa98f
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Michal-Wilczynski/acpi-Adjust-functions-installing-bus-event-handlers/20230512-220607
        git checkout e12cdb4ace4a523a569590ecc95f782f3d6fa98f
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/acpi/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202305130350.ZEskVtFO-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/acpi/tiny-power-button.c: In function 'acpi_tiny_power_button_add':
>> drivers/acpi/tiny-power-button.c:25:51: error: 'acpi_tiny_power_button_notify' undeclared (first use in this function); did you mean 'acpi_tiny_power_button_add'?
      25 |                                                   acpi_tiny_power_button_notify);
         |                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                                                   acpi_tiny_power_button_add
   drivers/acpi/tiny-power-button.c:25:51: note: each undeclared identifier is reported only once for each function it appears in
   drivers/acpi/tiny-power-button.c: In function 'acpi_tiny_power_button_remove':
   drivers/acpi/tiny-power-button.c:31:42: error: 'acpi_tiny_power_button_notify' undeclared (first use in this function); did you mean 'acpi_tiny_power_button_remove'?
      31 |                                          acpi_tiny_power_button_notify);
         |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                                          acpi_tiny_power_button_remove
   drivers/acpi/tiny-power-button.c: In function 'acpi_tiny_power_button_add':
   drivers/acpi/tiny-power-button.c:26:1: error: control reaches end of non-void function [-Werror=return-type]
      26 | }
         | ^
   drivers/acpi/tiny-power-button.c: At top level:
   drivers/acpi/tiny-power-button.c:34:13: warning: 'acpi_tiny_power_button_notify' defined but not used [-Wunused-function]
      34 | static void acpi_tiny_power_button_notify(acpi_handle handle, u32 event, void *data)
         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +25 drivers/acpi/tiny-power-button.c

    21	
    22	static int acpi_tiny_power_button_add(struct acpi_device *device)
    23	{
    24		return acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY,
  > 25							  acpi_tiny_power_button_notify);
    26	}
    27
diff mbox series

Patch

diff --git a/drivers/acpi/tiny-power-button.c b/drivers/acpi/tiny-power-button.c
index 598f548b21f3..b14ba2f0dd3f 100644
--- a/drivers/acpi/tiny-power-button.c
+++ b/drivers/acpi/tiny-power-button.c
@@ -19,16 +19,19 @@  static const struct acpi_device_id tiny_power_button_device_ids[] = {
 };
 MODULE_DEVICE_TABLE(acpi, tiny_power_button_device_ids);
 
-static int acpi_noop_add(struct acpi_device *device)
+static int acpi_tiny_power_button_add(struct acpi_device *device)
 {
-	return 0;
+	return acpi_device_install_event_handler(device, ACPI_DEVICE_NOTIFY,
+						  acpi_tiny_power_button_notify);
 }
 
-static void acpi_noop_remove(struct acpi_device *device)
+static void acpi_tiny_power_button_remove(struct acpi_device *device)
 {
+	acpi_device_remove_event_handler(device->handle, ACPI_DEVICE_NOTIFY,
+					 acpi_tiny_power_button_notify);
 }
 
-static void acpi_tiny_power_button_notify(struct acpi_device *device, u32 event)
+static void acpi_tiny_power_button_notify(acpi_handle handle, u32 event, void *data)
 {
 	kill_cad_pid(power_signal, 1);
 }
@@ -38,9 +41,8 @@  static struct acpi_driver acpi_tiny_power_button_driver = {
 	.class = "tiny-power-button",
 	.ids = tiny_power_button_device_ids,
 	.ops = {
-		.add = acpi_noop_add,
-		.remove = acpi_noop_remove,
-		.notify = acpi_tiny_power_button_notify,
+		.add = acpi_tiny_power_button_add,
+		.remove = acpi_tiny_power_button_remove,
 	},
 };