linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/16] backlight updates
@ 2020-05-17 19:01 Sam Ravnborg
  2020-05-17 19:01 ` [PATCH v2 01/16] video: amba-clcd: use devm_of_find_backlight Sam Ravnborg
                   ` (16 more replies)
  0 siblings, 17 replies; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

v2:
  - Dropped drm patches that was reviewed and thus applied (Thanks Tomi)
  - Updated backlight_is_blank() based on Daniel's feedback
  - Dropped EXPORT_SYMBOL that was no longer relevant
  - Reordered patches, so patches with no external
    dependencies comes first
  - Updated the description that follows.

This following series touches a lot of backlight things.

It starts by migrating the last user of of_find_backlight_by_node()
over to devm_of_find_backlight().
*Tomi*/*Peter* review feedback would be great - as this allows a smooth
removal of the export of of_find_backlight_by_node().

Then a small refactoring in backligth.c to remove some indents.
This increases the readability and no functional changes.

Then a new helper backlight_is_blank() is added.
This helper will simplify the implementation of update_status()
in almost all backlight drivers.

Then while surfing the code I missed some documentation.
So I got a bit carried away and updated the documentation
for the backlight core and added it to kernel-doc.
The documentation express my current understanding.
Everything from spelling errors to outright wrong content
shall be anticipated - so please review!
We are all best helped if the documentation is correct
and up-to-date and it is readable.

In this process I identified that the backlight_bl was no
longer is use - so drop it.

All the functions that is no longer used by any drivers
are then marked static to avoid adding new users.
There are dependencies to the omap patch in drivers/video/fbdev/
so these patches needs to wait until that one is applied.

The last patch is for now just an RFC patch that shows
the potential simplifications by introducing the
use of the backlight_is_blank() helper.

I have local patches to introduce backlight_is_blank()
in the remaining backlight drivers.
But they will await that this patch set matures a bit.

Everything builds, but so far no run-time testing.

	Sam

Sam Ravnborg (16):
      video: amba-clcd: use devm_of_find_backlight
      backlight: refactor fb_notifier_callback()
      backlight: add backlight_is_blank()
      backlight: improve backlight_ops documentation
      backlight: improve backlight_properties documentation
      backlight: improve backlight_device documentation
      backlight: document inline functions in backlight.h
      backlight: document enums in backlight.h
      backlight: remove the unused backlight_bl driver
      backlight: drop extern from prototypes
      backlight: add overview and update existing doc
      backlight: wire up kernel-doc documentation
      backlight: make of_find_backlight static
      backlight: drop backlight_put()
      backlight: make of_find_backlight_by_node() static
      backlight: use backlight_is_blank() in all backlight drivers

 Documentation/gpu/backlight.rst          |  12 +
 Documentation/gpu/index.rst              |   1 +
 drivers/video/backlight/88pm860x_bl.c    |   8 +-
 drivers/video/backlight/Kconfig          |   8 -
 drivers/video/backlight/Makefile         |   1 -
 drivers/video/backlight/adp5520_bl.c     |   5 +-
 drivers/video/backlight/adp8860_bl.c     |   5 +-
 drivers/video/backlight/adp8870_bl.c     |   5 +-
 drivers/video/backlight/as3711_bl.c      |   8 +-
 drivers/video/backlight/backlight.c      | 235 +++++++++--------
 drivers/video/backlight/bd6107.c         |   4 +-
 drivers/video/backlight/corgi_lcd.c      |   5 +-
 drivers/video/backlight/cr_bllcd.c       |  22 +-
 drivers/video/backlight/da903x_bl.c      |   8 +-
 drivers/video/backlight/ep93xx_bl.c      |   3 +-
 drivers/video/backlight/generic_bl.c     | 110 --------
 drivers/video/backlight/gpio_backlight.c |   4 +-
 drivers/video/backlight/hp680_bl.c       |   4 +-
 drivers/video/backlight/jornada720_bl.c  |   2 +-
 drivers/video/backlight/kb3886_bl.c      |   4 +-
 drivers/video/backlight/led_bl.c         |   4 +-
 drivers/video/backlight/lm3533_bl.c      |   4 +-
 drivers/video/backlight/locomolcd.c      |   4 +-
 drivers/video/backlight/lv5207lp.c       |   4 +-
 drivers/video/backlight/max8925_bl.c     |   8 +-
 drivers/video/backlight/pwm_bl.c         |   4 +-
 drivers/video/backlight/qcom-wled.c      |   4 +-
 drivers/video/backlight/tps65217_bl.c    |   4 +-
 drivers/video/backlight/wm831x_bl.c      |   8 +-
 drivers/video/fbdev/amba-clcd.c          |  19 +-
 include/linux/backlight.h                | 417 ++++++++++++++++++++++++-------
 31 files changed, 522 insertions(+), 412 deletions(-)



^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH v2 01/16] video: amba-clcd: use devm_of_find_backlight
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18  8:10   ` Linus Walleij
  2020-05-17 19:01 ` [PATCH v2 02/16] backlight: refactor fb_notifier_callback() Sam Ravnborg
                   ` (15 subsequent siblings)
  16 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

Look up backlight device using devm_of_find_backlight().
This simplifies the code and prevents us from hardcoding
the node name in the driver.

v2:
  - Added Cc: Peter Ujfalusi

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Douglas Anderson <dianders@chromium.org>
---
 drivers/video/fbdev/amba-clcd.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c
index c3d55fc6c4e0..b7682de412d8 100644
--- a/drivers/video/fbdev/amba-clcd.c
+++ b/drivers/video/fbdev/amba-clcd.c
@@ -602,20 +602,17 @@ static int clcdfb_snprintf_mode(char *buf, int size, struct fb_videomode *mode)
 			mode->refresh);
 }
 
-static int clcdfb_of_get_backlight(struct device_node *panel,
+static int clcdfb_of_get_backlight(struct device *dev,
 				   struct clcd_panel *clcd_panel)
 {
-	struct device_node *backlight;
+	struct backlight_device *backlight;
 
-	/* Look up the optional backlight phandle */
-	backlight = of_parse_phandle(panel, "backlight", 0);
-	if (backlight) {
-		clcd_panel->backlight = of_find_backlight_by_node(backlight);
-		of_node_put(backlight);
+	/* Look up the optional backlight device */
+	backlight = devm_of_find_backlight(dev);
+	if (IS_ERR(backlight))
+		return PTR_ERR(backlight);
 
-		if (!clcd_panel->backlight)
-			return -EPROBE_DEFER;
-	}
+	clcd_panel->backlight = backlight;
 	return 0;
 }
 
@@ -717,7 +714,7 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)
 	if (!panel)
 		return -ENODEV;
 
-	err = clcdfb_of_get_backlight(panel, fb->panel);
+	err = clcdfb_of_get_backlight(&fb->dev->dev, fb->panel);
 	if (err)
 		return err;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v2 02/16] backlight: refactor fb_notifier_callback()
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
  2020-05-17 19:01 ` [PATCH v2 01/16] video: amba-clcd: use devm_of_find_backlight Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18 14:54   ` Daniel Thompson
  2020-05-20 10:41   ` Emil Velikov
  2020-05-17 19:01 ` [PATCH v2 03/16] backlight: add backlight_is_blank() Sam Ravnborg
                   ` (14 subsequent siblings)
  16 siblings, 2 replies; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

Increase readability of fb_notifier_callback() by removing
a few indent levels.
No functional change.

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>
---
 drivers/video/backlight/backlight.c | 43 +++++++++++++++--------------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index cac3e35d7630..17f04cff50ab 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -58,28 +58,29 @@ static int fb_notifier_callback(struct notifier_block *self,
 
 	bd = container_of(self, struct backlight_device, fb_notif);
 	mutex_lock(&bd->ops_lock);
-	if (bd->ops)
-		if (!bd->ops->check_fb ||
-		    bd->ops->check_fb(bd, evdata->info)) {
-			fb_blank = *(int *)evdata->data;
-			if (fb_blank == FB_BLANK_UNBLANK &&
-			    !bd->fb_bl_on[node]) {
-				bd->fb_bl_on[node] = true;
-				if (!bd->use_count++) {
-					bd->props.state &= ~BL_CORE_FBBLANK;
-					bd->props.fb_blank = FB_BLANK_UNBLANK;
-					backlight_update_status(bd);
-				}
-			} else if (fb_blank != FB_BLANK_UNBLANK &&
-				   bd->fb_bl_on[node]) {
-				bd->fb_bl_on[node] = false;
-				if (!(--bd->use_count)) {
-					bd->props.state |= BL_CORE_FBBLANK;
-					bd->props.fb_blank = fb_blank;
-					backlight_update_status(bd);
-				}
-			}
+
+	if (!bd->ops)
+		goto out;
+	if (bd->ops->check_fb && !bd->ops->check_fb(bd, evdata->info))
+		goto out;
+
+	fb_blank = *(int *)evdata->data;
+	if (fb_blank == FB_BLANK_UNBLANK && !bd->fb_bl_on[node]) {
+		bd->fb_bl_on[node] = true;
+		if (!bd->use_count++) {
+			bd->props.state &= ~BL_CORE_FBBLANK;
+			bd->props.fb_blank = FB_BLANK_UNBLANK;
+			backlight_update_status(bd);
+		}
+	} else if (fb_blank != FB_BLANK_UNBLANK && bd->fb_bl_on[node]) {
+		bd->fb_bl_on[node] = false;
+		if (!(--bd->use_count)) {
+			bd->props.state |= BL_CORE_FBBLANK;
+			bd->props.fb_blank = fb_blank;
+			backlight_update_status(bd);
 		}
+	}
+out:
 	mutex_unlock(&bd->ops_lock);
 	return 0;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v2 03/16] backlight: add backlight_is_blank()
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
  2020-05-17 19:01 ` [PATCH v2 01/16] video: amba-clcd: use devm_of_find_backlight Sam Ravnborg
  2020-05-17 19:01 ` [PATCH v2 02/16] backlight: refactor fb_notifier_callback() Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18 15:00   ` Daniel Thompson
                     ` (2 more replies)
  2020-05-17 19:01 ` [PATCH v2 04/16] backlight: improve backlight_ops documentation Sam Ravnborg
                   ` (13 subsequent siblings)
  16 siblings, 3 replies; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

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(+)

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


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v2 04/16] backlight: improve backlight_ops documentation
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
                   ` (2 preceding siblings ...)
  2020-05-17 19:01 ` [PATCH v2 03/16] backlight: add backlight_is_blank() Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18 15:02   ` Daniel Thompson
  2020-05-17 19:01 ` [PATCH v2 05/16] backlight: improve backlight_properties documentation Sam Ravnborg
                   ` (12 subsequent siblings)
  16 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

Improve the documentation for backlight_ops and
adapt it to kernel-doc style.

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 | 60 +++++++++++++++++++++++++++++++++++----
 1 file changed, 54 insertions(+), 6 deletions(-)

diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index a0a083b35c47..519dc61ce7e4 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -55,19 +55,67 @@ enum backlight_scale {
 struct backlight_device;
 struct fb_info;
 
+/**
+ * struct backlight_ops - backlight operations
+ *
+ * The backlight operations are specifed when the backlight device is registered.
+ */
 struct backlight_ops {
+	/**
+	 * @options:
+	 *
+	 * The options parameter is used to adjust the behaviour of the core.
+	 * Set BL_CORE_SUSPENDRESUME to get the update_status() operation called
+	 * upon suspend and resume.
+	 */
 	unsigned int options;
 
 #define BL_CORE_SUSPENDRESUME	(1 << 0)
 
-	/* Notify the backlight driver some property has changed */
+	/**
+	 * @update_status:
+	 *
+	 * Notify the backlight driver some property has changed.
+	 * The update_status operation is protected by the update_lock.
+	 *
+	 * The backlight driver is expected to use backlight_is_blank()
+	 * to check if the display is blanked and set brightness accordingly.
+	 * update_status() is called when any of the properties has changed.
+	 *
+	 * RETURNS:
+	 *
+	 * 0 on sucees, negative error code if any failure occured.
+	 */
 	int (*update_status)(struct backlight_device *);
-	/* Return the current backlight brightness (accounting for power,
-	   fb_blank etc.) */
+
+	/**
+	 * @get_brightness:
+	 *
+	 * Return the current backlight brightness.
+	 * The driver may implement this as a readback from the HW.
+	 * This operation is optional and if not present then the current brightness
+	 * property value is used.
+	 *
+	 * RETURNS:
+	 *
+	 * A brightness value which is 0 or a positive numer.
+	 * On failure a negative error code is returned.
+	 */
 	int (*get_brightness)(struct backlight_device *);
-	/* Check if given framebuffer device is the one bound to this backlight;
-	   return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */
-	int (*check_fb)(struct backlight_device *, struct fb_info *);
+
+	/**
+	 * @check_fb:
+	 *
+	 * Check if given framebuffer device is the one bound to this backlight.
+	 * This operation is optional and if not implemented it is assumed that the
+	 * fbdev is always the one bound to the backlight.
+	 *
+	 * RETURNS:
+	 *
+	 * If info is NULL or the info matches the fbdev bound to the backlight return true.
+	 * If info does not match the fbdev bound to the backlight return false.
+	 */
+	int (*check_fb)(struct backlight_device *bd, struct fb_info *info);
 };
 
 /* This structure defines all the properties of a backlight */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v2 05/16] backlight: improve backlight_properties documentation
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
                   ` (3 preceding siblings ...)
  2020-05-17 19:01 ` [PATCH v2 04/16] backlight: improve backlight_ops documentation Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18 15:53   ` Daniel Thompson
  2020-05-17 19:01 ` [PATCH v2 06/16] backlight: improve backlight_device documentation Sam Ravnborg
                   ` (11 subsequent siblings)
  16 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

Improve the documentation for backlight_properties and
adapt it to kernel-doc style.

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 | 101 +++++++++++++++++++++++++++++++++-----
 1 file changed, 90 insertions(+), 11 deletions(-)

diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 519dc61ce7e4..7f9cef299d6e 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -118,28 +118,107 @@ struct backlight_ops {
 	int (*check_fb)(struct backlight_device *bd, struct fb_info *info);
 };
 
-/* This structure defines all the properties of a backlight */
+/**
+ * struct backlight_properties - backlight properties
+ *
+ * This structure defines all the properties of a backlight.
+ */
 struct backlight_properties {
-	/* Current User requested brightness (0 - max_brightness) */
+	/**
+	 * @brightness:
+	 *
+	 * The current requested brightness by the user.
+	 * The backlight core makes sure the range is (0 - max_brightness)
+	 * when the brightness is set via the sysfs attribute:
+	 * /sys/class/backlight/<backlight>/brightness.
+	 *
+	 * This value can be set in the backlight_properties passed
+	 * to devm_backlight_device_register() to set a default brightness
+	 * value.
+	 */
 	int brightness;
-	/* Maximal value for brightness (read-only) */
+
+	/**
+	 * @max_brightness:
+	 *
+	 * The maximum brightness value.
+	 *
+	 * This value must be set in the backlight_properties passed
+	 * to devm_backlight_device_register().
+	 *
+	 * This property must not be modified by a driver except
+	 * before registering the backlight device as explained above.
+	 */
 	int max_brightness;
-	/* Current FB Power mode (0: full on, 1..3: power saving
-	   modes; 4: full off), see FB_BLANK_XXX */
+
+	/**
+	 * @power:
+	 *
+	 * The current power mode. User space configure the power mode using
+	 * the sysfs attribute: /sys/class/backlight/<backlight>/bl_power
+	 * When the power property is updated update_status() is called.
+	 *
+	 * The possible values are: (0: full on, 1..3: power saving
+	 * modes; 4: full off), see FB_BLANK_XXX.
+	 *
+	 * When the backlight device is enabled @power is set
+	 * to FB_BLANK_UNBLANK. When the backlight device is disabled
+	 * @power is set to FB_BLANK_POWERDOWN.
+	 */
 	int power;
-	/* FB Blanking active? (values as for power) */
-	/* Due to be removed, please use (state & BL_CORE_FBBLANK) */
+
+	/**
+	 * @fb_blank:
+	 *
+	 * When the FBIOBLANK ioctl is called fb_blank is set to the
+	 * blank parameter and the update_status() operation is called.
+	 *
+	 * When the backlight device is enabled @fb_blank is set
+	 * to FB_BLANK_UNBLANK. When the backlight device is disabled
+	 * @fb_blank is set to FB_BLANK_POWERDOWN.
+	 *
+	 * This property must not be modified by a driver.
+	 * The backlight driver shall never read this variable,
+	 * as the necessary info is avaialble via the state.
+	 *
+	 * fb_blank is deprecated and will be removed.
+	 */
 	int fb_blank;
-	/* Backlight type */
+
+	/**
+	 * @type:
+	 *
+	 * The type of backlight supported.
+	 * The backlight type allows userspace to make appropriate
+	 * policy desicions based on the backlight type.
+	 *
+	 * This value must be set in the backlight_properties
+	 * passed to devm_backlight_device_register().
+	 */
 	enum backlight_type type;
-	/* Flags used to signal drivers of state changes */
+
+	/**
+	 * @state:
+	 *
+	 * The state property is used to inform drivers of state changes
+	 * when the update_status() operation is called.
+	 * The state is a bitmask. BL_CORE_FBBLANK is set when the display
+	 * is expected to be blank. BL_CORE_SUSPENDED is set when the
+	 * driver is suspended.
+	 *
+	 * This property must not be modified by a driver.
+	 */
 	unsigned int state;
-	/* Type of the brightness scale (linear, non-linear, ...) */
-	enum backlight_scale scale;
 
 #define BL_CORE_SUSPENDED	(1 << 0)	/* backlight is suspended */
 #define BL_CORE_FBBLANK		(1 << 1)	/* backlight is under an fb blank event */
 
+	/**
+	 * @scale:
+	 *
+	 * The type of the brightness scale (linear, non-linear, ...)
+	 */
+	enum backlight_scale scale;
 };
 
 struct backlight_device {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v2 06/16] backlight: improve backlight_device documentation
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
                   ` (4 preceding siblings ...)
  2020-05-17 19:01 ` [PATCH v2 05/16] backlight: improve backlight_properties documentation Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18 16:03   ` Daniel Thompson
  2020-05-17 19:01 ` [PATCH v2 07/16] backlight: document inline functions in backlight.h Sam Ravnborg
                   ` (10 subsequent siblings)
  16 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

Improve the documentation for backlight_device and
adapt it to kernel-doc style.

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 | 81 ++++++++++++++++++++++++++++-----------
 1 file changed, 58 insertions(+), 23 deletions(-)

diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 7f9cef299d6e..e2d72936bf05 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -14,21 +14,6 @@
 #include <linux/mutex.h>
 #include <linux/notifier.h>
 
-/* Notes on locking:
- *
- * backlight_device->ops_lock is an internal backlight lock protecting the
- * ops pointer and no code outside the core should need to touch it.
- *
- * Access to update_status() is serialised by the update_lock mutex since
- * most drivers seem to need this and historically get it wrong.
- *
- * Most drivers don't need locking on their get_brightness() method.
- * If yours does, you need to implement it in the driver. You can use the
- * update_lock mutex if appropriate.
- *
- * Any other use of the locks below is probably wrong.
- */
-
 enum backlight_update_reason {
 	BACKLIGHT_UPDATE_HOTKEY,
 	BACKLIGHT_UPDATE_SYSFS,
@@ -221,30 +206,80 @@ struct backlight_properties {
 	enum backlight_scale scale;
 };
 
+/**
+ * struct backlight_device - backlight device data
+ *
+ * This structure holds all data required by a backlight device.
+ */
 struct backlight_device {
-	/* Backlight properties */
+	/**
+	 * @props:
+	 *
+	 * Backlight properties
+	 */
 	struct backlight_properties props;
 
-	/* Serialise access to update_status method */
+	/**
+	 * @update_lock:
+	 *
+	 * update_lock is an internal backlight lock that serialise access
+	 * to the update_status() method. The iupdate_lock mutex shall not be used
+	 * by backlight drivers.
+	 */
 	struct mutex update_lock;
 
-	/* This protects the 'ops' field. If 'ops' is NULL, the driver that
-	   registered this device has been unloaded, and if class_get_devdata()
-	   points to something in the body of that driver, it is also invalid. */
+	/**
+	 * @ops_lock:
+	 *
+	 * ops_lock is an internal backlight lock that protects the ops pointer
+	 * and is used around all accesses to ops and when the operations are
+	 * invoked. The mutex shall not be used by backlight drivers.
+	 */
 	struct mutex ops_lock;
+
+	/**
+	 * @ops:
+	 *
+	 * Pointer to the backlight operations. If ops is NULL, the driver that
+	 * registered this device has been unloaded, and if class_get_devdata()
+	 * points to something in the body of that driver, it is also invalid.
+	 */
 	const struct backlight_ops *ops;
 
-	/* The framebuffer notifier block */
+	/**
+	 * @fb_notif:
+	 *
+	 * The framebuffer notifier block
+	 */
 	struct notifier_block fb_notif;
 
-	/* list entry of all registered backlight devices */
+	/**
+	 * @entry:
+	 *
+	 * List entry of all registered backlight devices
+	 */
 	struct list_head entry;
 
+	/**
+	 * @dev:
+	 *
+	 * Parent device.
+	 */
 	struct device dev;
 
-	/* Multiple framebuffers may share one backlight device */
+	/**
+	 * @fb_bl_on:
+	 *
+	 * Multiple fbdev's may share one backlight device. The fb_bl_on
+	 * records the state of the individual fbdev.
+	 */
 	bool fb_bl_on[FB_MAX];
 
+	/**
+	 * @use_count:
+	 *
+	 * The number of uses of fb_bl_on.
+	 */
 	int use_count;
 };
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v2 07/16] backlight: document inline functions in backlight.h
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
                   ` (5 preceding siblings ...)
  2020-05-17 19:01 ` [PATCH v2 06/16] backlight: improve backlight_device documentation Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18 16:04   ` Daniel Thompson
  2020-05-17 19:01 ` [PATCH v2 08/16] backlight: document enums " Sam Ravnborg
                   ` (9 subsequent siblings)
  16 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

Add documentation for the inline functions in backlight.h

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 | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index e2d72936bf05..98349a2984dc 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -283,6 +283,10 @@ struct backlight_device {
 	int use_count;
 };
 
+/**
+ * backlight_update_status - force an update of the backligt device status
+ * @bd: the backlight device
+ */
 static inline int backlight_update_status(struct backlight_device *bd)
 {
 	int ret = -ENOENT;
@@ -375,6 +379,18 @@ extern int backlight_device_set_brightness(struct backlight_device *bd, unsigned
 
 #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
 
+/**
+ * bl_get_data - access devdata
+ * @bl_dev: pointer to backlight device
+ *
+ * When a backlight device is registered the driver has the possibility
+ * to supply a void * devdata. bl_get_data() return a pointer to the
+ * devdata.
+ *
+ * RETURNS:
+ *
+ * pointer to devdata stored while registering the backlight device.
+ */
 static inline void * bl_get_data(struct backlight_device *bl_dev)
 {
 	return dev_get_drvdata(&bl_dev->dev);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v2 08/16] backlight: document enums in backlight.h
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
                   ` (6 preceding siblings ...)
  2020-05-17 19:01 ` [PATCH v2 07/16] backlight: document inline functions in backlight.h Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18 16:15   ` Daniel Thompson
  2020-05-17 19:01 ` [PATCH v2 09/16] backlight: remove the unused backlight_bl driver Sam Ravnborg
                   ` (8 subsequent siblings)
  16 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

Add kernel-doc documentation for the backlight enums

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 | 84 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 84 insertions(+)

diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 98349a2984dc..b779c29142fd 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -14,26 +14,110 @@
 #include <linux/mutex.h>
 #include <linux/notifier.h>
 
+/**
+ * enum backlight_update_reason - what method was used to update backlight
+ *
+ * A driver indicates the method (reason) used for updating the backlight
+ * when calling backlight_force_update().
+ */
 enum backlight_update_reason {
+	/**
+	 * @BACKLIGHT_UPDATE_HOTKEY:
+	 *
+	 * The backlight was updated using a hot-key.
+	 */
 	BACKLIGHT_UPDATE_HOTKEY,
+
+	/**
+	 * @BACKLIGHT_UPDATE_SYSFS:
+	 *
+	 * The backlight was updated using sysfs.
+	 */
 	BACKLIGHT_UPDATE_SYSFS,
 };
 
+/**
+ * enum backlight_type - the type of backlight control
+ *
+ * The type of interface used to control the backlight.
+ */
 enum backlight_type {
+	/**
+	 * @BACKLIGHT_RAW:
+	 *
+	 * The backlight is controlled using hardware registers directly.
+	 */
 	BACKLIGHT_RAW = 1,
+
+	/**
+	 * @BACKLIGHT_PLATFORM:
+	 *
+	 * The backlight is controller using a platform-specific interface.
+	 */
 	BACKLIGHT_PLATFORM,
+
+	/**
+	 * @BACKLIGHT_FIRMWARE:
+	 *
+	 * The backlight is controlled using a standard firmware interface.
+	 */
 	BACKLIGHT_FIRMWARE,
+
+	/**
+	 * @BACKLIGHT_TYPE_MAX: Number of entries.
+	 */
 	BACKLIGHT_TYPE_MAX,
 };
 
+/**
+ * enum backlight_notification - the type of notification
+ *
+ * The notifications that is used for notification sent to the receiver
+ * that registered notifications using backlight_register_notifier().
+ */
 enum backlight_notification {
+	/**
+	 * @BACKLIGHT_REGISTERED:
+	 *
+	 * The backlight device is registered.
+	 */
 	BACKLIGHT_REGISTERED,
+
+	/**
+	 * @BACKLIGHT_UNREGISTERED:
+	 *
+	 * The backlight revice is unregistered.
+	 */
 	BACKLIGHT_UNREGISTERED,
 };
 
+/** enum backlight_scale - the type of scale used for brightness values
+ *
+ * The type of scale used for brightness values.
+ */
 enum backlight_scale {
+	/**
+	 * @BACKLIGHT_SCALE_UNKNOWN:
+	 *
+	 * The scale is unknown.
+	 */
 	BACKLIGHT_SCALE_UNKNOWN = 0,
+
+	/**
+	 * @BACKLIGHT_SCALE_LINEAR:
+	 *
+	 * The scale is linear, so the brigness increase is the same
+	 * when increasing with the same steps (more or less).
+	 */
 	BACKLIGHT_SCALE_LINEAR,
+
+	/**
+	 * @BACKLIGHT_SCALE_NON_LINEAR:
+	 *
+	 * The scale is not linear. This is often used when the brightness
+	 * values tries to adjust to the relative perception of the eye
+	 * demanding a non-linear scale.
+	 */
 	BACKLIGHT_SCALE_NON_LINEAR,
 };
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v2 09/16] backlight: remove the unused backlight_bl driver
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
                   ` (7 preceding siblings ...)
  2020-05-17 19:01 ` [PATCH v2 08/16] backlight: document enums " Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18 16:17   ` Daniel Thompson
  2020-05-17 19:01 ` [PATCH v2 10/16] backlight: drop extern from prototypes Sam Ravnborg
                   ` (7 subsequent siblings)
  16 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

The driver required initialization using struct generic_bl_info.
As there are no more references to this struct there is no users left.
So it is safe to delete the driver.

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>
---
 drivers/video/backlight/Kconfig      |   8 --
 drivers/video/backlight/Makefile     |   1 -
 drivers/video/backlight/generic_bl.c | 110 ---------------------------
 include/linux/backlight.h            |   9 ---
 4 files changed, 128 deletions(-)
 delete mode 100644 drivers/video/backlight/generic_bl.c

diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index 7d22d7377606..14abfeee8868 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -173,14 +173,6 @@ config BACKLIGHT_EP93XX
 	  To compile this driver as a module, choose M here: the module will
 	  be called ep93xx_bl.
 
-config BACKLIGHT_GENERIC
-	tristate "Generic (aka Sharp Corgi) Backlight Driver"
-	default y
-	help
-	  Say y to enable the generic platform backlight driver previously
-	  known as the Corgi backlight driver. If you have a Sharp Zaurus
-	  SL-C7xx, SL-Cxx00 or SL-6000x say y.
-
 config BACKLIGHT_IPAQ_MICRO
 	tristate "iPAQ microcontroller backlight driver"
 	depends on MFD_IPAQ_MICRO
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 0c1a1524627a..9b998cfdc56d 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -31,7 +31,6 @@ obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE)	+= backlight.o
 obj-$(CONFIG_BACKLIGHT_DA903X)		+= da903x_bl.o
 obj-$(CONFIG_BACKLIGHT_DA9052)		+= da9052_bl.o
 obj-$(CONFIG_BACKLIGHT_EP93XX)		+= ep93xx_bl.o
-obj-$(CONFIG_BACKLIGHT_GENERIC)		+= generic_bl.o
 obj-$(CONFIG_BACKLIGHT_GPIO)		+= gpio_backlight.o
 obj-$(CONFIG_BACKLIGHT_HP680)		+= hp680_bl.o
 obj-$(CONFIG_BACKLIGHT_HP700)		+= jornada720_bl.o
diff --git a/drivers/video/backlight/generic_bl.c b/drivers/video/backlight/generic_bl.c
deleted file mode 100644
index 8fe63dbc8590..000000000000
--- a/drivers/video/backlight/generic_bl.c
+++ /dev/null
@@ -1,110 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- *  Generic Backlight Driver
- *
- *  Copyright (c) 2004-2008 Richard Purdie
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/mutex.h>
-#include <linux/fb.h>
-#include <linux/backlight.h>
-
-static int genericbl_intensity;
-static struct backlight_device *generic_backlight_device;
-static struct generic_bl_info *bl_machinfo;
-
-static int genericbl_send_intensity(struct backlight_device *bd)
-{
-	int intensity = bd->props.brightness;
-
-	if (bd->props.power != FB_BLANK_UNBLANK)
-		intensity = 0;
-	if (bd->props.state & BL_CORE_FBBLANK)
-		intensity = 0;
-	if (bd->props.state & BL_CORE_SUSPENDED)
-		intensity = 0;
-
-	bl_machinfo->set_bl_intensity(intensity);
-
-	genericbl_intensity = intensity;
-
-	if (bl_machinfo->kick_battery)
-		bl_machinfo->kick_battery();
-
-	return 0;
-}
-
-static int genericbl_get_intensity(struct backlight_device *bd)
-{
-	return genericbl_intensity;
-}
-
-static const struct backlight_ops genericbl_ops = {
-	.options = BL_CORE_SUSPENDRESUME,
-	.get_brightness = genericbl_get_intensity,
-	.update_status  = genericbl_send_intensity,
-};
-
-static int genericbl_probe(struct platform_device *pdev)
-{
-	struct backlight_properties props;
-	struct generic_bl_info *machinfo = dev_get_platdata(&pdev->dev);
-	const char *name = "generic-bl";
-	struct backlight_device *bd;
-
-	bl_machinfo = machinfo;
-	if (!machinfo->limit_mask)
-		machinfo->limit_mask = -1;
-
-	if (machinfo->name)
-		name = machinfo->name;
-
-	memset(&props, 0, sizeof(struct backlight_properties));
-	props.type = BACKLIGHT_RAW;
-	props.max_brightness = machinfo->max_intensity;
-	bd = devm_backlight_device_register(&pdev->dev, name, &pdev->dev,
-					NULL, &genericbl_ops, &props);
-	if (IS_ERR(bd))
-		return PTR_ERR(bd);
-
-	platform_set_drvdata(pdev, bd);
-
-	bd->props.power = FB_BLANK_UNBLANK;
-	bd->props.brightness = machinfo->default_intensity;
-	backlight_update_status(bd);
-
-	generic_backlight_device = bd;
-
-	dev_info(&pdev->dev, "Generic Backlight Driver Initialized.\n");
-	return 0;
-}
-
-static int genericbl_remove(struct platform_device *pdev)
-{
-	struct backlight_device *bd = platform_get_drvdata(pdev);
-
-	bd->props.power = 0;
-	bd->props.brightness = 0;
-	backlight_update_status(bd);
-
-	dev_info(&pdev->dev, "Generic Backlight Driver Unloaded\n");
-	return 0;
-}
-
-static struct platform_driver genericbl_driver = {
-	.probe		= genericbl_probe,
-	.remove		= genericbl_remove,
-	.driver		= {
-		.name	= "generic-bl",
-	},
-};
-
-module_platform_driver(genericbl_driver);
-
-MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
-MODULE_DESCRIPTION("Generic Backlight Driver");
-MODULE_LICENSE("GPL");
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index b779c29142fd..eae7a5e66248 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -480,15 +480,6 @@ static inline void * bl_get_data(struct backlight_device *bl_dev)
 	return dev_get_drvdata(&bl_dev->dev);
 }
 
-struct generic_bl_info {
-	const char *name;
-	int max_intensity;
-	int default_intensity;
-	int limit_mask;
-	void (*set_bl_intensity)(int intensity);
-	void (*kick_battery)(void);
-};
-
 #ifdef CONFIG_OF
 struct backlight_device *of_find_backlight_by_node(struct device_node *node);
 #else
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v2 10/16] backlight: drop extern from prototypes
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
                   ` (8 preceding siblings ...)
  2020-05-17 19:01 ` [PATCH v2 09/16] backlight: remove the unused backlight_bl driver Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18 16:22   ` Daniel Thompson
  2020-05-17 19:01 ` [PATCH v2 11/16] backlight: add overview and update existing doc Sam Ravnborg
                   ` (6 subsequent siblings)
  16 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

No need to put "extern" in front of prototypes.
While touching the prototypes adjust indent to follow
the kernel style.

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 | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index eae7a5e66248..308aec67fa4f 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -444,22 +444,25 @@ static inline bool backlight_is_blank(struct backlight_device *bd)
 	       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);
-extern struct backlight_device *devm_backlight_device_register(
-	struct device *dev, const char *name, struct device *parent,
-	void *devdata, const struct backlight_ops *ops,
-	const struct backlight_properties *props);
-extern void backlight_device_unregister(struct backlight_device *bd);
-extern void devm_backlight_device_unregister(struct device *dev,
-					struct backlight_device *bd);
-extern void backlight_force_update(struct backlight_device *bd,
-				   enum backlight_update_reason reason);
-extern int backlight_register_notifier(struct notifier_block *nb);
-extern int backlight_unregister_notifier(struct notifier_block *nb);
-extern struct backlight_device *backlight_device_get_by_type(enum backlight_type type);
-extern int backlight_device_set_brightness(struct backlight_device *bd, unsigned long brightness);
+struct backlight_device *
+backlight_device_register(const char *name, struct device *dev, void *devdata,
+			  const struct backlight_ops *ops,
+			  const struct backlight_properties *props);
+struct backlight_device *
+devm_backlight_device_register(struct device *dev, const char *name,
+			       struct device *parent, void *devdata,
+			       const struct backlight_ops *ops,
+			       const struct backlight_properties *props);
+void backlight_device_unregister(struct backlight_device *bd);
+void devm_backlight_device_unregister(struct device *dev,
+				      struct backlight_device *bd);
+void backlight_force_update(struct backlight_device *bd,
+			    enum backlight_update_reason reason);
+int backlight_register_notifier(struct notifier_block *nb);
+int backlight_unregister_notifier(struct notifier_block *nb);
+struct backlight_device *backlight_device_get_by_type(enum backlight_type type);
+int backlight_device_set_brightness(struct backlight_device *bd,
+				    unsigned long brightness);
 
 #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v2 11/16] backlight: add overview and update existing doc
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
                   ` (9 preceding siblings ...)
  2020-05-17 19:01 ` [PATCH v2 10/16] backlight: drop extern from prototypes Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18 16:44   ` Daniel Thompson
  2020-05-17 19:01 ` [PATCH v2 12/16] backlight: wire up kernel-doc documentation Sam Ravnborg
                   ` (5 subsequent siblings)
  16 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

Add overview chapter to backlight.c.
Update existing kernel-doc to follow a more consistent
style and drop kernel-doc for deprecated functions.

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>
---
 drivers/video/backlight/backlight.c | 131 +++++++++++++++++++---------
 1 file changed, 90 insertions(+), 41 deletions(-)

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 17f04cff50ab..2212f0e3570e 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -22,6 +22,45 @@
 #include <asm/backlight.h>
 #endif
 
+/**
+ * DOC: overview
+ *
+ * The backlight core supports implementing backlight drivers.
+ *
+ * backlight is controlled from userspace via firmware, a platform
+ * specific way or via sysfs. The backlight core provide support
+ * for all three types of backlight control.
+ *
+ * A backlight driver registers a driver using
+ * devm_backlight_device_register(). The properties of the backlight
+ * driver such as type and max_brightness must be specified.
+ * When the core detect changes in for example brightness or power state
+ * the update_status() operation is called. The backlight driver shall
+ * implement this operation and use it to adjust backlight.
+ *
+ * Several sysfs attributes are provided by the backlight core::
+ *
+ * - brightness         R/W, set the requested brightness level
+ * - actual_brighness   RO, the brightness level used by the HW
+ * - max_brightness     RO, the maximum  brightness level supported
+ *
+ * See Documentation/ABI/stable/sysfs-class-backlight for the full list.
+ *
+ * The driver shall implement the get_brightness() operation if
+ * the HW do not support all the levels that can be specified in
+ * brightness, thus providing user-space access to the actual level
+ * via the actual_brightness attribute.
+ * When the backlight changes this is reported to user-space using
+ * an uevent connected to the actual_brightness attribute.
+ * When brightness is set by platform specific means, for example
+ * a hot-key to adjust backlight, the driver must notify the backlight
+ * core that brighness has changed using backlight_force_update().
+ *
+ * The backlight driver core receives notifications from fbdev and
+ * if the event is FB_EVENT_BLANK the value of blank, from the FBIOBLANK
+ * ioclt, is passed to the driver via the update_status() operation.
+ */
+
 static struct list_head backlight_dev_list;
 static struct mutex backlight_dev_list_mutex;
 static struct blocking_notifier_head backlight_notifier;
@@ -40,9 +79,17 @@ static const char *const backlight_scale_types[] = {
 
 #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
 			   defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE))
-/* This callback gets called when something important happens inside a
- * framebuffer driver. We're looking if that important event is blanking,
- * and if it is and necessary, we're switching backlight power as well ...
+/*
+ * fb_notifier_callback
+ *
+ * This callback gets called when something important happens inside a
+ * framebuffer driver. The backlight core only care about FB_BLANK_UNBLANK
+ * which is reported to the driver using backlight_update_status()
+ * as a state change.
+ *
+ * There may be several fbdev's connected to the backlight device,
+ * in which case they are kept track of. A state change is only reported
+ * if there is a change in backligt for the specified fbdev.
  */
 static int fb_notifier_callback(struct notifier_block *self,
 				unsigned long event, void *data)
@@ -318,12 +365,16 @@ static struct attribute *bl_device_attrs[] = {
 ATTRIBUTE_GROUPS(bl_device);
 
 /**
- * backlight_force_update - tell the backlight subsystem that hardware state
- *   has changed
+ * backlight_force_update - force an update due to a hardware change
  * @bd: the backlight device to update
+ * @reason: the method used for the backlight update
  *
  * Updates the internal state of the backlight in response to a hardware event,
- * and generate a uevent to notify userspace
+ * and generate an uevent to notify userspace.
+ * A backlight driver shall call backlight_force_update() when the backlight
+ * is changed using, for example, a hot-key.
+ * The updated brightness is read using get_brightness() and the brightness
+ * value is reported using an uevent.
  */
 void backlight_force_update(struct backlight_device *bd,
 			    enum backlight_update_reason reason)
@@ -336,19 +387,7 @@ void backlight_force_update(struct backlight_device *bd,
 }
 EXPORT_SYMBOL(backlight_force_update);
 
-/**
- * backlight_device_register - create and register a new object of
- *   backlight_device class.
- * @name: the name of the new object(must be the same as the name of the
- *   respective framebuffer device).
- * @parent: a pointer to the parent device
- * @devdata: an optional pointer to be stored for private driver use. The
- *   methods may retrieve it by using bl_get_data(bd).
- * @ops: the backlight operations structure.
- *
- * Creates and registers new backlight device. Returns either an
- * ERR_PTR() or a pointer to the newly allocated device.
- */
+/* deprecated - use devm_backlight_device_register() */
 struct backlight_device *backlight_device_register(const char *name,
 	struct device *parent, void *devdata, const struct backlight_ops *ops,
 	const struct backlight_properties *props)
@@ -415,6 +454,15 @@ struct backlight_device *backlight_device_register(const char *name,
 }
 EXPORT_SYMBOL(backlight_device_register);
 
+/** backlight_device_get_by_type - find first backlight device of a type
+ * @type: the type of backlight device
+ *
+ * Look up the first backlight device of the specified type
+ *
+ * RETURNS:
+ *
+ * Pointer to backlight device if any was found. Otherwise NULL.
+ */
 struct backlight_device *backlight_device_get_by_type(enum backlight_type type)
 {
 	bool found = false;
@@ -433,12 +481,7 @@ struct backlight_device *backlight_device_get_by_type(enum backlight_type type)
 }
 EXPORT_SYMBOL(backlight_device_get_by_type);
 
-/**
- * backlight_device_unregister - unregisters a backlight device object.
- * @bd: the backlight device object to be unregistered and freed.
- *
- * Unregisters a previously registered via backlight_device_register object.
- */
+/* deprecated - use devm_backlight_device_unregister() */
 void backlight_device_unregister(struct backlight_device *bd)
 {
 	if (!bd)
@@ -486,10 +529,12 @@ static int devm_backlight_device_match(struct device *dev, void *res,
  * backlight_register_notifier - get notified of backlight (un)registration
  * @nb: notifier block with the notifier to call on backlight (un)registration
  *
- * @return 0 on success, otherwise a negative error code
- *
  * Register a notifier to get notified when backlight devices get registered
  * or unregistered.
+ *
+ * RETURNS:
+ *
+ * 0 on success, otherwise a negative error code
  */
 int backlight_register_notifier(struct notifier_block *nb)
 {
@@ -501,10 +546,12 @@ EXPORT_SYMBOL(backlight_register_notifier);
  * backlight_unregister_notifier - unregister a backlight notifier
  * @nb: notifier block to unregister
  *
- * @return 0 on success, otherwise a negative error code
- *
  * Register a notifier to get notified when backlight devices get registered
  * or unregistered.
+ *
+ * RETURNS:
+ *
+ * 0 on success, otherwise a negative error code
  */
 int backlight_unregister_notifier(struct notifier_block *nb)
 {
@@ -513,20 +560,22 @@ int backlight_unregister_notifier(struct notifier_block *nb)
 EXPORT_SYMBOL(backlight_unregister_notifier);
 
 /**
- * devm_backlight_device_register - resource managed backlight_device_register()
+ * devm_backlight_device_register - registering a new backlight device
  * @dev: the device to register
  * @name: the name of the device
- * @parent: a pointer to the parent device
+ * @parent: a pointer to the parent device (often the same as @dev)
  * @devdata: an optional pointer to be stored for private driver use
  * @ops: the backlight operations structure
  * @props: the backlight properties
  *
- * @return a struct backlight on success, or an ERR_PTR on error
+ * Creates and registers new backlight device. When a backlight device
+ * is registered the configuration must be specified in the @props
+ * parameter. See description of &backlight_properties.
  *
- * Managed backlight_device_register(). The backlight_device returned
- * from this function are automatically freed on driver detach.
- * See backlight_device_register() for more information.
- */
+ * RETURNS:
+ *
+ * struct backlight on success, or an ERR_PTR on error
+*/
 struct backlight_device *devm_backlight_device_register(struct device *dev,
 	const char *name, struct device *parent, void *devdata,
 	const struct backlight_ops *ops,
@@ -553,13 +602,13 @@ struct backlight_device *devm_backlight_device_register(struct device *dev,
 EXPORT_SYMBOL(devm_backlight_device_register);
 
 /**
- * devm_backlight_device_unregister - resource managed backlight_device_unregister()
+ * devm_backlight_device_unregister - backlight device unregister
  * @dev: the device to unregister
  * @bd: the backlight device to unregister
  *
- * Deallocated a backlight allocated with devm_backlight_device_register().
+ * Deallocates a backlight allocated with devm_backlight_device_register().
  * Normally this function will not need to be called and the resource management
- * code will ensure that the resource is freed.
+ * code will ensure that the resources are freed.
  */
 void devm_backlight_device_unregister(struct device *dev,
 				struct backlight_device *bd)
@@ -650,8 +699,8 @@ static void devm_backlight_release(void *data)
 }
 
 /**
- * devm_of_find_backlight - Resource-managed of_find_backlight()
- * @dev: Device
+ * devm_of_find_backlight - find backlight for a device
+ * @dev: the device
  *
  * Device managed version of of_find_backlight().
  * The reference on the backlight device is automatically
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v2 12/16] backlight: wire up kernel-doc documentation
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
                   ` (10 preceding siblings ...)
  2020-05-17 19:01 ` [PATCH v2 11/16] backlight: add overview and update existing doc Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18 16:50   ` Daniel Thompson
  2020-05-17 19:01 ` [PATCH v2 13/16] backlight: make of_find_backlight static Sam Ravnborg
                   ` (4 subsequent siblings)
  16 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Daniel Vetter

Include backlight so the documentation is now generated
with make htmldocs and friends.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Jonathan Corbet <corbet@lwn.net>
---
 Documentation/gpu/backlight.rst | 12 ++++++++++++
 Documentation/gpu/index.rst     |  1 +
 2 files changed, 13 insertions(+)
 create mode 100644 Documentation/gpu/backlight.rst

diff --git a/Documentation/gpu/backlight.rst b/Documentation/gpu/backlight.rst
new file mode 100644
index 000000000000..9ebfc9d0aced
--- /dev/null
+++ b/Documentation/gpu/backlight.rst
@@ -0,0 +1,12 @@
+=================
+Backlight support
+=================
+
+.. kernel-doc:: drivers/video/backlight/backlight.c
+   :doc: overview
+
+.. kernel-doc:: include/linux/backlight.h
+   :internal:
+
+.. kernel-doc:: drivers/video/backlight/backlight.c
+   :export:
diff --git a/Documentation/gpu/index.rst b/Documentation/gpu/index.rst
index 1fcf8e851e15..c9a51e3bfb5a 100644
--- a/Documentation/gpu/index.rst
+++ b/Documentation/gpu/index.rst
@@ -12,6 +12,7 @@ Linux GPU Driver Developer's Guide
    drm-uapi
    drm-client
    drivers
+   backlight
    vga-switcheroo
    vgaarbiter
    todo
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v2 13/16] backlight: make of_find_backlight static
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
                   ` (11 preceding siblings ...)
  2020-05-17 19:01 ` [PATCH v2 12/16] backlight: wire up kernel-doc documentation Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18 16:53   ` Daniel Thompson
  2020-05-17 19:01 ` [PATCH v2 14/16] backlight: drop backlight_put() Sam Ravnborg
                   ` (3 subsequent siblings)
  16 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

There are no external users of of_find_backlight,
as they have all changed to use the managed version.
Make of_find_backlight static to prevent new external users.

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>
---
 drivers/video/backlight/backlight.c | 31 ++++++++++-------------------
 include/linux/backlight.h           |  6 ------
 2 files changed, 11 insertions(+), 26 deletions(-)

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 2212f0e3570e..e23b09d03a65 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -650,22 +650,7 @@ struct backlight_device *of_find_backlight_by_node(struct device_node *node)
 EXPORT_SYMBOL(of_find_backlight_by_node);
 #endif
 
-/**
- * of_find_backlight - Get backlight device
- * @dev: Device
- *
- * This function looks for a property named 'backlight' on the DT node
- * connected to @dev and looks up the backlight device.
- *
- * Call backlight_put() to drop the reference on the backlight device.
- *
- * Returns:
- * A pointer to the backlight device if found.
- * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight
- * device is found.
- * NULL if there's no backlight property.
- */
-struct backlight_device *of_find_backlight(struct device *dev)
+static struct backlight_device *of_find_backlight(struct device *dev)
 {
 	struct backlight_device *bd = NULL;
 	struct device_node *np;
@@ -691,7 +676,6 @@ struct backlight_device *of_find_backlight(struct device *dev)
 
 	return bd;
 }
-EXPORT_SYMBOL(of_find_backlight);
 
 static void devm_backlight_release(void *data)
 {
@@ -702,9 +686,16 @@ static void devm_backlight_release(void *data)
  * devm_of_find_backlight - find backlight for a device
  * @dev: the device
  *
- * Device managed version of of_find_backlight().
- * The reference on the backlight device is automatically
- * dropped on driver detach.
+ * This function looks for a property named 'backlight' on the DT node
+ * connected to @dev and looks up the backlight device.
+ * The lookup is device managed so the reference to the backlight device
+ * is automatically dropped on driver detach.
+ *
+ * Returns:
+ * A pointer to the backlight device if found.
+ * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight
+ * device is found.
+ * NULL if there's no backlight property.
  */
 struct backlight_device *devm_of_find_backlight(struct device *dev)
 {
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 308aec67fa4f..99e7cdace2be 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -494,14 +494,8 @@ of_find_backlight_by_node(struct device_node *node)
 #endif
 
 #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
-struct backlight_device *of_find_backlight(struct device *dev);
 struct backlight_device *devm_of_find_backlight(struct device *dev);
 #else
-static inline struct backlight_device *of_find_backlight(struct device *dev)
-{
-	return NULL;
-}
-
 static inline struct backlight_device *
 devm_of_find_backlight(struct device *dev)
 {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v2 14/16] backlight: drop backlight_put()
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
                   ` (12 preceding siblings ...)
  2020-05-17 19:01 ` [PATCH v2 13/16] backlight: make of_find_backlight static Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18 16:53   ` Daniel Thompson
  2020-05-17 19:01 ` [PATCH v2 15/16] backlight: make of_find_backlight_by_node() static Sam Ravnborg
                   ` (2 subsequent siblings)
  16 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

There are no external users of backlight_put().
Drop it and open code the two users in backlight.c.

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>
---
 drivers/video/backlight/backlight.c |  7 +++++--
 include/linux/backlight.h           | 10 ----------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index e23b09d03a65..7f3eecaf8317 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -679,7 +679,10 @@ static struct backlight_device *of_find_backlight(struct device *dev)
 
 static void devm_backlight_release(void *data)
 {
-	backlight_put(data);
+	struct backlight_device *bd = data;
+
+	if (bd)
+		put_device(&bd->dev);
 }
 
 /**
@@ -707,7 +710,7 @@ struct backlight_device *devm_of_find_backlight(struct device *dev)
 		return bd;
 	ret = devm_add_action(dev, devm_backlight_release, bd);
 	if (ret) {
-		backlight_put(bd);
+		put_device(&bd->dev);
 		return ERR_PTR(ret);
 	}
 	return bd;
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 99e7cdace2be..d92e523650ec 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -415,16 +415,6 @@ static inline int backlight_disable(struct backlight_device *bd)
 	return backlight_update_status(bd);
 }
 
-/**
- * backlight_put - Drop backlight reference
- * @bd: the backlight device to put
- */
-static inline void backlight_put(struct backlight_device *bd)
-{
-	if (bd)
-		put_device(&bd->dev);
-}
-
 /**
  * backlight_is_blank - Return true if display is expected to be blank
  * @bd: the backlight device
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v2 15/16] backlight: make of_find_backlight_by_node() static
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
                   ` (13 preceding siblings ...)
  2020-05-17 19:01 ` [PATCH v2 14/16] backlight: drop backlight_put() Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18 16:56   ` Daniel Thompson
  2020-05-17 19:01 ` [PATCH v2 16/16] backlight: use backlight_is_blank() in all backlight drivers Sam Ravnborg
  2020-05-20 11:01 ` [PATCH v2 0/16] backlight updates Emil Velikov
  16 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

There are no external users of of_find_backlight_by_node().
Make it static so we keep it that way.

v2:
  - drop EXPORT of of_find_backlight_by_node

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>
---
 drivers/video/backlight/backlight.c | 23 +++++++++--------------
 include/linux/backlight.h           | 10 ----------
 2 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 7f3eecaf8317..3fa29330a820 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -627,19 +627,9 @@ static int of_parent_match(struct device *dev, const void *data)
 	return dev->parent && dev->parent->of_node == data;
 }
 
-/**
- * of_find_backlight_by_node() - find backlight device by device-tree node
- * @node: device-tree node of the backlight device
- *
- * Returns a pointer to the backlight device corresponding to the given DT
- * node or NULL if no such backlight device exists or if the device hasn't
- * been probed yet.
- *
- * This function obtains a reference on the backlight device and it is the
- * caller's responsibility to drop the reference by calling put_device() on
- * the backlight device's .dev field.
- */
-struct backlight_device *of_find_backlight_by_node(struct device_node *node)
+/* Find backlight device by device-tree node */
+static struct backlight_device *
+of_find_backlight_by_node(struct device_node *node)
 {
 	struct device *dev;
 
@@ -647,7 +637,12 @@ struct backlight_device *of_find_backlight_by_node(struct device_node *node)
 
 	return dev ? to_backlight_device(dev) : NULL;
 }
-EXPORT_SYMBOL(of_find_backlight_by_node);
+#else
+static struct backlight_device *
+of_find_backlight_by_node(struct device_node *node)
+{
+	return NULL;
+}
 #endif
 
 static struct backlight_device *of_find_backlight(struct device *dev)
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index d92e523650ec..1e29ab43f4f6 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -473,16 +473,6 @@ static inline void * bl_get_data(struct backlight_device *bl_dev)
 	return dev_get_drvdata(&bl_dev->dev);
 }
 
-#ifdef CONFIG_OF
-struct backlight_device *of_find_backlight_by_node(struct device_node *node);
-#else
-static inline struct backlight_device *
-of_find_backlight_by_node(struct device_node *node)
-{
-	return NULL;
-}
-#endif
-
 #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
 struct backlight_device *devm_of_find_backlight(struct device *dev);
 #else
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v2 16/16] backlight: use backlight_is_blank() in all backlight drivers
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
                   ` (14 preceding siblings ...)
  2020-05-17 19:01 ` [PATCH v2 15/16] backlight: make of_find_backlight_by_node() static Sam Ravnborg
@ 2020-05-17 19:01 ` Sam Ravnborg
  2020-05-18 16:59   ` Daniel Thompson
                     ` (2 more replies)
  2020-05-20 11:01 ` [PATCH v2 0/16] backlight updates Emil Velikov
  16 siblings, 3 replies; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-17 19:01 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Sam Ravnborg, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

Replaces the open-coded checks of the state etc.,
with the backlight_is_blank() helper.
This increases readability of the code and align
the functionality across the drivers.

v2:
  - Fixed so changelog is readable

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>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Cc: Support Opensource <support.opensource@diasemi.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Andy Gross <agross@kernel.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: linux-pwm@vger.kernel.org
Cc: linux-arm-msm@vger.kernel.org
Cc: patches@opensource.cirrus.com
---
 drivers/video/backlight/88pm860x_bl.c    |  8 +-------
 drivers/video/backlight/adp5520_bl.c     |  5 +----
 drivers/video/backlight/adp8860_bl.c     |  5 +----
 drivers/video/backlight/adp8870_bl.c     |  5 +----
 drivers/video/backlight/as3711_bl.c      |  8 +++-----
 drivers/video/backlight/bd6107.c         |  4 +---
 drivers/video/backlight/corgi_lcd.c      |  5 +----
 drivers/video/backlight/cr_bllcd.c       | 22 +++++++---------------
 drivers/video/backlight/da903x_bl.c      |  8 +-------
 drivers/video/backlight/ep93xx_bl.c      |  3 +--
 drivers/video/backlight/gpio_backlight.c |  4 +---
 drivers/video/backlight/hp680_bl.c       |  4 +---
 drivers/video/backlight/jornada720_bl.c  |  2 +-
 drivers/video/backlight/kb3886_bl.c      |  4 +---
 drivers/video/backlight/led_bl.c         |  4 +---
 drivers/video/backlight/lm3533_bl.c      |  4 +---
 drivers/video/backlight/locomolcd.c      |  4 +---
 drivers/video/backlight/lv5207lp.c       |  4 +---
 drivers/video/backlight/max8925_bl.c     |  8 +-------
 drivers/video/backlight/pwm_bl.c         |  4 +---
 drivers/video/backlight/qcom-wled.c      |  4 +---
 drivers/video/backlight/tps65217_bl.c    |  4 +---
 drivers/video/backlight/wm831x_bl.c      |  8 +-------
 23 files changed, 31 insertions(+), 100 deletions(-)

diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c
index 20d96a5ac384..162c83ab0f5a 100644
--- a/drivers/video/backlight/88pm860x_bl.c
+++ b/drivers/video/backlight/88pm860x_bl.c
@@ -123,13 +123,7 @@ static int pm860x_backlight_update_status(struct backlight_device *bl)
 {
 	int brightness = bl->props.brightness;
 
-	if (bl->props.power != FB_BLANK_UNBLANK)
-		brightness = 0;
-
-	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
-		brightness = 0;
-
-	if (bl->props.state & BL_CORE_SUSPENDED)
+	if (backlight_is_blank(bl))
 		brightness = 0;
 
 	return pm860x_backlight_set(bl, brightness);
diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
index 0f63f76723a5..d817b0d95c9d 100644
--- a/drivers/video/backlight/adp5520_bl.c
+++ b/drivers/video/backlight/adp5520_bl.c
@@ -67,10 +67,7 @@ static int adp5520_bl_update_status(struct backlight_device *bl)
 {
 	int brightness = bl->props.brightness;
 
-	if (bl->props.power != FB_BLANK_UNBLANK)
-		brightness = 0;
-
-	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
+	if (backlight_is_blank(bl))
 		brightness = 0;
 
 	return adp5520_bl_set(bl, brightness);
diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
index 19968104fc47..a0ce2a3701fa 100644
--- a/drivers/video/backlight/adp8860_bl.c
+++ b/drivers/video/backlight/adp8860_bl.c
@@ -363,10 +363,7 @@ static int adp8860_bl_update_status(struct backlight_device *bl)
 {
 	int brightness = bl->props.brightness;
 
-	if (bl->props.power != FB_BLANK_UNBLANK)
-		brightness = 0;
-
-	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
+	if (backlight_is_blank(bl))
 		brightness = 0;
 
 	return adp8860_bl_set(bl, brightness);
diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
index 4c0032010cfe..ae4269fdb189 100644
--- a/drivers/video/backlight/adp8870_bl.c
+++ b/drivers/video/backlight/adp8870_bl.c
@@ -401,10 +401,7 @@ static int adp8870_bl_update_status(struct backlight_device *bl)
 {
 	int brightness = bl->props.brightness;
 
-	if (bl->props.power != FB_BLANK_UNBLANK)
-		brightness = 0;
-
-	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
+	if (backlight_is_blank(bl))
 		brightness = 0;
 
 	return adp8870_bl_set(bl, brightness);
diff --git a/drivers/video/backlight/as3711_bl.c b/drivers/video/backlight/as3711_bl.c
index 33f0f0f2e8b3..7fa76008c7bf 100644
--- a/drivers/video/backlight/as3711_bl.c
+++ b/drivers/video/backlight/as3711_bl.c
@@ -107,13 +107,11 @@ static int as3711_bl_update_status(struct backlight_device *bl)
 	int brightness = bl->props.brightness;
 	int ret = 0;
 
-	dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, blank %x, state %x\n",
+	dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, state %x\n",
 		__func__, bl->props.brightness, bl->props.power,
-		bl->props.fb_blank, bl->props.state);
+		bl->props.state);
 
-	if (bl->props.power != FB_BLANK_UNBLANK ||
-	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
-	    bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
+	if (backlight_is_blank(bl))
 		brightness = 0;
 
 	if (data->type == AS3711_BL_SU1) {
diff --git a/drivers/video/backlight/bd6107.c b/drivers/video/backlight/bd6107.c
index d5d5fb457e78..f6a5c1dba3bc 100644
--- a/drivers/video/backlight/bd6107.c
+++ b/drivers/video/backlight/bd6107.c
@@ -84,9 +84,7 @@ static int bd6107_backlight_update_status(struct backlight_device *backlight)
 	struct bd6107 *bd = bl_get_data(backlight);
 	int brightness = backlight->props.brightness;
 
-	if (backlight->props.power != FB_BLANK_UNBLANK ||
-	    backlight->props.fb_blank != FB_BLANK_UNBLANK ||
-	    backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
+	if (backlight_is_blank(backlight))
 		brightness = 0;
 
 	if (brightness) {
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c
index 25ef0cbd7583..c9adf4e26355 100644
--- a/drivers/video/backlight/corgi_lcd.c
+++ b/drivers/video/backlight/corgi_lcd.c
@@ -422,10 +422,7 @@ static int corgi_bl_update_status(struct backlight_device *bd)
 	struct corgi_lcd *lcd = bl_get_data(bd);
 	int intensity = bd->props.brightness;
 
-	if (bd->props.power != FB_BLANK_UNBLANK)
-		intensity = 0;
-
-	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
+	if (backlight_is_blank(bd))
 		intensity = 0;
 
 	if (corgibl_flags & CORGIBL_SUSPENDED)
diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c
index 4624b7b7c6a6..d5ab7675f55c 100644
--- a/drivers/video/backlight/cr_bllcd.c
+++ b/drivers/video/backlight/cr_bllcd.c
@@ -59,26 +59,18 @@ struct cr_panel {
 
 static int cr_backlight_set_intensity(struct backlight_device *bd)
 {
-	int intensity = bd->props.brightness;
 	u32 addr = gpio_bar + CRVML_PANEL_PORT;
 	u32 cur = inl(addr);
 
-	if (bd->props.power == FB_BLANK_UNBLANK)
-		intensity = FB_BLANK_UNBLANK;
-	if (bd->props.fb_blank == FB_BLANK_UNBLANK)
-		intensity = FB_BLANK_UNBLANK;
-	if (bd->props.power == FB_BLANK_POWERDOWN)
-		intensity = FB_BLANK_POWERDOWN;
-	if (bd->props.fb_blank == FB_BLANK_POWERDOWN)
-		intensity = FB_BLANK_POWERDOWN;
-
-	if (intensity == FB_BLANK_UNBLANK) { /* FULL ON */
-		cur &= ~CRVML_BACKLIGHT_OFF;
-		outl(cur, addr);
-	} else if (intensity == FB_BLANK_POWERDOWN) { /* OFF */
+	if (backlight_is_blank(bd)) {
+		/* OFF */
 		cur |= CRVML_BACKLIGHT_OFF;
 		outl(cur, addr);
-	} /* anything else, don't bother */
+	} else {
+		/* FULL ON */
+		cur &= ~CRVML_BACKLIGHT_OFF;
+		outl(cur, addr);
+	}
 
 	return 0;
 }
diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c
index 62540e4bdedb..ca351badfdcf 100644
--- a/drivers/video/backlight/da903x_bl.c
+++ b/drivers/video/backlight/da903x_bl.c
@@ -79,13 +79,7 @@ static int da903x_backlight_update_status(struct backlight_device *bl)
 {
 	int brightness = bl->props.brightness;
 
-	if (bl->props.power != FB_BLANK_UNBLANK)
-		brightness = 0;
-
-	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
-		brightness = 0;
-
-	if (bl->props.state & BL_CORE_SUSPENDED)
+	if (backlight_is_blank(bl))
 		brightness = 0;
 
 	return da903x_backlight_set(bl, brightness);
diff --git a/drivers/video/backlight/ep93xx_bl.c b/drivers/video/backlight/ep93xx_bl.c
index 4149e0b2f83c..491185df1411 100644
--- a/drivers/video/backlight/ep93xx_bl.c
+++ b/drivers/video/backlight/ep93xx_bl.c
@@ -38,8 +38,7 @@ static int ep93xxbl_update_status(struct backlight_device *bl)
 {
 	int brightness = bl->props.brightness;
 
-	if (bl->props.power != FB_BLANK_UNBLANK ||
-	    bl->props.fb_blank != FB_BLANK_UNBLANK)
+	if (backlight_is_blank(bl))
 		brightness = 0;
 
 	return ep93xxbl_set(bl, brightness);
diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
index 75409ddfba3e..94b65e4d2aa0 100644
--- a/drivers/video/backlight/gpio_backlight.c
+++ b/drivers/video/backlight/gpio_backlight.c
@@ -25,9 +25,7 @@ static int gpio_backlight_get_next_brightness(struct backlight_device *bl)
 {
 	int brightness = bl->props.brightness;
 
-	if (bl->props.power != FB_BLANK_UNBLANK ||
-	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
-	    bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
+	if (backlight_is_blank(bl))
 		brightness = 0;
 
 	return brightness;
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
index 8ea42b8d9bc8..01d805ca8415 100644
--- a/drivers/video/backlight/hp680_bl.c
+++ b/drivers/video/backlight/hp680_bl.c
@@ -35,9 +35,7 @@ static void hp680bl_send_intensity(struct backlight_device *bd)
 	u16 v;
 	int intensity = bd->props.brightness;
 
-	if (bd->props.power != FB_BLANK_UNBLANK)
-		intensity = 0;
-	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
+	if (backlight_is_blank(bd))
 		intensity = 0;
 	if (hp680bl_suspended)
 		intensity = 0;
diff --git a/drivers/video/backlight/jornada720_bl.c b/drivers/video/backlight/jornada720_bl.c
index f0385f9cf9da..996f7ba3b373 100644
--- a/drivers/video/backlight/jornada720_bl.c
+++ b/drivers/video/backlight/jornada720_bl.c
@@ -54,7 +54,7 @@ static int jornada_bl_update_status(struct backlight_device *bd)
 	jornada_ssp_start();
 
 	/* If backlight is off then really turn it off */
-	if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) {
+	if (backlight_is_blank(bd)) {
 		ret = jornada_ssp_byte(BRIGHTNESSOFF);
 		if (ret != TXDUMMY) {
 			dev_info(&bd->dev, "brightness off timeout\n");
diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
index 1dfe13c18925..a0fd5d3d82f5 100644
--- a/drivers/video/backlight/kb3886_bl.c
+++ b/drivers/video/backlight/kb3886_bl.c
@@ -89,9 +89,7 @@ static int kb3886bl_send_intensity(struct backlight_device *bd)
 {
 	int intensity = bd->props.brightness;
 
-	if (bd->props.power != FB_BLANK_UNBLANK)
-		intensity = 0;
-	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
+	if (backlight_is_blank(bd))
 		intensity = 0;
 	if (kb3886bl_flags & KB3886BL_SUSPENDED)
 		intensity = 0;
diff --git a/drivers/video/backlight/led_bl.c b/drivers/video/backlight/led_bl.c
index 3f66549997c8..c655ddd99cfb 100644
--- a/drivers/video/backlight/led_bl.c
+++ b/drivers/video/backlight/led_bl.c
@@ -56,9 +56,7 @@ static int led_bl_update_status(struct backlight_device *bl)
 	struct led_bl_data *priv = bl_get_data(bl);
 	int brightness = bl->props.brightness;
 
-	if (bl->props.power != FB_BLANK_UNBLANK ||
-	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
-	    bl->props.state & BL_CORE_FBBLANK)
+	if (backlight_is_blank(bl))
 		brightness = 0;
 
 	if (brightness > 0)
diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
index ee09d1bd02b9..476146b62c4e 100644
--- a/drivers/video/backlight/lm3533_bl.c
+++ b/drivers/video/backlight/lm3533_bl.c
@@ -41,9 +41,7 @@ static int lm3533_bl_update_status(struct backlight_device *bd)
 	struct lm3533_bl *bl = bl_get_data(bd);
 	int brightness = bd->props.brightness;
 
-	if (bd->props.power != FB_BLANK_UNBLANK)
-		brightness = 0;
-	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
+	if (backlight_is_blank(bd))
 		brightness = 0;
 
 	return lm3533_ctrlbank_set_brightness(&bl->cb, (u8)brightness);
diff --git a/drivers/video/backlight/locomolcd.c b/drivers/video/backlight/locomolcd.c
index cdc02e04f89d..8064cad8d683 100644
--- a/drivers/video/backlight/locomolcd.c
+++ b/drivers/video/backlight/locomolcd.c
@@ -113,9 +113,7 @@ static int locomolcd_set_intensity(struct backlight_device *bd)
 {
 	int intensity = bd->props.brightness;
 
-	if (bd->props.power != FB_BLANK_UNBLANK)
-		intensity = 0;
-	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
+	if (backlight_is_blank(bd))
 		intensity = 0;
 	if (locomolcd_flags & LOCOMOLCD_SUSPENDED)
 		intensity = 0;
diff --git a/drivers/video/backlight/lv5207lp.c b/drivers/video/backlight/lv5207lp.c
index c6ad73a784e2..ef8aa9803577 100644
--- a/drivers/video/backlight/lv5207lp.c
+++ b/drivers/video/backlight/lv5207lp.c
@@ -48,9 +48,7 @@ static int lv5207lp_backlight_update_status(struct backlight_device *backlight)
 	struct lv5207lp *lv = bl_get_data(backlight);
 	int brightness = backlight->props.brightness;
 
-	if (backlight->props.power != FB_BLANK_UNBLANK ||
-	    backlight->props.fb_blank != FB_BLANK_UNBLANK ||
-	    backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
+	if (backlight_is_blank(backlight))
 		brightness = 0;
 
 	if (brightness) {
diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
index 97cc260ff9d1..b8af2c6407d3 100644
--- a/drivers/video/backlight/max8925_bl.c
+++ b/drivers/video/backlight/max8925_bl.c
@@ -66,13 +66,7 @@ static int max8925_backlight_update_status(struct backlight_device *bl)
 {
 	int brightness = bl->props.brightness;
 
-	if (bl->props.power != FB_BLANK_UNBLANK)
-		brightness = 0;
-
-	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
-		brightness = 0;
-
-	if (bl->props.state & BL_CORE_SUSPENDED)
+	if (backlight_is_blank(bl))
 		brightness = 0;
 
 	return max8925_backlight_set(bl, brightness);
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 82b8d7594701..7d0ffcd37f07 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -111,9 +111,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
 	int brightness = bl->props.brightness;
 	struct pwm_state state;
 
-	if (bl->props.power != FB_BLANK_UNBLANK ||
-	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
-	    bl->props.state & BL_CORE_FBBLANK)
+	if (backlight_is_blank(bl))
 		brightness = 0;
 
 	if (pb->notify)
diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c
index 3d276b30a78c..9600f5d58ece 100644
--- a/drivers/video/backlight/qcom-wled.c
+++ b/drivers/video/backlight/qcom-wled.c
@@ -261,9 +261,7 @@ static int wled_update_status(struct backlight_device *bl)
 	u16 brightness = bl->props.brightness;
 	int rc = 0;
 
-	if (bl->props.power != FB_BLANK_UNBLANK ||
-	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
-	    bl->props.state & BL_CORE_FBBLANK)
+	if (backlight_is_blank(bl))
 		brightness = 0;
 
 	mutex_lock(&wled->lock);
diff --git a/drivers/video/backlight/tps65217_bl.c b/drivers/video/backlight/tps65217_bl.c
index 762e3feed097..1041e5e62ee3 100644
--- a/drivers/video/backlight/tps65217_bl.c
+++ b/drivers/video/backlight/tps65217_bl.c
@@ -82,9 +82,7 @@ static int tps65217_bl_update_status(struct backlight_device *bl)
 	if (bl->props.state & BL_CORE_SUSPENDED)
 		brightness = 0;
 
-	if ((bl->props.power != FB_BLANK_UNBLANK) ||
-		(bl->props.fb_blank != FB_BLANK_UNBLANK))
-		/* framebuffer in low power mode or blanking active */
+	if (backlight_is_blank(bl))
 		brightness = 0;
 
 	if (brightness > 0) {
diff --git a/drivers/video/backlight/wm831x_bl.c b/drivers/video/backlight/wm831x_bl.c
index e55977d54c15..dc2ab6c8b7f9 100644
--- a/drivers/video/backlight/wm831x_bl.c
+++ b/drivers/video/backlight/wm831x_bl.c
@@ -93,13 +93,7 @@ static int wm831x_backlight_update_status(struct backlight_device *bl)
 {
 	int brightness = bl->props.brightness;
 
-	if (bl->props.power != FB_BLANK_UNBLANK)
-		brightness = 0;
-
-	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
-		brightness = 0;
-
-	if (bl->props.state & BL_CORE_SUSPENDED)
+	if (backlight_is_blank(bl))
 		brightness = 0;
 
 	return wm831x_backlight_set(bl, brightness);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 01/16] video: amba-clcd: use devm_of_find_backlight
  2020-05-17 19:01 ` [PATCH v2 01/16] video: amba-clcd: use devm_of_find_backlight Sam Ravnborg
@ 2020-05-18  8:10   ` Linus Walleij
  2020-05-18 10:16     ` Sam Ravnborg
  0 siblings, 1 reply; 48+ messages in thread
From: Linus Walleij @ 2020-05-18  8:10 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: open list:DRM PANEL DRIVERS, Jingoo Han, Lee Jones,
	Daniel Thompson, Peter Ujfalusi, Tomi Valkeinen, Andy Gross,
	Bartlomiej Zolnierkiewicz, Bjorn Andersson, Daniel Vetter,
	David Airlie, Douglas Anderson, Jani Nikula, Jonathan Corbet,
	MSM, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Russell King, Support Opensource,
	Thierry Reding, Thomas Zimmermann, Uwe Kleine-Konig

On Sun, May 17, 2020 at 9:01 PM Sam Ravnborg <sam@ravnborg.org> wrote:

> Look up backlight device using devm_of_find_backlight().
> This simplifies the code and prevents us from hardcoding
> the node name in the driver.
>
> v2:
>   - Added Cc: Peter Ujfalusi
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: Russell King <linux@armlinux.org.uk>
> Cc: Sam Ravnborg <sam@ravnborg.org>
> Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: Douglas Anderson <dianders@chromium.org>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 01/16] video: amba-clcd: use devm_of_find_backlight
  2020-05-18  8:10   ` Linus Walleij
@ 2020-05-18 10:16     ` Sam Ravnborg
  2020-05-25  8:42       ` Linus Walleij
  0 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-18 10:16 UTC (permalink / raw)
  To: Linus Walleij
  Cc: open list:DRM PANEL DRIVERS, Jingoo Han, Lee Jones,
	Daniel Thompson, Peter Ujfalusi, Tomi Valkeinen, Andy Gross,
	Bartlomiej Zolnierkiewicz, Bjorn Andersson, Daniel Vetter,
	David Airlie, Douglas Anderson, Jani Nikula, Jonathan Corbet,
	MSM, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Russell King, Support Opensource,
	Thierry Reding, Thomas Zimmermann, Uwe Kleine-Konig

Hi Linus.

On Mon, May 18, 2020 at 10:10:12AM +0200, Linus Walleij wrote:
> On Sun, May 17, 2020 at 9:01 PM Sam Ravnborg <sam@ravnborg.org> wrote:
> 
> > Look up backlight device using devm_of_find_backlight().
> > This simplifies the code and prevents us from hardcoding
> > the node name in the driver.
> >
> > v2:
> >   - Added Cc: Peter Ujfalusi
> >
> > Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> > Cc: Russell King <linux@armlinux.org.uk>
> > Cc: Sam Ravnborg <sam@ravnborg.org>
> > Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> > Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Linus Walleij <linus.walleij@linaro.org>
> > Cc: Jani Nikula <jani.nikula@intel.com>
> > Cc: Douglas Anderson <dianders@chromium.org>
> 
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
Thanks. I went ahead and applied this now, so we could kill
the last user of of_find_backlight_by_node().

I hope we can make of_find_backlight_by_node() static after the merge window
so no new users appears.

	Sam

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 02/16] backlight: refactor fb_notifier_callback()
  2020-05-17 19:01 ` [PATCH v2 02/16] backlight: refactor fb_notifier_callback() Sam Ravnborg
@ 2020-05-18 14:54   ` Daniel Thompson
  2020-05-20 10:41   ` Emil Velikov
  1 sibling, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 14:54 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

On Sun, May 17, 2020 at 09:01:25PM +0200, Sam Ravnborg wrote:
> Increase readability of fb_notifier_callback() by removing
> a few indent levels.
> No functional change.
> 
> 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>

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


> ---
>  drivers/video/backlight/backlight.c | 43 +++++++++++++++--------------
>  1 file changed, 22 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index cac3e35d7630..17f04cff50ab 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -58,28 +58,29 @@ static int fb_notifier_callback(struct notifier_block *self,
>  
>  	bd = container_of(self, struct backlight_device, fb_notif);
>  	mutex_lock(&bd->ops_lock);
> -	if (bd->ops)
> -		if (!bd->ops->check_fb ||
> -		    bd->ops->check_fb(bd, evdata->info)) {
> -			fb_blank = *(int *)evdata->data;
> -			if (fb_blank == FB_BLANK_UNBLANK &&
> -			    !bd->fb_bl_on[node]) {
> -				bd->fb_bl_on[node] = true;
> -				if (!bd->use_count++) {
> -					bd->props.state &= ~BL_CORE_FBBLANK;
> -					bd->props.fb_blank = FB_BLANK_UNBLANK;
> -					backlight_update_status(bd);
> -				}
> -			} else if (fb_blank != FB_BLANK_UNBLANK &&
> -				   bd->fb_bl_on[node]) {
> -				bd->fb_bl_on[node] = false;
> -				if (!(--bd->use_count)) {
> -					bd->props.state |= BL_CORE_FBBLANK;
> -					bd->props.fb_blank = fb_blank;
> -					backlight_update_status(bd);
> -				}
> -			}
> +
> +	if (!bd->ops)
> +		goto out;
> +	if (bd->ops->check_fb && !bd->ops->check_fb(bd, evdata->info))
> +		goto out;
> +
> +	fb_blank = *(int *)evdata->data;
> +	if (fb_blank == FB_BLANK_UNBLANK && !bd->fb_bl_on[node]) {
> +		bd->fb_bl_on[node] = true;
> +		if (!bd->use_count++) {
> +			bd->props.state &= ~BL_CORE_FBBLANK;
> +			bd->props.fb_blank = FB_BLANK_UNBLANK;
> +			backlight_update_status(bd);
> +		}
> +	} else if (fb_blank != FB_BLANK_UNBLANK && bd->fb_bl_on[node]) {
> +		bd->fb_bl_on[node] = false;
> +		if (!(--bd->use_count)) {
> +			bd->props.state |= BL_CORE_FBBLANK;
> +			bd->props.fb_blank = fb_blank;
> +			backlight_update_status(bd);
>  		}
> +	}
> +out:
>  	mutex_unlock(&bd->ops_lock);
>  	return 0;
>  }
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 03/16] backlight: add backlight_is_blank()
  2020-05-17 19:01 ` [PATCH v2 03/16] backlight: add backlight_is_blank() Sam Ravnborg
@ 2020-05-18 15:00   ` Daniel Thompson
  2020-05-20 10:45   ` Emil Velikov
  2020-05-28 13:39   ` Peter Ujfalusi
  2 siblings, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 15:00 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

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
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 04/16] backlight: improve backlight_ops documentation
  2020-05-17 19:01 ` [PATCH v2 04/16] backlight: improve backlight_ops documentation Sam Ravnborg
@ 2020-05-18 15:02   ` Daniel Thompson
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 15:02 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

On Sun, May 17, 2020 at 09:01:27PM +0200, Sam Ravnborg wrote:
> Improve the documentation for backlight_ops and
> adapt it to kernel-doc style.
> 
> 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>

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


> ---
>  include/linux/backlight.h | 60 +++++++++++++++++++++++++++++++++++----
>  1 file changed, 54 insertions(+), 6 deletions(-)
> 
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index a0a083b35c47..519dc61ce7e4 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -55,19 +55,67 @@ enum backlight_scale {
>  struct backlight_device;
>  struct fb_info;
>  
> +/**
> + * struct backlight_ops - backlight operations
> + *
> + * The backlight operations are specifed when the backlight device is registered.
> + */
>  struct backlight_ops {
> +	/**
> +	 * @options:
> +	 *
> +	 * The options parameter is used to adjust the behaviour of the core.
> +	 * Set BL_CORE_SUSPENDRESUME to get the update_status() operation called
> +	 * upon suspend and resume.
> +	 */
>  	unsigned int options;
>  
>  #define BL_CORE_SUSPENDRESUME	(1 << 0)
>  
> -	/* Notify the backlight driver some property has changed */
> +	/**
> +	 * @update_status:
> +	 *
> +	 * Notify the backlight driver some property has changed.
> +	 * The update_status operation is protected by the update_lock.
> +	 *
> +	 * The backlight driver is expected to use backlight_is_blank()
> +	 * to check if the display is blanked and set brightness accordingly.
> +	 * update_status() is called when any of the properties has changed.
> +	 *
> +	 * RETURNS:
> +	 *
> +	 * 0 on sucees, negative error code if any failure occured.
> +	 */
>  	int (*update_status)(struct backlight_device *);
> -	/* Return the current backlight brightness (accounting for power,
> -	   fb_blank etc.) */
> +
> +	/**
> +	 * @get_brightness:
> +	 *
> +	 * Return the current backlight brightness.
> +	 * The driver may implement this as a readback from the HW.
> +	 * This operation is optional and if not present then the current brightness
> +	 * property value is used.
> +	 *
> +	 * RETURNS:
> +	 *
> +	 * A brightness value which is 0 or a positive numer.
> +	 * On failure a negative error code is returned.
> +	 */
>  	int (*get_brightness)(struct backlight_device *);
> -	/* Check if given framebuffer device is the one bound to this backlight;
> -	   return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */
> -	int (*check_fb)(struct backlight_device *, struct fb_info *);
> +
> +	/**
> +	 * @check_fb:
> +	 *
> +	 * Check if given framebuffer device is the one bound to this backlight.
> +	 * This operation is optional and if not implemented it is assumed that the
> +	 * fbdev is always the one bound to the backlight.
> +	 *
> +	 * RETURNS:
> +	 *
> +	 * If info is NULL or the info matches the fbdev bound to the backlight return true.
> +	 * If info does not match the fbdev bound to the backlight return false.
> +	 */
> +	int (*check_fb)(struct backlight_device *bd, struct fb_info *info);
>  };
>  
>  /* This structure defines all the properties of a backlight */
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 05/16] backlight: improve backlight_properties documentation
  2020-05-17 19:01 ` [PATCH v2 05/16] backlight: improve backlight_properties documentation Sam Ravnborg
@ 2020-05-18 15:53   ` Daniel Thompson
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 15:53 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

On Sun, May 17, 2020 at 09:01:28PM +0200, Sam Ravnborg wrote:
> Improve the documentation for backlight_properties and
> adapt it to kernel-doc style.
> 
> 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>

Overall looks good but enough nits that I felt compelled to comment!


> ---
>  include/linux/backlight.h | 101 +++++++++++++++++++++++++++++++++-----
>  1 file changed, 90 insertions(+), 11 deletions(-)
> 
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index 519dc61ce7e4..7f9cef299d6e 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -118,28 +118,107 @@ struct backlight_ops {
>  	int (*check_fb)(struct backlight_device *bd, struct fb_info *info);
>  };
>  
> -/* This structure defines all the properties of a backlight */
> +/**
> + * struct backlight_properties - backlight properties
> + *
> + * This structure defines all the properties of a backlight.
> + */
>  struct backlight_properties {
> -	/* Current User requested brightness (0 - max_brightness) */
> +	/**
> +	 * @brightness:
> +	 *
> +	 * The current requested brightness by the user.

This applies throughout this file (and perhaps I overlooked it in the
previous patc too) but having line breaks after @brightness: differs
from the canonical description of a kerneldoc command in:
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#in-line-member-documentation-comments

Also: s/requested brightness/brightness requested/


> +	 * The backlight core makes sure the range is (0 - max_brightness)

I know this is a copy of the original text but I'd prefer the range not
to use the subtract operator ;-). Maybe 0..max_brightness like the
ranges below?


> +	 * when the brightness is set via the sysfs attribute:
> +	 * /sys/class/backlight/<backlight>/brightness.
> +	 *
> +	 * This value can be set in the backlight_properties passed
> +	 * to devm_backlight_device_register() to set a default brightness
> +	 * value.
> +	 */
>  	int brightness;
> -	/* Maximal value for brightness (read-only) */
> +
> +	/**
> +	 * @max_brightness:
> +	 *
> +	 * The maximum brightness value.
> +	 *
> +	 * This value must be set in the backlight_properties passed
> +	 * to devm_backlight_device_register().
> +	 *
> +	 * This property must not be modified by a driver except
> +	 * before registering the backlight device as explained above.

Perhaps combine these (rather than "as explained above"):

  This value must be set in the backlight_properties passed to
  devm_backlight_device_register() and shall not be modified by the
  driver after registration.


> +	 */
>  	int max_brightness;
> -	/* Current FB Power mode (0: full on, 1..3: power saving
> -	   modes; 4: full off), see FB_BLANK_XXX */
> +
> +	/**
> +	 * @power:
> +	 *
> +	 * The current power mode. User space configure the power mode using

s/configure/can configure/

> +	 * the sysfs attribute: /sys/class/backlight/<backlight>/bl_power
> +	 * When the power property is updated update_status() is called.
> +	 *
> +	 * The possible values are: (0: full on, 1..3: power saving
> +	 * modes; 4: full off), see FB_BLANK_XXX.
> +	 *
> +	 * When the backlight device is enabled @power is set
> +	 * to FB_BLANK_UNBLANK. When the backlight device is disabled
> +	 * @power is set to FB_BLANK_POWERDOWN.
> +	 */
>  	int power;
> -	/* FB Blanking active? (values as for power) */
> -	/* Due to be removed, please use (state & BL_CORE_FBBLANK) */
> +
> +	/**
> +	 * @fb_blank:
> +	 *
> +	 * When the FBIOBLANK ioctl is called fb_blank is set to the
> +	 * blank parameter and the update_status() operation is called.
> +	 *
> +	 * When the backlight device is enabled @fb_blank is set
> +	 * to FB_BLANK_UNBLANK. When the backlight device is disabled
> +	 * @fb_blank is set to FB_BLANK_POWERDOWN.
> +	 *
> +	 * This property must not be modified by a driver.
> +	 * The backlight driver shall never read this variable,
> +	 * as the necessary info is avaialble via the state.

I'd rather be told what to do that what not to do!

Maybe.

  Backlight drivers should avoid using this property. It has been
  replaced by state & BL_CORE_FBLANK (although most drivers should
  use backlight_is_blank() as the preferred means to get the blank
  state.



Daniel.


> +	 *
> +	 * fb_blank is deprecated and will be removed.
> +	 */
>  	int fb_blank;
> -	/* Backlight type */
> +
> +	/**
> +	 * @type:
> +	 *
> +	 * The type of backlight supported.
> +	 * The backlight type allows userspace to make appropriate
> +	 * policy desicions based on the backlight type.
> +	 *
> +	 * This value must be set in the backlight_properties
> +	 * passed to devm_backlight_device_register().
> +	 */
>  	enum backlight_type type;
> -	/* Flags used to signal drivers of state changes */
> +
> +	/**
> +	 * @state:
> +	 *
> +	 * The state property is used to inform drivers of state changes
> +	 * when the update_status() operation is called.
> +	 * The state is a bitmask. BL_CORE_FBBLANK is set when the display
> +	 * is expected to be blank. BL_CORE_SUSPENDED is set when the
> +	 * driver is suspended.
> +	 *
> +	 * This property must not be modified by a driver.
> +	 */
>  	unsigned int state;
> -	/* Type of the brightness scale (linear, non-linear, ...) */
> -	enum backlight_scale scale;
>  
>  #define BL_CORE_SUSPENDED	(1 << 0)	/* backlight is suspended */
>  #define BL_CORE_FBBLANK		(1 << 1)	/* backlight is under an fb blank event */
>  
> +	/**
> +	 * @scale:
> +	 *
> +	 * The type of the brightness scale (linear, non-linear, ...)
> +	 */
> +	enum backlight_scale scale;
>  };
>  
>  struct backlight_device {
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 06/16] backlight: improve backlight_device documentation
  2020-05-17 19:01 ` [PATCH v2 06/16] backlight: improve backlight_device documentation Sam Ravnborg
@ 2020-05-18 16:03   ` Daniel Thompson
  2020-05-18 17:03     ` Jani Nikula
  0 siblings, 1 reply; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 16:03 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

On Sun, May 17, 2020 at 09:01:29PM +0200, Sam Ravnborg wrote:
> Improve the documentation for backlight_device and
> adapt it to kernel-doc style.
> 
> 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 | 81 ++++++++++++++++++++++++++++-----------
>  1 file changed, 58 insertions(+), 23 deletions(-)
> 
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index 7f9cef299d6e..e2d72936bf05 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -14,21 +14,6 @@
>  #include <linux/mutex.h>
>  #include <linux/notifier.h>
>  
> -/* Notes on locking:
> - *
> - * backlight_device->ops_lock is an internal backlight lock protecting the
> - * ops pointer and no code outside the core should need to touch it.
> - *
> - * Access to update_status() is serialised by the update_lock mutex since
> - * most drivers seem to need this and historically get it wrong.
> - *
> - * Most drivers don't need locking on their get_brightness() method.
> - * If yours does, you need to implement it in the driver. You can use the
> - * update_lock mutex if appropriate.
> - *
> - * Any other use of the locks below is probably wrong.
> - */
> -
>  enum backlight_update_reason {
>  	BACKLIGHT_UPDATE_HOTKEY,
>  	BACKLIGHT_UPDATE_SYSFS,
> @@ -221,30 +206,80 @@ struct backlight_properties {
>  	enum backlight_scale scale;
>  };
>  
> +/**
> + * struct backlight_device - backlight device data
> + *
> + * This structure holds all data required by a backlight device.
> + */
>  struct backlight_device {
> -	/* Backlight properties */
> +	/**
> +	 * @props:
> +	 *

As last patch. Why no brief descriptions?


> +	 * Backlight properties
> +	 */
>  	struct backlight_properties props;
>  
> -	/* Serialise access to update_status method */
> +	/**
> +	 * @update_lock:
> +	 *
> +	 * update_lock is an internal backlight lock that serialise access
> +	 * to the update_status() method. The iupdate_lock mutex shall not be used
> +	 * by backlight drivers.

In addition to the typo this directly contradicts the advice in the
original "Notes on locking".

A change this dramatic needs to be fully explaining in the patch
description.


Daniel.


> +	 */
>  	struct mutex update_lock;
>  
> -	/* This protects the 'ops' field. If 'ops' is NULL, the driver that
> -	   registered this device has been unloaded, and if class_get_devdata()
> -	   points to something in the body of that driver, it is also invalid. */
> +	/**
> +	 * @ops_lock:
> +	 *
> +	 * ops_lock is an internal backlight lock that protects the ops pointer
> +	 * and is used around all accesses to ops and when the operations are
> +	 * invoked. The mutex shall not be used by backlight drivers.
> +	 */
>  	struct mutex ops_lock;
> +
> +	/**
> +	 * @ops:
> +	 *
> +	 * Pointer to the backlight operations. If ops is NULL, the driver that
> +	 * registered this device has been unloaded, and if class_get_devdata()
> +	 * points to something in the body of that driver, it is also invalid.
> +	 */
>  	const struct backlight_ops *ops;
>  
> -	/* The framebuffer notifier block */
> +	/**
> +	 * @fb_notif:
> +	 *
> +	 * The framebuffer notifier block
> +	 */
>  	struct notifier_block fb_notif;
>  
> -	/* list entry of all registered backlight devices */
> +	/**
> +	 * @entry:
> +	 *
> +	 * List entry of all registered backlight devices
> +	 */
>  	struct list_head entry;
>  
> +	/**
> +	 * @dev:
> +	 *
> +	 * Parent device.
> +	 */
>  	struct device dev;
>  
> -	/* Multiple framebuffers may share one backlight device */
> +	/**
> +	 * @fb_bl_on:
> +	 *
> +	 * Multiple fbdev's may share one backlight device. The fb_bl_on
> +	 * records the state of the individual fbdev.
> +	 */
>  	bool fb_bl_on[FB_MAX];
>  
> +	/**
> +	 * @use_count:
> +	 *
> +	 * The number of uses of fb_bl_on.
> +	 */
>  	int use_count;
>  };
>  
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 07/16] backlight: document inline functions in backlight.h
  2020-05-17 19:01 ` [PATCH v2 07/16] backlight: document inline functions in backlight.h Sam Ravnborg
@ 2020-05-18 16:04   ` Daniel Thompson
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 16:04 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

On Sun, May 17, 2020 at 09:01:30PM +0200, Sam Ravnborg wrote:
> Add documentation for the inline functions in backlight.h
> 
> 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 | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index e2d72936bf05..98349a2984dc 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -283,6 +283,10 @@ struct backlight_device {
>  	int use_count;
>  };
>  
> +/**
> + * backlight_update_status - force an update of the backligt device status

Typo.

Other than that,

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


Daniel.

> + * @bd: the backlight device
> + */
>  static inline int backlight_update_status(struct backlight_device *bd)
>  {
>  	int ret = -ENOENT;
> @@ -375,6 +379,18 @@ extern int backlight_device_set_brightness(struct backlight_device *bd, unsigned
>  
>  #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
>  
> +/**
> + * bl_get_data - access devdata
> + * @bl_dev: pointer to backlight device
> + *
> + * When a backlight device is registered the driver has the possibility
> + * to supply a void * devdata. bl_get_data() return a pointer to the
> + * devdata.
> + *
> + * RETURNS:
> + *
> + * pointer to devdata stored while registering the backlight device.
> + */
>  static inline void * bl_get_data(struct backlight_device *bl_dev)
>  {
>  	return dev_get_drvdata(&bl_dev->dev);
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 08/16] backlight: document enums in backlight.h
  2020-05-17 19:01 ` [PATCH v2 08/16] backlight: document enums " Sam Ravnborg
@ 2020-05-18 16:15   ` Daniel Thompson
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 16:15 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

On Sun, May 17, 2020 at 09:01:31PM +0200, Sam Ravnborg wrote:
> Add kernel-doc documentation for the backlight enums
> 
> 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>

Other than the usual comment about the form in the kernel-doc howto:

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>



> ---
>  include/linux/backlight.h | 84 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 84 insertions(+)
> 
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index 98349a2984dc..b779c29142fd 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -14,26 +14,110 @@
>  #include <linux/mutex.h>
>  #include <linux/notifier.h>
>  
> +/**
> + * enum backlight_update_reason - what method was used to update backlight
> + *
> + * A driver indicates the method (reason) used for updating the backlight
> + * when calling backlight_force_update().
> + */
>  enum backlight_update_reason {
> +	/**
> +	 * @BACKLIGHT_UPDATE_HOTKEY:
> +	 *
> +	 * The backlight was updated using a hot-key.
> +	 */
>  	BACKLIGHT_UPDATE_HOTKEY,
> +
> +	/**
> +	 * @BACKLIGHT_UPDATE_SYSFS:
> +	 *
> +	 * The backlight was updated using sysfs.
> +	 */
>  	BACKLIGHT_UPDATE_SYSFS,
>  };
>  
> +/**
> + * enum backlight_type - the type of backlight control
> + *
> + * The type of interface used to control the backlight.
> + */
>  enum backlight_type {
> +	/**
> +	 * @BACKLIGHT_RAW:
> +	 *
> +	 * The backlight is controlled using hardware registers directly.
> +	 */
>  	BACKLIGHT_RAW = 1,
> +
> +	/**
> +	 * @BACKLIGHT_PLATFORM:
> +	 *
> +	 * The backlight is controller using a platform-specific interface.
> +	 */
>  	BACKLIGHT_PLATFORM,
> +
> +	/**
> +	 * @BACKLIGHT_FIRMWARE:
> +	 *
> +	 * The backlight is controlled using a standard firmware interface.
> +	 */
>  	BACKLIGHT_FIRMWARE,
> +
> +	/**
> +	 * @BACKLIGHT_TYPE_MAX: Number of entries.
> +	 */
>  	BACKLIGHT_TYPE_MAX,
>  };
>  
> +/**
> + * enum backlight_notification - the type of notification
> + *
> + * The notifications that is used for notification sent to the receiver
> + * that registered notifications using backlight_register_notifier().
> + */
>  enum backlight_notification {
> +	/**
> +	 * @BACKLIGHT_REGISTERED:
> +	 *
> +	 * The backlight device is registered.
> +	 */
>  	BACKLIGHT_REGISTERED,
> +
> +	/**
> +	 * @BACKLIGHT_UNREGISTERED:
> +	 *
> +	 * The backlight revice is unregistered.
> +	 */
>  	BACKLIGHT_UNREGISTERED,
>  };
>  
> +/** enum backlight_scale - the type of scale used for brightness values
> + *
> + * The type of scale used for brightness values.
> + */
>  enum backlight_scale {
> +	/**
> +	 * @BACKLIGHT_SCALE_UNKNOWN:
> +	 *
> +	 * The scale is unknown.
> +	 */
>  	BACKLIGHT_SCALE_UNKNOWN = 0,
> +
> +	/**
> +	 * @BACKLIGHT_SCALE_LINEAR:
> +	 *
> +	 * The scale is linear, so the brigness increase is the same
> +	 * when increasing with the same steps (more or less).
> +	 */
>  	BACKLIGHT_SCALE_LINEAR,
> +
> +	/**
> +	 * @BACKLIGHT_SCALE_NON_LINEAR:
> +	 *
> +	 * The scale is not linear. This is often used when the brightness
> +	 * values tries to adjust to the relative perception of the eye
> +	 * demanding a non-linear scale.
> +	 */
>  	BACKLIGHT_SCALE_NON_LINEAR,
>  };
>  
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 09/16] backlight: remove the unused backlight_bl driver
  2020-05-17 19:01 ` [PATCH v2 09/16] backlight: remove the unused backlight_bl driver Sam Ravnborg
@ 2020-05-18 16:17   ` Daniel Thompson
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 16:17 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

On Sun, May 17, 2020 at 09:01:32PM +0200, Sam Ravnborg wrote:
> The driver required initialization using struct generic_bl_info.
> As there are no more references to this struct there is no users left.
> So it is safe to delete the driver.
> 
> 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>

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


> ---
>  drivers/video/backlight/Kconfig      |   8 --
>  drivers/video/backlight/Makefile     |   1 -
>  drivers/video/backlight/generic_bl.c | 110 ---------------------------
>  include/linux/backlight.h            |   9 ---
>  4 files changed, 128 deletions(-)
>  delete mode 100644 drivers/video/backlight/generic_bl.c
> 
> diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
> index 7d22d7377606..14abfeee8868 100644
> --- a/drivers/video/backlight/Kconfig
> +++ b/drivers/video/backlight/Kconfig
> @@ -173,14 +173,6 @@ config BACKLIGHT_EP93XX
>  	  To compile this driver as a module, choose M here: the module will
>  	  be called ep93xx_bl.
>  
> -config BACKLIGHT_GENERIC
> -	tristate "Generic (aka Sharp Corgi) Backlight Driver"
> -	default y
> -	help
> -	  Say y to enable the generic platform backlight driver previously
> -	  known as the Corgi backlight driver. If you have a Sharp Zaurus
> -	  SL-C7xx, SL-Cxx00 or SL-6000x say y.
> -
>  config BACKLIGHT_IPAQ_MICRO
>  	tristate "iPAQ microcontroller backlight driver"
>  	depends on MFD_IPAQ_MICRO
> diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
> index 0c1a1524627a..9b998cfdc56d 100644
> --- a/drivers/video/backlight/Makefile
> +++ b/drivers/video/backlight/Makefile
> @@ -31,7 +31,6 @@ obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE)	+= backlight.o
>  obj-$(CONFIG_BACKLIGHT_DA903X)		+= da903x_bl.o
>  obj-$(CONFIG_BACKLIGHT_DA9052)		+= da9052_bl.o
>  obj-$(CONFIG_BACKLIGHT_EP93XX)		+= ep93xx_bl.o
> -obj-$(CONFIG_BACKLIGHT_GENERIC)		+= generic_bl.o
>  obj-$(CONFIG_BACKLIGHT_GPIO)		+= gpio_backlight.o
>  obj-$(CONFIG_BACKLIGHT_HP680)		+= hp680_bl.o
>  obj-$(CONFIG_BACKLIGHT_HP700)		+= jornada720_bl.o
> diff --git a/drivers/video/backlight/generic_bl.c b/drivers/video/backlight/generic_bl.c
> deleted file mode 100644
> index 8fe63dbc8590..000000000000
> --- a/drivers/video/backlight/generic_bl.c
> +++ /dev/null
> @@ -1,110 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0-only
> -/*
> - *  Generic Backlight Driver
> - *
> - *  Copyright (c) 2004-2008 Richard Purdie
> - */
> -
> -#include <linux/module.h>
> -#include <linux/kernel.h>
> -#include <linux/init.h>
> -#include <linux/platform_device.h>
> -#include <linux/mutex.h>
> -#include <linux/fb.h>
> -#include <linux/backlight.h>
> -
> -static int genericbl_intensity;
> -static struct backlight_device *generic_backlight_device;
> -static struct generic_bl_info *bl_machinfo;
> -
> -static int genericbl_send_intensity(struct backlight_device *bd)
> -{
> -	int intensity = bd->props.brightness;
> -
> -	if (bd->props.power != FB_BLANK_UNBLANK)
> -		intensity = 0;
> -	if (bd->props.state & BL_CORE_FBBLANK)
> -		intensity = 0;
> -	if (bd->props.state & BL_CORE_SUSPENDED)
> -		intensity = 0;
> -
> -	bl_machinfo->set_bl_intensity(intensity);
> -
> -	genericbl_intensity = intensity;
> -
> -	if (bl_machinfo->kick_battery)
> -		bl_machinfo->kick_battery();
> -
> -	return 0;
> -}
> -
> -static int genericbl_get_intensity(struct backlight_device *bd)
> -{
> -	return genericbl_intensity;
> -}
> -
> -static const struct backlight_ops genericbl_ops = {
> -	.options = BL_CORE_SUSPENDRESUME,
> -	.get_brightness = genericbl_get_intensity,
> -	.update_status  = genericbl_send_intensity,
> -};
> -
> -static int genericbl_probe(struct platform_device *pdev)
> -{
> -	struct backlight_properties props;
> -	struct generic_bl_info *machinfo = dev_get_platdata(&pdev->dev);
> -	const char *name = "generic-bl";
> -	struct backlight_device *bd;
> -
> -	bl_machinfo = machinfo;
> -	if (!machinfo->limit_mask)
> -		machinfo->limit_mask = -1;
> -
> -	if (machinfo->name)
> -		name = machinfo->name;
> -
> -	memset(&props, 0, sizeof(struct backlight_properties));
> -	props.type = BACKLIGHT_RAW;
> -	props.max_brightness = machinfo->max_intensity;
> -	bd = devm_backlight_device_register(&pdev->dev, name, &pdev->dev,
> -					NULL, &genericbl_ops, &props);
> -	if (IS_ERR(bd))
> -		return PTR_ERR(bd);
> -
> -	platform_set_drvdata(pdev, bd);
> -
> -	bd->props.power = FB_BLANK_UNBLANK;
> -	bd->props.brightness = machinfo->default_intensity;
> -	backlight_update_status(bd);
> -
> -	generic_backlight_device = bd;
> -
> -	dev_info(&pdev->dev, "Generic Backlight Driver Initialized.\n");
> -	return 0;
> -}
> -
> -static int genericbl_remove(struct platform_device *pdev)
> -{
> -	struct backlight_device *bd = platform_get_drvdata(pdev);
> -
> -	bd->props.power = 0;
> -	bd->props.brightness = 0;
> -	backlight_update_status(bd);
> -
> -	dev_info(&pdev->dev, "Generic Backlight Driver Unloaded\n");
> -	return 0;
> -}
> -
> -static struct platform_driver genericbl_driver = {
> -	.probe		= genericbl_probe,
> -	.remove		= genericbl_remove,
> -	.driver		= {
> -		.name	= "generic-bl",
> -	},
> -};
> -
> -module_platform_driver(genericbl_driver);
> -
> -MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
> -MODULE_DESCRIPTION("Generic Backlight Driver");
> -MODULE_LICENSE("GPL");
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index b779c29142fd..eae7a5e66248 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -480,15 +480,6 @@ static inline void * bl_get_data(struct backlight_device *bl_dev)
>  	return dev_get_drvdata(&bl_dev->dev);
>  }
>  
> -struct generic_bl_info {
> -	const char *name;
> -	int max_intensity;
> -	int default_intensity;
> -	int limit_mask;
> -	void (*set_bl_intensity)(int intensity);
> -	void (*kick_battery)(void);
> -};
> -
>  #ifdef CONFIG_OF
>  struct backlight_device *of_find_backlight_by_node(struct device_node *node);
>  #else
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 10/16] backlight: drop extern from prototypes
  2020-05-17 19:01 ` [PATCH v2 10/16] backlight: drop extern from prototypes Sam Ravnborg
@ 2020-05-18 16:22   ` Daniel Thompson
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 16:22 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

On Sun, May 17, 2020 at 09:01:33PM +0200, Sam Ravnborg wrote:
> No need to put "extern" in front of prototypes.
> While touching the prototypes adjust indent to follow
> the kernel style.
> 
> 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>

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>



> ---
>  include/linux/backlight.h | 35 +++++++++++++++++++----------------
>  1 file changed, 19 insertions(+), 16 deletions(-)
> 
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index eae7a5e66248..308aec67fa4f 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -444,22 +444,25 @@ static inline bool backlight_is_blank(struct backlight_device *bd)
>  	       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);
> -extern struct backlight_device *devm_backlight_device_register(
> -	struct device *dev, const char *name, struct device *parent,
> -	void *devdata, const struct backlight_ops *ops,
> -	const struct backlight_properties *props);
> -extern void backlight_device_unregister(struct backlight_device *bd);
> -extern void devm_backlight_device_unregister(struct device *dev,
> -					struct backlight_device *bd);
> -extern void backlight_force_update(struct backlight_device *bd,
> -				   enum backlight_update_reason reason);
> -extern int backlight_register_notifier(struct notifier_block *nb);
> -extern int backlight_unregister_notifier(struct notifier_block *nb);
> -extern struct backlight_device *backlight_device_get_by_type(enum backlight_type type);
> -extern int backlight_device_set_brightness(struct backlight_device *bd, unsigned long brightness);
> +struct backlight_device *
> +backlight_device_register(const char *name, struct device *dev, void *devdata,
> +			  const struct backlight_ops *ops,
> +			  const struct backlight_properties *props);
> +struct backlight_device *
> +devm_backlight_device_register(struct device *dev, const char *name,
> +			       struct device *parent, void *devdata,
> +			       const struct backlight_ops *ops,
> +			       const struct backlight_properties *props);
> +void backlight_device_unregister(struct backlight_device *bd);
> +void devm_backlight_device_unregister(struct device *dev,
> +				      struct backlight_device *bd);
> +void backlight_force_update(struct backlight_device *bd,
> +			    enum backlight_update_reason reason);
> +int backlight_register_notifier(struct notifier_block *nb);
> +int backlight_unregister_notifier(struct notifier_block *nb);
> +struct backlight_device *backlight_device_get_by_type(enum backlight_type type);
> +int backlight_device_set_brightness(struct backlight_device *bd,
> +				    unsigned long brightness);
>  
>  #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
>  
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 11/16] backlight: add overview and update existing doc
  2020-05-17 19:01 ` [PATCH v2 11/16] backlight: add overview and update existing doc Sam Ravnborg
@ 2020-05-18 16:44   ` Daniel Thompson
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 16:44 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	linux-pwm, Support Opensource, Michael Hennerich,
	Bartlomiej Zolnierkiewicz, David Airlie, Daniel Vetter,
	Jonathan Corbet, Douglas Anderson, Bjorn Andersson, Jani Nikula,
	Andy Gross, Thierry Reding, Thomas Zimmermann, linux-arm-msm,
	Russell King, patches, Uwe Kleine-Konig

On Sun, May 17, 2020 at 09:01:34PM +0200, Sam Ravnborg wrote:
> Add overview chapter to backlight.c.
> Update existing kernel-doc to follow a more consistent
> style and drop kernel-doc for deprecated functions.
> 
> 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>
> ---
>  drivers/video/backlight/backlight.c | 131 +++++++++++++++++++---------
>  1 file changed, 90 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index 17f04cff50ab..2212f0e3570e 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -22,6 +22,45 @@
>  #include <asm/backlight.h>
>  #endif
>  
> +/**
> + * DOC: overview
> + *
> + * The backlight core supports implementing backlight drivers.
> + *
> + * backlight is controlled from userspace via firmware, a platform
> + * specific way or via sysfs. The backlight core provide support
> + * for all three types of backlight control.

This paragraph seems very difficult for a reader to absorb (isn't
"controlled from userspace via firmware" more like the backlight
subsytem notifying the userspace when something else controls the
backlight behind the userspace's back).

Maybe just drop the paragraph? Notifications are covered further down
anyway.


> + *
> + * A backlight driver registers a driver using
> + * devm_backlight_device_register(). The properties of the backlight
> + * driver such as type and max_brightness must be specified.
> + * When the core detect changes in for example brightness or power state
> + * the update_status() operation is called. The backlight driver shall
> + * implement this operation and use it to adjust backlight.
> + *
> + * Several sysfs attributes are provided by the backlight core::
> + *
> + * - brightness         R/W, set the requested brightness level
> + * - actual_brighness   RO, the brightness level used by the HW
> + * - max_brightness     RO, the maximum  brightness level supported

I've not come across this markup before. Do all these extra
spaces create readable output when formatted?


> + *
> + * See Documentation/ABI/stable/sysfs-class-backlight for the full list.
> + *
> + * The driver shall implement the get_brightness() operation if
> + * the HW do not support all the levels that can be specified in
> + * brightness, thus providing user-space access to the actual level
> + * via the actual_brightness attribute.

Again... this doesn't look like the formatted output will get a
paragraph break here.


> + * When the backlight changes this is reported to user-space using
> + * an uevent connected to the actual_brightness attribute.
> + * When brightness is set by platform specific means, for example
> + * a hot-key to adjust backlight, the driver must notify the backlight
> + * core that brighness has changed using backlight_force_update().
> + *
> + * The backlight driver core receives notifications from fbdev and
> + * if the event is FB_EVENT_BLANK the value of blank, from the FBIOBLANK
> + * ioclt, is passed to the driver via the update_status() operation.
> + */
> +
>  static struct list_head backlight_dev_list;
>  static struct mutex backlight_dev_list_mutex;
>  static struct blocking_notifier_head backlight_notifier;
> @@ -40,9 +79,17 @@ static const char *const backlight_scale_types[] = {
>  
>  #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
>  			   defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE))
> -/* This callback gets called when something important happens inside a
> - * framebuffer driver. We're looking if that important event is blanking,
> - * and if it is and necessary, we're switching backlight power as well ...
> +/*
> + * fb_notifier_callback
> + *
> + * This callback gets called when something important happens inside a
> + * framebuffer driver. The backlight core only care about FB_BLANK_UNBLANK

s/care/cares/

> + * which is reported to the driver using backlight_update_status()
> + * as a state change.
> + *
> + * There may be several fbdev's connected to the backlight device,
> + * in which case they are kept track of. A state change is only reported
> + * if there is a change in backligt for the specified fbdev.

Typo.


>   */
>  static int fb_notifier_callback(struct notifier_block *self,
>  				unsigned long event, void *data)
> @@ -318,12 +365,16 @@ static struct attribute *bl_device_attrs[] = {
>  ATTRIBUTE_GROUPS(bl_device);
>  
>  /**
> - * backlight_force_update - tell the backlight subsystem that hardware state
> - *   has changed
> + * backlight_force_update - force an update due to a hardware change
>   * @bd: the backlight device to update
> + * @reason: the method used for the backlight update
>   *
>   * Updates the internal state of the backlight in response to a hardware event,
> - * and generate a uevent to notify userspace
> + * and generate an uevent to notify userspace.

s/generate/generates/


> + * A backlight driver shall call backlight_force_update() when the backlight
> + * is changed using, for example, a hot-key.
> + * The updated brightness is read using get_brightness() and the brightness
> + * value is reported using an uevent.

There seem to be several missing paragraph breaks above.

>   */
>  void backlight_force_update(struct backlight_device *bd,
>  			    enum backlight_update_reason reason)
> @@ -336,19 +387,7 @@ void backlight_force_update(struct backlight_device *bd,
>  }
>  EXPORT_SYMBOL(backlight_force_update);
>  
> -/**
> - * backlight_device_register - create and register a new object of
> - *   backlight_device class.
> - * @name: the name of the new object(must be the same as the name of the
> - *   respective framebuffer device).
> - * @parent: a pointer to the parent device
> - * @devdata: an optional pointer to be stored for private driver use. The
> - *   methods may retrieve it by using bl_get_data(bd).
> - * @ops: the backlight operations structure.
> - *
> - * Creates and registers new backlight device. Returns either an
> - * ERR_PTR() or a pointer to the newly allocated device.
> - */
> +/* deprecated - use devm_backlight_device_register() */
>  struct backlight_device *backlight_device_register(const char *name,
>  	struct device *parent, void *devdata, const struct backlight_ops *ops,
>  	const struct backlight_properties *props)
> @@ -415,6 +454,15 @@ struct backlight_device *backlight_device_register(const char *name,
>  }
>  EXPORT_SYMBOL(backlight_device_register);
>  
> +/** backlight_device_get_by_type - find first backlight device of a type
> + * @type: the type of backlight device
> + *
> + * Look up the first backlight device of the specified type
> + *
> + * RETURNS:
> + *
> + * Pointer to backlight device if any was found. Otherwise NULL.
> + */
>  struct backlight_device *backlight_device_get_by_type(enum backlight_type type)
>  {
>  	bool found = false;
> @@ -433,12 +481,7 @@ struct backlight_device *backlight_device_get_by_type(enum backlight_type type)
>  }
>  EXPORT_SYMBOL(backlight_device_get_by_type);
>  
> -/**
> - * backlight_device_unregister - unregisters a backlight device object.
> - * @bd: the backlight device object to be unregistered and freed.
> - *
> - * Unregisters a previously registered via backlight_device_register object.
> - */
> +/* deprecated - use devm_backlight_device_unregister() */
>  void backlight_device_unregister(struct backlight_device *bd)
>  {
>  	if (!bd)
> @@ -486,10 +529,12 @@ static int devm_backlight_device_match(struct device *dev, void *res,
>   * backlight_register_notifier - get notified of backlight (un)registration
>   * @nb: notifier block with the notifier to call on backlight (un)registration
>   *
> - * @return 0 on success, otherwise a negative error code
> - *
>   * Register a notifier to get notified when backlight devices get registered
>   * or unregistered.
> + *
> + * RETURNS:
> + *
> + * 0 on success, otherwise a negative error code
>   */
>  int backlight_register_notifier(struct notifier_block *nb)
>  {
> @@ -501,10 +546,12 @@ EXPORT_SYMBOL(backlight_register_notifier);
>   * backlight_unregister_notifier - unregister a backlight notifier
>   * @nb: notifier block to unregister
>   *
> - * @return 0 on success, otherwise a negative error code
> - *
>   * Register a notifier to get notified when backlight devices get registered
>   * or unregistered.
> + *
> + * RETURNS:
> + *
> + * 0 on success, otherwise a negative error code
>   */
>  int backlight_unregister_notifier(struct notifier_block *nb)
>  {
> @@ -513,20 +560,22 @@ int backlight_unregister_notifier(struct notifier_block *nb)
>  EXPORT_SYMBOL(backlight_unregister_notifier);
>  
>  /**
> - * devm_backlight_device_register - resource managed backlight_device_register()
> + * devm_backlight_device_register - registering a new backlight device

s/registering/register/

>   * @dev: the device to register
>   * @name: the name of the device
> - * @parent: a pointer to the parent device
> + * @parent: a pointer to the parent device (often the same as @dev)
>   * @devdata: an optional pointer to be stored for private driver use
>   * @ops: the backlight operations structure
>   * @props: the backlight properties
>   *
> - * @return a struct backlight on success, or an ERR_PTR on error
> + * Creates and registers new backlight device. When a backlight device
> + * is registered the configuration must be specified in the @props
> + * parameter. See description of &backlight_properties.
>   *
> - * Managed backlight_device_register(). The backlight_device returned
> - * from this function are automatically freed on driver detach.
> - * See backlight_device_register() for more information.
> - */
> + * RETURNS:
> + *
> + * struct backlight on success, or an ERR_PTR on error
> +*/
>  struct backlight_device *devm_backlight_device_register(struct device *dev,
>  	const char *name, struct device *parent, void *devdata,
>  	const struct backlight_ops *ops,
> @@ -553,13 +602,13 @@ struct backlight_device *devm_backlight_device_register(struct device *dev,
>  EXPORT_SYMBOL(devm_backlight_device_register);
>  
>  /**
> - * devm_backlight_device_unregister - resource managed backlight_device_unregister()
> + * devm_backlight_device_unregister - backlight device unregister

s/backlight device unregister/unregister backlight device/


Daniel.


>   * @dev: the device to unregister
>   * @bd: the backlight device to unregister
>   *
> - * Deallocated a backlight allocated with devm_backlight_device_register().
> + * Deallocates a backlight allocated with devm_backlight_device_register().
>   * Normally this function will not need to be called and the resource management
> - * code will ensure that the resource is freed.
> + * code will ensure that the resources are freed.
>   */
>  void devm_backlight_device_unregister(struct device *dev,
>  				struct backlight_device *bd)
> @@ -650,8 +699,8 @@ static void devm_backlight_release(void *data)
>  }
>  
>  /**
> - * devm_of_find_backlight - Resource-managed of_find_backlight()
> - * @dev: Device
> + * devm_of_find_backlight - find backlight for a device
> + * @dev: the device
>   *
>   * Device managed version of of_find_backlight().
>   * The reference on the backlight device is automatically
> -- 
> 2.25.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 12/16] backlight: wire up kernel-doc documentation
  2020-05-17 19:01 ` [PATCH v2 12/16] backlight: wire up kernel-doc documentation Sam Ravnborg
@ 2020-05-18 16:50   ` Daniel Thompson
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 16:50 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Daniel Vetter

On Sun, May 17, 2020 at 09:01:35PM +0200, Sam Ravnborg wrote:
> Include backlight so the documentation is now generated
> with make htmldocs and friends.
> 
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maxime Ripard <mripard@kernel.org>
> Cc: Thomas Zimmermann <tzimmermann@suse.de>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Jonathan Corbet <corbet@lwn.net>

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


> ---
>  Documentation/gpu/backlight.rst | 12 ++++++++++++
>  Documentation/gpu/index.rst     |  1 +
>  2 files changed, 13 insertions(+)
>  create mode 100644 Documentation/gpu/backlight.rst
> 
> diff --git a/Documentation/gpu/backlight.rst b/Documentation/gpu/backlight.rst
> new file mode 100644
> index 000000000000..9ebfc9d0aced
> --- /dev/null
> +++ b/Documentation/gpu/backlight.rst
> @@ -0,0 +1,12 @@
> +=================
> +Backlight support
> +=================
> +
> +.. kernel-doc:: drivers/video/backlight/backlight.c
> +   :doc: overview
> +
> +.. kernel-doc:: include/linux/backlight.h
> +   :internal:
> +
> +.. kernel-doc:: drivers/video/backlight/backlight.c
> +   :export:
> diff --git a/Documentation/gpu/index.rst b/Documentation/gpu/index.rst
> index 1fcf8e851e15..c9a51e3bfb5a 100644
> --- a/Documentation/gpu/index.rst
> +++ b/Documentation/gpu/index.rst
> @@ -12,6 +12,7 @@ Linux GPU Driver Developer's Guide
>     drm-uapi
>     drm-client
>     drivers
> +   backlight
>     vga-switcheroo
>     vgaarbiter
>     todo
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 13/16] backlight: make of_find_backlight static
  2020-05-17 19:01 ` [PATCH v2 13/16] backlight: make of_find_backlight static Sam Ravnborg
@ 2020-05-18 16:53   ` Daniel Thompson
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 16:53 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

On Sun, May 17, 2020 at 09:01:36PM +0200, Sam Ravnborg wrote:
> There are no external users of of_find_backlight,
> as they have all changed to use the managed version.
> Make of_find_backlight static to prevent new external users.
> 
> 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>

In principle I'm OK with this... just a couple of tiny nitpicks in the
new documentation.


Daniel.


> ---
>  drivers/video/backlight/backlight.c | 31 ++++++++++-------------------
>  include/linux/backlight.h           |  6 ------
>  2 files changed, 11 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index 2212f0e3570e..e23b09d03a65 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -650,22 +650,7 @@ struct backlight_device *of_find_backlight_by_node(struct device_node *node)
>  EXPORT_SYMBOL(of_find_backlight_by_node);
>  #endif
>  
> -/**
> - * of_find_backlight - Get backlight device
> - * @dev: Device
> - *
> - * This function looks for a property named 'backlight' on the DT node
> - * connected to @dev and looks up the backlight device.
> - *
> - * Call backlight_put() to drop the reference on the backlight device.
> - *
> - * Returns:
> - * A pointer to the backlight device if found.
> - * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight
> - * device is found.
> - * NULL if there's no backlight property.
> - */
> -struct backlight_device *of_find_backlight(struct device *dev)
> +static struct backlight_device *of_find_backlight(struct device *dev)
>  {
>  	struct backlight_device *bd = NULL;
>  	struct device_node *np;
> @@ -691,7 +676,6 @@ struct backlight_device *of_find_backlight(struct device *dev)
>  
>  	return bd;
>  }
> -EXPORT_SYMBOL(of_find_backlight);
>  
>  static void devm_backlight_release(void *data)
>  {
> @@ -702,9 +686,16 @@ static void devm_backlight_release(void *data)
>   * devm_of_find_backlight - find backlight for a device
>   * @dev: the device
>   *
> - * Device managed version of of_find_backlight().
> - * The reference on the backlight device is automatically
> - * dropped on driver detach.
> + * This function looks for a property named 'backlight' on the DT node
> + * connected to @dev and looks up the backlight device.

Should this be a full paragraph?

> + * The lookup is device managed so the reference to the backlight device
> + * is automatically dropped on driver detach.
> + *
> + * Returns:

Wasn't this upper case everywhere else?


> + * A pointer to the backlight device if found.
> + * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight
> + * device is found.
> + * NULL if there's no backlight property.
>   */
>  struct backlight_device *devm_of_find_backlight(struct device *dev)
>  {
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index 308aec67fa4f..99e7cdace2be 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -494,14 +494,8 @@ of_find_backlight_by_node(struct device_node *node)
>  #endif
>  
>  #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
> -struct backlight_device *of_find_backlight(struct device *dev);
>  struct backlight_device *devm_of_find_backlight(struct device *dev);
>  #else
> -static inline struct backlight_device *of_find_backlight(struct device *dev)
> -{
> -	return NULL;
> -}
> -
>  static inline struct backlight_device *
>  devm_of_find_backlight(struct device *dev)
>  {
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 14/16] backlight: drop backlight_put()
  2020-05-17 19:01 ` [PATCH v2 14/16] backlight: drop backlight_put() Sam Ravnborg
@ 2020-05-18 16:53   ` Daniel Thompson
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 16:53 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

On Sun, May 17, 2020 at 09:01:37PM +0200, Sam Ravnborg wrote:
> There are no external users of backlight_put().
> Drop it and open code the two users in backlight.c.
> 
> 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>

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


> ---
>  drivers/video/backlight/backlight.c |  7 +++++--
>  include/linux/backlight.h           | 10 ----------
>  2 files changed, 5 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index e23b09d03a65..7f3eecaf8317 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -679,7 +679,10 @@ static struct backlight_device *of_find_backlight(struct device *dev)
>  
>  static void devm_backlight_release(void *data)
>  {
> -	backlight_put(data);
> +	struct backlight_device *bd = data;
> +
> +	if (bd)
> +		put_device(&bd->dev);
>  }
>  
>  /**
> @@ -707,7 +710,7 @@ struct backlight_device *devm_of_find_backlight(struct device *dev)
>  		return bd;
>  	ret = devm_add_action(dev, devm_backlight_release, bd);
>  	if (ret) {
> -		backlight_put(bd);
> +		put_device(&bd->dev);
>  		return ERR_PTR(ret);
>  	}
>  	return bd;
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index 99e7cdace2be..d92e523650ec 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -415,16 +415,6 @@ static inline int backlight_disable(struct backlight_device *bd)
>  	return backlight_update_status(bd);
>  }
>  
> -/**
> - * backlight_put - Drop backlight reference
> - * @bd: the backlight device to put
> - */
> -static inline void backlight_put(struct backlight_device *bd)
> -{
> -	if (bd)
> -		put_device(&bd->dev);
> -}
> -
>  /**
>   * backlight_is_blank - Return true if display is expected to be blank
>   * @bd: the backlight device
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 15/16] backlight: make of_find_backlight_by_node() static
  2020-05-17 19:01 ` [PATCH v2 15/16] backlight: make of_find_backlight_by_node() static Sam Ravnborg
@ 2020-05-18 16:56   ` Daniel Thompson
  2020-05-18 18:12     ` Sam Ravnborg
  0 siblings, 1 reply; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 16:56 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

On Sun, May 17, 2020 at 09:01:38PM +0200, Sam Ravnborg wrote:
> There are no external users of of_find_backlight_by_node().
> Make it static so we keep it that way.
> 
> v2:
>   - drop EXPORT of of_find_backlight_by_node
> 
> 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>

Assuming the 0day-ci comments are because some of the patches have
already been sucked up in a different tree then:

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


Daniel.


> ---
>  drivers/video/backlight/backlight.c | 23 +++++++++--------------
>  include/linux/backlight.h           | 10 ----------
>  2 files changed, 9 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index 7f3eecaf8317..3fa29330a820 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -627,19 +627,9 @@ static int of_parent_match(struct device *dev, const void *data)
>  	return dev->parent && dev->parent->of_node == data;
>  }
>  
> -/**
> - * of_find_backlight_by_node() - find backlight device by device-tree node
> - * @node: device-tree node of the backlight device
> - *
> - * Returns a pointer to the backlight device corresponding to the given DT
> - * node or NULL if no such backlight device exists or if the device hasn't
> - * been probed yet.
> - *
> - * This function obtains a reference on the backlight device and it is the
> - * caller's responsibility to drop the reference by calling put_device() on
> - * the backlight device's .dev field.
> - */
> -struct backlight_device *of_find_backlight_by_node(struct device_node *node)
> +/* Find backlight device by device-tree node */
> +static struct backlight_device *
> +of_find_backlight_by_node(struct device_node *node)
>  {
>  	struct device *dev;
>  
> @@ -647,7 +637,12 @@ struct backlight_device *of_find_backlight_by_node(struct device_node *node)
>  
>  	return dev ? to_backlight_device(dev) : NULL;
>  }
> -EXPORT_SYMBOL(of_find_backlight_by_node);
> +#else
> +static struct backlight_device *
> +of_find_backlight_by_node(struct device_node *node)
> +{
> +	return NULL;
> +}
>  #endif
>  
>  static struct backlight_device *of_find_backlight(struct device *dev)
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index d92e523650ec..1e29ab43f4f6 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -473,16 +473,6 @@ static inline void * bl_get_data(struct backlight_device *bl_dev)
>  	return dev_get_drvdata(&bl_dev->dev);
>  }
>  
> -#ifdef CONFIG_OF
> -struct backlight_device *of_find_backlight_by_node(struct device_node *node);
> -#else
> -static inline struct backlight_device *
> -of_find_backlight_by_node(struct device_node *node)
> -{
> -	return NULL;
> -}
> -#endif
> -
>  #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
>  struct backlight_device *devm_of_find_backlight(struct device *dev);
>  #else
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 16/16] backlight: use backlight_is_blank() in all backlight drivers
  2020-05-17 19:01 ` [PATCH v2 16/16] backlight: use backlight_is_blank() in all backlight drivers Sam Ravnborg
@ 2020-05-18 16:59   ` Daniel Thompson
  2020-05-20 10:56   ` Emil Velikov
  2020-05-28 13:39   ` Peter Ujfalusi
  2 siblings, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 16:59 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

On Sun, May 17, 2020 at 09:01:39PM +0200, Sam Ravnborg wrote:
> Replaces the open-coded checks of the state etc.,
> with the backlight_is_blank() helper.
> This increases readability of the code and align
> the functionality across the drivers.
> 
> v2:
>   - Fixed so changelog is readable
> 
> 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>
> Cc: Michael Hennerich <michael.hennerich@analog.com>
> Cc: Support Opensource <support.opensource@diasemi.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Andy Gross <agross@kernel.org>
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
> Cc: linux-pwm@vger.kernel.org
> Cc: linux-arm-msm@vger.kernel.org
> Cc: patches@opensource.cirrus.com

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>


> ---
>  drivers/video/backlight/88pm860x_bl.c    |  8 +-------
>  drivers/video/backlight/adp5520_bl.c     |  5 +----
>  drivers/video/backlight/adp8860_bl.c     |  5 +----
>  drivers/video/backlight/adp8870_bl.c     |  5 +----
>  drivers/video/backlight/as3711_bl.c      |  8 +++-----
>  drivers/video/backlight/bd6107.c         |  4 +---
>  drivers/video/backlight/corgi_lcd.c      |  5 +----
>  drivers/video/backlight/cr_bllcd.c       | 22 +++++++---------------
>  drivers/video/backlight/da903x_bl.c      |  8 +-------
>  drivers/video/backlight/ep93xx_bl.c      |  3 +--
>  drivers/video/backlight/gpio_backlight.c |  4 +---
>  drivers/video/backlight/hp680_bl.c       |  4 +---
>  drivers/video/backlight/jornada720_bl.c  |  2 +-
>  drivers/video/backlight/kb3886_bl.c      |  4 +---
>  drivers/video/backlight/led_bl.c         |  4 +---
>  drivers/video/backlight/lm3533_bl.c      |  4 +---
>  drivers/video/backlight/locomolcd.c      |  4 +---
>  drivers/video/backlight/lv5207lp.c       |  4 +---
>  drivers/video/backlight/max8925_bl.c     |  8 +-------
>  drivers/video/backlight/pwm_bl.c         |  4 +---
>  drivers/video/backlight/qcom-wled.c      |  4 +---
>  drivers/video/backlight/tps65217_bl.c    |  4 +---
>  drivers/video/backlight/wm831x_bl.c      |  8 +-------
>  23 files changed, 31 insertions(+), 100 deletions(-)
> 
> diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c
> index 20d96a5ac384..162c83ab0f5a 100644
> --- a/drivers/video/backlight/88pm860x_bl.c
> +++ b/drivers/video/backlight/88pm860x_bl.c
> @@ -123,13 +123,7 @@ static int pm860x_backlight_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.state & BL_CORE_SUSPENDED)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return pm860x_backlight_set(bl, brightness);
> diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
> index 0f63f76723a5..d817b0d95c9d 100644
> --- a/drivers/video/backlight/adp5520_bl.c
> +++ b/drivers/video/backlight/adp5520_bl.c
> @@ -67,10 +67,7 @@ static int adp5520_bl_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return adp5520_bl_set(bl, brightness);
> diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
> index 19968104fc47..a0ce2a3701fa 100644
> --- a/drivers/video/backlight/adp8860_bl.c
> +++ b/drivers/video/backlight/adp8860_bl.c
> @@ -363,10 +363,7 @@ static int adp8860_bl_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return adp8860_bl_set(bl, brightness);
> diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
> index 4c0032010cfe..ae4269fdb189 100644
> --- a/drivers/video/backlight/adp8870_bl.c
> +++ b/drivers/video/backlight/adp8870_bl.c
> @@ -401,10 +401,7 @@ static int adp8870_bl_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return adp8870_bl_set(bl, brightness);
> diff --git a/drivers/video/backlight/as3711_bl.c b/drivers/video/backlight/as3711_bl.c
> index 33f0f0f2e8b3..7fa76008c7bf 100644
> --- a/drivers/video/backlight/as3711_bl.c
> +++ b/drivers/video/backlight/as3711_bl.c
> @@ -107,13 +107,11 @@ static int as3711_bl_update_status(struct backlight_device *bl)
>  	int brightness = bl->props.brightness;
>  	int ret = 0;
>  
> -	dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, blank %x, state %x\n",
> +	dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, state %x\n",
>  		__func__, bl->props.brightness, bl->props.power,
> -		bl->props.fb_blank, bl->props.state);
> +		bl->props.state);
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK ||
> -	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
> -	    bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	if (data->type == AS3711_BL_SU1) {
> diff --git a/drivers/video/backlight/bd6107.c b/drivers/video/backlight/bd6107.c
> index d5d5fb457e78..f6a5c1dba3bc 100644
> --- a/drivers/video/backlight/bd6107.c
> +++ b/drivers/video/backlight/bd6107.c
> @@ -84,9 +84,7 @@ static int bd6107_backlight_update_status(struct backlight_device *backlight)
>  	struct bd6107 *bd = bl_get_data(backlight);
>  	int brightness = backlight->props.brightness;
>  
> -	if (backlight->props.power != FB_BLANK_UNBLANK ||
> -	    backlight->props.fb_blank != FB_BLANK_UNBLANK ||
> -	    backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
> +	if (backlight_is_blank(backlight))
>  		brightness = 0;
>  
>  	if (brightness) {
> diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c
> index 25ef0cbd7583..c9adf4e26355 100644
> --- a/drivers/video/backlight/corgi_lcd.c
> +++ b/drivers/video/backlight/corgi_lcd.c
> @@ -422,10 +422,7 @@ static int corgi_bl_update_status(struct backlight_device *bd)
>  	struct corgi_lcd *lcd = bl_get_data(bd);
>  	int intensity = bd->props.brightness;
>  
> -	if (bd->props.power != FB_BLANK_UNBLANK)
> -		intensity = 0;
> -
> -	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bd))
>  		intensity = 0;
>  
>  	if (corgibl_flags & CORGIBL_SUSPENDED)
> diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c
> index 4624b7b7c6a6..d5ab7675f55c 100644
> --- a/drivers/video/backlight/cr_bllcd.c
> +++ b/drivers/video/backlight/cr_bllcd.c
> @@ -59,26 +59,18 @@ struct cr_panel {
>  
>  static int cr_backlight_set_intensity(struct backlight_device *bd)
>  {
> -	int intensity = bd->props.brightness;
>  	u32 addr = gpio_bar + CRVML_PANEL_PORT;
>  	u32 cur = inl(addr);
>  
> -	if (bd->props.power == FB_BLANK_UNBLANK)
> -		intensity = FB_BLANK_UNBLANK;
> -	if (bd->props.fb_blank == FB_BLANK_UNBLANK)
> -		intensity = FB_BLANK_UNBLANK;
> -	if (bd->props.power == FB_BLANK_POWERDOWN)
> -		intensity = FB_BLANK_POWERDOWN;
> -	if (bd->props.fb_blank == FB_BLANK_POWERDOWN)
> -		intensity = FB_BLANK_POWERDOWN;
> -
> -	if (intensity == FB_BLANK_UNBLANK) { /* FULL ON */
> -		cur &= ~CRVML_BACKLIGHT_OFF;
> -		outl(cur, addr);
> -	} else if (intensity == FB_BLANK_POWERDOWN) { /* OFF */
> +	if (backlight_is_blank(bd)) {
> +		/* OFF */
>  		cur |= CRVML_BACKLIGHT_OFF;
>  		outl(cur, addr);
> -	} /* anything else, don't bother */
> +	} else {
> +		/* FULL ON */
> +		cur &= ~CRVML_BACKLIGHT_OFF;
> +		outl(cur, addr);
> +	}
>  
>  	return 0;
>  }
> diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c
> index 62540e4bdedb..ca351badfdcf 100644
> --- a/drivers/video/backlight/da903x_bl.c
> +++ b/drivers/video/backlight/da903x_bl.c
> @@ -79,13 +79,7 @@ static int da903x_backlight_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.state & BL_CORE_SUSPENDED)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return da903x_backlight_set(bl, brightness);
> diff --git a/drivers/video/backlight/ep93xx_bl.c b/drivers/video/backlight/ep93xx_bl.c
> index 4149e0b2f83c..491185df1411 100644
> --- a/drivers/video/backlight/ep93xx_bl.c
> +++ b/drivers/video/backlight/ep93xx_bl.c
> @@ -38,8 +38,7 @@ static int ep93xxbl_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK ||
> -	    bl->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return ep93xxbl_set(bl, brightness);
> diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
> index 75409ddfba3e..94b65e4d2aa0 100644
> --- a/drivers/video/backlight/gpio_backlight.c
> +++ b/drivers/video/backlight/gpio_backlight.c
> @@ -25,9 +25,7 @@ static int gpio_backlight_get_next_brightness(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK ||
> -	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
> -	    bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return brightness;
> diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
> index 8ea42b8d9bc8..01d805ca8415 100644
> --- a/drivers/video/backlight/hp680_bl.c
> +++ b/drivers/video/backlight/hp680_bl.c
> @@ -35,9 +35,7 @@ static void hp680bl_send_intensity(struct backlight_device *bd)
>  	u16 v;
>  	int intensity = bd->props.brightness;
>  
> -	if (bd->props.power != FB_BLANK_UNBLANK)
> -		intensity = 0;
> -	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bd))
>  		intensity = 0;
>  	if (hp680bl_suspended)
>  		intensity = 0;
> diff --git a/drivers/video/backlight/jornada720_bl.c b/drivers/video/backlight/jornada720_bl.c
> index f0385f9cf9da..996f7ba3b373 100644
> --- a/drivers/video/backlight/jornada720_bl.c
> +++ b/drivers/video/backlight/jornada720_bl.c
> @@ -54,7 +54,7 @@ static int jornada_bl_update_status(struct backlight_device *bd)
>  	jornada_ssp_start();
>  
>  	/* If backlight is off then really turn it off */
> -	if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) {
> +	if (backlight_is_blank(bd)) {
>  		ret = jornada_ssp_byte(BRIGHTNESSOFF);
>  		if (ret != TXDUMMY) {
>  			dev_info(&bd->dev, "brightness off timeout\n");
> diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
> index 1dfe13c18925..a0fd5d3d82f5 100644
> --- a/drivers/video/backlight/kb3886_bl.c
> +++ b/drivers/video/backlight/kb3886_bl.c
> @@ -89,9 +89,7 @@ static int kb3886bl_send_intensity(struct backlight_device *bd)
>  {
>  	int intensity = bd->props.brightness;
>  
> -	if (bd->props.power != FB_BLANK_UNBLANK)
> -		intensity = 0;
> -	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bd))
>  		intensity = 0;
>  	if (kb3886bl_flags & KB3886BL_SUSPENDED)
>  		intensity = 0;
> diff --git a/drivers/video/backlight/led_bl.c b/drivers/video/backlight/led_bl.c
> index 3f66549997c8..c655ddd99cfb 100644
> --- a/drivers/video/backlight/led_bl.c
> +++ b/drivers/video/backlight/led_bl.c
> @@ -56,9 +56,7 @@ static int led_bl_update_status(struct backlight_device *bl)
>  	struct led_bl_data *priv = bl_get_data(bl);
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK ||
> -	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
> -	    bl->props.state & BL_CORE_FBBLANK)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	if (brightness > 0)
> diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
> index ee09d1bd02b9..476146b62c4e 100644
> --- a/drivers/video/backlight/lm3533_bl.c
> +++ b/drivers/video/backlight/lm3533_bl.c
> @@ -41,9 +41,7 @@ static int lm3533_bl_update_status(struct backlight_device *bd)
>  	struct lm3533_bl *bl = bl_get_data(bd);
>  	int brightness = bd->props.brightness;
>  
> -	if (bd->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bd))
>  		brightness = 0;
>  
>  	return lm3533_ctrlbank_set_brightness(&bl->cb, (u8)brightness);
> diff --git a/drivers/video/backlight/locomolcd.c b/drivers/video/backlight/locomolcd.c
> index cdc02e04f89d..8064cad8d683 100644
> --- a/drivers/video/backlight/locomolcd.c
> +++ b/drivers/video/backlight/locomolcd.c
> @@ -113,9 +113,7 @@ static int locomolcd_set_intensity(struct backlight_device *bd)
>  {
>  	int intensity = bd->props.brightness;
>  
> -	if (bd->props.power != FB_BLANK_UNBLANK)
> -		intensity = 0;
> -	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bd))
>  		intensity = 0;
>  	if (locomolcd_flags & LOCOMOLCD_SUSPENDED)
>  		intensity = 0;
> diff --git a/drivers/video/backlight/lv5207lp.c b/drivers/video/backlight/lv5207lp.c
> index c6ad73a784e2..ef8aa9803577 100644
> --- a/drivers/video/backlight/lv5207lp.c
> +++ b/drivers/video/backlight/lv5207lp.c
> @@ -48,9 +48,7 @@ static int lv5207lp_backlight_update_status(struct backlight_device *backlight)
>  	struct lv5207lp *lv = bl_get_data(backlight);
>  	int brightness = backlight->props.brightness;
>  
> -	if (backlight->props.power != FB_BLANK_UNBLANK ||
> -	    backlight->props.fb_blank != FB_BLANK_UNBLANK ||
> -	    backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
> +	if (backlight_is_blank(backlight))
>  		brightness = 0;
>  
>  	if (brightness) {
> diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
> index 97cc260ff9d1..b8af2c6407d3 100644
> --- a/drivers/video/backlight/max8925_bl.c
> +++ b/drivers/video/backlight/max8925_bl.c
> @@ -66,13 +66,7 @@ static int max8925_backlight_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.state & BL_CORE_SUSPENDED)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return max8925_backlight_set(bl, brightness);
> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index 82b8d7594701..7d0ffcd37f07 100644
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> @@ -111,9 +111,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
>  	int brightness = bl->props.brightness;
>  	struct pwm_state state;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK ||
> -	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
> -	    bl->props.state & BL_CORE_FBBLANK)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	if (pb->notify)
> diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c
> index 3d276b30a78c..9600f5d58ece 100644
> --- a/drivers/video/backlight/qcom-wled.c
> +++ b/drivers/video/backlight/qcom-wled.c
> @@ -261,9 +261,7 @@ static int wled_update_status(struct backlight_device *bl)
>  	u16 brightness = bl->props.brightness;
>  	int rc = 0;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK ||
> -	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
> -	    bl->props.state & BL_CORE_FBBLANK)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	mutex_lock(&wled->lock);
> diff --git a/drivers/video/backlight/tps65217_bl.c b/drivers/video/backlight/tps65217_bl.c
> index 762e3feed097..1041e5e62ee3 100644
> --- a/drivers/video/backlight/tps65217_bl.c
> +++ b/drivers/video/backlight/tps65217_bl.c
> @@ -82,9 +82,7 @@ static int tps65217_bl_update_status(struct backlight_device *bl)
>  	if (bl->props.state & BL_CORE_SUSPENDED)
>  		brightness = 0;
>  
> -	if ((bl->props.power != FB_BLANK_UNBLANK) ||
> -		(bl->props.fb_blank != FB_BLANK_UNBLANK))
> -		/* framebuffer in low power mode or blanking active */
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	if (brightness > 0) {
> diff --git a/drivers/video/backlight/wm831x_bl.c b/drivers/video/backlight/wm831x_bl.c
> index e55977d54c15..dc2ab6c8b7f9 100644
> --- a/drivers/video/backlight/wm831x_bl.c
> +++ b/drivers/video/backlight/wm831x_bl.c
> @@ -93,13 +93,7 @@ static int wm831x_backlight_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.state & BL_CORE_SUSPENDED)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return wm831x_backlight_set(bl, brightness);
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 06/16] backlight: improve backlight_device documentation
  2020-05-18 16:03   ` Daniel Thompson
@ 2020-05-18 17:03     ` Jani Nikula
  2020-05-18 17:58       ` Daniel Thompson
  0 siblings, 1 reply; 48+ messages in thread
From: Jani Nikula @ 2020-05-18 17:03 UTC (permalink / raw)
  To: Daniel Thompson, Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi, Tomi Valkeinen,
	Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jonathan Corbet,
	Linus Walleij, linux-arm-msm, linux-pwm, Maarten Lankhorst,
	Maxime Ripard, Michael Hennerich, patches, Russell King,
	Support Opensource, Thierry Reding, Thomas Zimmermann,
	Uwe Kleine-Konig

On Mon, 18 May 2020, Daniel Thompson <daniel.thompson@linaro.org> wrote:
> On Sun, May 17, 2020 at 09:01:29PM +0200, Sam Ravnborg wrote:
>> Improve the documentation for backlight_device and
>> adapt it to kernel-doc style.
>> 
>> 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 | 81 ++++++++++++++++++++++++++++-----------
>>  1 file changed, 58 insertions(+), 23 deletions(-)
>> 
>> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
>> index 7f9cef299d6e..e2d72936bf05 100644
>> --- a/include/linux/backlight.h
>> +++ b/include/linux/backlight.h
>> @@ -14,21 +14,6 @@
>>  #include <linux/mutex.h>
>>  #include <linux/notifier.h>
>>  
>> -/* Notes on locking:
>> - *
>> - * backlight_device->ops_lock is an internal backlight lock protecting the
>> - * ops pointer and no code outside the core should need to touch it.
>> - *
>> - * Access to update_status() is serialised by the update_lock mutex since
>> - * most drivers seem to need this and historically get it wrong.
>> - *
>> - * Most drivers don't need locking on their get_brightness() method.
>> - * If yours does, you need to implement it in the driver. You can use the
>> - * update_lock mutex if appropriate.
>> - *
>> - * Any other use of the locks below is probably wrong.
>> - */
>> -
>>  enum backlight_update_reason {
>>  	BACKLIGHT_UPDATE_HOTKEY,
>>  	BACKLIGHT_UPDATE_SYSFS,
>> @@ -221,30 +206,80 @@ struct backlight_properties {
>>  	enum backlight_scale scale;
>>  };
>>  
>> +/**
>> + * struct backlight_device - backlight device data
>> + *
>> + * This structure holds all data required by a backlight device.
>> + */
>>  struct backlight_device {
>> -	/* Backlight properties */
>> +	/**
>> +	 * @props:
>> +	 *
>
> As last patch. Why no brief descriptions?

There are no "brief descriptions" in kernel-doc struct member inline
markup.

It would be possible to shorten this to:

	/**
	 * @props: Backlight properties
	 */

BR,
Jani.


>
>
>> +	 * Backlight properties
>> +	 */
>>  	struct backlight_properties props;
>>  
>> -	/* Serialise access to update_status method */
>> +	/**
>> +	 * @update_lock:
>> +	 *
>> +	 * update_lock is an internal backlight lock that serialise access
>> +	 * to the update_status() method. The iupdate_lock mutex shall not be used
>> +	 * by backlight drivers.
>
> In addition to the typo this directly contradicts the advice in the
> original "Notes on locking".
>
> A change this dramatic needs to be fully explaining in the patch
> description.
>
>
> Daniel.
>
>
>> +	 */
>>  	struct mutex update_lock;
>>  
>> -	/* This protects the 'ops' field. If 'ops' is NULL, the driver that
>> -	   registered this device has been unloaded, and if class_get_devdata()
>> -	   points to something in the body of that driver, it is also invalid. */
>> +	/**
>> +	 * @ops_lock:
>> +	 *
>> +	 * ops_lock is an internal backlight lock that protects the ops pointer
>> +	 * and is used around all accesses to ops and when the operations are
>> +	 * invoked. The mutex shall not be used by backlight drivers.
>> +	 */
>>  	struct mutex ops_lock;
>> +
>> +	/**
>> +	 * @ops:
>> +	 *
>> +	 * Pointer to the backlight operations. If ops is NULL, the driver that
>> +	 * registered this device has been unloaded, and if class_get_devdata()
>> +	 * points to something in the body of that driver, it is also invalid.
>> +	 */
>>  	const struct backlight_ops *ops;
>>  
>> -	/* The framebuffer notifier block */
>> +	/**
>> +	 * @fb_notif:
>> +	 *
>> +	 * The framebuffer notifier block
>> +	 */
>>  	struct notifier_block fb_notif;
>>  
>> -	/* list entry of all registered backlight devices */
>> +	/**
>> +	 * @entry:
>> +	 *
>> +	 * List entry of all registered backlight devices
>> +	 */
>>  	struct list_head entry;
>>  
>> +	/**
>> +	 * @dev:
>> +	 *
>> +	 * Parent device.
>> +	 */
>>  	struct device dev;
>>  
>> -	/* Multiple framebuffers may share one backlight device */
>> +	/**
>> +	 * @fb_bl_on:
>> +	 *
>> +	 * Multiple fbdev's may share one backlight device. The fb_bl_on
>> +	 * records the state of the individual fbdev.
>> +	 */
>>  	bool fb_bl_on[FB_MAX];
>>  
>> +	/**
>> +	 * @use_count:
>> +	 *
>> +	 * The number of uses of fb_bl_on.
>> +	 */
>>  	int use_count;
>>  };
>>  
>> -- 
>> 2.25.1
>> 

-- 
Jani Nikula, Intel Open Source Graphics Center

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 06/16] backlight: improve backlight_device documentation
  2020-05-18 17:03     ` Jani Nikula
@ 2020-05-18 17:58       ` Daniel Thompson
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 17:58 UTC (permalink / raw)
  To: Jani Nikula
  Cc: Sam Ravnborg, dri-devel, Jingoo Han, Lee Jones, Peter Ujfalusi,
	Tomi Valkeinen, Andy Gross, Bartlomiej Zolnierkiewicz,
	Bjorn Andersson, Daniel Vetter, David Airlie, Douglas Anderson,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

On Mon, May 18, 2020 at 08:03:21PM +0300, Jani Nikula wrote:
> On Mon, 18 May 2020, Daniel Thompson <daniel.thompson@linaro.org> wrote:
> > On Sun, May 17, 2020 at 09:01:29PM +0200, Sam Ravnborg wrote:
> >> Improve the documentation for backlight_device and
> >> adapt it to kernel-doc style.
> >> 
> >> 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 | 81 ++++++++++++++++++++++++++++-----------
> >>  1 file changed, 58 insertions(+), 23 deletions(-)
> >> 
> >> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> >> index 7f9cef299d6e..e2d72936bf05 100644
> >> --- a/include/linux/backlight.h
> >> +++ b/include/linux/backlight.h
> >> @@ -14,21 +14,6 @@
> >>  #include <linux/mutex.h>
> >>  #include <linux/notifier.h>
> >>  
> >> -/* Notes on locking:
> >> - *
> >> - * backlight_device->ops_lock is an internal backlight lock protecting the
> >> - * ops pointer and no code outside the core should need to touch it.
> >> - *
> >> - * Access to update_status() is serialised by the update_lock mutex since
> >> - * most drivers seem to need this and historically get it wrong.
> >> - *
> >> - * Most drivers don't need locking on their get_brightness() method.
> >> - * If yours does, you need to implement it in the driver. You can use the
> >> - * update_lock mutex if appropriate.
> >> - *
> >> - * Any other use of the locks below is probably wrong.
> >> - */
> >> -
> >>  enum backlight_update_reason {
> >>  	BACKLIGHT_UPDATE_HOTKEY,
> >>  	BACKLIGHT_UPDATE_SYSFS,
> >> @@ -221,30 +206,80 @@ struct backlight_properties {
> >>  	enum backlight_scale scale;
> >>  };
> >>  
> >> +/**
> >> + * struct backlight_device - backlight device data
> >> + *
> >> + * This structure holds all data required by a backlight device.
> >> + */
> >>  struct backlight_device {
> >> -	/* Backlight properties */
> >> +	/**
> >> +	 * @props:
> >> +	 *
> >
> > As last patch. Why no brief descriptions?
> 
> There are no "brief descriptions" in kernel-doc struct member inline
> markup.
> 
> It would be possible to shorten this to:
> 
> 	/**
> 	 * @props: Backlight properties
> 	 */

Sorry. Loose phrasing on my part... basically the question is why
deviate from the form proposed in "Writing kernel-doc comments"?


Daniel.



> >
> >> +	 * Backlight properties
> >> +	 */
> >>  	struct backlight_properties props;
> >>  
> >> -	/* Serialise access to update_status method */
> >> +	/**
> >> +	 * @update_lock:
> >> +	 *
> >> +	 * update_lock is an internal backlight lock that serialise access
> >> +	 * to the update_status() method. The iupdate_lock mutex shall not be used
> >> +	 * by backlight drivers.
> >
> > In addition to the typo this directly contradicts the advice in the
> > original "Notes on locking".
> >
> > A change this dramatic needs to be fully explaining in the patch
> > description.
> >
> >
> > Daniel.
> >
> >
> >> +	 */
> >>  	struct mutex update_lock;
> >>  
> >> -	/* This protects the 'ops' field. If 'ops' is NULL, the driver that
> >> -	   registered this device has been unloaded, and if class_get_devdata()
> >> -	   points to something in the body of that driver, it is also invalid. */
> >> +	/**
> >> +	 * @ops_lock:
> >> +	 *
> >> +	 * ops_lock is an internal backlight lock that protects the ops pointer
> >> +	 * and is used around all accesses to ops and when the operations are
> >> +	 * invoked. The mutex shall not be used by backlight drivers.
> >> +	 */
> >>  	struct mutex ops_lock;
> >> +
> >> +	/**
> >> +	 * @ops:
> >> +	 *
> >> +	 * Pointer to the backlight operations. If ops is NULL, the driver that
> >> +	 * registered this device has been unloaded, and if class_get_devdata()
> >> +	 * points to something in the body of that driver, it is also invalid.
> >> +	 */
> >>  	const struct backlight_ops *ops;
> >>  
> >> -	/* The framebuffer notifier block */
> >> +	/**
> >> +	 * @fb_notif:
> >> +	 *
> >> +	 * The framebuffer notifier block
> >> +	 */
> >>  	struct notifier_block fb_notif;
> >>  
> >> -	/* list entry of all registered backlight devices */
> >> +	/**
> >> +	 * @entry:
> >> +	 *
> >> +	 * List entry of all registered backlight devices
> >> +	 */
> >>  	struct list_head entry;
> >>  
> >> +	/**
> >> +	 * @dev:
> >> +	 *
> >> +	 * Parent device.
> >> +	 */
> >>  	struct device dev;
> >>  
> >> -	/* Multiple framebuffers may share one backlight device */
> >> +	/**
> >> +	 * @fb_bl_on:
> >> +	 *
> >> +	 * Multiple fbdev's may share one backlight device. The fb_bl_on
> >> +	 * records the state of the individual fbdev.
> >> +	 */
> >>  	bool fb_bl_on[FB_MAX];
> >>  
> >> +	/**
> >> +	 * @use_count:
> >> +	 *
> >> +	 * The number of uses of fb_bl_on.
> >> +	 */
> >>  	int use_count;
> >>  };
> >>  
> >> -- 
> >> 2.25.1
> >> 
> 
> -- 
> Jani Nikula, Intel Open Source Graphics Center

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 15/16] backlight: make of_find_backlight_by_node() static
  2020-05-18 16:56   ` Daniel Thompson
@ 2020-05-18 18:12     ` Sam Ravnborg
  2020-05-18 19:56       ` Daniel Thompson
  0 siblings, 1 reply; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-18 18:12 UTC (permalink / raw)
  To: Daniel Thompson
  Cc: David Airlie, Daniel Vetter, dri-devel, Bjorn Andersson,
	Peter Ujfalusi, Thierry Reding, Lee Jones, Jonathan Corbet,
	Tomi Valkeinen, Russell King, Andy Gross, Uwe Kleine-Konig,
	linux-pwm, Michael Hennerich, Bartlomiej Zolnierkiewicz,
	Jani Nikula, linux-arm-msm, Support Opensource, Jingoo Han,
	Douglas Anderson, Thomas Zimmermann, patches

On Mon, May 18, 2020 at 05:56:48PM +0100, Daniel Thompson wrote:
> On Sun, May 17, 2020 at 09:01:38PM +0200, Sam Ravnborg wrote:
> > There are no external users of of_find_backlight_by_node().
> > Make it static so we keep it that way.
> > 
> > v2:
> >   - drop EXPORT of of_find_backlight_by_node
> > 
> > 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>
> 
> Assuming the 0day-ci comments are because some of the patches have
> already been sucked up in a different tree then:
Correct. For now only drm-misc-next have no users of
of_find_backlight_by_node() which is why the other trees failed.

 
> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Thanks for all your reviews!
I will shortly (within a few days) address the comments and send out a v3.

Is is correct that I assume you or Lee or Jingoo will apply the patches
to a backlight tree somewhere when they are ready?
If you have a tree you use for backlight patches I can base v3 on that,
given that I get a link and have access to pull from it.

	Sam

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 15/16] backlight: make of_find_backlight_by_node() static
  2020-05-18 18:12     ` Sam Ravnborg
@ 2020-05-18 19:56       ` Daniel Thompson
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-18 19:56 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: David Airlie, Daniel Vetter, dri-devel, Bjorn Andersson,
	Peter Ujfalusi, Thierry Reding, Lee Jones, Jonathan Corbet,
	Tomi Valkeinen, Russell King, Andy Gross, Uwe Kleine-Konig,
	linux-pwm, Michael Hennerich, Bartlomiej Zolnierkiewicz,
	Jani Nikula, linux-arm-msm, Support Opensource, Jingoo Han,
	Douglas Anderson, Thomas Zimmermann, patches

On Mon, May 18, 2020 at 08:12:27PM +0200, Sam Ravnborg wrote:
> On Mon, May 18, 2020 at 05:56:48PM +0100, Daniel Thompson wrote:
> > On Sun, May 17, 2020 at 09:01:38PM +0200, Sam Ravnborg wrote:
> > > There are no external users of of_find_backlight_by_node().
> > > Make it static so we keep it that way.
> > > 
> > > v2:
> > >   - drop EXPORT of of_find_backlight_by_node
> > > 
> > > 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>
> > 
> > Assuming the 0day-ci comments are because some of the patches have
> > already been sucked up in a different tree then:
> Correct. For now only drm-misc-next have no users of
> of_find_backlight_by_node() which is why the other trees failed.
> 
>  
> > Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
> Thanks for all your reviews!
> I will shortly (within a few days) address the comments and send out a v3.
> 
> Is is correct that I assume you or Lee or Jingoo will apply the patches
> to a backlight tree somewhere when they are ready?
> If you have a tree you use for backlight patches I can base v3 on that,
> given that I get a link and have access to pull from it.

Absent holidays and the like, Lee usually does that actual patch
hoovering.


Daniel.

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 02/16] backlight: refactor fb_notifier_callback()
  2020-05-17 19:01 ` [PATCH v2 02/16] backlight: refactor fb_notifier_callback() Sam Ravnborg
  2020-05-18 14:54   ` Daniel Thompson
@ 2020-05-20 10:41   ` Emil Velikov
  1 sibling, 0 replies; 48+ messages in thread
From: Emil Velikov @ 2020-05-20 10:41 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: ML dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen, linux-pwm, Support Opensource,
	Michael Hennerich, Bartlomiej Zolnierkiewicz, David Airlie,
	Daniel Vetter, Jonathan Corbet, Douglas Anderson,
	Bjorn Andersson, Jani Nikula, Andy Gross, Thierry Reding,
	Thomas Zimmermann, linux-arm-msm, Russell King, patches,
	Uwe Kleine-Konig

Hi Sam,

On Sun, 17 May 2020 at 20:02, Sam Ravnborg <sam@ravnborg.org> wrote:
>
> Increase readability of fb_notifier_callback() by removing
> a few indent levels.
> No functional change.
>
> 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>
> ---
>  drivers/video/backlight/backlight.c | 43 +++++++++++++++--------------
>  1 file changed, 22 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index cac3e35d7630..17f04cff50ab 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -58,28 +58,29 @@ static int fb_notifier_callback(struct notifier_block *self,
>
>         bd = container_of(self, struct backlight_device, fb_notif);
>         mutex_lock(&bd->ops_lock);
> -       if (bd->ops)
> -               if (!bd->ops->check_fb ||
> -                   bd->ops->check_fb(bd, evdata->info)) {
> -                       fb_blank = *(int *)evdata->data;
> -                       if (fb_blank == FB_BLANK_UNBLANK &&
> -                           !bd->fb_bl_on[node]) {
> -                               bd->fb_bl_on[node] = true;
> -                               if (!bd->use_count++) {
> -                                       bd->props.state &= ~BL_CORE_FBBLANK;
> -                                       bd->props.fb_blank = FB_BLANK_UNBLANK;
> -                                       backlight_update_status(bd);
> -                               }
> -                       } else if (fb_blank != FB_BLANK_UNBLANK &&
> -                                  bd->fb_bl_on[node]) {
> -                               bd->fb_bl_on[node] = false;
> -                               if (!(--bd->use_count)) {
> -                                       bd->props.state |= BL_CORE_FBBLANK;
> -                                       bd->props.fb_blank = fb_blank;
> -                                       backlight_update_status(bd);
> -                               }
> -                       }
> +
> +       if (!bd->ops)
> +               goto out;
> +       if (bd->ops->check_fb && !bd->ops->check_fb(bd, evdata->info))
Mildly related: Would be a nice to define which ops are mandatory and
which aren't.
That plus enforcement in backlight_device_register.

But that's for another patchset.

> +               goto out;
> +
> +       fb_blank = *(int *)evdata->data;
> +       if (fb_blank == FB_BLANK_UNBLANK && !bd->fb_bl_on[node]) {
> +               bd->fb_bl_on[node] = true;
> +               if (!bd->use_count++) {
> +                       bd->props.state &= ~BL_CORE_FBBLANK;
> +                       bd->props.fb_blank = FB_BLANK_UNBLANK;
> +                       backlight_update_status(bd);
> +               }
> +       } else if (fb_blank != FB_BLANK_UNBLANK && bd->fb_bl_on[node]) {
> +               bd->fb_bl_on[node] = false;
> +               if (!(--bd->use_count)) {
> +                       bd->props.state |= BL_CORE_FBBLANK;
> +                       bd->props.fb_blank = fb_blank;
> +                       backlight_update_status(bd);
>                 }
Something like the following reads better, plus one could simplify it
with follow-on patch.

if (fb_blank == FB_BLANK_UNBLANK)
    if (!bd->fb_bl_on[node] && !bd->use_count++) {
        bd->props.state &= ~BL_CORE_FBBLANK;
        bd->props.fb_blank = FB_BLANK_UNBLANK;
        backlight_update_status(bd);
        // above is backlight_enable()
    }
    bd->fb_bl_on[node] = true;
} else {
    if (bd->fb_bl_on[node] && !(--bd->use_count)) {
        bd->props.state |= BL_CORE_FBBLANK;
        bd->props.fb_blank = fb_blank;
        backlight_update_status(bd);
        // above is backlight_disable()
   }
    bd->fb_bl_on[node] = false;
}

As-is, one cannot use the backlight helpers indicated, since it
touches .power. First one should ensure the drivers honour .power - by
using the helper introduced later.

-Emil

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 03/16] backlight: add backlight_is_blank()
  2020-05-17 19:01 ` [PATCH v2 03/16] backlight: add backlight_is_blank() Sam Ravnborg
  2020-05-18 15:00   ` Daniel Thompson
@ 2020-05-20 10:45   ` Emil Velikov
  2020-05-28 13:39   ` Peter Ujfalusi
  2 siblings, 0 replies; 48+ messages in thread
From: Emil Velikov @ 2020-05-20 10:45 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: ML dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen, linux-pwm, Support Opensource,
	Michael Hennerich, Bartlomiej Zolnierkiewicz, David Airlie,
	Daniel Vetter, Jonathan Corbet, Douglas Anderson,
	Bjorn Andersson, Jani Nikula, Andy Gross, Thierry Reding,
	Thomas Zimmermann, linux-arm-msm, Russell King, patches,
	Uwe Kleine-Konig

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

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 16/16] backlight: use backlight_is_blank() in all backlight drivers
  2020-05-17 19:01 ` [PATCH v2 16/16] backlight: use backlight_is_blank() in all backlight drivers Sam Ravnborg
  2020-05-18 16:59   ` Daniel Thompson
@ 2020-05-20 10:56   ` Emil Velikov
  2020-05-20 15:11     ` Daniel Thompson
  2020-05-28 13:39   ` Peter Ujfalusi
  2 siblings, 1 reply; 48+ messages in thread
From: Emil Velikov @ 2020-05-20 10:56 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: ML dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen, linux-pwm, Support Opensource,
	Michael Hennerich, Bartlomiej Zolnierkiewicz, David Airlie,
	Daniel Vetter, Jonathan Corbet, Douglas Anderson,
	Bjorn Andersson, Jani Nikula, Andy Gross, Thierry Reding,
	Thomas Zimmermann, linux-arm-msm, Russell King, patches,
	Uwe Kleine-Konig

Hi Sam,

On Sun, 17 May 2020 at 20:02, Sam Ravnborg <sam@ravnborg.org> wrote:

> --- a/drivers/video/backlight/88pm860x_bl.c
> +++ b/drivers/video/backlight/88pm860x_bl.c
> @@ -123,13 +123,7 @@ static int pm860x_backlight_update_status(struct backlight_device *bl)
>  {
>         int brightness = bl->props.brightness;
>
> -       if (bl->props.power != FB_BLANK_UNBLANK)
> -               brightness = 0;
> -
> -       if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> -               brightness = 0;
> -
> -       if (bl->props.state & BL_CORE_SUSPENDED)
> +       if (backlight_is_blank(bl))
>                 brightness = 0;
Off the top of my head, the above two lines should really be in backlight core.
There's nothing driver specific to them, plus it minimises the chances
of next-driver getting it wrong.


> --- a/drivers/video/backlight/as3711_bl.c
> +++ b/drivers/video/backlight/as3711_bl.c
> @@ -107,13 +107,11 @@ static int as3711_bl_update_status(struct backlight_device *bl)
>         int brightness = bl->props.brightness;
>         int ret = 0;
>
> -       dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, blank %x, state %x\n",
> +       dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, state %x\n",
>                 __func__, bl->props.brightness, bl->props.power,
> -               bl->props.fb_blank, bl->props.state);
> +               bl->props.state);
>
Let's also move this to backlight core.

-Emil

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 0/16] backlight updates
  2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
                   ` (15 preceding siblings ...)
  2020-05-17 19:01 ` [PATCH v2 16/16] backlight: use backlight_is_blank() in all backlight drivers Sam Ravnborg
@ 2020-05-20 11:01 ` Emil Velikov
  16 siblings, 0 replies; 48+ messages in thread
From: Emil Velikov @ 2020-05-20 11:01 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: ML dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Peter Ujfalusi, Tomi Valkeinen, linux-pwm, Support Opensource,
	Michael Hennerich, Bartlomiej Zolnierkiewicz, David Airlie,
	Daniel Vetter, Jonathan Corbet, Douglas Anderson,
	Bjorn Andersson, Jani Nikula, Andy Gross, Thierry Reding,
	Thomas Zimmermann, linux-arm-msm, Russell King, patches,
	Uwe Kleine-Konig

Hi Sam,

It's a little weird to see this series, just after I mentioned that I
had one in the works.
Either way, patches 2 and 16 need some work. Although if you prefer
that can be done as follow-up.

For the rest:
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>

-Emil

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 16/16] backlight: use backlight_is_blank() in all backlight drivers
  2020-05-20 10:56   ` Emil Velikov
@ 2020-05-20 15:11     ` Daniel Thompson
  0 siblings, 0 replies; 48+ messages in thread
From: Daniel Thompson @ 2020-05-20 15:11 UTC (permalink / raw)
  To: Emil Velikov
  Cc: Sam Ravnborg, ML dri-devel, Jingoo Han, Lee Jones,
	Peter Ujfalusi, Tomi Valkeinen, linux-pwm, Support Opensource,
	Michael Hennerich, Bartlomiej Zolnierkiewicz, David Airlie,
	Daniel Vetter, Jonathan Corbet, Douglas Anderson,
	Bjorn Andersson, Jani Nikula, Andy Gross, Thierry Reding,
	Thomas Zimmermann, linux-arm-msm, Russell King, patches,
	Uwe Kleine-Konig

On Wed, May 20, 2020 at 11:56:43AM +0100, Emil Velikov wrote:
> Hi Sam,
> 
> On Sun, 17 May 2020 at 20:02, Sam Ravnborg <sam@ravnborg.org> wrote:
> 
> > --- a/drivers/video/backlight/88pm860x_bl.c
> > +++ b/drivers/video/backlight/88pm860x_bl.c
> > @@ -123,13 +123,7 @@ static int pm860x_backlight_update_status(struct backlight_device *bl)
> >  {
> >         int brightness = bl->props.brightness;
> >
> > -       if (bl->props.power != FB_BLANK_UNBLANK)
> > -               brightness = 0;
> > -
> > -       if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> > -               brightness = 0;
> > -
> > -       if (bl->props.state & BL_CORE_SUSPENDED)
> > +       if (backlight_is_blank(bl))
> >                 brightness = 0;
> Off the top of my head, the above two lines should really be in backlight core.
> There's nothing driver specific to them, plus it minimises the chances
> of next-driver getting it wrong.
> 
> 
> > --- a/drivers/video/backlight/as3711_bl.c
> > +++ b/drivers/video/backlight/as3711_bl.c
> > @@ -107,13 +107,11 @@ static int as3711_bl_update_status(struct backlight_device *bl)
> >         int brightness = bl->props.brightness;
> >         int ret = 0;
> >
> > -       dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, blank %x, state %x\n",
> > +       dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, state %x\n",
> >                 __func__, bl->props.brightness, bl->props.power,
> > -               bl->props.fb_blank, bl->props.state);
> > +               bl->props.state);
> >
> Let's also move this to backlight core.

Or just nuke it ;-)


Daniel.


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 01/16] video: amba-clcd: use devm_of_find_backlight
  2020-05-18 10:16     ` Sam Ravnborg
@ 2020-05-25  8:42       ` Linus Walleij
  2020-05-25 11:01         ` Sam Ravnborg
  0 siblings, 1 reply; 48+ messages in thread
From: Linus Walleij @ 2020-05-25  8:42 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: open list:DRM PANEL DRIVERS, Jingoo Han, Lee Jones,
	Daniel Thompson, Peter Ujfalusi, Tomi Valkeinen, Andy Gross,
	Bartlomiej Zolnierkiewicz, Bjorn Andersson, Daniel Vetter,
	David Airlie, Douglas Anderson, Jani Nikula, Jonathan Corbet,
	MSM, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Russell King, Support Opensource,
	Thierry Reding, Thomas Zimmermann, Uwe Kleine-Konig

On Mon, May 18, 2020 at 12:16 PM Sam Ravnborg <sam@ravnborg.org> wrote:
> Hi Linus.
>
> On Mon, May 18, 2020 at 10:10:12AM +0200, Linus Walleij wrote:
> > On Sun, May 17, 2020 at 9:01 PM Sam Ravnborg <sam@ravnborg.org> wrote:
> >
> > > Look up backlight device using devm_of_find_backlight().
> > > This simplifies the code and prevents us from hardcoding
> > > the node name in the driver.
> > >
> > > v2:
> > >   - Added Cc: Peter Ujfalusi
> > >
> > > Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> > > Cc: Russell King <linux@armlinux.org.uk>
> > > Cc: Sam Ravnborg <sam@ravnborg.org>
> > > Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> > > Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
> > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > Cc: Linus Walleij <linus.walleij@linaro.org>
> > > Cc: Jani Nikula <jani.nikula@intel.com>
> > > Cc: Douglas Anderson <dianders@chromium.org>
> >
> > Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Thanks. I went ahead and applied this now, so we could kill
> the last user of of_find_backlight_by_node().
>
> I hope we can make of_find_backlight_by_node() static after the merge window
> so no new users appears.

For this driver (drivers/video/fbdev/amba-clcd.c) there are zero
users after the merge window (all users moved over to DRM) so
I plan to retire it completely.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 01/16] video: amba-clcd: use devm_of_find_backlight
  2020-05-25  8:42       ` Linus Walleij
@ 2020-05-25 11:01         ` Sam Ravnborg
  0 siblings, 0 replies; 48+ messages in thread
From: Sam Ravnborg @ 2020-05-25 11:01 UTC (permalink / raw)
  To: Linus Walleij
  Cc: open list:DRM PANEL DRIVERS, Jingoo Han, Lee Jones,
	Daniel Thompson, Peter Ujfalusi, Tomi Valkeinen, Andy Gross,
	Bartlomiej Zolnierkiewicz, Bjorn Andersson, Daniel Vetter,
	David Airlie, Douglas Anderson, Jani Nikula, Jonathan Corbet,
	MSM, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Russell King, Support Opensource,
	Thierry Reding, Thomas Zimmermann, Uwe Kleine-Konig

Hi Linus.

> For this driver (drivers/video/fbdev/amba-clcd.c) there are zero
> users after the merge window (all users moved over to DRM) so
> I plan to retire it completely.

Sounds like a brilliant plan.

	Sam

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 16/16] backlight: use backlight_is_blank() in all backlight drivers
  2020-05-17 19:01 ` [PATCH v2 16/16] backlight: use backlight_is_blank() in all backlight drivers Sam Ravnborg
  2020-05-18 16:59   ` Daniel Thompson
  2020-05-20 10:56   ` Emil Velikov
@ 2020-05-28 13:39   ` Peter Ujfalusi
  2020-05-28 13:43     ` Peter Ujfalusi
  2 siblings, 1 reply; 48+ messages in thread
From: Peter Ujfalusi @ 2020-05-28 13:39 UTC (permalink / raw)
  To: Sam Ravnborg, dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

[-- Attachment #1: Type: text/plain, Size: 18034 bytes --]

Hi Sam,

On 17/05/2020 22.01, Sam Ravnborg wrote:
> Replaces the open-coded checks of the state etc.,
> with the backlight_is_blank() helper.
> This increases readability of the code and align
> the functionality across the drivers.

Thanks for the cleanup in with the series!

Checked gpio/pwm/led backlight drivers mostly:
Reviewed-by: Peter Ujfalusi <peter.ujflausi@ti.com>

> v2:
>   - Fixed so changelog is readable
> 
> 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>
> Cc: Michael Hennerich <michael.hennerich@analog.com>
> Cc: Support Opensource <support.opensource@diasemi.com>
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
> Cc: Andy Gross <agross@kernel.org>
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
> Cc: linux-pwm@vger.kernel.org
> Cc: linux-arm-msm@vger.kernel.org
> Cc: patches@opensource.cirrus.com
> ---
>  drivers/video/backlight/88pm860x_bl.c    |  8 +-------
>  drivers/video/backlight/adp5520_bl.c     |  5 +----
>  drivers/video/backlight/adp8860_bl.c     |  5 +----
>  drivers/video/backlight/adp8870_bl.c     |  5 +----
>  drivers/video/backlight/as3711_bl.c      |  8 +++-----
>  drivers/video/backlight/bd6107.c         |  4 +---
>  drivers/video/backlight/corgi_lcd.c      |  5 +----
>  drivers/video/backlight/cr_bllcd.c       | 22 +++++++---------------
>  drivers/video/backlight/da903x_bl.c      |  8 +-------
>  drivers/video/backlight/ep93xx_bl.c      |  3 +--
>  drivers/video/backlight/gpio_backlight.c |  4 +---
>  drivers/video/backlight/hp680_bl.c       |  4 +---
>  drivers/video/backlight/jornada720_bl.c  |  2 +-
>  drivers/video/backlight/kb3886_bl.c      |  4 +---
>  drivers/video/backlight/led_bl.c         |  4 +---
>  drivers/video/backlight/lm3533_bl.c      |  4 +---
>  drivers/video/backlight/locomolcd.c      |  4 +---
>  drivers/video/backlight/lv5207lp.c       |  4 +---
>  drivers/video/backlight/max8925_bl.c     |  8 +-------
>  drivers/video/backlight/pwm_bl.c         |  4 +---
>  drivers/video/backlight/qcom-wled.c      |  4 +---
>  drivers/video/backlight/tps65217_bl.c    |  4 +---
>  drivers/video/backlight/wm831x_bl.c      |  8 +-------
>  23 files changed, 31 insertions(+), 100 deletions(-)
> 
> diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c
> index 20d96a5ac384..162c83ab0f5a 100644
> --- a/drivers/video/backlight/88pm860x_bl.c
> +++ b/drivers/video/backlight/88pm860x_bl.c
> @@ -123,13 +123,7 @@ static int pm860x_backlight_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.state & BL_CORE_SUSPENDED)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return pm860x_backlight_set(bl, brightness);
> diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
> index 0f63f76723a5..d817b0d95c9d 100644
> --- a/drivers/video/backlight/adp5520_bl.c
> +++ b/drivers/video/backlight/adp5520_bl.c
> @@ -67,10 +67,7 @@ static int adp5520_bl_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return adp5520_bl_set(bl, brightness);
> diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
> index 19968104fc47..a0ce2a3701fa 100644
> --- a/drivers/video/backlight/adp8860_bl.c
> +++ b/drivers/video/backlight/adp8860_bl.c
> @@ -363,10 +363,7 @@ static int adp8860_bl_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return adp8860_bl_set(bl, brightness);
> diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
> index 4c0032010cfe..ae4269fdb189 100644
> --- a/drivers/video/backlight/adp8870_bl.c
> +++ b/drivers/video/backlight/adp8870_bl.c
> @@ -401,10 +401,7 @@ static int adp8870_bl_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return adp8870_bl_set(bl, brightness);
> diff --git a/drivers/video/backlight/as3711_bl.c b/drivers/video/backlight/as3711_bl.c
> index 33f0f0f2e8b3..7fa76008c7bf 100644
> --- a/drivers/video/backlight/as3711_bl.c
> +++ b/drivers/video/backlight/as3711_bl.c
> @@ -107,13 +107,11 @@ static int as3711_bl_update_status(struct backlight_device *bl)
>  	int brightness = bl->props.brightness;
>  	int ret = 0;
>  
> -	dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, blank %x, state %x\n",
> +	dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, state %x\n",
>  		__func__, bl->props.brightness, bl->props.power,
> -		bl->props.fb_blank, bl->props.state);
> +		bl->props.state);
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK ||
> -	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
> -	    bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	if (data->type == AS3711_BL_SU1) {
> diff --git a/drivers/video/backlight/bd6107.c b/drivers/video/backlight/bd6107.c
> index d5d5fb457e78..f6a5c1dba3bc 100644
> --- a/drivers/video/backlight/bd6107.c
> +++ b/drivers/video/backlight/bd6107.c
> @@ -84,9 +84,7 @@ static int bd6107_backlight_update_status(struct backlight_device *backlight)
>  	struct bd6107 *bd = bl_get_data(backlight);
>  	int brightness = backlight->props.brightness;
>  
> -	if (backlight->props.power != FB_BLANK_UNBLANK ||
> -	    backlight->props.fb_blank != FB_BLANK_UNBLANK ||
> -	    backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
> +	if (backlight_is_blank(backlight))
>  		brightness = 0;
>  
>  	if (brightness) {
> diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c
> index 25ef0cbd7583..c9adf4e26355 100644
> --- a/drivers/video/backlight/corgi_lcd.c
> +++ b/drivers/video/backlight/corgi_lcd.c
> @@ -422,10 +422,7 @@ static int corgi_bl_update_status(struct backlight_device *bd)
>  	struct corgi_lcd *lcd = bl_get_data(bd);
>  	int intensity = bd->props.brightness;
>  
> -	if (bd->props.power != FB_BLANK_UNBLANK)
> -		intensity = 0;
> -
> -	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bd))
>  		intensity = 0;
>  
>  	if (corgibl_flags & CORGIBL_SUSPENDED)
> diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c
> index 4624b7b7c6a6..d5ab7675f55c 100644
> --- a/drivers/video/backlight/cr_bllcd.c
> +++ b/drivers/video/backlight/cr_bllcd.c
> @@ -59,26 +59,18 @@ struct cr_panel {
>  
>  static int cr_backlight_set_intensity(struct backlight_device *bd)
>  {
> -	int intensity = bd->props.brightness;
>  	u32 addr = gpio_bar + CRVML_PANEL_PORT;
>  	u32 cur = inl(addr);
>  
> -	if (bd->props.power == FB_BLANK_UNBLANK)
> -		intensity = FB_BLANK_UNBLANK;
> -	if (bd->props.fb_blank == FB_BLANK_UNBLANK)
> -		intensity = FB_BLANK_UNBLANK;
> -	if (bd->props.power == FB_BLANK_POWERDOWN)
> -		intensity = FB_BLANK_POWERDOWN;
> -	if (bd->props.fb_blank == FB_BLANK_POWERDOWN)
> -		intensity = FB_BLANK_POWERDOWN;
> -
> -	if (intensity == FB_BLANK_UNBLANK) { /* FULL ON */
> -		cur &= ~CRVML_BACKLIGHT_OFF;
> -		outl(cur, addr);
> -	} else if (intensity == FB_BLANK_POWERDOWN) { /* OFF */
> +	if (backlight_is_blank(bd)) {
> +		/* OFF */
>  		cur |= CRVML_BACKLIGHT_OFF;
>  		outl(cur, addr);
> -	} /* anything else, don't bother */
> +	} else {
> +		/* FULL ON */
> +		cur &= ~CRVML_BACKLIGHT_OFF;
> +		outl(cur, addr);
> +	}
>  
>  	return 0;
>  }
> diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c
> index 62540e4bdedb..ca351badfdcf 100644
> --- a/drivers/video/backlight/da903x_bl.c
> +++ b/drivers/video/backlight/da903x_bl.c
> @@ -79,13 +79,7 @@ static int da903x_backlight_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.state & BL_CORE_SUSPENDED)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return da903x_backlight_set(bl, brightness);
> diff --git a/drivers/video/backlight/ep93xx_bl.c b/drivers/video/backlight/ep93xx_bl.c
> index 4149e0b2f83c..491185df1411 100644
> --- a/drivers/video/backlight/ep93xx_bl.c
> +++ b/drivers/video/backlight/ep93xx_bl.c
> @@ -38,8 +38,7 @@ static int ep93xxbl_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK ||
> -	    bl->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return ep93xxbl_set(bl, brightness);
> diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
> index 75409ddfba3e..94b65e4d2aa0 100644
> --- a/drivers/video/backlight/gpio_backlight.c
> +++ b/drivers/video/backlight/gpio_backlight.c
> @@ -25,9 +25,7 @@ static int gpio_backlight_get_next_brightness(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK ||
> -	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
> -	    bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return brightness;
> diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
> index 8ea42b8d9bc8..01d805ca8415 100644
> --- a/drivers/video/backlight/hp680_bl.c
> +++ b/drivers/video/backlight/hp680_bl.c
> @@ -35,9 +35,7 @@ static void hp680bl_send_intensity(struct backlight_device *bd)
>  	u16 v;
>  	int intensity = bd->props.brightness;
>  
> -	if (bd->props.power != FB_BLANK_UNBLANK)
> -		intensity = 0;
> -	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bd))
>  		intensity = 0;
>  	if (hp680bl_suspended)
>  		intensity = 0;
> diff --git a/drivers/video/backlight/jornada720_bl.c b/drivers/video/backlight/jornada720_bl.c
> index f0385f9cf9da..996f7ba3b373 100644
> --- a/drivers/video/backlight/jornada720_bl.c
> +++ b/drivers/video/backlight/jornada720_bl.c
> @@ -54,7 +54,7 @@ static int jornada_bl_update_status(struct backlight_device *bd)
>  	jornada_ssp_start();
>  
>  	/* If backlight is off then really turn it off */
> -	if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) {
> +	if (backlight_is_blank(bd)) {
>  		ret = jornada_ssp_byte(BRIGHTNESSOFF);
>  		if (ret != TXDUMMY) {
>  			dev_info(&bd->dev, "brightness off timeout\n");
> diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
> index 1dfe13c18925..a0fd5d3d82f5 100644
> --- a/drivers/video/backlight/kb3886_bl.c
> +++ b/drivers/video/backlight/kb3886_bl.c
> @@ -89,9 +89,7 @@ static int kb3886bl_send_intensity(struct backlight_device *bd)
>  {
>  	int intensity = bd->props.brightness;
>  
> -	if (bd->props.power != FB_BLANK_UNBLANK)
> -		intensity = 0;
> -	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bd))
>  		intensity = 0;
>  	if (kb3886bl_flags & KB3886BL_SUSPENDED)
>  		intensity = 0;
> diff --git a/drivers/video/backlight/led_bl.c b/drivers/video/backlight/led_bl.c
> index 3f66549997c8..c655ddd99cfb 100644
> --- a/drivers/video/backlight/led_bl.c
> +++ b/drivers/video/backlight/led_bl.c
> @@ -56,9 +56,7 @@ static int led_bl_update_status(struct backlight_device *bl)
>  	struct led_bl_data *priv = bl_get_data(bl);
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK ||
> -	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
> -	    bl->props.state & BL_CORE_FBBLANK)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	if (brightness > 0)
> diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
> index ee09d1bd02b9..476146b62c4e 100644
> --- a/drivers/video/backlight/lm3533_bl.c
> +++ b/drivers/video/backlight/lm3533_bl.c
> @@ -41,9 +41,7 @@ static int lm3533_bl_update_status(struct backlight_device *bd)
>  	struct lm3533_bl *bl = bl_get_data(bd);
>  	int brightness = bd->props.brightness;
>  
> -	if (bd->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bd))
>  		brightness = 0;
>  
>  	return lm3533_ctrlbank_set_brightness(&bl->cb, (u8)brightness);
> diff --git a/drivers/video/backlight/locomolcd.c b/drivers/video/backlight/locomolcd.c
> index cdc02e04f89d..8064cad8d683 100644
> --- a/drivers/video/backlight/locomolcd.c
> +++ b/drivers/video/backlight/locomolcd.c
> @@ -113,9 +113,7 @@ static int locomolcd_set_intensity(struct backlight_device *bd)
>  {
>  	int intensity = bd->props.brightness;
>  
> -	if (bd->props.power != FB_BLANK_UNBLANK)
> -		intensity = 0;
> -	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
> +	if (backlight_is_blank(bd))
>  		intensity = 0;
>  	if (locomolcd_flags & LOCOMOLCD_SUSPENDED)
>  		intensity = 0;
> diff --git a/drivers/video/backlight/lv5207lp.c b/drivers/video/backlight/lv5207lp.c
> index c6ad73a784e2..ef8aa9803577 100644
> --- a/drivers/video/backlight/lv5207lp.c
> +++ b/drivers/video/backlight/lv5207lp.c
> @@ -48,9 +48,7 @@ static int lv5207lp_backlight_update_status(struct backlight_device *backlight)
>  	struct lv5207lp *lv = bl_get_data(backlight);
>  	int brightness = backlight->props.brightness;
>  
> -	if (backlight->props.power != FB_BLANK_UNBLANK ||
> -	    backlight->props.fb_blank != FB_BLANK_UNBLANK ||
> -	    backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
> +	if (backlight_is_blank(backlight))
>  		brightness = 0;
>  
>  	if (brightness) {
> diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
> index 97cc260ff9d1..b8af2c6407d3 100644
> --- a/drivers/video/backlight/max8925_bl.c
> +++ b/drivers/video/backlight/max8925_bl.c
> @@ -66,13 +66,7 @@ static int max8925_backlight_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.state & BL_CORE_SUSPENDED)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return max8925_backlight_set(bl, brightness);
> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index 82b8d7594701..7d0ffcd37f07 100644
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> @@ -111,9 +111,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
>  	int brightness = bl->props.brightness;
>  	struct pwm_state state;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK ||
> -	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
> -	    bl->props.state & BL_CORE_FBBLANK)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	if (pb->notify)
> diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c
> index 3d276b30a78c..9600f5d58ece 100644
> --- a/drivers/video/backlight/qcom-wled.c
> +++ b/drivers/video/backlight/qcom-wled.c
> @@ -261,9 +261,7 @@ static int wled_update_status(struct backlight_device *bl)
>  	u16 brightness = bl->props.brightness;
>  	int rc = 0;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK ||
> -	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
> -	    bl->props.state & BL_CORE_FBBLANK)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	mutex_lock(&wled->lock);
> diff --git a/drivers/video/backlight/tps65217_bl.c b/drivers/video/backlight/tps65217_bl.c
> index 762e3feed097..1041e5e62ee3 100644
> --- a/drivers/video/backlight/tps65217_bl.c
> +++ b/drivers/video/backlight/tps65217_bl.c
> @@ -82,9 +82,7 @@ static int tps65217_bl_update_status(struct backlight_device *bl)
>  	if (bl->props.state & BL_CORE_SUSPENDED)
>  		brightness = 0;
>  
> -	if ((bl->props.power != FB_BLANK_UNBLANK) ||
> -		(bl->props.fb_blank != FB_BLANK_UNBLANK))
> -		/* framebuffer in low power mode or blanking active */
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	if (brightness > 0) {
> diff --git a/drivers/video/backlight/wm831x_bl.c b/drivers/video/backlight/wm831x_bl.c
> index e55977d54c15..dc2ab6c8b7f9 100644
> --- a/drivers/video/backlight/wm831x_bl.c
> +++ b/drivers/video/backlight/wm831x_bl.c
> @@ -93,13 +93,7 @@ static int wm831x_backlight_update_status(struct backlight_device *bl)
>  {
>  	int brightness = bl->props.brightness;
>  
> -	if (bl->props.power != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
> -		brightness = 0;
> -
> -	if (bl->props.state & BL_CORE_SUSPENDED)
> +	if (backlight_is_blank(bl))
>  		brightness = 0;
>  
>  	return wm831x_backlight_set(bl, brightness);
> 

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

[-- Attachment #2: pEpkey.asc --]
[-- Type: application/pgp-keys, Size: 1783 bytes --]

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 03/16] backlight: add backlight_is_blank()
  2020-05-17 19:01 ` [PATCH v2 03/16] backlight: add backlight_is_blank() Sam Ravnborg
  2020-05-18 15:00   ` Daniel Thompson
  2020-05-20 10:45   ` Emil Velikov
@ 2020-05-28 13:39   ` Peter Ujfalusi
  2 siblings, 0 replies; 48+ messages in thread
From: Peter Ujfalusi @ 2020-05-28 13:39 UTC (permalink / raw)
  To: Sam Ravnborg, dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

[-- Attachment #1: Type: text/plain, Size: 2432 bytes --]



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

[-- Attachment #2: pEpkey.asc --]
[-- Type: application/pgp-keys, Size: 1783 bytes --]

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v2 16/16] backlight: use backlight_is_blank() in all backlight drivers
  2020-05-28 13:39   ` Peter Ujfalusi
@ 2020-05-28 13:43     ` Peter Ujfalusi
  0 siblings, 0 replies; 48+ messages in thread
From: Peter Ujfalusi @ 2020-05-28 13:43 UTC (permalink / raw)
  To: Sam Ravnborg, dri-devel, Jingoo Han, Lee Jones, Daniel Thompson,
	Tomi Valkeinen
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Douglas Anderson, Jani Nikula,
	Jonathan Corbet, Linus Walleij, linux-arm-msm, linux-pwm,
	Maarten Lankhorst, Maxime Ripard, Michael Hennerich, patches,
	Russell King, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig

[-- Attachment #1: Type: text/plain, Size: 18818 bytes --]



On 28/05/2020 16.39, Peter Ujfalusi wrote:
> Hi Sam,
> 
> On 17/05/2020 22.01, Sam Ravnborg wrote:
>> Replaces the open-coded checks of the state etc.,
>> with the backlight_is_blank() helper.
>> This increases readability of the code and align
>> the functionality across the drivers.
> 
> Thanks for the cleanup in with the series!
> 
> Checked gpio/pwm/led backlight drivers mostly:
> Reviewed-by: Peter Ujfalusi <peter.ujflausi@ti.com>

Interesting, I had a typo in my e-mail address :o
Let's try again:
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

> 
>> v2:
>>   - Fixed so changelog is readable
>>
>> 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>
>> Cc: Michael Hennerich <michael.hennerich@analog.com>
>> Cc: Support Opensource <support.opensource@diasemi.com>
>> Cc: Thierry Reding <thierry.reding@gmail.com>
>> Cc: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
>> Cc: Andy Gross <agross@kernel.org>
>> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
>> Cc: linux-pwm@vger.kernel.org
>> Cc: linux-arm-msm@vger.kernel.org
>> Cc: patches@opensource.cirrus.com
>> ---
>>  drivers/video/backlight/88pm860x_bl.c    |  8 +-------
>>  drivers/video/backlight/adp5520_bl.c     |  5 +----
>>  drivers/video/backlight/adp8860_bl.c     |  5 +----
>>  drivers/video/backlight/adp8870_bl.c     |  5 +----
>>  drivers/video/backlight/as3711_bl.c      |  8 +++-----
>>  drivers/video/backlight/bd6107.c         |  4 +---
>>  drivers/video/backlight/corgi_lcd.c      |  5 +----
>>  drivers/video/backlight/cr_bllcd.c       | 22 +++++++---------------
>>  drivers/video/backlight/da903x_bl.c      |  8 +-------
>>  drivers/video/backlight/ep93xx_bl.c      |  3 +--
>>  drivers/video/backlight/gpio_backlight.c |  4 +---
>>  drivers/video/backlight/hp680_bl.c       |  4 +---
>>  drivers/video/backlight/jornada720_bl.c  |  2 +-
>>  drivers/video/backlight/kb3886_bl.c      |  4 +---
>>  drivers/video/backlight/led_bl.c         |  4 +---
>>  drivers/video/backlight/lm3533_bl.c      |  4 +---
>>  drivers/video/backlight/locomolcd.c      |  4 +---
>>  drivers/video/backlight/lv5207lp.c       |  4 +---
>>  drivers/video/backlight/max8925_bl.c     |  8 +-------
>>  drivers/video/backlight/pwm_bl.c         |  4 +---
>>  drivers/video/backlight/qcom-wled.c      |  4 +---
>>  drivers/video/backlight/tps65217_bl.c    |  4 +---
>>  drivers/video/backlight/wm831x_bl.c      |  8 +-------
>>  23 files changed, 31 insertions(+), 100 deletions(-)
>>
>> diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c
>> index 20d96a5ac384..162c83ab0f5a 100644
>> --- a/drivers/video/backlight/88pm860x_bl.c
>> +++ b/drivers/video/backlight/88pm860x_bl.c
>> @@ -123,13 +123,7 @@ static int pm860x_backlight_update_status(struct backlight_device *bl)
>>  {
>>  	int brightness = bl->props.brightness;
>>  
>> -	if (bl->props.power != FB_BLANK_UNBLANK)
>> -		brightness = 0;
>> -
>> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
>> -		brightness = 0;
>> -
>> -	if (bl->props.state & BL_CORE_SUSPENDED)
>> +	if (backlight_is_blank(bl))
>>  		brightness = 0;
>>  
>>  	return pm860x_backlight_set(bl, brightness);
>> diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
>> index 0f63f76723a5..d817b0d95c9d 100644
>> --- a/drivers/video/backlight/adp5520_bl.c
>> +++ b/drivers/video/backlight/adp5520_bl.c
>> @@ -67,10 +67,7 @@ static int adp5520_bl_update_status(struct backlight_device *bl)
>>  {
>>  	int brightness = bl->props.brightness;
>>  
>> -	if (bl->props.power != FB_BLANK_UNBLANK)
>> -		brightness = 0;
>> -
>> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
>> +	if (backlight_is_blank(bl))
>>  		brightness = 0;
>>  
>>  	return adp5520_bl_set(bl, brightness);
>> diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
>> index 19968104fc47..a0ce2a3701fa 100644
>> --- a/drivers/video/backlight/adp8860_bl.c
>> +++ b/drivers/video/backlight/adp8860_bl.c
>> @@ -363,10 +363,7 @@ static int adp8860_bl_update_status(struct backlight_device *bl)
>>  {
>>  	int brightness = bl->props.brightness;
>>  
>> -	if (bl->props.power != FB_BLANK_UNBLANK)
>> -		brightness = 0;
>> -
>> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
>> +	if (backlight_is_blank(bl))
>>  		brightness = 0;
>>  
>>  	return adp8860_bl_set(bl, brightness);
>> diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
>> index 4c0032010cfe..ae4269fdb189 100644
>> --- a/drivers/video/backlight/adp8870_bl.c
>> +++ b/drivers/video/backlight/adp8870_bl.c
>> @@ -401,10 +401,7 @@ static int adp8870_bl_update_status(struct backlight_device *bl)
>>  {
>>  	int brightness = bl->props.brightness;
>>  
>> -	if (bl->props.power != FB_BLANK_UNBLANK)
>> -		brightness = 0;
>> -
>> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
>> +	if (backlight_is_blank(bl))
>>  		brightness = 0;
>>  
>>  	return adp8870_bl_set(bl, brightness);
>> diff --git a/drivers/video/backlight/as3711_bl.c b/drivers/video/backlight/as3711_bl.c
>> index 33f0f0f2e8b3..7fa76008c7bf 100644
>> --- a/drivers/video/backlight/as3711_bl.c
>> +++ b/drivers/video/backlight/as3711_bl.c
>> @@ -107,13 +107,11 @@ static int as3711_bl_update_status(struct backlight_device *bl)
>>  	int brightness = bl->props.brightness;
>>  	int ret = 0;
>>  
>> -	dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, blank %x, state %x\n",
>> +	dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, state %x\n",
>>  		__func__, bl->props.brightness, bl->props.power,
>> -		bl->props.fb_blank, bl->props.state);
>> +		bl->props.state);
>>  
>> -	if (bl->props.power != FB_BLANK_UNBLANK ||
>> -	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
>> -	    bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
>> +	if (backlight_is_blank(bl))
>>  		brightness = 0;
>>  
>>  	if (data->type == AS3711_BL_SU1) {
>> diff --git a/drivers/video/backlight/bd6107.c b/drivers/video/backlight/bd6107.c
>> index d5d5fb457e78..f6a5c1dba3bc 100644
>> --- a/drivers/video/backlight/bd6107.c
>> +++ b/drivers/video/backlight/bd6107.c
>> @@ -84,9 +84,7 @@ static int bd6107_backlight_update_status(struct backlight_device *backlight)
>>  	struct bd6107 *bd = bl_get_data(backlight);
>>  	int brightness = backlight->props.brightness;
>>  
>> -	if (backlight->props.power != FB_BLANK_UNBLANK ||
>> -	    backlight->props.fb_blank != FB_BLANK_UNBLANK ||
>> -	    backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
>> +	if (backlight_is_blank(backlight))
>>  		brightness = 0;
>>  
>>  	if (brightness) {
>> diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c
>> index 25ef0cbd7583..c9adf4e26355 100644
>> --- a/drivers/video/backlight/corgi_lcd.c
>> +++ b/drivers/video/backlight/corgi_lcd.c
>> @@ -422,10 +422,7 @@ static int corgi_bl_update_status(struct backlight_device *bd)
>>  	struct corgi_lcd *lcd = bl_get_data(bd);
>>  	int intensity = bd->props.brightness;
>>  
>> -	if (bd->props.power != FB_BLANK_UNBLANK)
>> -		intensity = 0;
>> -
>> -	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
>> +	if (backlight_is_blank(bd))
>>  		intensity = 0;
>>  
>>  	if (corgibl_flags & CORGIBL_SUSPENDED)
>> diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c
>> index 4624b7b7c6a6..d5ab7675f55c 100644
>> --- a/drivers/video/backlight/cr_bllcd.c
>> +++ b/drivers/video/backlight/cr_bllcd.c
>> @@ -59,26 +59,18 @@ struct cr_panel {
>>  
>>  static int cr_backlight_set_intensity(struct backlight_device *bd)
>>  {
>> -	int intensity = bd->props.brightness;
>>  	u32 addr = gpio_bar + CRVML_PANEL_PORT;
>>  	u32 cur = inl(addr);
>>  
>> -	if (bd->props.power == FB_BLANK_UNBLANK)
>> -		intensity = FB_BLANK_UNBLANK;
>> -	if (bd->props.fb_blank == FB_BLANK_UNBLANK)
>> -		intensity = FB_BLANK_UNBLANK;
>> -	if (bd->props.power == FB_BLANK_POWERDOWN)
>> -		intensity = FB_BLANK_POWERDOWN;
>> -	if (bd->props.fb_blank == FB_BLANK_POWERDOWN)
>> -		intensity = FB_BLANK_POWERDOWN;
>> -
>> -	if (intensity == FB_BLANK_UNBLANK) { /* FULL ON */
>> -		cur &= ~CRVML_BACKLIGHT_OFF;
>> -		outl(cur, addr);
>> -	} else if (intensity == FB_BLANK_POWERDOWN) { /* OFF */
>> +	if (backlight_is_blank(bd)) {
>> +		/* OFF */
>>  		cur |= CRVML_BACKLIGHT_OFF;
>>  		outl(cur, addr);
>> -	} /* anything else, don't bother */
>> +	} else {
>> +		/* FULL ON */
>> +		cur &= ~CRVML_BACKLIGHT_OFF;
>> +		outl(cur, addr);
>> +	}
>>  
>>  	return 0;
>>  }
>> diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c
>> index 62540e4bdedb..ca351badfdcf 100644
>> --- a/drivers/video/backlight/da903x_bl.c
>> +++ b/drivers/video/backlight/da903x_bl.c
>> @@ -79,13 +79,7 @@ static int da903x_backlight_update_status(struct backlight_device *bl)
>>  {
>>  	int brightness = bl->props.brightness;
>>  
>> -	if (bl->props.power != FB_BLANK_UNBLANK)
>> -		brightness = 0;
>> -
>> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
>> -		brightness = 0;
>> -
>> -	if (bl->props.state & BL_CORE_SUSPENDED)
>> +	if (backlight_is_blank(bl))
>>  		brightness = 0;
>>  
>>  	return da903x_backlight_set(bl, brightness);
>> diff --git a/drivers/video/backlight/ep93xx_bl.c b/drivers/video/backlight/ep93xx_bl.c
>> index 4149e0b2f83c..491185df1411 100644
>> --- a/drivers/video/backlight/ep93xx_bl.c
>> +++ b/drivers/video/backlight/ep93xx_bl.c
>> @@ -38,8 +38,7 @@ static int ep93xxbl_update_status(struct backlight_device *bl)
>>  {
>>  	int brightness = bl->props.brightness;
>>  
>> -	if (bl->props.power != FB_BLANK_UNBLANK ||
>> -	    bl->props.fb_blank != FB_BLANK_UNBLANK)
>> +	if (backlight_is_blank(bl))
>>  		brightness = 0;
>>  
>>  	return ep93xxbl_set(bl, brightness);
>> diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
>> index 75409ddfba3e..94b65e4d2aa0 100644
>> --- a/drivers/video/backlight/gpio_backlight.c
>> +++ b/drivers/video/backlight/gpio_backlight.c
>> @@ -25,9 +25,7 @@ static int gpio_backlight_get_next_brightness(struct backlight_device *bl)
>>  {
>>  	int brightness = bl->props.brightness;
>>  
>> -	if (bl->props.power != FB_BLANK_UNBLANK ||
>> -	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
>> -	    bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
>> +	if (backlight_is_blank(bl))
>>  		brightness = 0;
>>  
>>  	return brightness;
>> diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
>> index 8ea42b8d9bc8..01d805ca8415 100644
>> --- a/drivers/video/backlight/hp680_bl.c
>> +++ b/drivers/video/backlight/hp680_bl.c
>> @@ -35,9 +35,7 @@ static void hp680bl_send_intensity(struct backlight_device *bd)
>>  	u16 v;
>>  	int intensity = bd->props.brightness;
>>  
>> -	if (bd->props.power != FB_BLANK_UNBLANK)
>> -		intensity = 0;
>> -	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
>> +	if (backlight_is_blank(bd))
>>  		intensity = 0;
>>  	if (hp680bl_suspended)
>>  		intensity = 0;
>> diff --git a/drivers/video/backlight/jornada720_bl.c b/drivers/video/backlight/jornada720_bl.c
>> index f0385f9cf9da..996f7ba3b373 100644
>> --- a/drivers/video/backlight/jornada720_bl.c
>> +++ b/drivers/video/backlight/jornada720_bl.c
>> @@ -54,7 +54,7 @@ static int jornada_bl_update_status(struct backlight_device *bd)
>>  	jornada_ssp_start();
>>  
>>  	/* If backlight is off then really turn it off */
>> -	if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) {
>> +	if (backlight_is_blank(bd)) {
>>  		ret = jornada_ssp_byte(BRIGHTNESSOFF);
>>  		if (ret != TXDUMMY) {
>>  			dev_info(&bd->dev, "brightness off timeout\n");
>> diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
>> index 1dfe13c18925..a0fd5d3d82f5 100644
>> --- a/drivers/video/backlight/kb3886_bl.c
>> +++ b/drivers/video/backlight/kb3886_bl.c
>> @@ -89,9 +89,7 @@ static int kb3886bl_send_intensity(struct backlight_device *bd)
>>  {
>>  	int intensity = bd->props.brightness;
>>  
>> -	if (bd->props.power != FB_BLANK_UNBLANK)
>> -		intensity = 0;
>> -	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
>> +	if (backlight_is_blank(bd))
>>  		intensity = 0;
>>  	if (kb3886bl_flags & KB3886BL_SUSPENDED)
>>  		intensity = 0;
>> diff --git a/drivers/video/backlight/led_bl.c b/drivers/video/backlight/led_bl.c
>> index 3f66549997c8..c655ddd99cfb 100644
>> --- a/drivers/video/backlight/led_bl.c
>> +++ b/drivers/video/backlight/led_bl.c
>> @@ -56,9 +56,7 @@ static int led_bl_update_status(struct backlight_device *bl)
>>  	struct led_bl_data *priv = bl_get_data(bl);
>>  	int brightness = bl->props.brightness;
>>  
>> -	if (bl->props.power != FB_BLANK_UNBLANK ||
>> -	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
>> -	    bl->props.state & BL_CORE_FBBLANK)
>> +	if (backlight_is_blank(bl))
>>  		brightness = 0;
>>  
>>  	if (brightness > 0)
>> diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
>> index ee09d1bd02b9..476146b62c4e 100644
>> --- a/drivers/video/backlight/lm3533_bl.c
>> +++ b/drivers/video/backlight/lm3533_bl.c
>> @@ -41,9 +41,7 @@ static int lm3533_bl_update_status(struct backlight_device *bd)
>>  	struct lm3533_bl *bl = bl_get_data(bd);
>>  	int brightness = bd->props.brightness;
>>  
>> -	if (bd->props.power != FB_BLANK_UNBLANK)
>> -		brightness = 0;
>> -	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
>> +	if (backlight_is_blank(bd))
>>  		brightness = 0;
>>  
>>  	return lm3533_ctrlbank_set_brightness(&bl->cb, (u8)brightness);
>> diff --git a/drivers/video/backlight/locomolcd.c b/drivers/video/backlight/locomolcd.c
>> index cdc02e04f89d..8064cad8d683 100644
>> --- a/drivers/video/backlight/locomolcd.c
>> +++ b/drivers/video/backlight/locomolcd.c
>> @@ -113,9 +113,7 @@ static int locomolcd_set_intensity(struct backlight_device *bd)
>>  {
>>  	int intensity = bd->props.brightness;
>>  
>> -	if (bd->props.power != FB_BLANK_UNBLANK)
>> -		intensity = 0;
>> -	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
>> +	if (backlight_is_blank(bd))
>>  		intensity = 0;
>>  	if (locomolcd_flags & LOCOMOLCD_SUSPENDED)
>>  		intensity = 0;
>> diff --git a/drivers/video/backlight/lv5207lp.c b/drivers/video/backlight/lv5207lp.c
>> index c6ad73a784e2..ef8aa9803577 100644
>> --- a/drivers/video/backlight/lv5207lp.c
>> +++ b/drivers/video/backlight/lv5207lp.c
>> @@ -48,9 +48,7 @@ static int lv5207lp_backlight_update_status(struct backlight_device *backlight)
>>  	struct lv5207lp *lv = bl_get_data(backlight);
>>  	int brightness = backlight->props.brightness;
>>  
>> -	if (backlight->props.power != FB_BLANK_UNBLANK ||
>> -	    backlight->props.fb_blank != FB_BLANK_UNBLANK ||
>> -	    backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
>> +	if (backlight_is_blank(backlight))
>>  		brightness = 0;
>>  
>>  	if (brightness) {
>> diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
>> index 97cc260ff9d1..b8af2c6407d3 100644
>> --- a/drivers/video/backlight/max8925_bl.c
>> +++ b/drivers/video/backlight/max8925_bl.c
>> @@ -66,13 +66,7 @@ static int max8925_backlight_update_status(struct backlight_device *bl)
>>  {
>>  	int brightness = bl->props.brightness;
>>  
>> -	if (bl->props.power != FB_BLANK_UNBLANK)
>> -		brightness = 0;
>> -
>> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
>> -		brightness = 0;
>> -
>> -	if (bl->props.state & BL_CORE_SUSPENDED)
>> +	if (backlight_is_blank(bl))
>>  		brightness = 0;
>>  
>>  	return max8925_backlight_set(bl, brightness);
>> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
>> index 82b8d7594701..7d0ffcd37f07 100644
>> --- a/drivers/video/backlight/pwm_bl.c
>> +++ b/drivers/video/backlight/pwm_bl.c
>> @@ -111,9 +111,7 @@ static int pwm_backlight_update_status(struct backlight_device *bl)
>>  	int brightness = bl->props.brightness;
>>  	struct pwm_state state;
>>  
>> -	if (bl->props.power != FB_BLANK_UNBLANK ||
>> -	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
>> -	    bl->props.state & BL_CORE_FBBLANK)
>> +	if (backlight_is_blank(bl))
>>  		brightness = 0;
>>  
>>  	if (pb->notify)
>> diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c
>> index 3d276b30a78c..9600f5d58ece 100644
>> --- a/drivers/video/backlight/qcom-wled.c
>> +++ b/drivers/video/backlight/qcom-wled.c
>> @@ -261,9 +261,7 @@ static int wled_update_status(struct backlight_device *bl)
>>  	u16 brightness = bl->props.brightness;
>>  	int rc = 0;
>>  
>> -	if (bl->props.power != FB_BLANK_UNBLANK ||
>> -	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
>> -	    bl->props.state & BL_CORE_FBBLANK)
>> +	if (backlight_is_blank(bl))
>>  		brightness = 0;
>>  
>>  	mutex_lock(&wled->lock);
>> diff --git a/drivers/video/backlight/tps65217_bl.c b/drivers/video/backlight/tps65217_bl.c
>> index 762e3feed097..1041e5e62ee3 100644
>> --- a/drivers/video/backlight/tps65217_bl.c
>> +++ b/drivers/video/backlight/tps65217_bl.c
>> @@ -82,9 +82,7 @@ static int tps65217_bl_update_status(struct backlight_device *bl)
>>  	if (bl->props.state & BL_CORE_SUSPENDED)
>>  		brightness = 0;
>>  
>> -	if ((bl->props.power != FB_BLANK_UNBLANK) ||
>> -		(bl->props.fb_blank != FB_BLANK_UNBLANK))
>> -		/* framebuffer in low power mode or blanking active */
>> +	if (backlight_is_blank(bl))
>>  		brightness = 0;
>>  
>>  	if (brightness > 0) {
>> diff --git a/drivers/video/backlight/wm831x_bl.c b/drivers/video/backlight/wm831x_bl.c
>> index e55977d54c15..dc2ab6c8b7f9 100644
>> --- a/drivers/video/backlight/wm831x_bl.c
>> +++ b/drivers/video/backlight/wm831x_bl.c
>> @@ -93,13 +93,7 @@ static int wm831x_backlight_update_status(struct backlight_device *bl)
>>  {
>>  	int brightness = bl->props.brightness;
>>  
>> -	if (bl->props.power != FB_BLANK_UNBLANK)
>> -		brightness = 0;
>> -
>> -	if (bl->props.fb_blank != FB_BLANK_UNBLANK)
>> -		brightness = 0;
>> -
>> -	if (bl->props.state & BL_CORE_SUSPENDED)
>> +	if (backlight_is_blank(bl))
>>  		brightness = 0;
>>  
>>  	return wm831x_backlight_set(bl, brightness);
>>
> 
> - Péter
> 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

[-- Attachment #2: pEpkey.asc --]
[-- Type: application/pgp-keys, Size: 1783 bytes --]

^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2020-05-28 13:42 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-17 19:01 [PATCH v2 0/16] backlight updates Sam Ravnborg
2020-05-17 19:01 ` [PATCH v2 01/16] video: amba-clcd: use devm_of_find_backlight Sam Ravnborg
2020-05-18  8:10   ` Linus Walleij
2020-05-18 10:16     ` Sam Ravnborg
2020-05-25  8:42       ` Linus Walleij
2020-05-25 11:01         ` Sam Ravnborg
2020-05-17 19:01 ` [PATCH v2 02/16] backlight: refactor fb_notifier_callback() Sam Ravnborg
2020-05-18 14:54   ` Daniel Thompson
2020-05-20 10:41   ` Emil Velikov
2020-05-17 19:01 ` [PATCH v2 03/16] backlight: add backlight_is_blank() Sam Ravnborg
2020-05-18 15:00   ` Daniel Thompson
2020-05-20 10:45   ` Emil Velikov
2020-05-28 13:39   ` Peter Ujfalusi
2020-05-17 19:01 ` [PATCH v2 04/16] backlight: improve backlight_ops documentation Sam Ravnborg
2020-05-18 15:02   ` Daniel Thompson
2020-05-17 19:01 ` [PATCH v2 05/16] backlight: improve backlight_properties documentation Sam Ravnborg
2020-05-18 15:53   ` Daniel Thompson
2020-05-17 19:01 ` [PATCH v2 06/16] backlight: improve backlight_device documentation Sam Ravnborg
2020-05-18 16:03   ` Daniel Thompson
2020-05-18 17:03     ` Jani Nikula
2020-05-18 17:58       ` Daniel Thompson
2020-05-17 19:01 ` [PATCH v2 07/16] backlight: document inline functions in backlight.h Sam Ravnborg
2020-05-18 16:04   ` Daniel Thompson
2020-05-17 19:01 ` [PATCH v2 08/16] backlight: document enums " Sam Ravnborg
2020-05-18 16:15   ` Daniel Thompson
2020-05-17 19:01 ` [PATCH v2 09/16] backlight: remove the unused backlight_bl driver Sam Ravnborg
2020-05-18 16:17   ` Daniel Thompson
2020-05-17 19:01 ` [PATCH v2 10/16] backlight: drop extern from prototypes Sam Ravnborg
2020-05-18 16:22   ` Daniel Thompson
2020-05-17 19:01 ` [PATCH v2 11/16] backlight: add overview and update existing doc Sam Ravnborg
2020-05-18 16:44   ` Daniel Thompson
2020-05-17 19:01 ` [PATCH v2 12/16] backlight: wire up kernel-doc documentation Sam Ravnborg
2020-05-18 16:50   ` Daniel Thompson
2020-05-17 19:01 ` [PATCH v2 13/16] backlight: make of_find_backlight static Sam Ravnborg
2020-05-18 16:53   ` Daniel Thompson
2020-05-17 19:01 ` [PATCH v2 14/16] backlight: drop backlight_put() Sam Ravnborg
2020-05-18 16:53   ` Daniel Thompson
2020-05-17 19:01 ` [PATCH v2 15/16] backlight: make of_find_backlight_by_node() static Sam Ravnborg
2020-05-18 16:56   ` Daniel Thompson
2020-05-18 18:12     ` Sam Ravnborg
2020-05-18 19:56       ` Daniel Thompson
2020-05-17 19:01 ` [PATCH v2 16/16] backlight: use backlight_is_blank() in all backlight drivers Sam Ravnborg
2020-05-18 16:59   ` Daniel Thompson
2020-05-20 10:56   ` Emil Velikov
2020-05-20 15:11     ` Daniel Thompson
2020-05-28 13:39   ` Peter Ujfalusi
2020-05-28 13:43     ` Peter Ujfalusi
2020-05-20 11:01 ` [PATCH v2 0/16] backlight updates Emil Velikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).