diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 920a64b66b25..91547dfa5661 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -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
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index e6903be9c4df..5a14b4b0970d 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -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
diff --git a/drivers/hid/hid-generic.c b/drivers/hid/hid-generic.c
index 650c2121b403..57b81c86982c 100644
--- a/drivers/hid/hid-generic.c
+++ b/drivers/hid/hid-generic.c
@@ -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);diff --git a/drivers/hid/hid-lamparray.h b/drivers/hid/hid-lamparray.h
index b786ca00c404..ac3edd366a5b 100644
--- a/drivers/hid/hid-lamparray.h
+++ b/drivers/hid/hid-lamparray.h
@@ -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 */--
2.43.0