linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v5 0/19] backlight: backlight updates
@ 2020-07-19  8:07 Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 01/19] backlight: refactor fb_notifier_callback() Sam Ravnborg
                   ` (19 more replies)
  0 siblings, 20 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

Hi all.

Follow-up on v4 - with only a few changes listed below and
in the individual patches.
Thanks for all the reviews and the feedback on the patches!

I am planning a follow-up on this patchset to update the
backlight drivers all over to use backlight_get_brightness()
and backlight_is_blank() as appropriate.

v5:
  - Added r-b's
  - Updated cr_bllcd to use gpio-backlight semantics
  - Various editorial updates to changelogs
  - Rebased on top of Lee's backlight tree
  - Dropped "make of_find_backlight_by_node() static"
    The change depends on drm-misc-next.
    Will be re-send when the changes hits the backlight tree
    (We could have done this in other ways, but it is easier to just wait)

v4:
  - Introduced backlight_get_brightness based on feedback from Emil.
  - Properly described the rationale behind more restrictive locking use
    I checked that locking was not used outside backlight core
    by renaming the lock fields.
    As it is not used seems OK to restrict use to the core.
  - Introducing backlight_get_brightness invalidated
    some patches and I did a bit finer split to ease review.
  - Added acks
  - A few small adjustments documented in the individual patches

v3:
  - Dropped video patch that was reviewd and thus applied
  - Updated kernel-doc so all fields now have a short intro
  - Improved readability in a lot of places, thanks to review
    feedback from Daniel - thanks!
  - Added better intro to backlight
  - Added acks

    Several other smaller changes documented in the
    patches.
    I left out patches to make functions static as
    there are dependencies to drm-misc-next for these.

v2:
  - Dropped drm patches that was reviewed and thus applied (Thanks Tomi)
  - Updated backligth_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.

The following series touches a lot of backlight things.

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

Then two new helpers backlight_is_blank(), backlight_get_brightness()
are added. These helpers simplifies the implementation of update_status()
in the backlight drivers where they are used.

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 driver
was no longer in use - so drop it.

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

        Sam

Sam Ravnborg (19):
      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: introduce backlight_get_brightness()
      backlight: as3711_bl: simplify update_status
      backlight: cr_bllcd: introduce gpio-backlight semantics
      backlight: gpio_backlight: simplify update_status()
      backlight: jornada720_bl: introduce backlight_is_blank()
      backlight: use backlight_get_brightness()
      backlight: drop backlight_put()
      backlight: make of_find_backlight static

 Documentation/gpu/backlight.rst          |  12 +
 Documentation/gpu/index.rst              |   1 +
 drivers/video/backlight/88pm860x_bl.c    |  13 +-
 drivers/video/backlight/Kconfig          |   8 -
 drivers/video/backlight/Makefile         |   1 -
 drivers/video/backlight/adp5520_bl.c     |  10 +-
 drivers/video/backlight/adp8860_bl.c     |  10 +-
 drivers/video/backlight/adp8870_bl.c     |  10 +-
 drivers/video/backlight/as3711_bl.c      |  11 +-
 drivers/video/backlight/backlight.c      | 208 +++++++++-------
 drivers/video/backlight/bd6107.c         |   7 +-
 drivers/video/backlight/corgi_lcd.c      |   8 +-
 drivers/video/backlight/cr_bllcd.c       |  25 +-
 drivers/video/backlight/da903x_bl.c      |  13 +-
 drivers/video/backlight/ep93xx_bl.c      |   8 +-
 drivers/video/backlight/generic_bl.c     | 110 ---------
 drivers/video/backlight/gpio_backlight.c |  17 +-
 drivers/video/backlight/hp680_bl.c       |   6 +-
 drivers/video/backlight/jornada720_bl.c  |   2 +-
 drivers/video/backlight/kb3886_bl.c      |   6 +-
 drivers/video/backlight/led_bl.c         |   7 +-
 drivers/video/backlight/lm3533_bl.c      |   8 +-
 drivers/video/backlight/locomolcd.c      |   6 +-
 drivers/video/backlight/lv5207lp.c       |   7 +-
 drivers/video/backlight/max8925_bl.c     |  13 +-
 drivers/video/backlight/pwm_bl.c         |   7 +-
 drivers/video/backlight/qcom-wled.c      |   7 +-
 drivers/video/backlight/tps65217_bl.c    |  10 +-
 drivers/video/backlight/wm831x_bl.c      |  13 +-
 include/linux/backlight.h                | 399 +++++++++++++++++++++++++------
 30 files changed, 497 insertions(+), 466 deletions(-)

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

* [PATCH v5 01/19] backlight: refactor fb_notifier_callback()
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 02/19] backlight: add backlight_is_blank() Sam Ravnborg
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

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

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
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 744ba58488e0..18501956dd87 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] 24+ messages in thread

* [PATCH v5 02/19] backlight: add backlight_is_blank()
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 01/19] backlight: refactor fb_notifier_callback() Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 03/19] backlight: improve backlight_ops documentation Sam Ravnborg
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

The backlight support has three properties that express the state:
- power
- state
- fb_blank

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 bugs
due to the creative use of fb_blank in some drivers.
Introducing this helper will for some drivers results in
added support for fb_blank. This will be a change in
functionality, which will improve the backlight driver.

Rolling out this helper to all relevant backlight drivers
will eliminate almost all accesses to fb_blank.

v5:
  - Improved changelog, added fb_blank to properties
    that express state (Daniel)

v4:
  - struct backlight_device * is now const

v3:
  - Clarified that the fb_blank support in
    backlight_is_blank() may result in functionality
    changes for the users (Emil)

v2:
  - Added fb_blank condition (Daniel)

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
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 56e4580d4f55..56e51ebab740 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(const 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] 24+ messages in thread

* [PATCH v5 03/19] backlight: improve backlight_ops documentation
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 01/19] backlight: refactor fb_notifier_callback() Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 02/19] backlight: add backlight_is_blank() Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 04/19] backlight: improve backlight_properties documentation Sam Ravnborg
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

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

v2:
  - Add intro for each field (Daniel)

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Jingoo Han <jingoohan1@gmail.com>
---
 include/linux/backlight.h | 59 +++++++++++++++++++++++++++++++++++----
 1 file changed, 53 insertions(+), 6 deletions(-)

diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 56e51ebab740..dfb43ee02ea0 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -55,19 +55,66 @@ 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: Configure how operations are called from the core.
+	 *
+	 * 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: Operation called when properties have changed.
+	 *
+	 * 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 the framebuffer device.
+	 *
+	 * 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] 24+ messages in thread

* [PATCH v5 04/19] backlight: improve backlight_properties documentation
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (2 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 03/19] backlight: improve backlight_ops documentation Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 05/19] backlight: improve backlight_device documentation Sam Ravnborg
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

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

v3:
  - Added missing '@' in kernel-doc

v2:
  - Added into for each field (Daniel)
  - Re-written some parts to explain what to do, rather
    than what not to do.
    Partly based on suggestions from the review (Daniel)

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Jingoo Han <jingoohan1@gmail.com>
---
 include/linux/backlight.h | 96 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 85 insertions(+), 11 deletions(-)

diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index dfb43ee02ea0..10518b00b059 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -117,28 +117,102 @@ 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 brightness requested by the user.
+	 *
+	 * The backlight core makes sure the range is (0 to 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() 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 can 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 to 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: The power state from the FBIOBLANK ioclt.
+	 *
+	 * 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.
+	 *
+	 * 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).
+	 *
+	 * 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 of the backlight core.
+	 *
+	 * 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.
+	 *
+	 * backlight drivers are excpected to use backlight_is_blank()
+	 * in their update_status() operation rather than reading the
+	 * state property.
+	 *
+	 * The state is maintained by the core and drivers may not modify it.
+	 */
 	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.
+	 */
+	enum backlight_scale scale;
 };
 
 struct backlight_device {
-- 
2.25.1

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

* [PATCH v5 05/19] backlight: improve backlight_device documentation
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (3 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 04/19] backlight: improve backlight_properties documentation Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 06/19] backlight: document inline functions in backlight.h Sam Ravnborg
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

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

The updated documentation is more strict on how locking is used.
With the update neither update_lock nor ops_lock may be used
outside the backlight core.
This restriction was introduced to keep the locking simple
by keeping it in the core.
It was verified that this documents the current state by renaming
update_lock => bl_update_lock and ops_lock => bl_ops_lock.
The rename did not reveal any uses outside the backlight core.
The rename is NOT part of this patch.

v3:
  - Update changelog to explain locking details (Daniel)

v2:
  - Add short intro to all fields (Daniel)
  - Updated description of update_lock (Daniel)

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Jingoo Han <jingoohan1@gmail.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Jingoo Han <jingoohan1@gmail.com>
---
 include/linux/backlight.h | 72 ++++++++++++++++++++++++++-------------
 1 file changed, 49 insertions(+), 23 deletions(-)

diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 10518b00b059..7654fe5f1589 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,
@@ -215,30 +200,71 @@ 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: The lock used when calling the update_status() operation.
+	 *
+	 * update_lock is an internal backlight lock that serialise access
+	 * to the update_status() operation. The backlight core holds the update_lock
+	 * when calling the update_status() operation. The update_lock 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: The lock used around everything related to backlight_ops.
+	 *
+	 * 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 ops_lock 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: The state of individual fbdev's.
+	 *
+	 * 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] 24+ messages in thread

* [PATCH v5 06/19] backlight: document inline functions in backlight.h
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (4 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 05/19] backlight: improve backlight_device documentation Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 07/19] backlight: document enums " Sam Ravnborg
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

Add documentation for the inline functions in backlight.h

v2:
 - Fix spelling (Daniel)

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
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 7654fe5f1589..7d6cb61e10f5 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -268,6 +268,10 @@ struct backlight_device {
 	int use_count;
 };
 
+/**
+ * backlight_update_status - force an update of the backlight device status
+ * @bd: the backlight device
+ */
 static inline int backlight_update_status(struct backlight_device *bd)
 {
 	int ret = -ENOENT;
@@ -361,6 +365,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] 24+ messages in thread

* [PATCH v5 07/19] backlight: document enums in backlight.h
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (5 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 06/19] backlight: document inline functions in backlight.h Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 08/19] backlight: remove the unused backlight_bl driver Sam Ravnborg
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

Add kernel-doc documentation for the backlight enums

v2:
  - Add intro to each enum member (Daniel)
    Except backlight type as line lenght was too long.
    The generated HTML is the same.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Jingoo Han <jingoohan1@gmail.com>
---
 include/linux/backlight.h | 72 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)

diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 7d6cb61e10f5..0f425b32e6be 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -14,26 +14,98 @@
 #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.
+	 */
 	BACKLIGHT_RAW = 1,
+
+	/**
+	 * @BACKLIGHT_PLATFORM:
+	 *
+	 * The backlight is controlled 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.
+	 *
+	 * The linear scale will increase brightness the same for each step.
+	 */
 	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] 24+ messages in thread

* [PATCH v5 08/19] backlight: remove the unused backlight_bl driver
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (6 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 07/19] backlight: document enums " Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 09/19] backlight: drop extern from prototypes Sam Ravnborg
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

The backlight_bl 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>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
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 95c546cc8774..87f9fc238d28 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 2072d21b60f7..13463b99f1f9 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 0f425b32e6be..8f2005a6f8a9 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -454,15 +454,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] 24+ messages in thread

* [PATCH v5 09/19] backlight: drop extern from prototypes
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (7 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 08/19] backlight: remove the unused backlight_bl driver Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 10/19] backlight: add overview and update existing doc Sam Ravnborg
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

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>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
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 8f2005a6f8a9..c6ac4cbb9ddb 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -417,23 +417,26 @@ static inline bool backlight_is_blank(const 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);
+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_name(const char *name);
-extern int backlight_device_set_brightness(struct backlight_device *bd, unsigned long brightness);
+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] 24+ messages in thread

* [PATCH v5 10/19] backlight: add overview and update existing doc
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (8 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 09/19] backlight: drop extern from prototypes Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 11/19] backlight: wire up kernel-doc documentation Sam Ravnborg
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

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

v4:
  - Include updated devm_of_find_backlight doc
    (was accidently included in a later patch)

v3:
  - Updated a few editorial details (Daniel)

v2:
  - Sevaral editorial corrections that makes reading
    much easier (Daniel)
  - Spelling fixes (Daniel)
  - updated intro chapter with a little more info

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
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 | 140 +++++++++++++++++++---------
 1 file changed, 98 insertions(+), 42 deletions(-)

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 18501956dd87..93ae8c63fe4c 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -22,6 +22,47 @@
 #include <asm/backlight.h>
 #endif
 
+/**
+ * DOC: overview
+ *
+ * The backlight core supports implementing backlight drivers.
+ *
+ * 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 backlight can be adjusted using the sysfs interface, and
+ * the backlight driver may also support adjusting backlight using
+ * a hot-key or some other platfrom or firmware specific way.
+ *
+ * The driver must 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 brightness has changed using backlight_force_update().
+ *
+ * The backlight driver core receives notifications from fbdev and
+ * if the event is FB_EVENT_BLANK and if the value of blank, from the
+ * FBIOBLANK ioclt, results in a change in the backlight state the
+ * update_status() operation is called.
+ */
+
 static struct list_head backlight_dev_list;
 static struct mutex backlight_dev_list_mutex;
 static struct blocking_notifier_head backlight_notifier;
@@ -40,9 +81,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 cares 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 backlight for the specified fbdev.
  */
 static int fb_notifier_callback(struct notifier_block *self,
 				unsigned long event, void *data)
@@ -324,7 +373,10 @@ ATTRIBUTE_GROUPS(bl_device);
  * @reason: reason for update
  *
  * Updates the internal state of the backlight in response to a hardware event,
- * and generate a uevent to notify userspace
+ * and generates 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)
@@ -337,20 +389,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.
- * @props: pointer to backlight's properties 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)
@@ -417,6 +456,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;
@@ -456,12 +504,7 @@ struct backlight_device *backlight_device_get_by_name(const char *name)
 }
 EXPORT_SYMBOL(backlight_device_get_by_name);
 
-/**
- * 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)
@@ -509,10 +552,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)
 {
@@ -524,10 +569,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)
 {
@@ -536,20 +583,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 - register 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,
@@ -576,13 +625,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 - unregister backlight device
  * @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)
@@ -673,12 +722,19 @@ 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
+ * 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)
 {
-- 
2.25.1

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

* [PATCH v5 11/19] backlight: wire up kernel-doc documentation
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (9 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 10/19] backlight: add overview and update existing doc Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 12/19] backlight: introduce backlight_get_brightness() Sam Ravnborg
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

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

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
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] 24+ messages in thread

* [PATCH v5 12/19] backlight: introduce backlight_get_brightness()
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (10 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 11/19] backlight: wire up kernel-doc documentation Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 13/19] backlight: as3711_bl: simplify update_status Sam Ravnborg
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

Based on an idea from Emil Velikov <emil.l.velikov@gmail.com>
add a helper that checks backlight_is_blank() and return 0 as brightness
if display is blank or the property value if not.

This allows us to simplify the update_status() implementation
in most of the backlight drivers.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
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 c6ac4cbb9ddb..38db67588b16 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -417,6 +417,25 @@ static inline bool backlight_is_blank(const struct backlight_device *bd)
 	       bd->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK);
 }
 
+/**
+ * backlight_get_brightness - Returns the current brightness value
+ * @bd: the backlight device
+ *
+ * Returns the current brightness value, taking in consideration the current
+ * state. If backlight_is_blank() returns true then return 0 as brightness
+ * otherwise return the current brightness property value.
+ *
+ * Backlight drivers are expected to use this function in their update_status()
+ * operation to get the brightness value.
+ */
+static inline int backlight_get_brightness(const struct backlight_device *bd)
+{
+	if (backlight_is_blank(bd))
+		return 0;
+	else
+		return bd->props.brightness;
+}
+
 struct backlight_device *
 backlight_device_register(const char *name, struct device *dev, void *devdata,
 			  const struct backlight_ops *ops,
-- 
2.25.1

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

* [PATCH v5 13/19] backlight: as3711_bl: simplify update_status
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (11 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 12/19] backlight: introduce backlight_get_brightness() Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 14/19] backlight: cr_bllcd: introduce gpio-backlight semantics Sam Ravnborg
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

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

Futhermore drop the debug prints in update_status().
If we need debug printing then we can add it to the backlight core.

v2:
  - Use backlight_get_brightness()

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Jingoo Han <jingoohan1@gmail.com>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
---
 drivers/video/backlight/as3711_bl.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/video/backlight/as3711_bl.c b/drivers/video/backlight/as3711_bl.c
index 33f0f0f2e8b3..3b60019cdc2b 100644
--- a/drivers/video/backlight/as3711_bl.c
+++ b/drivers/video/backlight/as3711_bl.c
@@ -104,17 +104,10 @@ static int as3711_bl_update_status(struct backlight_device *bl)
 	struct as3711_bl_data *data = bl_get_data(bl);
 	struct as3711_bl_supply *supply = to_supply(data);
 	struct as3711 *as3711 = supply->as3711;
-	int brightness = bl->props.brightness;
+	int brightness;
 	int ret = 0;
 
-	dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, blank %x, state %x\n",
-		__func__, bl->props.brightness, bl->props.power,
-		bl->props.fb_blank, 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))
-		brightness = 0;
+	brightness = backlight_get_brightness(bl);
 
 	if (data->type == AS3711_BL_SU1) {
 		ret = as3711_set_brightness_v(as3711, brightness,
-- 
2.25.1

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

* [PATCH v5 14/19] backlight: cr_bllcd: introduce gpio-backlight semantics
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (12 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 13/19] backlight: as3711_bl: simplify update_status Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-20  8:48   ` Daniel Thompson
  2020-07-19  8:07 ` [PATCH v5 15/19] backlight: gpio_backlight: simplify update_status() Sam Ravnborg
                   ` (5 subsequent siblings)
  19 siblings, 1 reply; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

cr_bllcd can turn backlight ON or OFF.
Fix semantitics so they equals what we know from gpio-backlight.
brightness == 0   => backlight off
brightness == 1   => backlight on

Use the backlight_get_brightness() helper to simplify the code.

v2:
  - reworked to introduce gpio-backlight semantics (Daniel)

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/cr_bllcd.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c
index 4624b7b7c6a6..a24d42e1ea3c 100644
--- a/drivers/video/backlight/cr_bllcd.c
+++ b/drivers/video/backlight/cr_bllcd.c
@@ -63,22 +63,15 @@ static int cr_backlight_set_intensity(struct backlight_device *bd)
 	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_get_brightness(bd) == 0) {
+		/* 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;
 }
@@ -90,9 +83,9 @@ static int cr_backlight_get_intensity(struct backlight_device *bd)
 	u8 intensity;
 
 	if (cur & CRVML_BACKLIGHT_OFF)
-		intensity = FB_BLANK_POWERDOWN;
+		intensity = 0;
 	else
-		intensity = FB_BLANK_UNBLANK;
+		intensity = 1;
 
 	return intensity;
 }
-- 
2.25.1

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

* [PATCH v5 15/19] backlight: gpio_backlight: simplify update_status()
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (13 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 14/19] backlight: cr_bllcd: introduce gpio-backlight semantics Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 16/19] backlight: jornada720_bl: introduce backlight_is_blank() Sam Ravnborg
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

Introduce the use of backlight_get_brightness() to simplify
the update_status() operation.
With the simpler implementation drop the gpio_backlight_get_next_brightness()
helper as it was now a one-liner.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Jingoo Han <jingoohan1@gmail.com>
---
 drivers/video/backlight/gpio_backlight.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
index 75409ddfba3e..6f78d928f054 100644
--- a/drivers/video/backlight/gpio_backlight.c
+++ b/drivers/video/backlight/gpio_backlight.c
@@ -21,24 +21,11 @@ struct gpio_backlight {
 	struct gpio_desc *gpiod;
 };
 
-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))
-		brightness = 0;
-
-	return brightness;
-}
-
 static int gpio_backlight_update_status(struct backlight_device *bl)
 {
 	struct gpio_backlight *gbl = bl_get_data(bl);
-	int brightness = gpio_backlight_get_next_brightness(bl);
 
-	gpiod_set_value_cansleep(gbl->gpiod, brightness);
+	gpiod_set_value_cansleep(gbl->gpiod, backlight_get_brightness(bl));
 
 	return 0;
 }
@@ -108,7 +95,7 @@ static int gpio_backlight_probe(struct platform_device *pdev)
 
 	bl->props.brightness = 1;
 
-	init_brightness = gpio_backlight_get_next_brightness(bl);
+	init_brightness = backlight_get_brightness(bl);
 	ret = gpiod_direction_output(gbl->gpiod, init_brightness);
 	if (ret) {
 		dev_err(dev, "failed to set initial brightness\n");
-- 
2.25.1

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

* [PATCH v5 16/19] backlight: jornada720_bl: introduce backlight_is_blank()
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (14 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 15/19] backlight: gpio_backlight: simplify update_status() Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 17/19] backlight: use backlight_get_brightness() Sam Ravnborg
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

Use the backlight_is_blank() helper to simplify the code a bit.

The jornada720_bl driver distingush between backlight off
and brightness set to 0.

Thus this driver turn off backlight only when backlight_is_blank()
returns true.

v2:
  - Updated changelog (Daniel)

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Cc: Jingoo Han <jingoohan1@gmail.com>
---
 drivers/video/backlight/jornada720_bl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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");
-- 
2.25.1

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

* [PATCH v5 17/19] backlight: use backlight_get_brightness()
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (15 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 16/19] backlight: jornada720_bl: introduce backlight_is_blank() Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 18/19] backlight: drop backlight_put() Sam Ravnborg
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

Introduce the backlight_get_brightness() helper in all
video/backlight/* drivers.
This simplifies the code and align the implementation of the
update_status() operation across the different backlight drivers.

Some of the drivers gains a little extra functionality by the change
as they now respect the fb_blank() ioctl.

v2:
  - Fix spelling in subject (Uwe)

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
---
 drivers/video/backlight/88pm860x_bl.c | 13 +------------
 drivers/video/backlight/adp5520_bl.c  | 10 +---------
 drivers/video/backlight/adp8860_bl.c  | 10 +---------
 drivers/video/backlight/adp8870_bl.c  | 10 +---------
 drivers/video/backlight/bd6107.c      |  7 +------
 drivers/video/backlight/corgi_lcd.c   |  8 +-------
 drivers/video/backlight/da903x_bl.c   | 13 +------------
 drivers/video/backlight/ep93xx_bl.c   |  8 +-------
 drivers/video/backlight/hp680_bl.c    |  6 +-----
 drivers/video/backlight/kb3886_bl.c   |  6 +-----
 drivers/video/backlight/led_bl.c      |  7 +------
 drivers/video/backlight/lm3533_bl.c   |  8 +-------
 drivers/video/backlight/locomolcd.c   |  6 +-----
 drivers/video/backlight/lv5207lp.c    |  7 +------
 drivers/video/backlight/max8925_bl.c  | 13 +------------
 drivers/video/backlight/pwm_bl.c      |  7 +------
 drivers/video/backlight/qcom-wled.c   |  7 +------
 drivers/video/backlight/tps65217_bl.c | 10 +---------
 drivers/video/backlight/wm831x_bl.c   | 13 +------------
 19 files changed, 19 insertions(+), 150 deletions(-)

diff --git a/drivers/video/backlight/88pm860x_bl.c b/drivers/video/backlight/88pm860x_bl.c
index 20d96a5ac384..25e409bbb1a2 100644
--- a/drivers/video/backlight/88pm860x_bl.c
+++ b/drivers/video/backlight/88pm860x_bl.c
@@ -121,18 +121,7 @@ static int pm860x_backlight_set(struct backlight_device *bl, int brightness)
 
 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)
-		brightness = 0;
-
-	return pm860x_backlight_set(bl, brightness);
+	return pm860x_backlight_set(bl, backlight_get_brightness(bl));
 }
 
 static int pm860x_backlight_get_brightness(struct backlight_device *bl)
diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
index 0f63f76723a5..686988c3df3a 100644
--- a/drivers/video/backlight/adp5520_bl.c
+++ b/drivers/video/backlight/adp5520_bl.c
@@ -65,15 +65,7 @@ static int adp5520_bl_set(struct backlight_device *bl, int brightness)
 
 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)
-		brightness = 0;
-
-	return adp5520_bl_set(bl, brightness);
+	return adp5520_bl_set(bl, backlight_get_brightness(bl));
 }
 
 static int adp5520_bl_get_brightness(struct backlight_device *bl)
diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
index 19968104fc47..ddc7f5f0401f 100644
--- a/drivers/video/backlight/adp8860_bl.c
+++ b/drivers/video/backlight/adp8860_bl.c
@@ -361,15 +361,7 @@ static int adp8860_bl_set(struct backlight_device *bl, int brightness)
 
 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)
-		brightness = 0;
-
-	return adp8860_bl_set(bl, brightness);
+	return adp8860_bl_set(bl, backlight_get_brightness(bl));
 }
 
 static int adp8860_bl_get_brightness(struct backlight_device *bl)
diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
index 4c0032010cfe..8b5213a39527 100644
--- a/drivers/video/backlight/adp8870_bl.c
+++ b/drivers/video/backlight/adp8870_bl.c
@@ -399,15 +399,7 @@ static int adp8870_bl_set(struct backlight_device *bl, int brightness)
 
 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)
-		brightness = 0;
-
-	return adp8870_bl_set(bl, brightness);
+	return adp8870_bl_set(bl, backlight_get_brightness(bl));
 }
 
 static int adp8870_bl_get_brightness(struct backlight_device *bl)
diff --git a/drivers/video/backlight/bd6107.c b/drivers/video/backlight/bd6107.c
index d5d5fb457e78..515184fbe33a 100644
--- a/drivers/video/backlight/bd6107.c
+++ b/drivers/video/backlight/bd6107.c
@@ -82,12 +82,7 @@ static int bd6107_write(struct bd6107 *bd, u8 reg, u8 data)
 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))
-		brightness = 0;
+	int brightness = backlight_get_brightness(backlight);
 
 	if (brightness) {
 		bd6107_write(bd, BD6107_PORTSEL, BD6107_PORTSEL_LEDM(2) |
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c
index 25ef0cbd7583..33f5d80495e6 100644
--- a/drivers/video/backlight/corgi_lcd.c
+++ b/drivers/video/backlight/corgi_lcd.c
@@ -420,13 +420,7 @@ static int corgi_bl_set_intensity(struct corgi_lcd *lcd, int intensity)
 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)
-		intensity = 0;
+	int intensity = backlight_get_brightness(bd);
 
 	if (corgibl_flags & CORGIBL_SUSPENDED)
 		intensity = 0;
diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c
index 62540e4bdedb..71f21bbc7a9f 100644
--- a/drivers/video/backlight/da903x_bl.c
+++ b/drivers/video/backlight/da903x_bl.c
@@ -77,18 +77,7 @@ static int da903x_backlight_set(struct backlight_device *bl, int brightness)
 
 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)
-		brightness = 0;
-
-	return da903x_backlight_set(bl, brightness);
+	return da903x_backlight_set(bl, backlight_get_brightness(bl));
 }
 
 static int da903x_backlight_get_brightness(struct backlight_device *bl)
diff --git a/drivers/video/backlight/ep93xx_bl.c b/drivers/video/backlight/ep93xx_bl.c
index 4149e0b2f83c..2387009d452d 100644
--- a/drivers/video/backlight/ep93xx_bl.c
+++ b/drivers/video/backlight/ep93xx_bl.c
@@ -36,13 +36,7 @@ static int ep93xxbl_set(struct backlight_device *bl, int brightness)
 
 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)
-		brightness = 0;
-
-	return ep93xxbl_set(bl, brightness);
+	return ep93xxbl_set(bl, backlight_get_brightness(bl));
 }
 
 static int ep93xxbl_get_brightness(struct backlight_device *bl)
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c
index 8ea42b8d9bc8..9123c33def05 100644
--- a/drivers/video/backlight/hp680_bl.c
+++ b/drivers/video/backlight/hp680_bl.c
@@ -33,12 +33,8 @@ static void hp680bl_send_intensity(struct backlight_device *bd)
 {
 	unsigned long flags;
 	u16 v;
-	int intensity = bd->props.brightness;
+	int intensity = backlight_get_brightness(bd);
 
-	if (bd->props.power != FB_BLANK_UNBLANK)
-		intensity = 0;
-	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
-		intensity = 0;
 	if (hp680bl_suspended)
 		intensity = 0;
 
diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
index 1dfe13c18925..55794b239cff 100644
--- a/drivers/video/backlight/kb3886_bl.c
+++ b/drivers/video/backlight/kb3886_bl.c
@@ -87,12 +87,8 @@ static const struct dmi_system_id kb3886bl_device_table[] __initconst = {
 
 static int kb3886bl_send_intensity(struct backlight_device *bd)
 {
-	int intensity = bd->props.brightness;
+	int intensity = backlight_get_brightness(bd);
 
-	if (bd->props.power != FB_BLANK_UNBLANK)
-		intensity = 0;
-	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
-		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..f54d256e2d54 100644
--- a/drivers/video/backlight/led_bl.c
+++ b/drivers/video/backlight/led_bl.c
@@ -54,12 +54,7 @@ static void led_bl_power_off(struct led_bl_data *priv)
 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)
-		brightness = 0;
+	int brightness = backlight_get_brightness(bl);
 
 	if (brightness > 0)
 		led_bl_set_brightness(priv, brightness);
diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
index 0c7830f793de..1df1b6643c0b 100644
--- a/drivers/video/backlight/lm3533_bl.c
+++ b/drivers/video/backlight/lm3533_bl.c
@@ -39,14 +39,8 @@ static inline int lm3533_bl_get_ctrlbank_id(struct lm3533_bl *bl)
 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)
-		brightness = 0;
-
-	return lm3533_ctrlbank_set_brightness(&bl->cb, (u8)brightness);
+	return lm3533_ctrlbank_set_brightness(&bl->cb, backlight_get_brightness(bd));
 }
 
 static int lm3533_bl_get_brightness(struct backlight_device *bd)
diff --git a/drivers/video/backlight/locomolcd.c b/drivers/video/backlight/locomolcd.c
index cdc02e04f89d..297ee2e1ab0b 100644
--- a/drivers/video/backlight/locomolcd.c
+++ b/drivers/video/backlight/locomolcd.c
@@ -111,12 +111,8 @@ static int current_intensity;
 
 static int locomolcd_set_intensity(struct backlight_device *bd)
 {
-	int intensity = bd->props.brightness;
+	int intensity = backlight_get_brightness(bd);
 
-	if (bd->props.power != FB_BLANK_UNBLANK)
-		intensity = 0;
-	if (bd->props.fb_blank != FB_BLANK_UNBLANK)
-		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..1842ae9a55f8 100644
--- a/drivers/video/backlight/lv5207lp.c
+++ b/drivers/video/backlight/lv5207lp.c
@@ -46,12 +46,7 @@ static int lv5207lp_write(struct lv5207lp *lv, u8 reg, u8 data)
 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))
-		brightness = 0;
+	int brightness = backlight_get_brightness(backlight);
 
 	if (brightness) {
 		lv5207lp_write(lv, LV5207LP_CTRL1,
diff --git a/drivers/video/backlight/max8925_bl.c b/drivers/video/backlight/max8925_bl.c
index 97cc260ff9d1..e607ec6fd4bf 100644
--- a/drivers/video/backlight/max8925_bl.c
+++ b/drivers/video/backlight/max8925_bl.c
@@ -64,18 +64,7 @@ static int max8925_backlight_set(struct backlight_device *bl, int brightness)
 
 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)
-		brightness = 0;
-
-	return max8925_backlight_set(bl, brightness);
+	return max8925_backlight_set(bl, backlight_get_brightness(bl));
 }
 
 static int max8925_backlight_get_brightness(struct backlight_device *bl)
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 82b8d7594701..eff64db2e02e 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -108,14 +108,9 @@ static int compute_duty_cycle(struct pwm_bl_data *pb, int brightness)
 static int pwm_backlight_update_status(struct backlight_device *bl)
 {
 	struct pwm_bl_data *pb = bl_get_data(bl);
-	int brightness = bl->props.brightness;
+	int brightness = backlight_get_brightness(bl);
 	struct pwm_state state;
 
-	if (bl->props.power != FB_BLANK_UNBLANK ||
-	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
-	    bl->props.state & BL_CORE_FBBLANK)
-		brightness = 0;
-
 	if (pb->notify)
 		brightness = pb->notify(pb->dev, brightness);
 
diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c
index c25c31199952..3bc7800eb0a9 100644
--- a/drivers/video/backlight/qcom-wled.c
+++ b/drivers/video/backlight/qcom-wled.c
@@ -433,14 +433,9 @@ static int wled5_ovp_delay(struct wled *wled)
 static int wled_update_status(struct backlight_device *bl)
 {
 	struct wled *wled = bl_get_data(bl);
-	u16 brightness = bl->props.brightness;
+	u16 brightness = backlight_get_brightness(bl);
 	int rc = 0;
 
-	if (bl->props.power != FB_BLANK_UNBLANK ||
-	    bl->props.fb_blank != FB_BLANK_UNBLANK ||
-	    bl->props.state & BL_CORE_FBBLANK)
-		brightness = 0;
-
 	mutex_lock(&wled->lock);
 	if (brightness) {
 		rc = wled->wled_set_brightness(wled, brightness);
diff --git a/drivers/video/backlight/tps65217_bl.c b/drivers/video/backlight/tps65217_bl.c
index 762e3feed097..8457166f357f 100644
--- a/drivers/video/backlight/tps65217_bl.c
+++ b/drivers/video/backlight/tps65217_bl.c
@@ -77,15 +77,7 @@ static int tps65217_bl_update_status(struct backlight_device *bl)
 {
 	struct tps65217_bl *tps65217_bl = bl_get_data(bl);
 	int rc;
-	int brightness = bl->props.brightness;
-
-	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 */
-		brightness = 0;
+	int brightness = backlight_get_brightness(bl);
 
 	if (brightness > 0) {
 		rc = tps65217_reg_write(tps65217_bl->tps,
diff --git a/drivers/video/backlight/wm831x_bl.c b/drivers/video/backlight/wm831x_bl.c
index e55977d54c15..c5aaee205bdf 100644
--- a/drivers/video/backlight/wm831x_bl.c
+++ b/drivers/video/backlight/wm831x_bl.c
@@ -91,18 +91,7 @@ static int wm831x_backlight_set(struct backlight_device *bl, int brightness)
 
 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)
-		brightness = 0;
-
-	return wm831x_backlight_set(bl, brightness);
+	return wm831x_backlight_set(bl, backlight_get_brightness(bl));
 }
 
 static int wm831x_backlight_get_brightness(struct backlight_device *bl)
-- 
2.25.1

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

* [PATCH v5 18/19] backlight: drop backlight_put()
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (16 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 17/19] backlight: use backlight_get_brightness() Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-19  8:07 ` [PATCH v5 19/19] backlight: make of_find_backlight static Sam Ravnborg
  2020-07-20  9:36 ` [PATCH v5 0/19] backlight: backlight updates Lee Jones
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

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>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.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 93ae8c63fe4c..d8387c8e7112 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -718,7 +718,10 @@ EXPORT_SYMBOL(of_find_backlight);
 
 static void devm_backlight_release(void *data)
 {
-	backlight_put(data);
+	struct backlight_device *bd = data;
+
+	if (bd)
+		put_device(&bd->dev);
 }
 
 /**
@@ -746,7 +749,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 38db67588b16..f3b484c99789 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -388,16 +388,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] 24+ messages in thread

* [PATCH v5 19/19] backlight: make of_find_backlight static
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (17 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 18/19] backlight: drop backlight_put() Sam Ravnborg
@ 2020-07-19  8:07 ` Sam Ravnborg
  2020-07-20  9:36 ` [PATCH v5 0/19] backlight: backlight updates Lee Jones
  19 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-19  8:07 UTC (permalink / raw)
  To: dri-devel, Jingoo Han, Lee Jones, Daniel Thompson
  Cc: Andy Gross, Bartlomiej Zolnierkiewicz, Bjorn Andersson,
	Daniel Vetter, David Airlie, Emil Velikov, Jonathan Corbet,
	linux-arm-msm, linux-pwm, Maarten Lankhorst, Maxime Ripard,
	Michael Hennerich, patches, Support Opensource, Thierry Reding,
	Thomas Zimmermann, Uwe Kleine-Konig, Peter Ujfalusi,
	Tomi Valkeinen

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.

v3:
  - Move doc for devm_of_find_backlight out of this patch

v2:
  - Editorial corrections (Daniel)
  - Returns => RETURNS (Daniel)

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.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 | 18 +-----------------
 include/linux/backlight.h           |  6 ------
 2 files changed, 1 insertion(+), 23 deletions(-)

diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index d8387c8e7112..ff8406a15545 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -673,22 +673,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;
@@ -714,7 +699,6 @@ struct backlight_device *of_find_backlight(struct device *dev)
 
 	return bd;
 }
-EXPORT_SYMBOL(of_find_backlight);
 
 static void devm_backlight_release(void *data)
 {
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index f3b484c99789..8b43fd90d84a 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -477,14 +477,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] 24+ messages in thread

* Re: [PATCH v5 14/19] backlight: cr_bllcd: introduce gpio-backlight semantics
  2020-07-19  8:07 ` [PATCH v5 14/19] backlight: cr_bllcd: introduce gpio-backlight semantics Sam Ravnborg
@ 2020-07-20  8:48   ` Daniel Thompson
  2020-07-20  9:14     ` Sam Ravnborg
  0 siblings, 1 reply; 24+ messages in thread
From: Daniel Thompson @ 2020-07-20  8:48 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Lee Jones, Andy Gross,
	Bartlomiej Zolnierkiewicz, Bjorn Andersson, Daniel Vetter,
	David Airlie, Emil Velikov, Jonathan Corbet, linux-arm-msm,
	linux-pwm, Maarten Lankhorst, Maxime Ripard, Michael Hennerich,
	patches, Support Opensource, Thierry Reding, Thomas Zimmermann,
	Uwe

On Sun, Jul 19, 2020 at 10:07:38AM +0200, Sam Ravnborg wrote:
> cr_bllcd can turn backlight ON or OFF.
> Fix semantitics so they equals what we know from gpio-backlight.
> brightness == 0   => backlight off
> brightness == 1   => backlight on
> 
> Use the backlight_get_brightness() helper to simplify the code.
> 
> v2:
>   - reworked to introduce gpio-backlight semantics (Daniel)

Wasn't this added for v5? However, I spotted this change amoung the
other patches so no worries...


> 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>


Daniel.

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

* Re: [PATCH v5 14/19] backlight: cr_bllcd: introduce gpio-backlight semantics
  2020-07-20  8:48   ` Daniel Thompson
@ 2020-07-20  9:14     ` Sam Ravnborg
  0 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-20  9:14 UTC (permalink / raw)
  To: Daniel Thompson
  Cc: dri-devel, Jingoo Han, Lee Jones, Andy Gross,
	Bartlomiej Zolnierkiewicz, Bjorn Andersson, Daniel Vetter,
	David Airlie, Emil Velikov, Jonathan Corbet, linux-arm-msm,
	linux-pwm, Maarten Lankhorst, Maxime Ripard, Michael Hennerich,
	patches, Support Opensource, Thierry Reding, Thomas Zimmermann,
	Uwe

On Mon, Jul 20, 2020 at 09:48:22AM +0100, Daniel Thompson wrote:
> On Sun, Jul 19, 2020 at 10:07:38AM +0200, Sam Ravnborg wrote:
> > cr_bllcd can turn backlight ON or OFF.
> > Fix semantitics so they equals what we know from gpio-backlight.
> > brightness == 0   => backlight off
> > brightness == 1   => backlight on
> > 
> > Use the backlight_get_brightness() helper to simplify the code.
> > 
> > v2:
> >   - reworked to introduce gpio-backlight semantics (Daniel)
> 
> Wasn't this added for v5? However, I spotted this change amoung the
> other patches so no worries...

I do not increment version for individual patches unless there are
changes. So this is the second version of this patch, but included in the
v5 submission.
But I can see how this can confuse the receiver.
I will consider to adapt to the practice to indicate version of submission
and not the individual patches.


> 
> 
> > 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>
Very much appreciated - thanks!

	Sam

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

* Re: [PATCH v5 0/19] backlight: backlight updates
  2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
                   ` (18 preceding siblings ...)
  2020-07-19  8:07 ` [PATCH v5 19/19] backlight: make of_find_backlight static Sam Ravnborg
@ 2020-07-20  9:36 ` Lee Jones
  2020-07-20 11:01   ` Sam Ravnborg
  19 siblings, 1 reply; 24+ messages in thread
From: Lee Jones @ 2020-07-20  9:36 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: dri-devel, Jingoo Han, Daniel Thompson, Andy Gross,
	Bartlomiej Zolnierkiewicz, Bjorn Andersson, Daniel Vetter,
	David Airlie, Emil Velikov, Jonathan Corbet, linux-arm-msm,
	linux-pwm, Maarten Lankhorst, Maxime Ripard, Michael Hennerich,
	patches, Support Opensource, Thierry Reding, Thomas Zimmermann

On Sun, 19 Jul 2020, Sam Ravnborg wrote:

> Hi all.
> 
> Follow-up on v4 - with only a few changes listed below and
> in the individual patches.
> Thanks for all the reviews and the feedback on the patches!
> 
> I am planning a follow-up on this patchset to update the
> backlight drivers all over to use backlight_get_brightness()
> and backlight_is_blank() as appropriate.

[...]

> Sam Ravnborg (19):
>       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: introduce backlight_get_brightness()
>       backlight: as3711_bl: simplify update_status
>       backlight: cr_bllcd: introduce gpio-backlight semantics
>       backlight: gpio_backlight: simplify update_status()
>       backlight: jornada720_bl: introduce backlight_is_blank()
>       backlight: use backlight_get_brightness()
>       backlight: drop backlight_put()
>       backlight: make of_find_backlight static

All applied, but to be honest, that was quite painful.

A few notes for subsequent patches.

 - Enable spell-checkers in your editors
   - I fixed the issues up for you here - there were quite a few!
 - Run ./checkpatch.pl before submitting - here's what I find useful
   * .git/hooks/post-commit: https://pastebin.ubuntu.com/p/WpPFd6M2rB/
 - Please keep the in-patch changelog below the '---' line, so that it
   does not end up in the final commit log
 - Cc: lines *above* the *-bys please
 - Cc: lines dropped for any *-bys provided
 - Lines wrapped ~72 chars (not 50)
 - One whole empty line spacing between paragraphs
 - Ensure you use the formatting expected of the subsystem - in the
   case of Backlight it's:

     <subsystem>: <file>: Subject beginning with an upper-case char

   A `git log --oneline -- subsystem` would give you a good idea of
   what's expected.

-- 
lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH v5 0/19] backlight: backlight updates
  2020-07-20  9:36 ` [PATCH v5 0/19] backlight: backlight updates Lee Jones
@ 2020-07-20 11:01   ` Sam Ravnborg
  0 siblings, 0 replies; 24+ messages in thread
From: Sam Ravnborg @ 2020-07-20 11:01 UTC (permalink / raw)
  To: Lee Jones
  Cc: dri-devel, Jingoo Han, Daniel Thompson, Andy Gross,
	Bartlomiej Zolnierkiewicz, Bjorn Andersson, Daniel Vetter,
	David Airlie, Emil Velikov, Jonathan Corbet, linux-arm-msm,
	linux-pwm, Maarten Lankhorst, Maxime Ripard, Michael Hennerich,
	patches, Support Opensource, Thierry Reding, Thomas Zimmermann

Hi Lee.

On Mon, Jul 20, 2020 at 10:36:01AM +0100, Lee Jones wrote:
> On Sun, 19 Jul 2020, Sam Ravnborg wrote:
> 
> > Hi all.
> > 
> > Follow-up on v4 - with only a few changes listed below and
> > in the individual patches.
> > Thanks for all the reviews and the feedback on the patches!
> > 
> > I am planning a follow-up on this patchset to update the
> > backlight drivers all over to use backlight_get_brightness()
> > and backlight_is_blank() as appropriate.
> 
> [...]
> 
> > Sam Ravnborg (19):
> >       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: introduce backlight_get_brightness()
> >       backlight: as3711_bl: simplify update_status
> >       backlight: cr_bllcd: introduce gpio-backlight semantics
> >       backlight: gpio_backlight: simplify update_status()
> >       backlight: jornada720_bl: introduce backlight_is_blank()
> >       backlight: use backlight_get_brightness()
> >       backlight: drop backlight_put()
> >       backlight: make of_find_backlight static
> 
> All applied, but to be honest, that was quite painful.
That was not the intention :-(

> 
> A few notes for subsequent patches.
> 
>  - Enable spell-checkers in your editors
>    - I fixed the issues up for you here - there were quite a few!
>  - Run ./checkpatch.pl before submitting - here's what I find useful
>    * .git/hooks/post-commit: https://pastebin.ubuntu.com/p/WpPFd6M2rB/
>  - Please keep the in-patch changelog below the '---' line, so that it
>    does not end up in the final commit log
>  - Cc: lines *above* the *-bys please
>  - Cc: lines dropped for any *-bys provided
>  - Lines wrapped ~72 chars (not 50)
>  - One whole empty line spacing between paragraphs
>  - Ensure you use the formatting expected of the subsystem - in the
>    case of Backlight it's:
> 
>      <subsystem>: <file>: Subject beginning with an upper-case char
> 
>    A `git log --oneline -- subsystem` would give you a good idea of
>    what's expected.

Thanks for the input - I will use these points as guideline for the next
batch of backlight patches.

	Sam

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

end of thread, other threads:[~2020-07-20 11:01 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-19  8:07 [PATCH v5 0/19] backlight: backlight updates Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 01/19] backlight: refactor fb_notifier_callback() Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 02/19] backlight: add backlight_is_blank() Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 03/19] backlight: improve backlight_ops documentation Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 04/19] backlight: improve backlight_properties documentation Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 05/19] backlight: improve backlight_device documentation Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 06/19] backlight: document inline functions in backlight.h Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 07/19] backlight: document enums " Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 08/19] backlight: remove the unused backlight_bl driver Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 09/19] backlight: drop extern from prototypes Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 10/19] backlight: add overview and update existing doc Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 11/19] backlight: wire up kernel-doc documentation Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 12/19] backlight: introduce backlight_get_brightness() Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 13/19] backlight: as3711_bl: simplify update_status Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 14/19] backlight: cr_bllcd: introduce gpio-backlight semantics Sam Ravnborg
2020-07-20  8:48   ` Daniel Thompson
2020-07-20  9:14     ` Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 15/19] backlight: gpio_backlight: simplify update_status() Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 16/19] backlight: jornada720_bl: introduce backlight_is_blank() Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 17/19] backlight: use backlight_get_brightness() Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 18/19] backlight: drop backlight_put() Sam Ravnborg
2020-07-19  8:07 ` [PATCH v5 19/19] backlight: make of_find_backlight static Sam Ravnborg
2020-07-20  9:36 ` [PATCH v5 0/19] backlight: backlight updates Lee Jones
2020-07-20 11:01   ` Sam Ravnborg

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).