[PATCH v1 02/22] backlight: Add DECLARE_* macro for device registration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Device registration almost always uses a struct backlight_properties
variable to pass config info. Make it simpler and less error prone
by the introduction of a number of macros.

There is one macro for each type of backlight {firmware, platform, raw}.
All members in struct backlight_properties are initialized.

Signed-off-by: Sam Ravnborg <sam@xxxxxxxxxxxx>
Cc: Lee Jones <lee.jones@xxxxxxxxxx>
Cc: Daniel Thompson <daniel.thompson@xxxxxxxxxx>
Cc: Jingoo Han <jingoohan1@xxxxxxxxx>
---
 include/linux/backlight.h | 45 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 190963ffb7fc..d683c053ec09 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -272,6 +272,51 @@ struct backlight_properties {
 	enum backlight_scale scale;
 };
 
+#define BACKLIGHT_PROPS(_brightness, _max_brightness, _type)	\
+	.brightness = _brightness,				\
+	.max_brightness = _max_brightness,			\
+	.power = FB_BLANK_POWERDOWN,				\
+	.type = _type,						\
+	.fb_blank = 0,						\
+	.state = 0,						\
+	.scale = BACKLIGHT_SCALE_UNKNOWN,
+
+/**
+ * DECLARE_BACKLIGHT_INIT_RAW - backlight_properties to init a raw
+ *                              backlight device
+ *
+ * This macro is used to initialize backlight_properties that is used when
+ * registering a raw backlight device.
+ */
+#define DECLARE_BACKLIGHT_INIT_RAW(name, _brightness, _max_brightness)		\
+	const struct backlight_properties name = {				\
+		BACKLIGHT_PROPS(_brightness, _max_brightness, BACKLIGHT_RAW)	\
+	}
+
+/**
+ * DECLARE_BACKLIGHT_INIT_PLATFORM - backlight_properties to init a platform
+ *                                   backlight device
+ *
+ * This macro is used to initialize backlight_properties that is used when
+ * registering a platform backlight device.
+ */
+#define DECLARE_BACKLIGHT_INIT_PLATFORM(name, _brightness, _max_brightness)		\
+	const struct backlight_properties name = {					\
+		BACKLIGHT_PROPS(_brightness, _max_brightness, BACKLIGHT_PLATFORM)	\
+	}
+
+/**
+ * DECLARE_BACKLIGHT_INIT_FIRMWARE - backlight_properties to init a firmware
+ *                                   backlight device
+ *
+ * This macro is used to initialize backlight_properties that is used when
+ * registering a firmware backlight device.
+ */
+#define DECLARE_BACKLIGHT_INIT_FIRMWARE(name, _brightness, _max_brightness)		\
+	const struct backlight_properties name = {					\
+		BACKLIGHT_PROPS(_brightness, _max_brightness, BACKLIGHT_FIRMWARE)	\
+	}
+
 /**
  * struct backlight_device - backlight device data
  *
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux