All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] platform/x86: Move Lenovo files into lenovo subdir
@ 2025-05-07 19:04 Mark Pearson
  2025-05-07 19:04 ` [PATCH 2/2] platform/x86: export thinkpad_acpi handles Mark Pearson
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Mark Pearson @ 2025-05-07 19:04 UTC (permalink / raw)
  To: mpearson-lenovo
  Cc: hdegoede, ilpo.jarvinen, ikepanhc, W_Armin, andriy.shevchenko,
	linux-kernel, platform-driver-x86, ibm-acpi-devel

Move all Lenovo specific files into their own sub-directory as part
of clean-up exercise.
Longer term goal is to break-up thinkpad_acpi to improve maintainability
and perhaps share more functionality with other non thinkpad Lenovo
platforms.

Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
---
Some questions that I didn't want to put in the commit comment:

 - I didn't know if now was a good time to propose this change. I
   realise it could cause headaches for anybody with patches being
   worked on. Please let me know what makes it easiest for maintainers
   and other developers. If there is a particular branch that would be
   better to do this against also let me know.
 - Should I be updating the MAINTAINERS file? I'm still not sure what
   the protocol there is. I'm very happy to help review anything in the
   lenovo directory, but I didn't want to make assumptions.
 - I have tested on multiple platforms but I don't have any ideapads I
   can use.

 drivers/platform/x86/Kconfig                  | 229 +---------------
 drivers/platform/x86/Makefile                 |  13 +-
 drivers/platform/x86/lenovo/Kconfig           | 246 ++++++++++++++++++
 drivers/platform/x86/lenovo/Makefile          |  16 ++
 .../x86/{ => lenovo}/ideapad-laptop.c         |   0
 .../x86/{ => lenovo}/ideapad-laptop.h         |   0
 .../x86/{ => lenovo}/lenovo-wmi-camera.c      |   0
 .../lenovo-wmi-hotkey-utilities.c             |   0
 .../platform/x86/{ => lenovo}/lenovo-ymc.c    |   0
 .../lenovo-yoga-tab2-pro-1380-fastcharger.c   |   2 +-
 .../x86/{ => lenovo}/lenovo-yogabook.c        |   0
 drivers/platform/x86/{ => lenovo}/think-lmi.c |   2 +-
 drivers/platform/x86/{ => lenovo}/think-lmi.h |   0
 .../platform/x86/{ => lenovo}/thinkpad_acpi.c |   2 +-
 14 files changed, 270 insertions(+), 240 deletions(-)
 create mode 100644 drivers/platform/x86/lenovo/Kconfig
 create mode 100644 drivers/platform/x86/lenovo/Makefile
 rename drivers/platform/x86/{ => lenovo}/ideapad-laptop.c (100%)
 rename drivers/platform/x86/{ => lenovo}/ideapad-laptop.h (100%)
 rename drivers/platform/x86/{ => lenovo}/lenovo-wmi-camera.c (100%)
 rename drivers/platform/x86/{ => lenovo}/lenovo-wmi-hotkey-utilities.c (100%)
 rename drivers/platform/x86/{ => lenovo}/lenovo-ymc.c (100%)
 rename drivers/platform/x86/{ => lenovo}/lenovo-yoga-tab2-pro-1380-fastcharger.c (99%)
 rename drivers/platform/x86/{ => lenovo}/lenovo-yogabook.c (100%)
 rename drivers/platform/x86/{ => lenovo}/think-lmi.c (99%)
 rename drivers/platform/x86/{ => lenovo}/think-lmi.h (100%)
 rename drivers/platform/x86/{ => lenovo}/thinkpad_acpi.c (99%)

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 43407e76476b..20b61b658e88 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -120,32 +120,6 @@ config GIGABYTE_WMI
 	  To compile this driver as a module, choose M here: the module will
 	  be called gigabyte-wmi.
 
-config YOGABOOK
-	tristate "Lenovo Yoga Book tablet key driver"
-	depends on ACPI_WMI
-	depends on INPUT
-	depends on I2C
-	select LEDS_CLASS
-	select NEW_LEDS
-	help
-	  Say Y here if you want to support the 'Pen' key and keyboard backlight
-	  control on the Lenovo Yoga Book tablets.
-
-	  To compile this driver as a module, choose M here: the module will
-	  be called lenovo-yogabook.
-
-config YT2_1380
-	tristate "Lenovo Yoga Tablet 2 1380 fast charge driver"
-	depends on SERIAL_DEV_BUS
-	depends on EXTCON
-	depends on ACPI
-	help
-	  Say Y here to enable support for the custom fast charging protocol
-	  found on the Lenovo Yoga Tablet 2 1380F / 1380L models.
-
-	  To compile this driver as a module, choose M here: the module will
-	  be called lenovo-yogabook.
-
 config ACERHDF
 	tristate "Acer Aspire One temperature and fan driver"
 	depends on ACPI_EC && THERMAL
@@ -459,43 +433,6 @@ config IBM_RTL
 	 state = 0 (BIOS SMIs on)
 	 state = 1 (BIOS SMIs off)
 
-config IDEAPAD_LAPTOP
-	tristate "Lenovo IdeaPad Laptop Extras"
-	depends on ACPI
-	depends on RFKILL && INPUT
-	depends on SERIO_I8042
-	depends on BACKLIGHT_CLASS_DEVICE
-	depends on ACPI_VIDEO || ACPI_VIDEO = n
-	depends on ACPI_WMI || ACPI_WMI = n
-	select ACPI_PLATFORM_PROFILE
-	select INPUT_SPARSEKMAP
-	select NEW_LEDS
-	select LEDS_CLASS
-	help
-	  This is a driver for Lenovo IdeaPad netbooks contains drivers for
-	  rfkill switch, hotkey, fan control and backlight control.
-
-config LENOVO_WMI_HOTKEY_UTILITIES
-	tristate "Lenovo Hotkey Utility WMI extras driver"
-	depends on ACPI_WMI
-	select NEW_LEDS
-	select LEDS_CLASS
-	imply IDEAPAD_LAPTOP
-	help
-	  This driver provides WMI support for Lenovo customized hotkeys function,
-	  such as LED control for audio/mic mute event for Ideapad, YOGA, XiaoXin,
-	  Gaming, ThinkBook and so on.
-
-config LENOVO_YMC
-	tristate "Lenovo Yoga Tablet Mode Control"
-	depends on ACPI_WMI
-	depends on INPUT
-	depends on IDEAPAD_LAPTOP
-	select INPUT_SPARSEKMAP
-	help
-	  This driver maps the Tablet Mode Control switch to SW_TABLET_MODE input
-	  events for Lenovo Yoga notebooks.
-
 config SENSORS_HDAPS
 	tristate "Thinkpad Hard Drive Active Protection System (hdaps)"
 	depends on INPUT
@@ -514,160 +451,8 @@ config SENSORS_HDAPS
 	  Say Y here if you have an applicable laptop and want to experience
 	  the awesome power of hdaps.
 
-config THINKPAD_ACPI
-	tristate "ThinkPad ACPI Laptop Extras"
-	depends on ACPI_EC
-	depends on ACPI_BATTERY
-	depends on INPUT
-	depends on RFKILL || RFKILL = n
-	depends on ACPI_VIDEO || ACPI_VIDEO = n
-	depends on BACKLIGHT_CLASS_DEVICE
-	depends on I2C
-	depends on DRM
-	select ACPI_PLATFORM_PROFILE
-	select DRM_PRIVACY_SCREEN
-	select HWMON
-	select NVRAM
-	select NEW_LEDS
-	select LEDS_CLASS
-	select INPUT_SPARSEKMAP
-	help
-	  This is a driver for the IBM and Lenovo ThinkPad laptops. It adds
-	  support for Fn-Fx key combinations, Bluetooth control, video
-	  output switching, ThinkLight control, UltraBay eject and more.
-	  For more information about this driver see
-	  <file:Documentation/admin-guide/laptops/thinkpad-acpi.rst> and
-	  <http://ibm-acpi.sf.net/> .
-
-	  This driver was formerly known as ibm-acpi.
-
-	  Extra functionality will be available if the rfkill (CONFIG_RFKILL)
-	  and/or ALSA (CONFIG_SND) subsystems are available in the kernel.
-	  Note that if you want ThinkPad-ACPI to be built-in instead of
-	  modular, ALSA and rfkill will also have to be built-in.
-
-	  If you have an IBM or Lenovo ThinkPad laptop, say Y or M here.
-
-config THINKPAD_ACPI_ALSA_SUPPORT
-	bool "Console audio control ALSA interface"
-	depends on THINKPAD_ACPI
-	depends on SND
-	depends on SND = y || THINKPAD_ACPI = SND
-	default y
-	help
-	  Enables monitoring of the built-in console audio output control
-	  (headphone and speakers), which is operated by the mute and (in
-	  some ThinkPad models) volume hotkeys.
-
-	  If this option is enabled, ThinkPad-ACPI will export an ALSA card
-	  with a single read-only mixer control, which should be used for
-	  on-screen-display feedback purposes by the Desktop Environment.
-
-	  Optionally, the driver will also allow software control (the
-	  ALSA mixer will be made read-write).  Please refer to the driver
-	  documentation for details.
-
-	  All IBM models have both volume and mute control.  Newer Lenovo
-	  models only have mute control (the volume hotkeys are just normal
-	  keys and volume control is done through the main HDA mixer).
-
-config THINKPAD_ACPI_DEBUGFACILITIES
-	bool "Maintainer debug facilities"
-	depends on THINKPAD_ACPI
-	help
-	  Enables extra stuff in the thinkpad-acpi which is completely useless
-	  for normal use.  Read the driver source to find out what it does.
-
-	  Say N here, unless you were told by a kernel maintainer to do
-	  otherwise.
-
-config THINKPAD_ACPI_DEBUG
-	bool "Verbose debug mode"
-	depends on THINKPAD_ACPI
-	help
-	  Enables extra debugging information, at the expense of a slightly
-	  increase in driver size.
-
-	  If you are not sure, say N here.
-
-config THINKPAD_ACPI_UNSAFE_LEDS
-	bool "Allow control of important LEDs (unsafe)"
-	depends on THINKPAD_ACPI
-	help
-	  Overriding LED state on ThinkPads can mask important
-	  firmware alerts (like critical battery condition), or misled
-	  the user into damaging the hardware (undocking or ejecting
-	  the bay while buses are still active), etc.
-
-	  LED control on the ThinkPad is write-only (with very few
-	  exceptions on very ancient models), which makes it
-	  impossible to know beforehand if important information will
-	  be lost when one changes LED state.
-
-	  Users that know what they are doing can enable this option
-	  and the driver will allow control of every LED, including
-	  the ones on the dock stations.
-
-	  Never enable this option on a distribution kernel.
-
-	  Say N here, unless you are building a kernel for your own
-	  use, and need to control the important firmware LEDs.
-
-config THINKPAD_ACPI_VIDEO
-	bool "Video output control support"
-	depends on THINKPAD_ACPI
-	default y
-	help
-	  Allows the thinkpad_acpi driver to provide an interface to control
-	  the various video output ports.
-
-	  This feature often won't work well, depending on ThinkPad model,
-	  display state, video output devices in use, whether there is a X
-	  server running, phase of the moon, and the current mood of
-	  Schroedinger's cat.  If you can use X.org's RandR to control
-	  your ThinkPad's video output ports instead of this feature,
-	  don't think twice: do it and say N here to save memory and avoid
-	  bad interactions with X.org.
-
-	  NOTE: access to this feature is limited to processes with the
-	  CAP_SYS_ADMIN capability, to avoid local DoS issues in platforms
-	  where it interacts badly with X.org.
-
-	  If you are not sure, say Y here but do try to check if you could
-	  be using X.org RandR instead.
-
-config THINKPAD_ACPI_HOTKEY_POLL
-	bool "Support NVRAM polling for hot keys"
-	depends on THINKPAD_ACPI
-	default y
-	help
-	  Some thinkpad models benefit from NVRAM polling to detect a few of
-	  the hot key press events.  If you know your ThinkPad model does not
-	  need to do NVRAM polling to support any of the hot keys you use,
-	  unselecting this option will save about 1kB of memory.
-
-	  ThinkPads T40 and newer, R52 and newer, and X31 and newer are
-	  unlikely to need NVRAM polling in their latest BIOS versions.
-
-	  NVRAM polling can detect at most the following keys: ThinkPad/Access
-	  IBM, Zoom, Switch Display (fn+F7), ThinkLight, Volume up/down/mute,
-	  Brightness up/down, Display Expand (fn+F8), Hibernate (fn+F12).
-
-	  If you are not sure, say Y here.  The driver enables polling only if
-	  it is strictly necessary to do so.
-
-config THINKPAD_LMI
-	tristate "Lenovo WMI-based systems management driver"
-	depends on ACPI_WMI
-	select FW_ATTR_CLASS
-	help
-	  This driver allows changing BIOS settings on Lenovo machines whose
-	  BIOS support the WMI interface.
-
-	  To compile this driver as a module, choose M here: the module will
-	  be called think-lmi.
-
 source "drivers/platform/x86/intel/Kconfig"
+source "drivers/platform/x86/lenovo/Kconfig"
 
 config ACPI_QUICKSTART
 	tristate "ACPI Quickstart button driver"
@@ -1063,18 +848,6 @@ config INSPUR_PLATFORM_PROFILE
 	To compile this driver as a module, choose M here: the module
 	will be called inspur-platform-profile.
 
-config LENOVO_WMI_CAMERA
-	tristate "Lenovo WMI Camera Button driver"
-	depends on ACPI_WMI
-	depends on INPUT
-	help
-	  This driver provides support for Lenovo camera button. The Camera
-	  button is a GPIO device. This driver receives ACPI notifications when
-	  the camera button is switched on/off.
-
-	  To compile this driver as a module, choose M here: the module
-	  will be called lenovo-wmi-camera.
-
 source "drivers/platform/x86/x86-android-tablets/Kconfig"
 
 config FW_ATTR_CLASS
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 650dfbebb6c8..dae9dbb2ac94 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -58,21 +58,16 @@ obj-$(CONFIG_X86_PLATFORM_DRIVERS_HP)	+= hp/
 # Hewlett Packard Enterprise
 obj-$(CONFIG_UV_SYSFS)       += uv_sysfs.o
 
-# IBM Thinkpad and Lenovo
+# IBM Thinkpad
 obj-$(CONFIG_IBM_RTL)		+= ibm_rtl.o
-obj-$(CONFIG_IDEAPAD_LAPTOP)	+= ideapad-laptop.o
-obj-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES)	+= lenovo-wmi-hotkey-utilities.o
-obj-$(CONFIG_LENOVO_YMC)	+= lenovo-ymc.o
 obj-$(CONFIG_SENSORS_HDAPS)	+= hdaps.o
-obj-$(CONFIG_THINKPAD_ACPI)	+= thinkpad_acpi.o
-obj-$(CONFIG_THINKPAD_LMI)	+= think-lmi.o
-obj-$(CONFIG_YOGABOOK)		+= lenovo-yogabook.o
-obj-$(CONFIG_YT2_1380)		+= lenovo-yoga-tab2-pro-1380-fastcharger.o
-obj-$(CONFIG_LENOVO_WMI_CAMERA)	+= lenovo-wmi-camera.o
 
 # Intel
 obj-y				+= intel/
 
+# Lenovo
+obj-y				+= lenovo/
+
 # Microsoft
 obj-$(CONFIG_ACPI_QUICKSTART)  += quickstart.o
 
diff --git a/drivers/platform/x86/lenovo/Kconfig b/drivers/platform/x86/lenovo/Kconfig
new file mode 100644
index 000000000000..1c6e609cef6d
--- /dev/null
+++ b/drivers/platform/x86/lenovo/Kconfig
@@ -0,0 +1,246 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Lenovo X86 Platform Specific Drivers
+#
+
+menuconfig X86_PLATFORM_DRIVERS_LENOVO
+	bool "Lenovo X86 Platform Specific Device Drivers"
+	help
+	  Say Y here to get to see options for device drivers for various
+	  Lenovo x86 platforms, including vendor-specific laptop extension drivers.
+	  This option alone does not add any kernel code.
+
+	  If you say N, all options in this submenu will be skipped and disabled.
+
+if X86_PLATFORM_DRIVERS_LENOVO
+
+config YOGABOOK
+	tristate "Lenovo Yoga Book tablet key driver"
+	depends on ACPI_WMI
+	depends on INPUT
+	depends on I2C
+	select LEDS_CLASS
+	select NEW_LEDS
+	help
+	  Say Y here if you want to support the 'Pen' key and keyboard backlight
+	  control on the Lenovo Yoga Book tablets.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called lenovo-yogabook.
+
+config YT2_1380
+	tristate "Lenovo Yoga Tablet 2 1380 fast charge driver"
+	depends on SERIAL_DEV_BUS
+	depends on EXTCON
+	depends on ACPI
+	help
+	  Say Y here to enable support for the custom fast charging protocol
+	  found on the Lenovo Yoga Tablet 2 1380F / 1380L models.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called lenovo-yogabook.
+
+config IDEAPAD_LAPTOP
+	tristate "Lenovo IdeaPad Laptop Extras"
+	depends on ACPI
+	depends on RFKILL && INPUT
+	depends on SERIO_I8042
+	depends on BACKLIGHT_CLASS_DEVICE
+	depends on ACPI_VIDEO || ACPI_VIDEO = n
+	depends on ACPI_WMI || ACPI_WMI = n
+	select ACPI_PLATFORM_PROFILE
+	select INPUT_SPARSEKMAP
+	select NEW_LEDS
+	select LEDS_CLASS
+	help
+	  This is a driver for Lenovo IdeaPad netbooks contains drivers for
+	  rfkill switch, hotkey, fan control and backlight control.
+
+config LENOVO_WMI_HOTKEY_UTILITIES
+	tristate "Lenovo Hotkey Utility WMI extras driver"
+	depends on ACPI_WMI
+	select NEW_LEDS
+	select LEDS_CLASS
+	imply IDEAPAD_LAPTOP
+	help
+	  This driver provides WMI support for Lenovo customized hotkeys function,
+	  such as LED control for audio/mic mute event for Ideapad, YOGA, XiaoXin,
+	  Gaming, ThinkBook and so on.
+
+config LENOVO_YMC
+	tristate "Lenovo Yoga Tablet Mode Control"
+	depends on ACPI_WMI
+	depends on INPUT
+	depends on IDEAPAD_LAPTOP
+	select INPUT_SPARSEKMAP
+	help
+	  This driver maps the Tablet Mode Control switch to SW_TABLET_MODE input
+	  events for Lenovo Yoga notebooks.
+
+config THINKPAD_ACPI
+	tristate "ThinkPad ACPI Laptop Extras"
+	depends on ACPI_EC
+	depends on ACPI_BATTERY
+	depends on INPUT
+	depends on RFKILL || RFKILL = n
+	depends on ACPI_VIDEO || ACPI_VIDEO = n
+	depends on BACKLIGHT_CLASS_DEVICE
+	depends on I2C
+	depends on DRM
+	select ACPI_PLATFORM_PROFILE
+	select DRM_PRIVACY_SCREEN
+	select HWMON
+	select NVRAM
+	select NEW_LEDS
+	select LEDS_CLASS
+	select INPUT_SPARSEKMAP
+	help
+	  This is a driver for the IBM and Lenovo ThinkPad laptops. It adds
+	  support for Fn-Fx key combinations, Bluetooth control, video
+	  output switching, ThinkLight control, UltraBay eject and more.
+	  For more information about this driver see
+	  <file:Documentation/admin-guide/laptops/thinkpad-acpi.rst> and
+	  <http://ibm-acpi.sf.net/> .
+
+	  This driver was formerly known as ibm-acpi.
+
+	  Extra functionality will be available if the rfkill (CONFIG_RFKILL)
+	  and/or ALSA (CONFIG_SND) subsystems are available in the kernel.
+	  Note that if you want ThinkPad-ACPI to be built-in instead of
+	  modular, ALSA and rfkill will also have to be built-in.
+
+	  If you have an IBM or Lenovo ThinkPad laptop, say Y or M here.
+
+config THINKPAD_ACPI_ALSA_SUPPORT
+	bool "Console audio control ALSA interface"
+	depends on THINKPAD_ACPI
+	depends on SND
+	depends on SND = y || THINKPAD_ACPI = SND
+	default y
+	help
+	  Enables monitoring of the built-in console audio output control
+	  (headphone and speakers), which is operated by the mute and (in
+	  some ThinkPad models) volume hotkeys.
+
+	  If this option is enabled, ThinkPad-ACPI will export an ALSA card
+	  with a single read-only mixer control, which should be used for
+	  on-screen-display feedback purposes by the Desktop Environment.
+
+	  Optionally, the driver will also allow software control (the
+	  ALSA mixer will be made read-write).  Please refer to the driver
+	  documentation for details.
+
+	  All IBM models have both volume and mute control.  Newer Lenovo
+	  models only have mute control (the volume hotkeys are just normal
+	  keys and volume control is done through the main HDA mixer).
+
+config THINKPAD_ACPI_DEBUGFACILITIES
+	bool "Maintainer debug facilities"
+	depends on THINKPAD_ACPI
+	help
+	  Enables extra stuff in the thinkpad-acpi which is completely useless
+	  for normal use.  Read the driver source to find out what it does.
+
+	  Say N here, unless you were told by a kernel maintainer to do
+	  otherwise.
+
+config THINKPAD_ACPI_DEBUG
+	bool "Verbose debug mode"
+	depends on THINKPAD_ACPI
+	help
+	  Enables extra debugging information, at the expense of a slightly
+	  increase in driver size.
+
+	  If you are not sure, say N here.
+
+config THINKPAD_ACPI_UNSAFE_LEDS
+	bool "Allow control of important LEDs (unsafe)"
+	depends on THINKPAD_ACPI
+	help
+	  Overriding LED state on ThinkPads can mask important
+	  firmware alerts (like critical battery condition), or misled
+	  the user into damaging the hardware (undocking or ejecting
+	  the bay while buses are still active), etc.
+
+	  LED control on the ThinkPad is write-only (with very few
+	  exceptions on very ancient models), which makes it
+	  impossible to know beforehand if important information will
+	  be lost when one changes LED state.
+
+	  Users that know what they are doing can enable this option
+	  and the driver will allow control of every LED, including
+	  the ones on the dock stations.
+
+	  Never enable this option on a distribution kernel.
+
+	  Say N here, unless you are building a kernel for your own
+	  use, and need to control the important firmware LEDs.
+
+config THINKPAD_ACPI_VIDEO
+	bool "Video output control support"
+	depends on THINKPAD_ACPI
+	default y
+	help
+	  Allows the thinkpad_acpi driver to provide an interface to control
+	  the various video output ports.
+
+	  This feature often won't work well, depending on ThinkPad model,
+	  display state, video output devices in use, whether there is a X
+	  server running, phase of the moon, and the current mood of
+	  Schroedinger's cat.  If you can use X.org's RandR to control
+	  your ThinkPad's video output ports instead of this feature,
+	  don't think twice: do it and say N here to save memory and avoid
+	  bad interactions with X.org.
+
+	  NOTE: access to this feature is limited to processes with the
+	  CAP_SYS_ADMIN capability, to avoid local DoS issues in platforms
+	  where it interacts badly with X.org.
+
+	  If you are not sure, say Y here but do try to check if you could
+	  be using X.org RandR instead.
+
+config THINKPAD_ACPI_HOTKEY_POLL
+	bool "Support NVRAM polling for hot keys"
+	depends on THINKPAD_ACPI
+	default y
+	help
+	  Some thinkpad models benefit from NVRAM polling to detect a few of
+	  the hot key press events.  If you know your ThinkPad model does not
+	  need to do NVRAM polling to support any of the hot keys you use,
+	  unselecting this option will save about 1kB of memory.
+
+	  ThinkPads T40 and newer, R52 and newer, and X31 and newer are
+	  unlikely to need NVRAM polling in their latest BIOS versions.
+
+	  NVRAM polling can detect at most the following keys: ThinkPad/Access
+	  IBM, Zoom, Switch Display (fn+F7), ThinkLight, Volume up/down/mute,
+	  Brightness up/down, Display Expand (fn+F8), Hibernate (fn+F12).
+
+	  If you are not sure, say Y here.  The driver enables polling only if
+	  it is strictly necessary to do so.
+
+config THINKPAD_LMI
+	tristate "Lenovo WMI-based systems management driver"
+	depends on ACPI_WMI
+	select FW_ATTR_CLASS
+	help
+	  This driver allows changing BIOS settings on Lenovo machines whose
+	  BIOS support the WMI interface.
+
+	  To compile this driver as a module, choose M here: the module will
+	  be called think-lmi.
+
+config LENOVO_WMI_CAMERA
+	tristate "Lenovo WMI Camera Button driver"
+	depends on ACPI_WMI
+	depends on INPUT
+	help
+	  This driver provides support for Lenovo camera button. The Camera
+	  button is a GPIO device. This driver receives ACPI notifications when
+	  the camera button is switched on/off.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called lenovo-wmi-camera.
+
+endif # X86_PLATFORM_DRIVERS_LENOVO
+
diff --git a/drivers/platform/x86/lenovo/Makefile b/drivers/platform/x86/lenovo/Makefile
new file mode 100644
index 000000000000..f3290d9c6fd6
--- /dev/null
+++ b/drivers/platform/x86/lenovo/Makefile
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Makefile for linux/drivers/platform/x86/lenovo
+# Lenovo x86 Platform-Specific Drivers
+#
+obj-$(CONFIG_IDEAPAD_LAPTOP)	+= ideapad-laptop.o
+obj-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES)	+= lenovo-wmi-hotkey-utilities.o
+obj-$(CONFIG_LENOVO_YMC)	+= lenovo-ymc.o
+obj-$(CONFIG_THINKPAD_ACPI)	+= thinkpad_acpi.o
+obj-$(CONFIG_THINKPAD_LMI)	+= think-lmi.o
+obj-$(CONFIG_YOGABOOK)		+= lenovo-yogabook.o
+obj-$(CONFIG_YT2_1380)		+= lenovo-yoga-tab2-pro-1380-fastcharger.o
+obj-$(CONFIG_LENOVO_WMI_CAMERA)	+= lenovo-wmi-camera.o
+
+
+
diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/lenovo/ideapad-laptop.c
similarity index 100%
rename from drivers/platform/x86/ideapad-laptop.c
rename to drivers/platform/x86/lenovo/ideapad-laptop.c
diff --git a/drivers/platform/x86/ideapad-laptop.h b/drivers/platform/x86/lenovo/ideapad-laptop.h
similarity index 100%
rename from drivers/platform/x86/ideapad-laptop.h
rename to drivers/platform/x86/lenovo/ideapad-laptop.h
diff --git a/drivers/platform/x86/lenovo-wmi-camera.c b/drivers/platform/x86/lenovo/lenovo-wmi-camera.c
similarity index 100%
rename from drivers/platform/x86/lenovo-wmi-camera.c
rename to drivers/platform/x86/lenovo/lenovo-wmi-camera.c
diff --git a/drivers/platform/x86/lenovo-wmi-hotkey-utilities.c b/drivers/platform/x86/lenovo/lenovo-wmi-hotkey-utilities.c
similarity index 100%
rename from drivers/platform/x86/lenovo-wmi-hotkey-utilities.c
rename to drivers/platform/x86/lenovo/lenovo-wmi-hotkey-utilities.c
diff --git a/drivers/platform/x86/lenovo-ymc.c b/drivers/platform/x86/lenovo/lenovo-ymc.c
similarity index 100%
rename from drivers/platform/x86/lenovo-ymc.c
rename to drivers/platform/x86/lenovo/lenovo-ymc.c
diff --git a/drivers/platform/x86/lenovo-yoga-tab2-pro-1380-fastcharger.c b/drivers/platform/x86/lenovo/lenovo-yoga-tab2-pro-1380-fastcharger.c
similarity index 99%
rename from drivers/platform/x86/lenovo-yoga-tab2-pro-1380-fastcharger.c
rename to drivers/platform/x86/lenovo/lenovo-yoga-tab2-pro-1380-fastcharger.c
index 25933cd018d1..b3fd6a35052a 100644
--- a/drivers/platform/x86/lenovo-yoga-tab2-pro-1380-fastcharger.c
+++ b/drivers/platform/x86/lenovo/lenovo-yoga-tab2-pro-1380-fastcharger.c
@@ -21,7 +21,7 @@
 #include <linux/time.h>
 #include <linux/types.h>
 #include <linux/workqueue.h>
-#include "serdev_helpers.h"
+#include "../serdev_helpers.h"
 
 #define YT2_1380_FC_PDEV_NAME		"lenovo-yoga-tab2-pro-1380-fastcharger"
 #define YT2_1380_FC_SERDEV_CTRL		"serial0"
diff --git a/drivers/platform/x86/lenovo-yogabook.c b/drivers/platform/x86/lenovo/lenovo-yogabook.c
similarity index 100%
rename from drivers/platform/x86/lenovo-yogabook.c
rename to drivers/platform/x86/lenovo/lenovo-yogabook.c
diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/lenovo/think-lmi.c
similarity index 99%
rename from drivers/platform/x86/think-lmi.c
rename to drivers/platform/x86/lenovo/think-lmi.c
index 0fc275e461be..5d629a85a55a 100644
--- a/drivers/platform/x86/think-lmi.c
+++ b/drivers/platform/x86/lenovo/think-lmi.c
@@ -20,7 +20,7 @@
 #include <linux/types.h>
 #include <linux/dmi.h>
 #include <linux/wmi.h>
-#include "firmware_attributes_class.h"
+#include "../firmware_attributes_class.h"
 #include "think-lmi.h"
 
 static bool debug_support;
diff --git a/drivers/platform/x86/think-lmi.h b/drivers/platform/x86/lenovo/think-lmi.h
similarity index 100%
rename from drivers/platform/x86/think-lmi.h
rename to drivers/platform/x86/lenovo/think-lmi.h
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
similarity index 99%
rename from drivers/platform/x86/thinkpad_acpi.c
rename to drivers/platform/x86/lenovo/thinkpad_acpi.c
index 5790095c175e..7dd4abf47f61 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -81,7 +81,7 @@
 #include <sound/core.h>
 #include <sound/initval.h>
 
-#include "dual_accel_detect.h"
+#include "../dual_accel_detect.h"
 
 /* ThinkPad CMOS commands */
 #define TP_CMOS_VOLUME_DOWN	0
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/2] platform/x86: export thinkpad_acpi handles
  2025-05-07 19:04 [PATCH 1/2] platform/x86: Move Lenovo files into lenovo subdir Mark Pearson
@ 2025-05-07 19:04 ` Mark Pearson
  2025-05-08 14:03   ` Ilpo Järvinen
  2025-05-08 14:31   ` Andy Shevchenko
  2025-05-08 14:01 ` [PATCH 1/2] platform/x86: Move Lenovo files into lenovo subdir Ilpo Järvinen
  2025-05-08 14:29 ` Andy Shevchenko
  2 siblings, 2 replies; 13+ messages in thread
From: Mark Pearson @ 2025-05-07 19:04 UTC (permalink / raw)
  To: mpearson-lenovo
  Cc: hdegoede, ilpo.jarvinen, ikepanhc, W_Armin, andriy.shevchenko,
	linux-kernel, platform-driver-x86, ibm-acpi-devel

Add API to be able to get the thinkpad_acpi various handles.

Will use this to start pulling some of the thinkpad_acpi functionality
into separate modules in the future.

Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
---
 drivers/platform/x86/lenovo/thinkpad_acpi.c | 18 ++++++++++++++++++
 include/linux/thinkpad_acpi.h               | 17 +++++++++++++++++
 2 files changed, 35 insertions(+)
 create mode 100644 include/linux/thinkpad_acpi.h

diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
index 7dd4abf47f61..0eb33b4c99cf 100644
--- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
+++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
@@ -67,6 +67,7 @@
 #include <linux/string.h>
 #include <linux/string_helpers.h>
 #include <linux/sysfs.h>
+#include <linux/thinkpad_acpi.h>
 #include <linux/types.h>
 #include <linux/uaccess.h>
 #include <linux/units.h>
@@ -606,6 +607,23 @@ TPACPI_HANDLE(hkey, ec, "\\_SB.HKEY",	/* 600e/x, 770e, 770x */
  * ACPI helpers
  */
 
+int tp_acpi_get_handle(enum tp_acpi_handle_id handle_id, acpi_handle *handle)
+{
+	switch (handle_id) {
+	case TP_ROOT_HANDLE:
+		*handle = root_handle;
+		return 0;
+	case TP_EC_HANDLE:
+		*handle = ec_handle;
+		return 0;
+	case TP_HKEY_HANDLE:
+		*handle = hkey_handle;
+		return 0;
+	}
+	return -ENODEV;
+}
+EXPORT_SYMBOL_GPL(tp_acpi_get_handle);
+
 static int acpi_evalf(acpi_handle handle,
 		      int *res, char *method, char *fmt, ...)
 {
diff --git a/include/linux/thinkpad_acpi.h b/include/linux/thinkpad_acpi.h
new file mode 100644
index 000000000000..eb5273464658
--- /dev/null
+++ b/include/linux/thinkpad_acpi.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Thinkpad ACPI driver API
+ */
+
+#ifndef _TP_ACPI_H_
+#define _TP_ACPI_H_
+
+enum tp_acpi_handle_id {
+	TP_ROOT_HANDLE,
+	TP_EC_HANDLE,
+	TP_HKEY_HANDLE,
+};
+
+int tp_acpi_get_handle(enum tp_acpi_handle_id handle_id, acpi_handle *handle);
+
+#endif /* _TP_ACPI_H */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] platform/x86: Move Lenovo files into lenovo subdir
  2025-05-07 19:04 [PATCH 1/2] platform/x86: Move Lenovo files into lenovo subdir Mark Pearson
  2025-05-07 19:04 ` [PATCH 2/2] platform/x86: export thinkpad_acpi handles Mark Pearson
@ 2025-05-08 14:01 ` Ilpo Järvinen
  2025-05-08 14:23   ` Mark Pearson
  2025-05-08 14:29 ` Andy Shevchenko
  2 siblings, 1 reply; 13+ messages in thread
From: Ilpo Järvinen @ 2025-05-08 14:01 UTC (permalink / raw)
  To: Mark Pearson
  Cc: Hans de Goede, ikepanhc, W_Armin, Andy Shevchenko, LKML,
	platform-driver-x86, ibm-acpi-devel

On Wed, 7 May 2025, Mark Pearson wrote:

> Move all Lenovo specific files into their own sub-directory as part
> of clean-up exercise.
> Longer term goal is to break-up thinkpad_acpi to improve maintainability
> and perhaps share more functionality with other non thinkpad Lenovo
> platforms.
> 
> Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> ---
> Some questions that I didn't want to put in the commit comment:
> 
>  - I didn't know if now was a good time to propose this change. I
>    realise it could cause headaches for anybody with patches being
>    worked on.

Don't worry too much about other changes, if you don't recall anything 
immediately, there likely isn't anything that significant. If we always
postpone useful reorganizations in fear that some hypothetical work would 
have to rebase, it never gets done :-).

>    Please let me know what makes it easiest for maintainers
>    and other developers. If there is a particular branch that would be
>    better to do this against also let me know.

Once I've merged fixes branch into for-next (I should do that at latest 
early next week if not already this week), it should be pretty 
straightforward to handle such move without conflicts.

>  - Should I be updating the MAINTAINERS file? I'm still not sure what
>    the protocol there is. I'm very happy to help review anything in the
>    lenovo directory, but I didn't want to make assumptions.

You should certainly update MAINTAINERS in the same patch to the new 
paths. If you want to make other changes, put them such as add your name 
into some entry or create a generic LENOVO entry, put those into own 
patch after the move please.

>  - I have tested on multiple platforms but I don't have any ideapads I
>    can use.

Given it's just moves file to new place, the threat of breaking something 
that isn't detected by simple build test, isn't that high.

-- 
 i.

>  drivers/platform/x86/Kconfig                  | 229 +---------------
>  drivers/platform/x86/Makefile                 |  13 +-
>  drivers/platform/x86/lenovo/Kconfig           | 246 ++++++++++++++++++
>  drivers/platform/x86/lenovo/Makefile          |  16 ++
>  .../x86/{ => lenovo}/ideapad-laptop.c         |   0
>  .../x86/{ => lenovo}/ideapad-laptop.h         |   0
>  .../x86/{ => lenovo}/lenovo-wmi-camera.c      |   0
>  .../lenovo-wmi-hotkey-utilities.c             |   0
>  .../platform/x86/{ => lenovo}/lenovo-ymc.c    |   0
>  .../lenovo-yoga-tab2-pro-1380-fastcharger.c   |   2 +-
>  .../x86/{ => lenovo}/lenovo-yogabook.c        |   0
>  drivers/platform/x86/{ => lenovo}/think-lmi.c |   2 +-
>  drivers/platform/x86/{ => lenovo}/think-lmi.h |   0
>  .../platform/x86/{ => lenovo}/thinkpad_acpi.c |   2 +-
>  14 files changed, 270 insertions(+), 240 deletions(-)
>  create mode 100644 drivers/platform/x86/lenovo/Kconfig
>  create mode 100644 drivers/platform/x86/lenovo/Makefile
>  rename drivers/platform/x86/{ => lenovo}/ideapad-laptop.c (100%)
>  rename drivers/platform/x86/{ => lenovo}/ideapad-laptop.h (100%)
>  rename drivers/platform/x86/{ => lenovo}/lenovo-wmi-camera.c (100%)
>  rename drivers/platform/x86/{ => lenovo}/lenovo-wmi-hotkey-utilities.c (100%)
>  rename drivers/platform/x86/{ => lenovo}/lenovo-ymc.c (100%)
>  rename drivers/platform/x86/{ => lenovo}/lenovo-yoga-tab2-pro-1380-fastcharger.c (99%)
>  rename drivers/platform/x86/{ => lenovo}/lenovo-yogabook.c (100%)
>  rename drivers/platform/x86/{ => lenovo}/think-lmi.c (99%)
>  rename drivers/platform/x86/{ => lenovo}/think-lmi.h (100%)
>  rename drivers/platform/x86/{ => lenovo}/thinkpad_acpi.c (99%)
> 
> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> index 43407e76476b..20b61b658e88 100644
> --- a/drivers/platform/x86/Kconfig
> +++ b/drivers/platform/x86/Kconfig
> @@ -120,32 +120,6 @@ config GIGABYTE_WMI
>  	  To compile this driver as a module, choose M here: the module will
>  	  be called gigabyte-wmi.
>  
> -config YOGABOOK
> -	tristate "Lenovo Yoga Book tablet key driver"
> -	depends on ACPI_WMI
> -	depends on INPUT
> -	depends on I2C
> -	select LEDS_CLASS
> -	select NEW_LEDS
> -	help
> -	  Say Y here if you want to support the 'Pen' key and keyboard backlight
> -	  control on the Lenovo Yoga Book tablets.
> -
> -	  To compile this driver as a module, choose M here: the module will
> -	  be called lenovo-yogabook.
> -
> -config YT2_1380
> -	tristate "Lenovo Yoga Tablet 2 1380 fast charge driver"
> -	depends on SERIAL_DEV_BUS
> -	depends on EXTCON
> -	depends on ACPI
> -	help
> -	  Say Y here to enable support for the custom fast charging protocol
> -	  found on the Lenovo Yoga Tablet 2 1380F / 1380L models.
> -
> -	  To compile this driver as a module, choose M here: the module will
> -	  be called lenovo-yogabook.
> -
>  config ACERHDF
>  	tristate "Acer Aspire One temperature and fan driver"
>  	depends on ACPI_EC && THERMAL
> @@ -459,43 +433,6 @@ config IBM_RTL
>  	 state = 0 (BIOS SMIs on)
>  	 state = 1 (BIOS SMIs off)
>  
> -config IDEAPAD_LAPTOP
> -	tristate "Lenovo IdeaPad Laptop Extras"
> -	depends on ACPI
> -	depends on RFKILL && INPUT
> -	depends on SERIO_I8042
> -	depends on BACKLIGHT_CLASS_DEVICE
> -	depends on ACPI_VIDEO || ACPI_VIDEO = n
> -	depends on ACPI_WMI || ACPI_WMI = n
> -	select ACPI_PLATFORM_PROFILE
> -	select INPUT_SPARSEKMAP
> -	select NEW_LEDS
> -	select LEDS_CLASS
> -	help
> -	  This is a driver for Lenovo IdeaPad netbooks contains drivers for
> -	  rfkill switch, hotkey, fan control and backlight control.
> -
> -config LENOVO_WMI_HOTKEY_UTILITIES
> -	tristate "Lenovo Hotkey Utility WMI extras driver"
> -	depends on ACPI_WMI
> -	select NEW_LEDS
> -	select LEDS_CLASS
> -	imply IDEAPAD_LAPTOP
> -	help
> -	  This driver provides WMI support for Lenovo customized hotkeys function,
> -	  such as LED control for audio/mic mute event for Ideapad, YOGA, XiaoXin,
> -	  Gaming, ThinkBook and so on.
> -
> -config LENOVO_YMC
> -	tristate "Lenovo Yoga Tablet Mode Control"
> -	depends on ACPI_WMI
> -	depends on INPUT
> -	depends on IDEAPAD_LAPTOP
> -	select INPUT_SPARSEKMAP
> -	help
> -	  This driver maps the Tablet Mode Control switch to SW_TABLET_MODE input
> -	  events for Lenovo Yoga notebooks.
> -
>  config SENSORS_HDAPS
>  	tristate "Thinkpad Hard Drive Active Protection System (hdaps)"
>  	depends on INPUT
> @@ -514,160 +451,8 @@ config SENSORS_HDAPS
>  	  Say Y here if you have an applicable laptop and want to experience
>  	  the awesome power of hdaps.
>  
> -config THINKPAD_ACPI
> -	tristate "ThinkPad ACPI Laptop Extras"
> -	depends on ACPI_EC
> -	depends on ACPI_BATTERY
> -	depends on INPUT
> -	depends on RFKILL || RFKILL = n
> -	depends on ACPI_VIDEO || ACPI_VIDEO = n
> -	depends on BACKLIGHT_CLASS_DEVICE
> -	depends on I2C
> -	depends on DRM
> -	select ACPI_PLATFORM_PROFILE
> -	select DRM_PRIVACY_SCREEN
> -	select HWMON
> -	select NVRAM
> -	select NEW_LEDS
> -	select LEDS_CLASS
> -	select INPUT_SPARSEKMAP
> -	help
> -	  This is a driver for the IBM and Lenovo ThinkPad laptops. It adds
> -	  support for Fn-Fx key combinations, Bluetooth control, video
> -	  output switching, ThinkLight control, UltraBay eject and more.
> -	  For more information about this driver see
> -	  <file:Documentation/admin-guide/laptops/thinkpad-acpi.rst> and
> -	  <http://ibm-acpi.sf.net/> .
> -
> -	  This driver was formerly known as ibm-acpi.
> -
> -	  Extra functionality will be available if the rfkill (CONFIG_RFKILL)
> -	  and/or ALSA (CONFIG_SND) subsystems are available in the kernel.
> -	  Note that if you want ThinkPad-ACPI to be built-in instead of
> -	  modular, ALSA and rfkill will also have to be built-in.
> -
> -	  If you have an IBM or Lenovo ThinkPad laptop, say Y or M here.
> -
> -config THINKPAD_ACPI_ALSA_SUPPORT
> -	bool "Console audio control ALSA interface"
> -	depends on THINKPAD_ACPI
> -	depends on SND
> -	depends on SND = y || THINKPAD_ACPI = SND
> -	default y
> -	help
> -	  Enables monitoring of the built-in console audio output control
> -	  (headphone and speakers), which is operated by the mute and (in
> -	  some ThinkPad models) volume hotkeys.
> -
> -	  If this option is enabled, ThinkPad-ACPI will export an ALSA card
> -	  with a single read-only mixer control, which should be used for
> -	  on-screen-display feedback purposes by the Desktop Environment.
> -
> -	  Optionally, the driver will also allow software control (the
> -	  ALSA mixer will be made read-write).  Please refer to the driver
> -	  documentation for details.
> -
> -	  All IBM models have both volume and mute control.  Newer Lenovo
> -	  models only have mute control (the volume hotkeys are just normal
> -	  keys and volume control is done through the main HDA mixer).
> -
> -config THINKPAD_ACPI_DEBUGFACILITIES
> -	bool "Maintainer debug facilities"
> -	depends on THINKPAD_ACPI
> -	help
> -	  Enables extra stuff in the thinkpad-acpi which is completely useless
> -	  for normal use.  Read the driver source to find out what it does.
> -
> -	  Say N here, unless you were told by a kernel maintainer to do
> -	  otherwise.
> -
> -config THINKPAD_ACPI_DEBUG
> -	bool "Verbose debug mode"
> -	depends on THINKPAD_ACPI
> -	help
> -	  Enables extra debugging information, at the expense of a slightly
> -	  increase in driver size.
> -
> -	  If you are not sure, say N here.
> -
> -config THINKPAD_ACPI_UNSAFE_LEDS
> -	bool "Allow control of important LEDs (unsafe)"
> -	depends on THINKPAD_ACPI
> -	help
> -	  Overriding LED state on ThinkPads can mask important
> -	  firmware alerts (like critical battery condition), or misled
> -	  the user into damaging the hardware (undocking or ejecting
> -	  the bay while buses are still active), etc.
> -
> -	  LED control on the ThinkPad is write-only (with very few
> -	  exceptions on very ancient models), which makes it
> -	  impossible to know beforehand if important information will
> -	  be lost when one changes LED state.
> -
> -	  Users that know what they are doing can enable this option
> -	  and the driver will allow control of every LED, including
> -	  the ones on the dock stations.
> -
> -	  Never enable this option on a distribution kernel.
> -
> -	  Say N here, unless you are building a kernel for your own
> -	  use, and need to control the important firmware LEDs.
> -
> -config THINKPAD_ACPI_VIDEO
> -	bool "Video output control support"
> -	depends on THINKPAD_ACPI
> -	default y
> -	help
> -	  Allows the thinkpad_acpi driver to provide an interface to control
> -	  the various video output ports.
> -
> -	  This feature often won't work well, depending on ThinkPad model,
> -	  display state, video output devices in use, whether there is a X
> -	  server running, phase of the moon, and the current mood of
> -	  Schroedinger's cat.  If you can use X.org's RandR to control
> -	  your ThinkPad's video output ports instead of this feature,
> -	  don't think twice: do it and say N here to save memory and avoid
> -	  bad interactions with X.org.
> -
> -	  NOTE: access to this feature is limited to processes with the
> -	  CAP_SYS_ADMIN capability, to avoid local DoS issues in platforms
> -	  where it interacts badly with X.org.
> -
> -	  If you are not sure, say Y here but do try to check if you could
> -	  be using X.org RandR instead.
> -
> -config THINKPAD_ACPI_HOTKEY_POLL
> -	bool "Support NVRAM polling for hot keys"
> -	depends on THINKPAD_ACPI
> -	default y
> -	help
> -	  Some thinkpad models benefit from NVRAM polling to detect a few of
> -	  the hot key press events.  If you know your ThinkPad model does not
> -	  need to do NVRAM polling to support any of the hot keys you use,
> -	  unselecting this option will save about 1kB of memory.
> -
> -	  ThinkPads T40 and newer, R52 and newer, and X31 and newer are
> -	  unlikely to need NVRAM polling in their latest BIOS versions.
> -
> -	  NVRAM polling can detect at most the following keys: ThinkPad/Access
> -	  IBM, Zoom, Switch Display (fn+F7), ThinkLight, Volume up/down/mute,
> -	  Brightness up/down, Display Expand (fn+F8), Hibernate (fn+F12).
> -
> -	  If you are not sure, say Y here.  The driver enables polling only if
> -	  it is strictly necessary to do so.
> -
> -config THINKPAD_LMI
> -	tristate "Lenovo WMI-based systems management driver"
> -	depends on ACPI_WMI
> -	select FW_ATTR_CLASS
> -	help
> -	  This driver allows changing BIOS settings on Lenovo machines whose
> -	  BIOS support the WMI interface.
> -
> -	  To compile this driver as a module, choose M here: the module will
> -	  be called think-lmi.
> -
>  source "drivers/platform/x86/intel/Kconfig"
> +source "drivers/platform/x86/lenovo/Kconfig"
>  
>  config ACPI_QUICKSTART
>  	tristate "ACPI Quickstart button driver"
> @@ -1063,18 +848,6 @@ config INSPUR_PLATFORM_PROFILE
>  	To compile this driver as a module, choose M here: the module
>  	will be called inspur-platform-profile.
>  
> -config LENOVO_WMI_CAMERA
> -	tristate "Lenovo WMI Camera Button driver"
> -	depends on ACPI_WMI
> -	depends on INPUT
> -	help
> -	  This driver provides support for Lenovo camera button. The Camera
> -	  button is a GPIO device. This driver receives ACPI notifications when
> -	  the camera button is switched on/off.
> -
> -	  To compile this driver as a module, choose M here: the module
> -	  will be called lenovo-wmi-camera.
> -
>  source "drivers/platform/x86/x86-android-tablets/Kconfig"
>  
>  config FW_ATTR_CLASS
> diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
> index 650dfbebb6c8..dae9dbb2ac94 100644
> --- a/drivers/platform/x86/Makefile
> +++ b/drivers/platform/x86/Makefile
> @@ -58,21 +58,16 @@ obj-$(CONFIG_X86_PLATFORM_DRIVERS_HP)	+= hp/
>  # Hewlett Packard Enterprise
>  obj-$(CONFIG_UV_SYSFS)       += uv_sysfs.o
>  
> -# IBM Thinkpad and Lenovo
> +# IBM Thinkpad
>  obj-$(CONFIG_IBM_RTL)		+= ibm_rtl.o
> -obj-$(CONFIG_IDEAPAD_LAPTOP)	+= ideapad-laptop.o
> -obj-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES)	+= lenovo-wmi-hotkey-utilities.o
> -obj-$(CONFIG_LENOVO_YMC)	+= lenovo-ymc.o
>  obj-$(CONFIG_SENSORS_HDAPS)	+= hdaps.o
> -obj-$(CONFIG_THINKPAD_ACPI)	+= thinkpad_acpi.o
> -obj-$(CONFIG_THINKPAD_LMI)	+= think-lmi.o
> -obj-$(CONFIG_YOGABOOK)		+= lenovo-yogabook.o
> -obj-$(CONFIG_YT2_1380)		+= lenovo-yoga-tab2-pro-1380-fastcharger.o
> -obj-$(CONFIG_LENOVO_WMI_CAMERA)	+= lenovo-wmi-camera.o
>  
>  # Intel
>  obj-y				+= intel/
>  
> +# Lenovo
> +obj-y				+= lenovo/
> +
>  # Microsoft
>  obj-$(CONFIG_ACPI_QUICKSTART)  += quickstart.o
>  
> diff --git a/drivers/platform/x86/lenovo/Kconfig b/drivers/platform/x86/lenovo/Kconfig
> new file mode 100644
> index 000000000000..1c6e609cef6d
> --- /dev/null
> +++ b/drivers/platform/x86/lenovo/Kconfig
> @@ -0,0 +1,246 @@
> +# SPDX-License-Identifier: GPL-2.0-only
> +#
> +# Lenovo X86 Platform Specific Drivers
> +#
> +
> +menuconfig X86_PLATFORM_DRIVERS_LENOVO
> +	bool "Lenovo X86 Platform Specific Device Drivers"
> +	help
> +	  Say Y here to get to see options for device drivers for various
> +	  Lenovo x86 platforms, including vendor-specific laptop extension drivers.
> +	  This option alone does not add any kernel code.
> +
> +	  If you say N, all options in this submenu will be skipped and disabled.
> +
> +if X86_PLATFORM_DRIVERS_LENOVO
> +
> +config YOGABOOK
> +	tristate "Lenovo Yoga Book tablet key driver"
> +	depends on ACPI_WMI
> +	depends on INPUT
> +	depends on I2C
> +	select LEDS_CLASS
> +	select NEW_LEDS
> +	help
> +	  Say Y here if you want to support the 'Pen' key and keyboard backlight
> +	  control on the Lenovo Yoga Book tablets.
> +
> +	  To compile this driver as a module, choose M here: the module will
> +	  be called lenovo-yogabook.
> +
> +config YT2_1380
> +	tristate "Lenovo Yoga Tablet 2 1380 fast charge driver"
> +	depends on SERIAL_DEV_BUS
> +	depends on EXTCON
> +	depends on ACPI
> +	help
> +	  Say Y here to enable support for the custom fast charging protocol
> +	  found on the Lenovo Yoga Tablet 2 1380F / 1380L models.
> +
> +	  To compile this driver as a module, choose M here: the module will
> +	  be called lenovo-yogabook.
> +
> +config IDEAPAD_LAPTOP
> +	tristate "Lenovo IdeaPad Laptop Extras"
> +	depends on ACPI
> +	depends on RFKILL && INPUT
> +	depends on SERIO_I8042
> +	depends on BACKLIGHT_CLASS_DEVICE
> +	depends on ACPI_VIDEO || ACPI_VIDEO = n
> +	depends on ACPI_WMI || ACPI_WMI = n
> +	select ACPI_PLATFORM_PROFILE
> +	select INPUT_SPARSEKMAP
> +	select NEW_LEDS
> +	select LEDS_CLASS
> +	help
> +	  This is a driver for Lenovo IdeaPad netbooks contains drivers for
> +	  rfkill switch, hotkey, fan control and backlight control.
> +
> +config LENOVO_WMI_HOTKEY_UTILITIES
> +	tristate "Lenovo Hotkey Utility WMI extras driver"
> +	depends on ACPI_WMI
> +	select NEW_LEDS
> +	select LEDS_CLASS
> +	imply IDEAPAD_LAPTOP
> +	help
> +	  This driver provides WMI support for Lenovo customized hotkeys function,
> +	  such as LED control for audio/mic mute event for Ideapad, YOGA, XiaoXin,
> +	  Gaming, ThinkBook and so on.
> +
> +config LENOVO_YMC
> +	tristate "Lenovo Yoga Tablet Mode Control"
> +	depends on ACPI_WMI
> +	depends on INPUT
> +	depends on IDEAPAD_LAPTOP
> +	select INPUT_SPARSEKMAP
> +	help
> +	  This driver maps the Tablet Mode Control switch to SW_TABLET_MODE input
> +	  events for Lenovo Yoga notebooks.
> +
> +config THINKPAD_ACPI
> +	tristate "ThinkPad ACPI Laptop Extras"
> +	depends on ACPI_EC
> +	depends on ACPI_BATTERY
> +	depends on INPUT
> +	depends on RFKILL || RFKILL = n
> +	depends on ACPI_VIDEO || ACPI_VIDEO = n
> +	depends on BACKLIGHT_CLASS_DEVICE
> +	depends on I2C
> +	depends on DRM
> +	select ACPI_PLATFORM_PROFILE
> +	select DRM_PRIVACY_SCREEN
> +	select HWMON
> +	select NVRAM
> +	select NEW_LEDS
> +	select LEDS_CLASS
> +	select INPUT_SPARSEKMAP
> +	help
> +	  This is a driver for the IBM and Lenovo ThinkPad laptops. It adds
> +	  support for Fn-Fx key combinations, Bluetooth control, video
> +	  output switching, ThinkLight control, UltraBay eject and more.
> +	  For more information about this driver see
> +	  <file:Documentation/admin-guide/laptops/thinkpad-acpi.rst> and
> +	  <http://ibm-acpi.sf.net/> .
> +
> +	  This driver was formerly known as ibm-acpi.
> +
> +	  Extra functionality will be available if the rfkill (CONFIG_RFKILL)
> +	  and/or ALSA (CONFIG_SND) subsystems are available in the kernel.
> +	  Note that if you want ThinkPad-ACPI to be built-in instead of
> +	  modular, ALSA and rfkill will also have to be built-in.
> +
> +	  If you have an IBM or Lenovo ThinkPad laptop, say Y or M here.
> +
> +config THINKPAD_ACPI_ALSA_SUPPORT
> +	bool "Console audio control ALSA interface"
> +	depends on THINKPAD_ACPI
> +	depends on SND
> +	depends on SND = y || THINKPAD_ACPI = SND
> +	default y
> +	help
> +	  Enables monitoring of the built-in console audio output control
> +	  (headphone and speakers), which is operated by the mute and (in
> +	  some ThinkPad models) volume hotkeys.
> +
> +	  If this option is enabled, ThinkPad-ACPI will export an ALSA card
> +	  with a single read-only mixer control, which should be used for
> +	  on-screen-display feedback purposes by the Desktop Environment.
> +
> +	  Optionally, the driver will also allow software control (the
> +	  ALSA mixer will be made read-write).  Please refer to the driver
> +	  documentation for details.
> +
> +	  All IBM models have both volume and mute control.  Newer Lenovo
> +	  models only have mute control (the volume hotkeys are just normal
> +	  keys and volume control is done through the main HDA mixer).
> +
> +config THINKPAD_ACPI_DEBUGFACILITIES
> +	bool "Maintainer debug facilities"
> +	depends on THINKPAD_ACPI
> +	help
> +	  Enables extra stuff in the thinkpad-acpi which is completely useless
> +	  for normal use.  Read the driver source to find out what it does.
> +
> +	  Say N here, unless you were told by a kernel maintainer to do
> +	  otherwise.
> +
> +config THINKPAD_ACPI_DEBUG
> +	bool "Verbose debug mode"
> +	depends on THINKPAD_ACPI
> +	help
> +	  Enables extra debugging information, at the expense of a slightly
> +	  increase in driver size.
> +
> +	  If you are not sure, say N here.
> +
> +config THINKPAD_ACPI_UNSAFE_LEDS
> +	bool "Allow control of important LEDs (unsafe)"
> +	depends on THINKPAD_ACPI
> +	help
> +	  Overriding LED state on ThinkPads can mask important
> +	  firmware alerts (like critical battery condition), or misled
> +	  the user into damaging the hardware (undocking or ejecting
> +	  the bay while buses are still active), etc.
> +
> +	  LED control on the ThinkPad is write-only (with very few
> +	  exceptions on very ancient models), which makes it
> +	  impossible to know beforehand if important information will
> +	  be lost when one changes LED state.
> +
> +	  Users that know what they are doing can enable this option
> +	  and the driver will allow control of every LED, including
> +	  the ones on the dock stations.
> +
> +	  Never enable this option on a distribution kernel.
> +
> +	  Say N here, unless you are building a kernel for your own
> +	  use, and need to control the important firmware LEDs.
> +
> +config THINKPAD_ACPI_VIDEO
> +	bool "Video output control support"
> +	depends on THINKPAD_ACPI
> +	default y
> +	help
> +	  Allows the thinkpad_acpi driver to provide an interface to control
> +	  the various video output ports.
> +
> +	  This feature often won't work well, depending on ThinkPad model,
> +	  display state, video output devices in use, whether there is a X
> +	  server running, phase of the moon, and the current mood of
> +	  Schroedinger's cat.  If you can use X.org's RandR to control
> +	  your ThinkPad's video output ports instead of this feature,
> +	  don't think twice: do it and say N here to save memory and avoid
> +	  bad interactions with X.org.
> +
> +	  NOTE: access to this feature is limited to processes with the
> +	  CAP_SYS_ADMIN capability, to avoid local DoS issues in platforms
> +	  where it interacts badly with X.org.
> +
> +	  If you are not sure, say Y here but do try to check if you could
> +	  be using X.org RandR instead.
> +
> +config THINKPAD_ACPI_HOTKEY_POLL
> +	bool "Support NVRAM polling for hot keys"
> +	depends on THINKPAD_ACPI
> +	default y
> +	help
> +	  Some thinkpad models benefit from NVRAM polling to detect a few of
> +	  the hot key press events.  If you know your ThinkPad model does not
> +	  need to do NVRAM polling to support any of the hot keys you use,
> +	  unselecting this option will save about 1kB of memory.
> +
> +	  ThinkPads T40 and newer, R52 and newer, and X31 and newer are
> +	  unlikely to need NVRAM polling in their latest BIOS versions.
> +
> +	  NVRAM polling can detect at most the following keys: ThinkPad/Access
> +	  IBM, Zoom, Switch Display (fn+F7), ThinkLight, Volume up/down/mute,
> +	  Brightness up/down, Display Expand (fn+F8), Hibernate (fn+F12).
> +
> +	  If you are not sure, say Y here.  The driver enables polling only if
> +	  it is strictly necessary to do so.
> +
> +config THINKPAD_LMI
> +	tristate "Lenovo WMI-based systems management driver"
> +	depends on ACPI_WMI
> +	select FW_ATTR_CLASS
> +	help
> +	  This driver allows changing BIOS settings on Lenovo machines whose
> +	  BIOS support the WMI interface.
> +
> +	  To compile this driver as a module, choose M here: the module will
> +	  be called think-lmi.
> +
> +config LENOVO_WMI_CAMERA
> +	tristate "Lenovo WMI Camera Button driver"
> +	depends on ACPI_WMI
> +	depends on INPUT
> +	help
> +	  This driver provides support for Lenovo camera button. The Camera
> +	  button is a GPIO device. This driver receives ACPI notifications when
> +	  the camera button is switched on/off.
> +
> +	  To compile this driver as a module, choose M here: the module
> +	  will be called lenovo-wmi-camera.
> +
> +endif # X86_PLATFORM_DRIVERS_LENOVO
> +
> diff --git a/drivers/platform/x86/lenovo/Makefile b/drivers/platform/x86/lenovo/Makefile
> new file mode 100644
> index 000000000000..f3290d9c6fd6
> --- /dev/null
> +++ b/drivers/platform/x86/lenovo/Makefile
> @@ -0,0 +1,16 @@
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Makefile for linux/drivers/platform/x86/lenovo
> +# Lenovo x86 Platform-Specific Drivers
> +#
> +obj-$(CONFIG_IDEAPAD_LAPTOP)	+= ideapad-laptop.o
> +obj-$(CONFIG_LENOVO_WMI_HOTKEY_UTILITIES)	+= lenovo-wmi-hotkey-utilities.o
> +obj-$(CONFIG_LENOVO_YMC)	+= lenovo-ymc.o
> +obj-$(CONFIG_THINKPAD_ACPI)	+= thinkpad_acpi.o
> +obj-$(CONFIG_THINKPAD_LMI)	+= think-lmi.o
> +obj-$(CONFIG_YOGABOOK)		+= lenovo-yogabook.o
> +obj-$(CONFIG_YT2_1380)		+= lenovo-yoga-tab2-pro-1380-fastcharger.o
> +obj-$(CONFIG_LENOVO_WMI_CAMERA)	+= lenovo-wmi-camera.o
> +
> +
> +
> diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/lenovo/ideapad-laptop.c
> similarity index 100%
> rename from drivers/platform/x86/ideapad-laptop.c
> rename to drivers/platform/x86/lenovo/ideapad-laptop.c
> diff --git a/drivers/platform/x86/ideapad-laptop.h b/drivers/platform/x86/lenovo/ideapad-laptop.h
> similarity index 100%
> rename from drivers/platform/x86/ideapad-laptop.h
> rename to drivers/platform/x86/lenovo/ideapad-laptop.h
> diff --git a/drivers/platform/x86/lenovo-wmi-camera.c b/drivers/platform/x86/lenovo/lenovo-wmi-camera.c
> similarity index 100%
> rename from drivers/platform/x86/lenovo-wmi-camera.c
> rename to drivers/platform/x86/lenovo/lenovo-wmi-camera.c
> diff --git a/drivers/platform/x86/lenovo-wmi-hotkey-utilities.c b/drivers/platform/x86/lenovo/lenovo-wmi-hotkey-utilities.c
> similarity index 100%
> rename from drivers/platform/x86/lenovo-wmi-hotkey-utilities.c
> rename to drivers/platform/x86/lenovo/lenovo-wmi-hotkey-utilities.c
> diff --git a/drivers/platform/x86/lenovo-ymc.c b/drivers/platform/x86/lenovo/lenovo-ymc.c
> similarity index 100%
> rename from drivers/platform/x86/lenovo-ymc.c
> rename to drivers/platform/x86/lenovo/lenovo-ymc.c
> diff --git a/drivers/platform/x86/lenovo-yoga-tab2-pro-1380-fastcharger.c b/drivers/platform/x86/lenovo/lenovo-yoga-tab2-pro-1380-fastcharger.c
> similarity index 99%
> rename from drivers/platform/x86/lenovo-yoga-tab2-pro-1380-fastcharger.c
> rename to drivers/platform/x86/lenovo/lenovo-yoga-tab2-pro-1380-fastcharger.c
> index 25933cd018d1..b3fd6a35052a 100644
> --- a/drivers/platform/x86/lenovo-yoga-tab2-pro-1380-fastcharger.c
> +++ b/drivers/platform/x86/lenovo/lenovo-yoga-tab2-pro-1380-fastcharger.c
> @@ -21,7 +21,7 @@
>  #include <linux/time.h>
>  #include <linux/types.h>
>  #include <linux/workqueue.h>
> -#include "serdev_helpers.h"
> +#include "../serdev_helpers.h"
>  
>  #define YT2_1380_FC_PDEV_NAME		"lenovo-yoga-tab2-pro-1380-fastcharger"
>  #define YT2_1380_FC_SERDEV_CTRL		"serial0"
> diff --git a/drivers/platform/x86/lenovo-yogabook.c b/drivers/platform/x86/lenovo/lenovo-yogabook.c
> similarity index 100%
> rename from drivers/platform/x86/lenovo-yogabook.c
> rename to drivers/platform/x86/lenovo/lenovo-yogabook.c
> diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/lenovo/think-lmi.c
> similarity index 99%
> rename from drivers/platform/x86/think-lmi.c
> rename to drivers/platform/x86/lenovo/think-lmi.c
> index 0fc275e461be..5d629a85a55a 100644
> --- a/drivers/platform/x86/think-lmi.c
> +++ b/drivers/platform/x86/lenovo/think-lmi.c
> @@ -20,7 +20,7 @@
>  #include <linux/types.h>
>  #include <linux/dmi.h>
>  #include <linux/wmi.h>
> -#include "firmware_attributes_class.h"
> +#include "../firmware_attributes_class.h"
>  #include "think-lmi.h"
>  
>  static bool debug_support;
> diff --git a/drivers/platform/x86/think-lmi.h b/drivers/platform/x86/lenovo/think-lmi.h
> similarity index 100%
> rename from drivers/platform/x86/think-lmi.h
> rename to drivers/platform/x86/lenovo/think-lmi.h
> diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> similarity index 99%
> rename from drivers/platform/x86/thinkpad_acpi.c
> rename to drivers/platform/x86/lenovo/thinkpad_acpi.c
> index 5790095c175e..7dd4abf47f61 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> @@ -81,7 +81,7 @@
>  #include <sound/core.h>
>  #include <sound/initval.h>
>  
> -#include "dual_accel_detect.h"
> +#include "../dual_accel_detect.h"
>  
>  /* ThinkPad CMOS commands */
>  #define TP_CMOS_VOLUME_DOWN	0
> 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] platform/x86: export thinkpad_acpi handles
  2025-05-07 19:04 ` [PATCH 2/2] platform/x86: export thinkpad_acpi handles Mark Pearson
@ 2025-05-08 14:03   ` Ilpo Järvinen
  2025-05-08 14:28     ` Mark Pearson
  2025-05-08 14:31   ` Andy Shevchenko
  1 sibling, 1 reply; 13+ messages in thread
From: Ilpo Järvinen @ 2025-05-08 14:03 UTC (permalink / raw)
  To: Mark Pearson
  Cc: Hans de Goede, ikepanhc, W_Armin, Andy Shevchenko, LKML,
	platform-driver-x86, ibm-acpi-devel

On Wed, 7 May 2025, Mark Pearson wrote:

> Add API to be able to get the thinkpad_acpi various handles.
> 
> Will use this to start pulling some of the thinkpad_acpi functionality
> into separate modules in the future.
> 
> Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> ---
>  drivers/platform/x86/lenovo/thinkpad_acpi.c | 18 ++++++++++++++++++
>  include/linux/thinkpad_acpi.h               | 17 +++++++++++++++++
>  2 files changed, 35 insertions(+)
>  create mode 100644 include/linux/thinkpad_acpi.h
> 
> diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> index 7dd4abf47f61..0eb33b4c99cf 100644
> --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
> +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
> @@ -67,6 +67,7 @@
>  #include <linux/string.h>
>  #include <linux/string_helpers.h>
>  #include <linux/sysfs.h>
> +#include <linux/thinkpad_acpi.h>
>  #include <linux/types.h>
>  #include <linux/uaccess.h>
>  #include <linux/units.h>
> @@ -606,6 +607,23 @@ TPACPI_HANDLE(hkey, ec, "\\_SB.HKEY",	/* 600e/x, 770e, 770x */
>   * ACPI helpers
>   */
>  
> +int tp_acpi_get_handle(enum tp_acpi_handle_id handle_id, acpi_handle *handle)
> +{
> +	switch (handle_id) {
> +	case TP_ROOT_HANDLE:
> +		*handle = root_handle;
> +		return 0;
> +	case TP_EC_HANDLE:
> +		*handle = ec_handle;
> +		return 0;
> +	case TP_HKEY_HANDLE:
> +		*handle = hkey_handle;
> +		return 0;
> +	}
> +	return -ENODEV;
> +}
> +EXPORT_SYMBOL_GPL(tp_acpi_get_handle);

Please put these symbols into a namespace.

> +
>  static int acpi_evalf(acpi_handle handle,
>  		      int *res, char *method, char *fmt, ...)
>  {
> diff --git a/include/linux/thinkpad_acpi.h b/include/linux/thinkpad_acpi.h
> new file mode 100644
> index 000000000000..eb5273464658
> --- /dev/null
> +++ b/include/linux/thinkpad_acpi.h
> @@ -0,0 +1,17 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Thinkpad ACPI driver API
> + */
> +
> +#ifndef _TP_ACPI_H_
> +#define _TP_ACPI_H_
> +
> +enum tp_acpi_handle_id {
> +	TP_ROOT_HANDLE,
> +	TP_EC_HANDLE,
> +	TP_HKEY_HANDLE,
> +};
> +
> +int tp_acpi_get_handle(enum tp_acpi_handle_id handle_id, acpi_handle *handle);
> +
> +#endif /* _TP_ACPI_H */
> 

I suggest you send this in the series that introduces an user for this 
interface.

-- 
 i.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] platform/x86: Move Lenovo files into lenovo subdir
  2025-05-08 14:01 ` [PATCH 1/2] platform/x86: Move Lenovo files into lenovo subdir Ilpo Järvinen
@ 2025-05-08 14:23   ` Mark Pearson
  2025-05-08 14:27     ` Ilpo Järvinen
  0 siblings, 1 reply; 13+ messages in thread
From: Mark Pearson @ 2025-05-08 14:23 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Hans de Goede, ikepanhc, Armin Wolf, Andy Shevchenko, LKML,
	platform-driver-x86@vger.kernel.org, ibm-acpi-devel

Thanks Ilpo,

On Thu, May 8, 2025, at 10:01 AM, Ilpo Järvinen wrote:
> On Wed, 7 May 2025, Mark Pearson wrote:
>
>> Move all Lenovo specific files into their own sub-directory as part
>> of clean-up exercise.
>> Longer term goal is to break-up thinkpad_acpi to improve maintainability
>> and perhaps share more functionality with other non thinkpad Lenovo
>> platforms.
>> 
>> Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>> ---
>> Some questions that I didn't want to put in the commit comment:
>> 
>>  - I didn't know if now was a good time to propose this change. I
>>    realise it could cause headaches for anybody with patches being
>>    worked on.
>
> Don't worry too much about other changes, if you don't recall anything 
> immediately, there likely isn't anything that significant. If we always
> postpone useful reorganizations in fear that some hypothetical work would 
> have to rebase, it never gets done :-).
>
>>    Please let me know what makes it easiest for maintainers
>>    and other developers. If there is a particular branch that would be
>>    better to do this against also let me know.
>
> Once I've merged fixes branch into for-next (I should do that at latest 
> early next week if not already this week), it should be pretty 
> straightforward to handle such move without conflicts.
>

OK - thanks. If there's anything I can do to help let me know.


>>  - Should I be updating the MAINTAINERS file? I'm still not sure what
>>    the protocol there is. I'm very happy to help review anything in the
>>    lenovo directory, but I didn't want to make assumptions.
>
> You should certainly update MAINTAINERS in the same patch to the new 
> paths. If you want to make other changes, put them such as add your name 
> into some entry or create a generic LENOVO entry, put those into own 
> patch after the move please.
>

OK - I'll submit a v2 with that change. Thanks for the guidance

>>  - I have tested on multiple platforms but I don't have any ideapads I
>>    can use.
>
> Given it's just moves file to new place, the threat of breaking something 
> that isn't detected by simple build test, isn't that high.
>
Agreed - thanks for the review.

Mark

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] platform/x86: Move Lenovo files into lenovo subdir
  2025-05-08 14:23   ` Mark Pearson
@ 2025-05-08 14:27     ` Ilpo Järvinen
  2025-05-08 14:29       ` Mark Pearson
  0 siblings, 1 reply; 13+ messages in thread
From: Ilpo Järvinen @ 2025-05-08 14:27 UTC (permalink / raw)
  To: Mark Pearson
  Cc: Hans de Goede, ikepanhc, Armin Wolf, Andy Shevchenko, LKML,
	platform-driver-x86@vger.kernel.org, ibm-acpi-devel

[-- Attachment #1: Type: text/plain, Size: 2493 bytes --]

On Thu, 8 May 2025, Mark Pearson wrote:
> On Thu, May 8, 2025, at 10:01 AM, Ilpo Järvinen wrote:
> > On Wed, 7 May 2025, Mark Pearson wrote:
> >
> >> Move all Lenovo specific files into their own sub-directory as part
> >> of clean-up exercise.
> >> Longer term goal is to break-up thinkpad_acpi to improve maintainability
> >> and perhaps share more functionality with other non thinkpad Lenovo
> >> platforms.
> >> 
> >> Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
> >> ---
> >> Some questions that I didn't want to put in the commit comment:
> >> 
> >>  - I didn't know if now was a good time to propose this change. I
> >>    realise it could cause headaches for anybody with patches being
> >>    worked on.
> >
> > Don't worry too much about other changes, if you don't recall anything 
> > immediately, there likely isn't anything that significant. If we always
> > postpone useful reorganizations in fear that some hypothetical work would 
> > have to rebase, it never gets done :-).
> >
> >>    Please let me know what makes it easiest for maintainers
> >>    and other developers. If there is a particular branch that would be
> >>    better to do this against also let me know.
> >
> > Once I've merged fixes branch into for-next (I should do that at latest 
> > early next week if not already this week), it should be pretty 
> > straightforward to handle such move without conflicts.
> >
> 
> OK - thanks. If there's anything I can do to help let me know.
> 
> 
> >>  - Should I be updating the MAINTAINERS file? I'm still not sure what
> >>    the protocol there is. I'm very happy to help review anything in the
> >>    lenovo directory, but I didn't want to make assumptions.
> >
> > You should certainly update MAINTAINERS in the same patch to the new 
> > paths. If you want to make other changes, put them such as add your name 
> > into some entry or create a generic LENOVO entry, put those into own 
> > patch after the move please.
> >
> 
> OK - I'll submit a v2 with that change. Thanks for the guidance

Yes but please wait until I've done the merge so you can base v2 on top of 
it. Thanks.

> >>  - I have tested on multiple platforms but I don't have any ideapads I
> >>    can use.
> >
> > Given it's just moves file to new place, the threat of breaking something 
> > that isn't detected by simple build test, isn't that high.
> >
> Agreed - thanks for the review.
> 
> Mark
> 

-- 
 i.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] platform/x86: export thinkpad_acpi handles
  2025-05-08 14:03   ` Ilpo Järvinen
@ 2025-05-08 14:28     ` Mark Pearson
  2025-05-08 14:32       ` Andy Shevchenko
  0 siblings, 1 reply; 13+ messages in thread
From: Mark Pearson @ 2025-05-08 14:28 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Hans de Goede, ikepanhc, Armin Wolf, Andy Shevchenko, LKML,
	platform-driver-x86@vger.kernel.org, ibm-acpi-devel

Hi Ilpo,

On Thu, May 8, 2025, at 10:03 AM, Ilpo Järvinen wrote:
> On Wed, 7 May 2025, Mark Pearson wrote:
>
>> Add API to be able to get the thinkpad_acpi various handles.
>> 
>> Will use this to start pulling some of the thinkpad_acpi functionality
>> into separate modules in the future.
>> 
>> Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>> ---
>>  drivers/platform/x86/lenovo/thinkpad_acpi.c | 18 ++++++++++++++++++
>>  include/linux/thinkpad_acpi.h               | 17 +++++++++++++++++
>>  2 files changed, 35 insertions(+)
>>  create mode 100644 include/linux/thinkpad_acpi.h
>> 
>> diff --git a/drivers/platform/x86/lenovo/thinkpad_acpi.c b/drivers/platform/x86/lenovo/thinkpad_acpi.c
>> index 7dd4abf47f61..0eb33b4c99cf 100644
>> --- a/drivers/platform/x86/lenovo/thinkpad_acpi.c
>> +++ b/drivers/platform/x86/lenovo/thinkpad_acpi.c
>> @@ -67,6 +67,7 @@
>>  #include <linux/string.h>
>>  #include <linux/string_helpers.h>
>>  #include <linux/sysfs.h>
>> +#include <linux/thinkpad_acpi.h>
>>  #include <linux/types.h>
>>  #include <linux/uaccess.h>
>>  #include <linux/units.h>
>> @@ -606,6 +607,23 @@ TPACPI_HANDLE(hkey, ec, "\\_SB.HKEY",	/* 600e/x, 770e, 770x */
>>   * ACPI helpers
>>   */
>>  
>> +int tp_acpi_get_handle(enum tp_acpi_handle_id handle_id, acpi_handle *handle)
>> +{
>> +	switch (handle_id) {
>> +	case TP_ROOT_HANDLE:
>> +		*handle = root_handle;
>> +		return 0;
>> +	case TP_EC_HANDLE:
>> +		*handle = ec_handle;
>> +		return 0;
>> +	case TP_HKEY_HANDLE:
>> +		*handle = hkey_handle;
>> +		return 0;
>> +	}
>> +	return -ENODEV;
>> +}
>> +EXPORT_SYMBOL_GPL(tp_acpi_get_handle);
>
> Please put these symbols into a namespace.

Sorry, not quite sure what you mean here. Could you point me at an example?

>
>> +
>>  static int acpi_evalf(acpi_handle handle,
>>  		      int *res, char *method, char *fmt, ...)
>>  {
>> diff --git a/include/linux/thinkpad_acpi.h b/include/linux/thinkpad_acpi.h
>> new file mode 100644
>> index 000000000000..eb5273464658
>> --- /dev/null
>> +++ b/include/linux/thinkpad_acpi.h
>> @@ -0,0 +1,17 @@
>> +/* SPDX-License-Identifier: GPL-2.0-or-later */
>> +/*
>> + * Thinkpad ACPI driver API
>> + */
>> +
>> +#ifndef _TP_ACPI_H_
>> +#define _TP_ACPI_H_
>> +
>> +enum tp_acpi_handle_id {
>> +	TP_ROOT_HANDLE,
>> +	TP_EC_HANDLE,
>> +	TP_HKEY_HANDLE,
>> +};
>> +
>> +int tp_acpi_get_handle(enum tp_acpi_handle_id handle_id, acpi_handle *handle);
>> +
>> +#endif /* _TP_ACPI_H */
>> 
>
> I suggest you send this in the series that introduces an user for this 
> interface.

OK - will do. 
Side note - I do have one planned (new battery ACPI interface that gives some extra battery related information).

Thanks for the review
Mark

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] platform/x86: Move Lenovo files into lenovo subdir
  2025-05-07 19:04 [PATCH 1/2] platform/x86: Move Lenovo files into lenovo subdir Mark Pearson
  2025-05-07 19:04 ` [PATCH 2/2] platform/x86: export thinkpad_acpi handles Mark Pearson
  2025-05-08 14:01 ` [PATCH 1/2] platform/x86: Move Lenovo files into lenovo subdir Ilpo Järvinen
@ 2025-05-08 14:29 ` Andy Shevchenko
  2 siblings, 0 replies; 13+ messages in thread
From: Andy Shevchenko @ 2025-05-08 14:29 UTC (permalink / raw)
  To: Mark Pearson
  Cc: hdegoede, ilpo.jarvinen, ikepanhc, W_Armin, linux-kernel,
	platform-driver-x86, ibm-acpi-devel

On Wed, May 07, 2025 at 03:04:34PM -0400, Mark Pearson wrote:
> Move all Lenovo specific files into their own sub-directory as part
> of clean-up exercise.
> Longer term goal is to break-up thinkpad_acpi to improve maintainability
> and perhaps share more functionality with other non thinkpad Lenovo
> platforms.

...

> Some questions that I didn't want to put in the commit comment:
> 
>  - I didn't know if now was a good time to propose this change. I
>    realise it could cause headaches for anybody with patches being
>    worked on. Please let me know what makes it easiest for maintainers
>    and other developers. If there is a particular branch that would be
>    better to do this against also let me know.

For me Git handles renaming very well.

>  - Should I be updating the MAINTAINERS file? I'm still not sure what
>    the protocol there is. I'm very happy to help review anything in the
>    lenovo directory, but I didn't want to make assumptions.
>  - I have tested on multiple platforms but I don't have any ideapads I
>    can use.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/2] platform/x86: Move Lenovo files into lenovo subdir
  2025-05-08 14:27     ` Ilpo Järvinen
@ 2025-05-08 14:29       ` Mark Pearson
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Pearson @ 2025-05-08 14:29 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Hans de Goede, ikepanhc, Armin Wolf, Andy Shevchenko, LKML,
	platform-driver-x86@vger.kernel.org, ibm-acpi-devel

On Thu, May 8, 2025, at 10:27 AM, Ilpo Järvinen wrote:
> On Thu, 8 May 2025, Mark Pearson wrote:
>> On Thu, May 8, 2025, at 10:01 AM, Ilpo Järvinen wrote:
>> > On Wed, 7 May 2025, Mark Pearson wrote:
>> >
>> >> Move all Lenovo specific files into their own sub-directory as part
>> >> of clean-up exercise.
>> >> Longer term goal is to break-up thinkpad_acpi to improve maintainability
>> >> and perhaps share more functionality with other non thinkpad Lenovo
>> >> platforms.
>> >> 
>> >> Signed-off-by: Mark Pearson <mpearson-lenovo@squebb.ca>
>> >> ---
>> >> Some questions that I didn't want to put in the commit comment:
>> >> 
>> >>  - I didn't know if now was a good time to propose this change. I
>> >>    realise it could cause headaches for anybody with patches being
>> >>    worked on.
>> >
>> > Don't worry too much about other changes, if you don't recall anything 
>> > immediately, there likely isn't anything that significant. If we always
>> > postpone useful reorganizations in fear that some hypothetical work would 
>> > have to rebase, it never gets done :-).
>> >
>> >>    Please let me know what makes it easiest for maintainers
>> >>    and other developers. If there is a particular branch that would be
>> >>    better to do this against also let me know.
>> >
>> > Once I've merged fixes branch into for-next (I should do that at latest 
>> > early next week if not already this week), it should be pretty 
>> > straightforward to handle such move without conflicts.
>> >
>> 
>> OK - thanks. If there's anything I can do to help let me know.
>> 
>> 
>> >>  - Should I be updating the MAINTAINERS file? I'm still not sure what
>> >>    the protocol there is. I'm very happy to help review anything in the
>> >>    lenovo directory, but I didn't want to make assumptions.
>> >
>> > You should certainly update MAINTAINERS in the same patch to the new 
>> > paths. If you want to make other changes, put them such as add your name 
>> > into some entry or create a generic LENOVO entry, put those into own 
>> > patch after the move please.
>> >
>> 
>> OK - I'll submit a v2 with that change. Thanks for the guidance
>
> Yes but please wait until I've done the merge so you can base v2 on top of 
> it. Thanks.
>

Will do

Mark

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] platform/x86: export thinkpad_acpi handles
  2025-05-07 19:04 ` [PATCH 2/2] platform/x86: export thinkpad_acpi handles Mark Pearson
  2025-05-08 14:03   ` Ilpo Järvinen
@ 2025-05-08 14:31   ` Andy Shevchenko
  2025-05-08 15:01     ` Mark Pearson
  1 sibling, 1 reply; 13+ messages in thread
From: Andy Shevchenko @ 2025-05-08 14:31 UTC (permalink / raw)
  To: Mark Pearson
  Cc: hdegoede, ilpo.jarvinen, ikepanhc, W_Armin, linux-kernel,
	platform-driver-x86, ibm-acpi-devel

On Wed, May 07, 2025 at 03:04:35PM -0400, Mark Pearson wrote:
> Add API to be able to get the thinkpad_acpi various handles.
> 
> Will use this to start pulling some of the thinkpad_acpi functionality
> into separate modules in the future.

...

> +#ifndef _TP_ACPI_H_
> +#define _TP_ACPI_H_

+ include for  acpi_handle typedef.
Or it the forward declaration works

acpi_handle;

but I haven't checked and my gut feelings that it's not correct syntax as
compiler doesn't know what the heck this word means.

> +enum tp_acpi_handle_id {
> +	TP_ROOT_HANDLE,
> +	TP_EC_HANDLE,
> +	TP_HKEY_HANDLE,
> +};
> +
> +int tp_acpi_get_handle(enum tp_acpi_handle_id handle_id, acpi_handle *handle);
> +
> +#endif /* _TP_ACPI_H */

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] platform/x86: export thinkpad_acpi handles
  2025-05-08 14:28     ` Mark Pearson
@ 2025-05-08 14:32       ` Andy Shevchenko
  2025-05-08 15:02         ` Mark Pearson
  0 siblings, 1 reply; 13+ messages in thread
From: Andy Shevchenko @ 2025-05-08 14:32 UTC (permalink / raw)
  To: Mark Pearson
  Cc: Ilpo Järvinen, Hans de Goede, ikepanhc, Armin Wolf, LKML,
	platform-driver-x86@vger.kernel.org, ibm-acpi-devel

On Thu, May 08, 2025 at 10:28:26AM -0400, Mark Pearson wrote:
> On Thu, May 8, 2025, at 10:03 AM, Ilpo Järvinen wrote:
> > On Wed, 7 May 2025, Mark Pearson wrote:

...

> >> +EXPORT_SYMBOL_GPL(tp_acpi_get_handle);
> >
> > Please put these symbols into a namespace.
> 
> Sorry, not quite sure what you mean here. Could you point me at an example?

Use _NS variant of export.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] platform/x86: export thinkpad_acpi handles
  2025-05-08 14:31   ` Andy Shevchenko
@ 2025-05-08 15:01     ` Mark Pearson
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Pearson @ 2025-05-08 15:01 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Hans de Goede, Ilpo Järvinen, ikepanhc, Armin Wolf,
	linux-kernel, platform-driver-x86@vger.kernel.org, ibm-acpi-devel

On Thu, May 8, 2025, at 10:31 AM, Andy Shevchenko wrote:
> On Wed, May 07, 2025 at 03:04:35PM -0400, Mark Pearson wrote:
>> Add API to be able to get the thinkpad_acpi various handles.
>> 
>> Will use this to start pulling some of the thinkpad_acpi functionality
>> into separate modules in the future.
>
> ...
>
>> +#ifndef _TP_ACPI_H_
>> +#define _TP_ACPI_H_
>
> + include for  acpi_handle typedef.
> Or it the forward declaration works
>
> acpi_handle;
>
> but I haven't checked and my gut feelings that it's not correct syntax as
> compiler doesn't know what the heck this word means.
>

OK - I'll have a look and figure out what makes sense.
Thanks for the review
Mark

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/2] platform/x86: export thinkpad_acpi handles
  2025-05-08 14:32       ` Andy Shevchenko
@ 2025-05-08 15:02         ` Mark Pearson
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Pearson @ 2025-05-08 15:02 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Ilpo Järvinen, Hans de Goede, ikepanhc, Armin Wolf, LKML,
	platform-driver-x86@vger.kernel.org, ibm-acpi-devel

On Thu, May 8, 2025, at 10:32 AM, Andy Shevchenko wrote:
> On Thu, May 08, 2025 at 10:28:26AM -0400, Mark Pearson wrote:
>> On Thu, May 8, 2025, at 10:03 AM, Ilpo Järvinen wrote:
>> > On Wed, 7 May 2025, Mark Pearson wrote:
>
> ...
>
>> >> +EXPORT_SYMBOL_GPL(tp_acpi_get_handle);
>> >
>> > Please put these symbols into a namespace.
>> 
>> Sorry, not quite sure what you mean here. Could you point me at an example?
>
> Use _NS variant of export.
>
Thanks :)

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2025-05-08 15:02 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-07 19:04 [PATCH 1/2] platform/x86: Move Lenovo files into lenovo subdir Mark Pearson
2025-05-07 19:04 ` [PATCH 2/2] platform/x86: export thinkpad_acpi handles Mark Pearson
2025-05-08 14:03   ` Ilpo Järvinen
2025-05-08 14:28     ` Mark Pearson
2025-05-08 14:32       ` Andy Shevchenko
2025-05-08 15:02         ` Mark Pearson
2025-05-08 14:31   ` Andy Shevchenko
2025-05-08 15:01     ` Mark Pearson
2025-05-08 14:01 ` [PATCH 1/2] platform/x86: Move Lenovo files into lenovo subdir Ilpo Järvinen
2025-05-08 14:23   ` Mark Pearson
2025-05-08 14:27     ` Ilpo Järvinen
2025-05-08 14:29       ` Mark Pearson
2025-05-08 14:29 ` Andy Shevchenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.