drivers/leds/led-class.c | 9 +++--- drivers/mfd/cros_ec_dev.c | 9 ++++++ drivers/platform/chrome/Kconfig | 2 +- drivers/platform/chrome/cros_kbd_led_backlight.c | 40 ++++++++++++++++++++++-- include/linux/leds.h | 1 + 5 files changed, 54 insertions(+), 7 deletions(-)
Extend the cros_ec MFD device to also load cros_kbd_led_backlight
when the EC reports EC_FEATURE_PWM_KEYB.
As the driver can now be probed multiple times, some preparation in the
LED core is necessary to avoid name collisions.
Patch 1 is a general cleanup for the LED core.
Patch 2 modifies the LED core to skip the default collision handling.
Patch 3 adds the new probing logic to cros_kbd_led_backlight.
Patch 4 wires up the driver to the cros_ec mfd devices.
The helper keyboard_led_is_mfd_device is a bit iffy.
But using match data doesn't work.
* driver_data from platform_device_id is overwritten by the mfd platform data
* Setting the driver_data in drivers/mfd/cros_ec_dev.c would expose the
internals of cros_kbd_led_backlight
Tested on a Framework 13 AMD, Firmware 3.05, and a Jinlon Chromebook.
To: Lee Jones <lee@kernel.org>
To: Benson Leung <bleung@chromium.org>
To: Guenter Roeck <groeck@chromium.org>
To: Tzung-Bi Shih <tzungbi@kernel.org>
To: Pavel Machek <pavel@ucw.cz>
Cc: chrome-platform@lists.linux.dev
Cc: linux-kernel@vger.kernel.org
Cc: Dustin Howett <dustin@howett.net>
Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: linux-leds@vger.kernel.org
Cc: Rajas Paranjpe <paranjperajas@gmail.com>
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Changes in v3:
- Avoid probing multiple times (Confirmed by Rajas)
- Add Kconfig dependency on MFD_CROS_EC_DEV
- Link to v2: https://lore.kernel.org/r/20240511-cros_ec-kbd-led-framework-v2-0-b20c48109e46@weissschuh.net
Changes in v2:
- Fix build with CONFIG_MFD_CROS_EC_DEV=n (kernel test robot)
- Split out mfd registration into own commit (Lee)
- Simplify keyboard_led_is_mfd_device() with mfd_get_cell()
- Link to v1: https://lore.kernel.org/r/20240505-cros_ec-kbd-led-framework-v1-1-bfcca69013d2@weissschuh.net
---
Thomas Weißschuh (4):
leds: class: warn about name collisions earlier
leds: add flag to avoid automatic renaming of led devices
platform/chrome: cros_kbd_led_backlight: allow binding through mfd device
mfd: cros_ec: Register keyboard backlight subdevice
drivers/leds/led-class.c | 9 +++---
drivers/mfd/cros_ec_dev.c | 9 ++++++
drivers/platform/chrome/Kconfig | 2 +-
drivers/platform/chrome/cros_kbd_led_backlight.c | 40 ++++++++++++++++++++++--
include/linux/leds.h | 1 +
5 files changed, 54 insertions(+), 7 deletions(-)
---
base-commit: 6fbf71854e2ddea7c99397772fbbb3783bfe15b5
change-id: 20240505-cros_ec-kbd-led-framework-7e2e831bc79c
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
On Sun, 26 May 2024, Thomas Weißschuh wrote: > Extend the cros_ec MFD device to also load cros_kbd_led_backlight > when the EC reports EC_FEATURE_PWM_KEYB. > As the driver can now be probed multiple times, some preparation in the > LED core is necessary to avoid name collisions. > > Patch 1 is a general cleanup for the LED core. > Patch 2 modifies the LED core to skip the default collision handling. > Patch 3 adds the new probing logic to cros_kbd_led_backlight. > Patch 4 wires up the driver to the cros_ec mfd devices. > > The helper keyboard_led_is_mfd_device is a bit iffy. > But using match data doesn't work. > > * driver_data from platform_device_id is overwritten by the mfd platform data > * Setting the driver_data in drivers/mfd/cros_ec_dev.c would expose the > internals of cros_kbd_led_backlight > > Tested on a Framework 13 AMD, Firmware 3.05, and a Jinlon Chromebook. > > To: Lee Jones <lee@kernel.org> > To: Benson Leung <bleung@chromium.org> > To: Guenter Roeck <groeck@chromium.org> > To: Tzung-Bi Shih <tzungbi@kernel.org> > To: Pavel Machek <pavel@ucw.cz> > Cc: chrome-platform@lists.linux.dev > Cc: linux-kernel@vger.kernel.org > Cc: Dustin Howett <dustin@howett.net> > Cc: Mario Limonciello <mario.limonciello@amd.com> > Cc: linux-leds@vger.kernel.org > Cc: Rajas Paranjpe <paranjperajas@gmail.com> > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > > Changes in v3: > - Avoid probing multiple times (Confirmed by Rajas) > - Add Kconfig dependency on MFD_CROS_EC_DEV > - Link to v2: https://lore.kernel.org/r/20240511-cros_ec-kbd-led-framework-v2-0-b20c48109e46@weissschuh.net > > Changes in v2: > - Fix build with CONFIG_MFD_CROS_EC_DEV=n (kernel test robot) > - Split out mfd registration into own commit (Lee) > - Simplify keyboard_led_is_mfd_device() with mfd_get_cell() > - Link to v1: https://lore.kernel.org/r/20240505-cros_ec-kbd-led-framework-v1-1-bfcca69013d2@weissschuh.net > > --- > Thomas Weißschuh (4): > leds: class: warn about name collisions earlier > leds: add flag to avoid automatic renaming of led devices > platform/chrome: cros_kbd_led_backlight: allow binding through mfd device > mfd: cros_ec: Register keyboard backlight subdevice > > drivers/leds/led-class.c | 9 +++--- > drivers/mfd/cros_ec_dev.c | 9 ++++++ > drivers/platform/chrome/Kconfig | 2 +- > drivers/platform/chrome/cros_kbd_led_backlight.c | 40 ++++++++++++++++++++++-- > include/linux/leds.h | 1 + > 5 files changed, 54 insertions(+), 7 deletions(-) Looks okay. Does the platform patch need to be applied with the others? -- Lee Jones [李琼斯]
On 2024-05-31 16:35:30+0000, Lee Jones wrote: > On Sun, 26 May 2024, Thomas Weißschuh wrote: > > > Extend the cros_ec MFD device to also load cros_kbd_led_backlight > > when the EC reports EC_FEATURE_PWM_KEYB. > > As the driver can now be probed multiple times, some preparation in the > > LED core is necessary to avoid name collisions. > > > > Patch 1 is a general cleanup for the LED core. > > Patch 2 modifies the LED core to skip the default collision handling. > > Patch 3 adds the new probing logic to cros_kbd_led_backlight. > > Patch 4 wires up the driver to the cros_ec mfd devices. > > > > The helper keyboard_led_is_mfd_device is a bit iffy. > > But using match data doesn't work. > > > > * driver_data from platform_device_id is overwritten by the mfd platform data > > * Setting the driver_data in drivers/mfd/cros_ec_dev.c would expose the > > internals of cros_kbd_led_backlight > > > > Tested on a Framework 13 AMD, Firmware 3.05, and a Jinlon Chromebook. > > > > To: Lee Jones <lee@kernel.org> > > To: Benson Leung <bleung@chromium.org> > > To: Guenter Roeck <groeck@chromium.org> > > To: Tzung-Bi Shih <tzungbi@kernel.org> > > To: Pavel Machek <pavel@ucw.cz> > > Cc: chrome-platform@lists.linux.dev > > Cc: linux-kernel@vger.kernel.org > > Cc: Dustin Howett <dustin@howett.net> > > Cc: Mario Limonciello <mario.limonciello@amd.com> > > Cc: linux-leds@vger.kernel.org > > Cc: Rajas Paranjpe <paranjperajas@gmail.com> > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > > > > Changes in v3: > > - Avoid probing multiple times (Confirmed by Rajas) > > - Add Kconfig dependency on MFD_CROS_EC_DEV > > - Link to v2: https://lore.kernel.org/r/20240511-cros_ec-kbd-led-framework-v2-0-b20c48109e46@weissschuh.net > > > > Changes in v2: > > - Fix build with CONFIG_MFD_CROS_EC_DEV=n (kernel test robot) > > - Split out mfd registration into own commit (Lee) > > - Simplify keyboard_led_is_mfd_device() with mfd_get_cell() > > - Link to v1: https://lore.kernel.org/r/20240505-cros_ec-kbd-led-framework-v1-1-bfcca69013d2@weissschuh.net > > > > --- > > Thomas Weißschuh (4): > > leds: class: warn about name collisions earlier > > leds: add flag to avoid automatic renaming of led devices > > platform/chrome: cros_kbd_led_backlight: allow binding through mfd device > > mfd: cros_ec: Register keyboard backlight subdevice > > > > drivers/leds/led-class.c | 9 +++--- > > drivers/mfd/cros_ec_dev.c | 9 ++++++ > > drivers/platform/chrome/Kconfig | 2 +- > > drivers/platform/chrome/cros_kbd_led_backlight.c | 40 ++++++++++++++++++++++-- > > include/linux/leds.h | 1 + > > 5 files changed, 54 insertions(+), 7 deletions(-) > > Looks okay. Thanks. > Does the platform patch need to be applied with the others? Each patch depends on all its predecessors. (but I'm not sure I understood your question)
On Fri, 31 May 2024, Thomas Weißschuh wrote: > On 2024-05-31 16:35:30+0000, Lee Jones wrote: > > On Sun, 26 May 2024, Thomas Weißschuh wrote: > > > > > Extend the cros_ec MFD device to also load cros_kbd_led_backlight > > > when the EC reports EC_FEATURE_PWM_KEYB. > > > As the driver can now be probed multiple times, some preparation in the > > > LED core is necessary to avoid name collisions. > > > > > > Patch 1 is a general cleanup for the LED core. > > > Patch 2 modifies the LED core to skip the default collision handling. > > > Patch 3 adds the new probing logic to cros_kbd_led_backlight. > > > Patch 4 wires up the driver to the cros_ec mfd devices. > > > > > > The helper keyboard_led_is_mfd_device is a bit iffy. > > > But using match data doesn't work. > > > > > > * driver_data from platform_device_id is overwritten by the mfd platform data > > > * Setting the driver_data in drivers/mfd/cros_ec_dev.c would expose the > > > internals of cros_kbd_led_backlight > > > > > > Tested on a Framework 13 AMD, Firmware 3.05, and a Jinlon Chromebook. > > > > > > To: Lee Jones <lee@kernel.org> > > > To: Benson Leung <bleung@chromium.org> > > > To: Guenter Roeck <groeck@chromium.org> > > > To: Tzung-Bi Shih <tzungbi@kernel.org> > > > To: Pavel Machek <pavel@ucw.cz> > > > Cc: chrome-platform@lists.linux.dev > > > Cc: linux-kernel@vger.kernel.org > > > Cc: Dustin Howett <dustin@howett.net> > > > Cc: Mario Limonciello <mario.limonciello@amd.com> > > > Cc: linux-leds@vger.kernel.org > > > Cc: Rajas Paranjpe <paranjperajas@gmail.com> > > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > > > > > > Changes in v3: > > > - Avoid probing multiple times (Confirmed by Rajas) > > > - Add Kconfig dependency on MFD_CROS_EC_DEV > > > - Link to v2: https://lore.kernel.org/r/20240511-cros_ec-kbd-led-framework-v2-0-b20c48109e46@weissschuh.net > > > > > > Changes in v2: > > > - Fix build with CONFIG_MFD_CROS_EC_DEV=n (kernel test robot) > > > - Split out mfd registration into own commit (Lee) > > > - Simplify keyboard_led_is_mfd_device() with mfd_get_cell() > > > - Link to v1: https://lore.kernel.org/r/20240505-cros_ec-kbd-led-framework-v1-1-bfcca69013d2@weissschuh.net > > > > > > --- > > > Thomas Weißschuh (4): > > > leds: class: warn about name collisions earlier > > > leds: add flag to avoid automatic renaming of led devices > > > platform/chrome: cros_kbd_led_backlight: allow binding through mfd device > > > mfd: cros_ec: Register keyboard backlight subdevice > > > > > > drivers/leds/led-class.c | 9 +++--- > > > drivers/mfd/cros_ec_dev.c | 9 ++++++ > > > drivers/platform/chrome/Kconfig | 2 +- > > > drivers/platform/chrome/cros_kbd_led_backlight.c | 40 ++++++++++++++++++++++-- > > > include/linux/leds.h | 1 + > > > 5 files changed, 54 insertions(+), 7 deletions(-) > > > > Looks okay. > > Thanks. > > > Does the platform patch need to be applied with the others? > > Each patch depends on all its predecessors. > (but I'm not sure I understood your question) Does the Platform patch have 'build-time' deps on the others? -- Lee Jones [李琼斯]
On 2024-05-31 16:53:56+0000, Lee Jones wrote: > On Fri, 31 May 2024, Thomas Weißschuh wrote: > > > On 2024-05-31 16:35:30+0000, Lee Jones wrote: > > > On Sun, 26 May 2024, Thomas Weißschuh wrote: > > > > > > > Extend the cros_ec MFD device to also load cros_kbd_led_backlight > > > > when the EC reports EC_FEATURE_PWM_KEYB. > > > > As the driver can now be probed multiple times, some preparation in the > > > > LED core is necessary to avoid name collisions. > > > > > > > > Patch 1 is a general cleanup for the LED core. > > > > Patch 2 modifies the LED core to skip the default collision handling. > > > > Patch 3 adds the new probing logic to cros_kbd_led_backlight. > > > > Patch 4 wires up the driver to the cros_ec mfd devices. > > > > > > > > The helper keyboard_led_is_mfd_device is a bit iffy. > > > > But using match data doesn't work. > > > > > > > > * driver_data from platform_device_id is overwritten by the mfd platform data > > > > * Setting the driver_data in drivers/mfd/cros_ec_dev.c would expose the > > > > internals of cros_kbd_led_backlight > > > > > > > > Tested on a Framework 13 AMD, Firmware 3.05, and a Jinlon Chromebook. > > > > > > > > To: Lee Jones <lee@kernel.org> > > > > To: Benson Leung <bleung@chromium.org> > > > > To: Guenter Roeck <groeck@chromium.org> > > > > To: Tzung-Bi Shih <tzungbi@kernel.org> > > > > To: Pavel Machek <pavel@ucw.cz> > > > > Cc: chrome-platform@lists.linux.dev > > > > Cc: linux-kernel@vger.kernel.org > > > > Cc: Dustin Howett <dustin@howett.net> > > > > Cc: Mario Limonciello <mario.limonciello@amd.com> > > > > Cc: linux-leds@vger.kernel.org > > > > Cc: Rajas Paranjpe <paranjperajas@gmail.com> > > > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > > > > > > > > Changes in v3: > > > > - Avoid probing multiple times (Confirmed by Rajas) > > > > - Add Kconfig dependency on MFD_CROS_EC_DEV > > > > - Link to v2: https://lore.kernel.org/r/20240511-cros_ec-kbd-led-framework-v2-0-b20c48109e46@weissschuh.net > > > > > > > > Changes in v2: > > > > - Fix build with CONFIG_MFD_CROS_EC_DEV=n (kernel test robot) > > > > - Split out mfd registration into own commit (Lee) > > > > - Simplify keyboard_led_is_mfd_device() with mfd_get_cell() > > > > - Link to v1: https://lore.kernel.org/r/20240505-cros_ec-kbd-led-framework-v1-1-bfcca69013d2@weissschuh.net > > > > > > > > --- > > > > Thomas Weißschuh (4): > > > > leds: class: warn about name collisions earlier > > > > leds: add flag to avoid automatic renaming of led devices > > > > platform/chrome: cros_kbd_led_backlight: allow binding through mfd device > > > > mfd: cros_ec: Register keyboard backlight subdevice > > > > > > > > drivers/leds/led-class.c | 9 +++--- > > > > drivers/mfd/cros_ec_dev.c | 9 ++++++ > > > > drivers/platform/chrome/Kconfig | 2 +- > > > > drivers/platform/chrome/cros_kbd_led_backlight.c | 40 ++++++++++++++++++++++-- > > > > include/linux/leds.h | 1 + > > > > 5 files changed, 54 insertions(+), 7 deletions(-) > > > > > > Looks okay. > > > > Thanks. > > > > > Does the platform patch need to be applied with the others? > > > > Each patch depends on all its predecessors. > > (but I'm not sure I understood your question) > > Does the Platform patch have 'build-time' deps on the others? Yes. Patch 3 makes use of LED_REJECT_NAME_CONFLICT which was introduced in Patch 2. Patch 1, 2, 3 have build-time deps on their predecessors. Patch 4 has a run-time deps on Patch 3.
On Fri, May 31, 2024 at 05:59:01PM +0200, Thomas Weißschuh wrote: > On 2024-05-31 16:53:56+0000, Lee Jones wrote: > > On Fri, 31 May 2024, Thomas Weißschuh wrote: > > > > > On 2024-05-31 16:35:30+0000, Lee Jones wrote: > > > > On Sun, 26 May 2024, Thomas Weißschuh wrote: > > > > > > > > > Extend the cros_ec MFD device to also load cros_kbd_led_backlight > > > > > when the EC reports EC_FEATURE_PWM_KEYB. > > > > > As the driver can now be probed multiple times, some preparation in the > > > > > LED core is necessary to avoid name collisions. > > > > > > > > > > Patch 1 is a general cleanup for the LED core. > > > > > Patch 2 modifies the LED core to skip the default collision handling. > > > > > Patch 3 adds the new probing logic to cros_kbd_led_backlight. > > > > > Patch 4 wires up the driver to the cros_ec mfd devices. > > > > > > > > > > The helper keyboard_led_is_mfd_device is a bit iffy. > > > > > But using match data doesn't work. > > > > > > > > > > * driver_data from platform_device_id is overwritten by the mfd platform data > > > > > * Setting the driver_data in drivers/mfd/cros_ec_dev.c would expose the > > > > > internals of cros_kbd_led_backlight > > > > > > > > > > Tested on a Framework 13 AMD, Firmware 3.05, and a Jinlon Chromebook. > > > > > > > > > > To: Lee Jones <lee@kernel.org> > > > > > To: Benson Leung <bleung@chromium.org> > > > > > To: Guenter Roeck <groeck@chromium.org> > > > > > To: Tzung-Bi Shih <tzungbi@kernel.org> > > > > > To: Pavel Machek <pavel@ucw.cz> > > > > > Cc: chrome-platform@lists.linux.dev > > > > > Cc: linux-kernel@vger.kernel.org > > > > > Cc: Dustin Howett <dustin@howett.net> > > > > > Cc: Mario Limonciello <mario.limonciello@amd.com> > > > > > Cc: linux-leds@vger.kernel.org > > > > > Cc: Rajas Paranjpe <paranjperajas@gmail.com> > > > > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > > > > > > > > > > Changes in v3: > > > > > - Avoid probing multiple times (Confirmed by Rajas) > > > > > - Add Kconfig dependency on MFD_CROS_EC_DEV > > > > > - Link to v2: https://lore.kernel.org/r/20240511-cros_ec-kbd-led-framework-v2-0-b20c48109e46@weissschuh.net > > > > > > > > > > Changes in v2: > > > > > - Fix build with CONFIG_MFD_CROS_EC_DEV=n (kernel test robot) > > > > > - Split out mfd registration into own commit (Lee) > > > > > - Simplify keyboard_led_is_mfd_device() with mfd_get_cell() > > > > > - Link to v1: https://lore.kernel.org/r/20240505-cros_ec-kbd-led-framework-v1-1-bfcca69013d2@weissschuh.net > > > > > > > > > > --- > > > > > Thomas Weißschuh (4): > > > > > leds: class: warn about name collisions earlier > > > > > leds: add flag to avoid automatic renaming of led devices > > > > > platform/chrome: cros_kbd_led_backlight: allow binding through mfd device > > > > > mfd: cros_ec: Register keyboard backlight subdevice > > > > > > > > > > drivers/leds/led-class.c | 9 +++--- > > > > > drivers/mfd/cros_ec_dev.c | 9 ++++++ > > > > > drivers/platform/chrome/Kconfig | 2 +- > > > > > drivers/platform/chrome/cros_kbd_led_backlight.c | 40 ++++++++++++++++++++++-- > > > > > include/linux/leds.h | 1 + > > > > > 5 files changed, 54 insertions(+), 7 deletions(-) > > > > > > > > Looks okay. > > > > > > Thanks. > > > > > > > Does the platform patch need to be applied with the others? > > > > > > Each patch depends on all its predecessors. > > > (but I'm not sure I understood your question) > > > > Does the Platform patch have 'build-time' deps on the others? > > Yes. > > Patch 3 makes use of LED_REJECT_NAME_CONFLICT which was introduced in Patch 2. > > Patch 1, 2, 3 have build-time deps on their predecessors. > Patch 4 has a run-time deps on Patch 3. Patch 1 is independent actually.
Enjoy!
The following changes since commit 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0:
Linux 6.10-rc1 (2024-05-26 15:20:12 -0700)
are available in the Git repository at:
ssh://git@gitolite.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git tags/ib-mfd-leds-platform-v6.11
for you to fetch changes up to 970c3a6b7aa3c68ccdf5af2562c3d39533dd62a9:
mfd: cros_ec: Register keyboard backlight subdevice (2024-06-14 10:09:40 +0100)
----------------------------------------------------------------
Immutable branch between MFD, LEDs and Platform due for the v6.11 merge window
----------------------------------------------------------------
Thomas Weißschuh (4):
leds: class: Warn about name collisions earlier
leds: class: Add flag to avoid automatic renaming of LED devices
platform/chrome: cros_kbd_led_backlight: allow binding through MFD
mfd: cros_ec: Register keyboard backlight subdevice
drivers/leds/led-class.c | 9 +++---
drivers/mfd/cros_ec_dev.c | 9 ++++++
drivers/platform/chrome/Kconfig | 2 +-
drivers/platform/chrome/cros_kbd_led_backlight.c | 40 ++++++++++++++++++++++--
include/linux/leds.h | 1 +
5 files changed, 54 insertions(+), 7 deletions(-)
--
Lee Jones [李琼斯]
© 2016 - 2025 Red Hat, Inc.