Message ID | 20200517190139.740249-4-sam@ravnborg.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | backlight updates | expand |
On Sun, May 17, 2020 at 09:01:26PM +0200, Sam Ravnborg wrote: > The backlight support has two properties that express the state: > - power > - state > > It is un-documented and easy to get wrong. > Add backlight_is_blank() helper to make it simpler for drivers > to get the check of the state correct. > > A lot of drivers also includes checks for fb_blank. > This check is redundant when the state is checked > and thus not needed in this helper function. > But added anyway to avoid introducing subtle bug > due to the creative use in some drivers. > > Rolling out this helper to all relevant backlight drivers > will eliminate almost all accesses to fb_blank. > > v2: > - Added fb_blank condition (Daniel) > > Signed-off-by: Sam Ravnborg <sam@ravnborg.org> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch> > Cc: Lee Jones <lee.jones@linaro.org> > Cc: Daniel Thompson <daniel.thompson@linaro.org> > Cc: Jingoo Han <jingoohan1@gmail.com> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> > --- > include/linux/backlight.h | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/include/linux/backlight.h b/include/linux/backlight.h > index c7d6b2e8c3b5..a0a083b35c47 100644 > --- a/include/linux/backlight.h > +++ b/include/linux/backlight.h > @@ -175,6 +175,25 @@ static inline void backlight_put(struct backlight_device *bd) > put_device(&bd->dev); > } > > +/** > + * backlight_is_blank - Return true if display is expected to be blank > + * @bd: the backlight device > + * > + * Display is expected to be blank if any of these is true:: > + * > + * 1) if power in not UNBLANK > + * 2) if fb_blank is not UNBLANK > + * 3) if state indicate BLANK or SUSPENDED > + * > + * Returns true if display is expected to be blank, false otherwise. > + */ > +static inline bool backlight_is_blank(struct backlight_device *bd) > +{ > + return bd->props.power != FB_BLANK_UNBLANK || > + bd->props.fb_blank != FB_BLANK_UNBLANK || > + bd->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK); > +} > + > extern struct backlight_device *backlight_device_register(const char *name, > struct device *dev, void *devdata, const struct backlight_ops *ops, > const struct backlight_properties *props); > -- > 2.25.1 >
On Sun, 17 May 2020 at 20:02, Sam Ravnborg <sam@ravnborg.org> wrote: > > The backlight support has two properties that express the state: > - power > - state > > It is un-documented and easy to get wrong. > Add backlight_is_blank() helper to make it simpler for drivers > to get the check of the state correct. > > A lot of drivers also includes checks for fb_blank. > This check is redundant when the state is checked > and thus not needed in this helper function. > But added anyway to avoid introducing subtle bug > due to the creative use in some drivers. > > Rolling out this helper to all relevant backlight drivers > will eliminate almost all accesses to fb_blank. > Nit: please tweak your editor to wrap commit messages at 72 columns. > v2: > - Added fb_blank condition (Daniel) > I was going to mention this, but Daniel beat me to it. Please add an extra NOTE in the commit message. The fb_blank is a behaviour change, albeit in the right direction. -Emil
On 17/05/2020 22.01, Sam Ravnborg wrote: > The backlight support has two properties that express the state: > - power > - state > > It is un-documented and easy to get wrong. > Add backlight_is_blank() helper to make it simpler for drivers > to get the check of the state correct. > > A lot of drivers also includes checks for fb_blank. > This check is redundant when the state is checked > and thus not needed in this helper function. > But added anyway to avoid introducing subtle bug > due to the creative use in some drivers. > > Rolling out this helper to all relevant backlight drivers > will eliminate almost all accesses to fb_blank. Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com> > v2: > - Added fb_blank condition (Daniel) > > Signed-off-by: Sam Ravnborg <sam@ravnborg.org> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch> > Cc: Lee Jones <lee.jones@linaro.org> > Cc: Daniel Thompson <daniel.thompson@linaro.org> > Cc: Jingoo Han <jingoohan1@gmail.com> > --- > include/linux/backlight.h | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/include/linux/backlight.h b/include/linux/backlight.h > index c7d6b2e8c3b5..a0a083b35c47 100644 > --- a/include/linux/backlight.h > +++ b/include/linux/backlight.h > @@ -175,6 +175,25 @@ static inline void backlight_put(struct backlight_device *bd) > put_device(&bd->dev); > } > > +/** > + * backlight_is_blank - Return true if display is expected to be blank > + * @bd: the backlight device > + * > + * Display is expected to be blank if any of these is true:: > + * > + * 1) if power in not UNBLANK > + * 2) if fb_blank is not UNBLANK > + * 3) if state indicate BLANK or SUSPENDED > + * > + * Returns true if display is expected to be blank, false otherwise. > + */ > +static inline bool backlight_is_blank(struct backlight_device *bd) > +{ > + return bd->props.power != FB_BLANK_UNBLANK || > + bd->props.fb_blank != FB_BLANK_UNBLANK || > + bd->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK); > +} > + > extern struct backlight_device *backlight_device_register(const char *name, > struct device *dev, void *devdata, const struct backlight_ops *ops, > const struct backlight_properties *props); > - Péter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
diff --git a/include/linux/backlight.h b/include/linux/backlight.h index c7d6b2e8c3b5..a0a083b35c47 100644 --- a/include/linux/backlight.h +++ b/include/linux/backlight.h @@ -175,6 +175,25 @@ static inline void backlight_put(struct backlight_device *bd) put_device(&bd->dev); } +/** + * backlight_is_blank - Return true if display is expected to be blank + * @bd: the backlight device + * + * Display is expected to be blank if any of these is true:: + * + * 1) if power in not UNBLANK + * 2) if fb_blank is not UNBLANK + * 3) if state indicate BLANK or SUSPENDED + * + * Returns true if display is expected to be blank, false otherwise. + */ +static inline bool backlight_is_blank(struct backlight_device *bd) +{ + return bd->props.power != FB_BLANK_UNBLANK || + bd->props.fb_blank != FB_BLANK_UNBLANK || + bd->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK); +} + extern struct backlight_device *backlight_device_register(const char *name, struct device *dev, void *devdata, const struct backlight_ops *ops, const struct backlight_properties *props);
The backlight support has two properties that express the state: - power - state It is un-documented and easy to get wrong. Add backlight_is_blank() helper to make it simpler for drivers to get the check of the state correct. A lot of drivers also includes checks for fb_blank. This check is redundant when the state is checked and thus not needed in this helper function. But added anyway to avoid introducing subtle bug due to the creative use in some drivers. Rolling out this helper to all relevant backlight drivers will eliminate almost all accesses to fb_blank. v2: - Added fb_blank condition (Daniel) Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Cc: Daniel Vetter <daniel.vetter@ffwll.ch> Cc: Lee Jones <lee.jones@linaro.org> Cc: Daniel Thompson <daniel.thompson@linaro.org> Cc: Jingoo Han <jingoohan1@gmail.com> --- include/linux/backlight.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)