git: 78281dd98629 - stable/13 - linuxkpi: Add backlight_device_set_brightness

From: Emmanuel Vadot <manu_at_FreeBSD.org>
Date: Sat, 05 Mar 2022 11:34:19 UTC
The branch stable/13 has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=78281dd98629bb662bc54be90e9ca5ee6698b505

commit 78281dd98629bb662bc54be90e9ca5ee6698b505
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2022-02-15 11:05:07 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2022-03-05 11:12:44 +0000

    linuxkpi: Add backlight_device_set_brightness
    
    This simply set the brightness of a backlight device.
    Needed by drm-kmod v5.8
    
    Reviewed by:    bz, emaste
    MFC after:      2 weeks
    Sponsored by:   Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D34285
    
    (cherry picked from commit 2cc3af6e1d795c6d33afaf994c18abaab87a443b)
---
 sys/compat/linuxkpi/common/include/linux/backlight.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/backlight.h b/sys/compat/linuxkpi/common/include/linux/backlight.h
index 38b3786e738d..9591a4b671ab 100644
--- a/sys/compat/linuxkpi/common/include/linux/backlight.h
+++ b/sys/compat/linuxkpi/common/include/linux/backlight.h
@@ -91,6 +91,16 @@ backlight_force_update(struct backlight_device *bd, int reason)
 	bd->props.brightness = bd->ops->get_brightness(bd);
 }
 
+static inline int
+backlight_device_set_brightness(struct backlight_device *bd, int brightness)
+{
+
+	if (brightness > bd->props.max_brightness)
+		return (EINVAL);
+	bd->props.brightness = brightness;
+	return (bd->ops->update_status(bd));
+}
+
 static inline int
 backlight_enable(struct backlight_device *bd)
 {