From: Sam Ravnborg <sam@ravnborg.org> To: dri-devel@lists.freedesktop.org, Jingoo Han <jingoohan1@gmail.com>, Lee Jones <lee.jones@linaro.org>, Daniel Thompson <daniel.thompson@linaro.org> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>, Sam Ravnborg <sam@ravnborg.org> Subject: [PATCH v1 02/22] backlight: Add DECLARE_* macro for device registration Date: Sun, 2 Aug 2020 13:06:16 +0200 Message-ID: <20200802110636.1018743-3-sam@ravnborg.org> (raw) In-Reply-To: <20200802110636.1018743-1-sam@ravnborg.org> 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@ravnborg.org> Cc: Lee Jones <lee.jones@linaro.org> Cc: Daniel Thompson <daniel.thompson@linaro.org> Cc: Jingoo Han <jingoohan1@gmail.com> --- 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@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply index Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-02 11:06 [RFC PATCH v1 0/22] backlight: add init macros and accessors Sam Ravnborg 2020-08-02 11:06 ` [PATCH v1 01/22] backlight: Silently fail backlight_update_status() if no device Sam Ravnborg 2020-08-02 11:06 ` Sam Ravnborg [this message] 2020-08-02 11:06 ` [PATCH v1 03/22] backlight: Add get/set operations for brightness/power properties Sam Ravnborg 2020-08-04 16:43 ` daniel 2020-08-04 19:56 ` Sam Ravnborg 2020-08-05 7:16 ` daniel 2020-08-02 11:06 ` [PATCH v1 04/22] backlight: gpio: Use DECLARE_BACKLIGHT_INIT_RAW and get/setters Sam Ravnborg 2020-08-02 11:06 ` [PATCH v1 05/22] drm/gma500: Backlight support Sam Ravnborg 2020-08-02 11:06 ` [PATCH v1 06/22] drm/panel: asus-z00t-tm5p5-n35596: Backlight update Sam Ravnborg 2020-08-04 16:59 ` daniel 2020-08-02 11:06 ` [PATCH v1 07/22] drm/panel: jdi-lt070me05000: " Sam Ravnborg 2020-08-02 11:06 ` [PATCH v1 08/22] drm/panel: novatek-nt35510: " Sam Ravnborg 2020-08-04 21:29 ` Linus Walleij 2020-08-02 11:06 ` [PATCH v1 09/22] drm/panel: orisetech-otm8009a: " Sam Ravnborg 2020-08-02 11:06 ` [PATCH v1 10/22] drm/panel: raydium-rm67191: " Sam Ravnborg 2020-08-04 17:04 ` daniel 2020-08-02 11:06 ` [PATCH v1 11/22] drm/panel: samsung-s6e63m0: " Sam Ravnborg 2020-08-02 11:06 ` [PATCH v1 12/22] drm/panel: samsung-s6e63j0x03: " Sam Ravnborg 2020-08-02 11:06 ` [PATCH v1 13/22] drm/panel: samsung-s6e3ha2: " Sam Ravnborg 2020-08-02 11:06 ` [PATCH v1 14/22] drm/panel: sony-acx424akp: " Sam Ravnborg 2020-08-04 21:31 ` Linus Walleij 2020-08-02 11:06 ` [PATCH v1 15/22] drm/panel: sony-acx565akm: " Sam Ravnborg 2020-08-04 17:09 ` daniel 2020-08-02 11:06 ` [PATCH v1 16/22] drm/bridge: parade-ps8622: " Sam Ravnborg 2020-08-02 14:05 ` kernel test robot 2020-08-02 14:32 ` Sam Ravnborg 2020-08-02 11:06 ` [PATCH v1 17/22] drm/tilcdc: " Sam Ravnborg 2020-08-02 13:21 ` kernel test robot 2020-08-02 11:06 ` [PATCH v1 18/22] drm/radeon: " Sam Ravnborg 2020-08-02 11:06 ` [PATCH v1 19/22] drm/amdgpu/atom: " Sam Ravnborg 2020-08-02 11:06 ` [PATCH v1 20/22] drm/i915: " Sam Ravnborg 2020-08-02 11:06 ` [PATCH v1 21/22] drm/omap: display: " Sam Ravnborg 2020-08-02 14:26 ` Sebastian Reichel 2020-08-02 14:32 ` Sam Ravnborg 2020-08-02 22:48 ` Sebastian Reichel 2020-08-02 11:06 ` [PATCH v1 22/22] drm/shmobile: " Sam Ravnborg 2020-08-04 16:51 ` [RFC PATCH v1 0/22] backlight: add init macros and accessors daniel
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200802110636.1018743-3-sam@ravnborg.org \ --to=sam@ravnborg.org \ --cc=daniel.thompson@linaro.org \ --cc=daniel.vetter@ffwll.ch \ --cc=dri-devel@lists.freedesktop.org \ --cc=jingoohan1@gmail.com \ --cc=lee.jones@linaro.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
dri-devel Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/dri-devel/0 dri-devel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 dri-devel dri-devel/ https://lore.kernel.org/dri-devel \ dri-devel@lists.freedesktop.org public-inbox-index dri-devel Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.freedesktop.lists.dri-devel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git