HID: generic: fix build when LEDS_CLASS_MULTICOLOR is disabled
PATCH v2 1/1 HID: generic: fix build when LEDS_CLASS_MULTICOLOR is disabled
Building HID generic with LampArray support enabled caused link failures when LEDS_CLASS_MULTICOLOR was disabled, due to unresolved led_classdev_multicolor_* and led_mc_* symbols.
hid-lamparray.o was built whenever HID_GENERIC was enabled, regardless of LED multicolor support.
Introduce CONFIG_HID_LAMPARRAY with dependencies on HID_GENERIC && LEDS_CLASS && LEDS_CLASS_MULTICOLOR and build hid-lamparray.o only when enabled. Provide stub helpers so hid-generic.c builds cleanly when the option is disabled.
Changes in v2:
- Add CONFIG_HID_LAMPARRAY with proper dependencies
- Build hid-lamparray.o only when enabled
- Add stub helpers when disabled
- Fix build failures reported by kernel test robot
--- drivers/hid/Kconfig | 10 ++++++++++ drivers/hid/Makefile | 3 ++- drivers/hid/hid-generic.c | 4 ++-- drivers/hid/hid-lamparray.h | 25 ++++++++++++++++++++++++- 4 files changed, 38 insertions(+), 4 deletions(-)
drivers/hid/Kconfig +10 -0
@@ -92,6 +92,16 @@ config HID_GENERIC If unsure, say Y. +config HID_LAMPARRAY + bool "HID LampArray helper" + depends on HID_GENERIC && LEDS_CLASS && LEDS_CLASS_MULTICOLOR + default y + help + Helper for HID devices exposing a Lighting/LampArray collection. + Treats LampArray devices as a single-zone device and exposes a sysfs + interface for changing color and intensity values. Also exposes a + sysfs flag to be disabled e.g. by a userspace driver. + config HID_HAPTIC bool "Haptic touchpad support" default n
drivers/hid/Makefile +2 -1
@@ -12,7 +12,8 @@ obj-$(CONFIG_HID) += hid.o obj-$(CONFIG_UHID) += uhid.o obj-$(CONFIG_HID_GENERIC) += hid-generic.o -obj-$(CONFIG_HID_GENERIC) += hid-lamparray.o + +obj-$(CONFIG_HID_LAMPARRAY) += hid-lamparray.o hid-$(CONFIG_HIDRAW) += hidraw.o
drivers/hid/hid-generic.c +2 -2
@@ -77,7 +77,7 @@ static int hid_generic_probe(struct hid_device *hdev,* Optional: attach LampArray support if present. * Never fail probe on LampArray errors; keep device functional. */ -if (lamparray_is_supported_device (hdev)) { +if (IS_ENABLED (CONFIG_HID_LAMPARRAY ) &&lamparray_is_supported_device (hdev)) {const struct lamparray_init_state init = { .r =0xff , .g =0xff ,
@@ -108,7 +108,7 @@ static void hid_generic_remove(struct hid_device *hdev) {struct lamparray *la =hid_get_drvdata (hdev); -if (la) +if (IS_ENABLED (CONFIG_HID_LAMPARRAY ) && la)lamparray_unregister (la);hid_hw_stop (hdev);
drivers/hid/hid-lamparray.h +24 -1
@@ -6,6 +6,7 @@#include <linux/types.h> #include <linux/leds.h> #include <linux/err.h> +#include <linux/errno.h> struct hid_device ;struct lamparray ;
@@ -21,6 +22,8 @@ struct lamparray_init_state {enum led_brightness brightness; }; +#if IS_ENABLED (CONFIG_HID_LAMPARRAY ) +/** * lamparray_is_supported_device() - check whether a HID device supports LampArray * @hdev: HID device to inspect
@@ -65,4 +68,24 @@ struct lamparray *lamparray_register(struct hid_device *hdev,*/ void lamparray_unregister (struct lamparray *la); -#endif +#else /* !CONFIG_HID_LAMPARRAY */ + +static inline bool lamparray_is_supported_device (struct hid_device *hdev) +{ +return false; +} + +static inline struct lamparray * +lamparray_register (struct hid_device *hdev, +const struct lamparray_init_state *led_init_state) +{ +return ERR_PTR (-EOPNOTSUPP ); +} + +static inline void lamparray_unregister (struct lamparray *la) +{ +} + +#endif /* CONFIG_HID_LAMPARRAY */ + +#endif /* _HID_LAMPARRAY_H */
Signature · 1 line
2.43.0