History

Merge tag 'backlight-next-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight

Pull backlight updates from Lee Jones: "Core Framework: - Trivial: Code refactoring - New API backlight_is_blank() - New API backlight_get_brightness() - Additional/reworked documentation - Remove 'extern' labels from prototypes - Drop backlight_put() - Staticify of_find_backlight() Driver Removal: - Removal of unused OT200 driver - Removal of unused Generic Backlight driver Fix-ups - Bunch of W=1 warning fixes - Convert to GPIO descriptors; sky81452 - Move platform data handling into driver; sky81452 - Remove superfluous code; lms501kf03 - Many instances of using new APIs" * tag 'backlight-next-5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight: (34 commits) video: backlight: cr_bllcd: Remove unused variable 'intensity' backlight: backlight: Make of_find_backlight static backlight: backlight: Drop backlight_put() backlight: Use backlight_get_brightness() throughout backlight: jornada720_bl: Introduce backlight_is_blank() backlight: gpio_backlight: Simplify update_status() backlight: cr_bllcd: Introduce gpio-backlight semantics backlight: as3711_bl: Simplify update_status backlight: backlight: Introduce backlight_get_brightness() doc-rst: Wire-up Backlight kernel-doc documentation backlight: backlight: Add overview and update existing doc backlight: backlight: Drop extern from prototypes backlight: generic_bl: Remove this driver as it is unused backlight: backlight: Document enums in backlight.h backlight: backlight: Document inline functions in backlight.h backlight: backlight: Improve backlight_device documentation backlight: backlight: Improve backlight_properties documentation backlight: backlight: Improve backlight_ops documentation backlight: backlight: Add backlight_is_blank() backlight: backlight: Refactor fb_notifier_callback() ...

Linus Torvalds committed 6 years ago

Commit 96f970f2 parents c636eef 7eb99a339 files · +538 −717Browse files

Unified · Split

39 files
  1. Documentation/gpu/backlight.rst +12 −0
  2. Documentation/gpu/index.rst +1 −0
  3. drivers/mfd/sky81452.c +0 −2
  4. drivers/video/backlight/88pm860x_bl.c +1 −12
  5. drivers/video/backlight/Kconfig +0 −15
  6. drivers/video/backlight/Makefile +0 −2
  7. drivers/video/backlight/adp5520_bl.c +1 −9
  8. drivers/video/backlight/adp8860_bl.c +1 −9
  9. drivers/video/backlight/adp8870_bl.c +1 −9
  10. drivers/video/backlight/as3711_bl.c +2 −9
  11. drivers/video/backlight/backlight.c +126 −80
  12. drivers/video/backlight/bd6107.c +1 −6
  13. drivers/video/backlight/corgi_lcd.c +1 −7
  14. drivers/video/backlight/cr_bllcd.c +9 −17
  15. drivers/video/backlight/da903x_bl.c +1 −12
  16. drivers/video/backlight/ep93xx_bl.c +1 −7
  17. drivers/video/backlight/generic_bl.c +0 −110
  18. drivers/video/backlight/gpio_backlight.c +2 −15
  19. drivers/video/backlight/hp680_bl.c +1 −5
  20. drivers/video/backlight/ili922x.c +6 −2
  21. drivers/video/backlight/jornada720_bl.c +1 −1
  22. drivers/video/backlight/kb3886_bl.c +1 −5
  23. drivers/video/backlight/lcd.c +1 −0
  24. drivers/video/backlight/led_bl.c +1 −6
  25. drivers/video/backlight/lm3533_bl.c +2 −8
  26. drivers/video/backlight/lm3630a_bl.c +2 −2
  27. drivers/video/backlight/lms501kf03.c +0 −9
  28. drivers/video/backlight/locomolcd.c +1 −5
  29. drivers/video/backlight/lv5207lp.c +1 −6
  30. drivers/video/backlight/max8925_bl.c +1 −12
  31. drivers/video/backlight/ot200_bl.c +0 −162
  32. drivers/video/backlight/pwm_bl.c +1 −6
  33. drivers/video/backlight/qcom-wled.c +1 −14
  34. drivers/video/backlight/sky81452-backlight.c +31 −21
  35. drivers/video/backlight/tps65217_bl.c +1 −9
  36. drivers/video/backlight/wm831x_bl.c +1 −12
  37. include/linux/backlight.h +325 −74
  38. include/linux/mfd/sky81452.h +0 −2
  39. include/linux/platform_data/sky81452-backlight.h +0 −35
Documentation/gpu/backlight.rst+12−0
@@ -0,0 +1,12 @@
1+=================
2+Backlight support
3+=================
4+
5+.. kernel-doc:: drivers/video/backlight/backlight.c
6+ :doc: overview
7+
8+.. kernel-doc:: include/linux/backlight.h
9+ :internal:
10+
11+.. kernel-doc:: drivers/video/backlight/backlight.c
12+ :export:
Documentation/gpu/index.rst+1−0
@@ -12,6 +12,7 @@ Linux GPU Driver Developer's Guide · 11 unmodified lines
1212 drm-uapi
1313 drm-client
1414 drivers
15+ backlight
1516 vga-switcheroo
1617 vgaarbiter
1718 todo
drivers/mfd/sky81452.c+0−2
@@ -47,8 +47,6 @@ static int sky81452_probe(struct i2c_client *client, · 46 unmodified lines
4747 memset(cells, 0, sizeof(cells));
4848 cells[0].name = "sky81452-backlight";
4949 cells[0].of_compatible = "skyworks,sky81452-backlight";
50− cells[0].platform_data = pdata->bl_pdata;
51− cells[0].pdata_size = sizeof(*pdata->bl_pdata);
5250 cells[1].name = "sky81452-regulator";
5351 cells[1].platform_data = pdata->regulator_init_data;
5452 cells[1].pdata_size = sizeof(*pdata->regulator_init_data);
drivers/video/backlight/88pm860x_bl.c+1−12
@@ -121,18 +121,7 @@ out: · 120 unmodified lines
121121
122122 static int pm860x_backlight_update_status(struct backlight_device *bl)
123123 {
124− int brightness = bl->props.brightness;
125−
126− if (bl->props.power != FB_BLANK_UNBLANK)
127− brightness = 0;
128−
129− if (bl->props.fb_blank != FB_BLANK_UNBLANK)
130− brightness = 0;
131−
132− if (bl->props.state & BL_CORE_SUSPENDED)
133− brightness = 0;
134−
135− return pm860x_backlight_set(bl, brightness);
124+ return pm860x_backlight_set(bl, backlight_get_brightness(bl));
136125 }
137126
138127 static int pm860x_backlight_get_brightness(struct backlight_device *bl)
drivers/video/backlight/Kconfig+0−15
@@ -173,14 +173,6 @@ config BACKLIGHT_EP93XX · 172 unmodified lines
173173 To compile this driver as a module, choose M here: the module will
174174 be called ep93xx_bl.
175175
176−config BACKLIGHT_GENERIC
177− tristate "Generic (aka Sharp Corgi) Backlight Driver"
178− default y
179− help
180− Say y to enable the generic platform backlight driver previously
181− known as the Corgi backlight driver. If you have a Sharp Zaurus
182− SL-C7xx, SL-Cxx00 or SL-6000x say y.
183−
184176 config BACKLIGHT_IPAQ_MICRO
185177 tristate "iPAQ microcontroller backlight driver"
186178 depends on MFD_IPAQ_MICRO
@@ -386,13 +378,6 @@ config BACKLIGHT_LP8788 · 199 unmodified lines
386378 help
387379 This supports TI LP8788 backlight driver.
388380
389−config BACKLIGHT_OT200
390− tristate "Backlight driver for ot200 visualisation device"
391− depends on CS5535_MFGPT && GPIO_CS5535
392− help
393− To compile this driver as a module, choose M here: the module will be
394− called ot200_bl.
395−
396381 config BACKLIGHT_PANDORA
397382 tristate "Backlight driver for Pandora console"
398383 depends on TWL4030_CORE
drivers/video/backlight/Makefile+0−2
@@ -31,7 +31,6 @@ obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o · 30 unmodified lines
3131 obj-$(CONFIG_BACKLIGHT_DA903X) += da903x_bl.o
3232 obj-$(CONFIG_BACKLIGHT_DA9052) += da9052_bl.o
3333 obj-$(CONFIG_BACKLIGHT_EP93XX) += ep93xx_bl.o
34−obj-$(CONFIG_BACKLIGHT_GENERIC) += generic_bl.o
3534 obj-$(CONFIG_BACKLIGHT_GPIO) += gpio_backlight.o
3635 obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o
3736 obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o
@@ -45,7 +44,6 @@ obj-$(CONFIG_BACKLIGHT_LP8788) += lp8788_bl.o · 7 unmodified lines
4544 obj-$(CONFIG_BACKLIGHT_LV5207LP) += lv5207lp.o
4645 obj-$(CONFIG_BACKLIGHT_MAX8925) += max8925_bl.o
4746 obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
48−obj-$(CONFIG_BACKLIGHT_OT200) += ot200_bl.o
4947 obj-$(CONFIG_BACKLIGHT_PANDORA) += pandora_bl.o
5048 obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o
5149 obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o
drivers/video/backlight/adp5520_bl.c+1−9
@@ -65,15 +65,7 @@ static int adp5520_bl_set(struct backlight_device *bl, int brightness) · 64 unmodified lines
6565
6666 static int adp5520_bl_update_status(struct backlight_device *bl)
6767 {
68− int brightness = bl->props.brightness;
69−
70− if (bl->props.power != FB_BLANK_UNBLANK)
71− brightness = 0;
72−
73− if (bl->props.fb_blank != FB_BLANK_UNBLANK)
74− brightness = 0;
75−
76− return adp5520_bl_set(bl, brightness);
68+ return adp5520_bl_set(bl, backlight_get_brightness(bl));
7769 }
7870
7971 static int adp5520_bl_get_brightness(struct backlight_device *bl)
drivers/video/backlight/adp8860_bl.c+1−9
@@ -361,15 +361,7 @@ static int adp8860_bl_set(struct backlight_device *bl, int brightness) · 360 unmodified lines
361361
362362 static int adp8860_bl_update_status(struct backlight_device *bl)
363363 {
364− int brightness = bl->props.brightness;
365−
366− if (bl->props.power != FB_BLANK_UNBLANK)
367− brightness = 0;
368−
369− if (bl->props.fb_blank != FB_BLANK_UNBLANK)
370− brightness = 0;
371−
372− return adp8860_bl_set(bl, brightness);
364+ return adp8860_bl_set(bl, backlight_get_brightness(bl));
373365 }
374366
375367 static int adp8860_bl_get_brightness(struct backlight_device *bl)
drivers/video/backlight/adp8870_bl.c+1−9
@@ -399,15 +399,7 @@ static int adp8870_bl_set(struct backlight_device *bl, int brightness) · 398 unmodified lines
399399
400400 static int adp8870_bl_update_status(struct backlight_device *bl)
401401 {
402− int brightness = bl->props.brightness;
403−
404− if (bl->props.power != FB_BLANK_UNBLANK)
405− brightness = 0;
406−
407− if (bl->props.fb_blank != FB_BLANK_UNBLANK)
408− brightness = 0;
409−
410− return adp8870_bl_set(bl, brightness);
402+ return adp8870_bl_set(bl, backlight_get_brightness(bl));
411403 }
412404
413405 static int adp8870_bl_get_brightness(struct backlight_device *bl)
drivers/video/backlight/as3711_bl.c+2−9
@@ -104,17 +104,10 @@ static int as3711_bl_update_status(struct backlight_device *bl) · 103 unmodified lines
104104 struct as3711_bl_data *data = bl_get_data(bl);
105105 struct as3711_bl_supply *supply = to_supply(data);
106106 struct as3711 *as3711 = supply->as3711;
107− int brightness = bl->props.brightness;
107+ int brightness;
108108 int ret = 0;
109109
110− dev_dbg(&bl->dev, "%s(): brightness %u, pwr %x, blank %x, state %x\n",
111− __func__, bl->props.brightness, bl->props.power,
112− bl->props.fb_blank, bl->props.state);
113−
114− if (bl->props.power != FB_BLANK_UNBLANK ||
115− bl->props.fb_blank != FB_BLANK_UNBLANK ||
116− bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
117− brightness = 0;
110+ brightness = backlight_get_brightness(bl);
118111
119112 if (data->type == AS3711_BL_SU1) {
120113 ret = as3711_set_brightness_v(as3711, brightness,
drivers/video/backlight/backlight.c+126−80
@@ -22,6 +22,47 @@ · 21 unmodified lines
2222 #include <asm/backlight.h>
2323 #endif
2424
25+/**
26+ * DOC: overview
27+ *
28+ * The backlight core supports implementing backlight drivers.
29+ *
30+ * A backlight driver registers a driver using
31+ * devm_backlight_device_register(). The properties of the backlight
32+ * driver such as type and max_brightness must be specified.
33+ * When the core detect changes in for example brightness or power state
34+ * the update_status() operation is called. The backlight driver shall
35+ * implement this operation and use it to adjust backlight.
36+ *
37+ * Several sysfs attributes are provided by the backlight core::
38+ *
39+ * - brightness R/W, set the requested brightness level
40+ * - actual_brightness RO, the brightness level used by the HW
41+ * - max_brightness RO, the maximum brightness level supported
42+ *
43+ * See Documentation/ABI/stable/sysfs-class-backlight for the full list.
44+ *
45+ * The backlight can be adjusted using the sysfs interface, and
46+ * the backlight driver may also support adjusting backlight using
47+ * a hot-key or some other platform or firmware specific way.
48+ *
49+ * The driver must implement the get_brightness() operation if
50+ * the HW do not support all the levels that can be specified in
51+ * brightness, thus providing user-space access to the actual level
52+ * via the actual_brightness attribute.
53+ *
54+ * When the backlight changes this is reported to user-space using
55+ * an uevent connected to the actual_brightness attribute.
56+ * When brightness is set by platform specific means, for example
57+ * a hot-key to adjust backlight, the driver must notify the backlight
58+ * core that brightness has changed using backlight_force_update().
59+ *
60+ * The backlight driver core receives notifications from fbdev and
61+ * if the event is FB_EVENT_BLANK and if the value of blank, from the
62+ * FBIOBLANK ioctrl, results in a change in the backlight state the
63+ * update_status() operation is called.
64+ */
65+
2566 static struct list_head backlight_dev_list;
2667 static struct mutex backlight_dev_list_mutex;
2768 static struct blocking_notifier_head backlight_notifier;
@@ -40,9 +81,17 @@ static const char *const backlight_scale_types[] = { · 12 unmodified lines
4081
4182 #if defined(CONFIG_FB) || (defined(CONFIG_FB_MODULE) && \
4283 defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE))
43−/* This callback gets called when something important happens inside a
44− * framebuffer driver. We're looking if that important event is blanking,
45− * and if it is and necessary, we're switching backlight power as well ...
84+/*
85+ * fb_notifier_callback
86+ *
87+ * This callback gets called when something important happens inside a
88+ * framebuffer driver. The backlight core only cares about FB_BLANK_UNBLANK
89+ * which is reported to the driver using backlight_update_status()
90+ * as a state change.
91+ *
92+ * There may be several fbdev's connected to the backlight device,
93+ * in which case they are kept track of. A state change is only reported
94+ * if there is a change in backlight for the specified fbdev.
4695 */
4796 static int fb_notifier_callback(struct notifier_block *self,
4897 unsigned long event, void *data)
@@ -58,28 +107,29 @@ static int fb_notifier_callback(struct notifier_block *self, · 9 unmodified lines
58107
59108 bd = container_of(self, struct backlight_device, fb_notif);
60109 mutex_lock(&bd->ops_lock);
61− if (bd->ops)
62− if (!bd->ops->check_fb ||
63− bd->ops->check_fb(bd, evdata->info)) {
64− fb_blank = *(int *)evdata->data;
65− if (fb_blank == FB_BLANK_UNBLANK &&
66− !bd->fb_bl_on[node]) {
67− bd->fb_bl_on[node] = true;
68− if (!bd->use_count++) {
69− bd->props.state &= ~BL_CORE_FBBLANK;
70− bd->props.fb_blank = FB_BLANK_UNBLANK;
71− backlight_update_status(bd);
72− }
73− } else if (fb_blank != FB_BLANK_UNBLANK &&
74− bd->fb_bl_on[node]) {
75− bd->fb_bl_on[node] = false;
76− if (!(--bd->use_count)) {
77− bd->props.state |= BL_CORE_FBBLANK;
78− bd->props.fb_blank = fb_blank;
79− backlight_update_status(bd);
80− }
81− }
110+
111+ if (!bd->ops)
112+ goto out;
113+ if (bd->ops->check_fb && !bd->ops->check_fb(bd, evdata->info))
114+ goto out;
115+
116+ fb_blank = *(int *)evdata->data;
117+ if (fb_blank == FB_BLANK_UNBLANK && !bd->fb_bl_on[node]) {
118+ bd->fb_bl_on[node] = true;
119+ if (!bd->use_count++) {
120+ bd->props.state &= ~BL_CORE_FBBLANK;
121+ bd->props.fb_blank = FB_BLANK_UNBLANK;
122+ backlight_update_status(bd);
82123 }
124+ } else if (fb_blank != FB_BLANK_UNBLANK && bd->fb_bl_on[node]) {
125+ bd->fb_bl_on[node] = false;
126+ if (!(--bd->use_count)) {
127+ bd->props.state |= BL_CORE_FBBLANK;
128+ bd->props.fb_blank = fb_blank;
129+ backlight_update_status(bd);
130+ }
131+ }
132+out:
83133 mutex_unlock(&bd->ops_lock);
84134 return 0;
85135 }
@@ -320,9 +370,13 @@ ATTRIBUTE_GROUPS(bl_device); · 234 unmodified lines
320370 * backlight_force_update - tell the backlight subsystem that hardware state
321371 * has changed
322372 * @bd: the backlight device to update
373+ * @reason: reason for update
323374 *
324375 * Updates the internal state of the backlight in response to a hardware event,
325− * and generate a uevent to notify userspace
376+ * and generates an uevent to notify userspace. A backlight driver shall call
377+ * backlight_force_update() when the backlight is changed using, for example,
378+ * a hot-key. The updated brightness is read using get_brightness() and the
379+ * brightness value is reported using an uevent.
326380 */
327381 void backlight_force_update(struct backlight_device *bd,
328382 enum backlight_update_reason reason)
@@ -335,19 +389,7 @@ void backlight_force_update(struct backlight_device *bd, · 6 unmodified lines
335389 }
336390 EXPORT_SYMBOL(backlight_force_update);
337391
338−/**
339− * backlight_device_register - create and register a new object of
340− * backlight_device class.
341− * @name: the name of the new object(must be the same as the name of the
342− * respective framebuffer device).
343− * @parent: a pointer to the parent device
344− * @devdata: an optional pointer to be stored for private driver use. The
345− * methods may retrieve it by using bl_get_data(bd).
346− * @ops: the backlight operations structure.
347− *
348− * Creates and registers new backlight device. Returns either an
349− * ERR_PTR() or a pointer to the newly allocated device.
350− */
392+/* deprecated - use devm_backlight_device_register() */
351393 struct backlight_device *backlight_device_register(const char *name,
352394 struct device *parent, void *devdata, const struct backlight_ops *ops,
353395 const struct backlight_properties *props)
@@ -414,6 +456,15 @@ struct backlight_device *backlight_device_register(const char *name, · 60 unmodified lines
414456 }
415457 EXPORT_SYMBOL(backlight_device_register);
416458
459+/** backlight_device_get_by_type - find first backlight device of a type
460+ * @type: the type of backlight device
461+ *
462+ * Look up the first backlight device of the specified type
463+ *
464+ * RETURNS:
465+ *
466+ * Pointer to backlight device if any was found. Otherwise NULL.
467+ */
417468 struct backlight_device *backlight_device_get_by_type(enum backlight_type type)
418469 {
419470 bool found = false;
@@ -453,12 +504,7 @@ struct backlight_device *backlight_device_get_by_name(const char *name) · 33 unmodified lines
453504 }
454505 EXPORT_SYMBOL(backlight_device_get_by_name);
455506
456−/**
457− * backlight_device_unregister - unregisters a backlight device object.
458− * @bd: the backlight device object to be unregistered and freed.
459− *
460− * Unregisters a previously registered via backlight_device_register object.
461− */
507+/* deprecated - use devm_backlight_device_unregister() */
462508 void backlight_device_unregister(struct backlight_device *bd)
463509 {
464510 if (!bd)
@@ -506,10 +552,12 @@ static int devm_backlight_device_match(struct device *dev, void *res, · 41 unmodified lines
506552 * backlight_register_notifier - get notified of backlight (un)registration
507553 * @nb: notifier block with the notifier to call on backlight (un)registration
508554 *
509− * @return 0 on success, otherwise a negative error code
510− *
511555 * Register a notifier to get notified when backlight devices get registered
512556 * or unregistered.
557+ *
558+ * RETURNS:
559+ *
560+ * 0 on success, otherwise a negative error code
513561 */
514562 int backlight_register_notifier(struct notifier_block *nb)
515563 {
@@ -521,10 +569,12 @@ EXPORT_SYMBOL(backlight_register_notifier); · 5 unmodified lines
521569 * backlight_unregister_notifier - unregister a backlight notifier
522570 * @nb: notifier block to unregister
523571 *
524− * @return 0 on success, otherwise a negative error code
525− *
526572 * Register a notifier to get notified when backlight devices get registered
527573 * or unregistered.
574+ *
575+ * RETURNS:
576+ *
577+ * 0 on success, otherwise a negative error code
528578 */
529579 int backlight_unregister_notifier(struct notifier_block *nb)
530580 {
@@ -533,19 +583,21 @@ int backlight_unregister_notifier(struct notifier_block *nb) · 2 unmodified lines
533583 EXPORT_SYMBOL(backlight_unregister_notifier);
534584
535585 /**
536− * devm_backlight_device_register - resource managed backlight_device_register()
586+ * devm_backlight_device_register - register a new backlight device
537587 * @dev: the device to register
538588 * @name: the name of the device
539− * @parent: a pointer to the parent device
589+ * @parent: a pointer to the parent device (often the same as @dev)
540590 * @devdata: an optional pointer to be stored for private driver use
541591 * @ops: the backlight operations structure
542592 * @props: the backlight properties
543593 *
544− * @return a struct backlight on success, or an ERR_PTR on error
594+ * Creates and registers new backlight device. When a backlight device
595+ * is registered the configuration must be specified in the @props
596+ * parameter. See description of &backlight_properties.
597+ *
598+ * RETURNS:
545599 *
546− * Managed backlight_device_register(). The backlight_device returned
547− * from this function are automatically freed on driver detach.
548− * See backlight_device_register() for more information.
600+ * struct backlight on success, or an ERR_PTR on error
549601 */
550602 struct backlight_device *devm_backlight_device_register(struct device *dev,
551603 const char *name, struct device *parent, void *devdata,
@@ -573,13 +625,13 @@ struct backlight_device *devm_backlight_device_register(struct device *dev, · 21 unmodified lines
573625 EXPORT_SYMBOL(devm_backlight_device_register);
574626
575627 /**
576− * devm_backlight_device_unregister - resource managed backlight_device_unregister()
628+ * devm_backlight_device_unregister - unregister backlight device
577629 * @dev: the device to unregister
578630 * @bd: the backlight device to unregister
579631 *
580− * Deallocated a backlight allocated with devm_backlight_device_register().
632+ * Deallocates a backlight allocated with devm_backlight_device_register().
581633 * Normally this function will not need to be called and the resource management
582− * code will ensure that the resource is freed.
634+ * code will ensure that the resources are freed.
583635 */
584636 void devm_backlight_device_unregister(struct device *dev,
585637 struct backlight_device *bd)
@@ -621,22 +673,7 @@ struct backlight_device *of_find_backlight_by_node(struct device_node *node) · 35 unmodified lines
621673 EXPORT_SYMBOL(of_find_backlight_by_node);
622674 #endif
623675
624−/**
625− * of_find_backlight - Get backlight device
626− * @dev: Device
627− *
628− * This function looks for a property named 'backlight' on the DT node
629− * connected to @dev and looks up the backlight device.
630− *
631− * Call backlight_put() to drop the reference on the backlight device.
632− *
633− * Returns:
634− * A pointer to the backlight device if found.
635− * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight
636− * device is found.
637− * NULL if there's no backlight property.
638− */
639−struct backlight_device *of_find_backlight(struct device *dev)
676+static struct backlight_device *of_find_backlight(struct device *dev)
640677 {
641678 struct backlight_device *bd = NULL;
642679 struct device_node *np;
@@ -662,20 +699,29 @@ struct backlight_device *of_find_backlight(struct device *dev) · 19 unmodified lines
662699
663700 return bd;
664701 }
665−EXPORT_SYMBOL(of_find_backlight);
666702
667703 static void devm_backlight_release(void *data)
668704 {
669− backlight_put(data);
705+ struct backlight_device *bd = data;
706+
707+ if (bd)
708+ put_device(&bd->dev);
670709 }
671710
672711 /**
673− * devm_of_find_backlight - Resource-managed of_find_backlight()
674− * @dev: Device
712+ * devm_of_find_backlight - find backlight for a device
713+ * @dev: the device
675714 *
676− * Device managed version of of_find_backlight().
677− * The reference on the backlight device is automatically
715+ * This function looks for a property named 'backlight' on the DT node
716+ * connected to @dev and looks up the backlight device. The lookup is
717+ * device managed so the reference to the backlight device is automatically
678718 * dropped on driver detach.
719+ *
720+ * RETURNS:
721+ *
722+ * A pointer to the backlight device if found.
723+ * Error pointer -EPROBE_DEFER if the DT property is set, but no backlight
724+ * device is found. NULL if there's no backlight property.
679725 */
680726 struct backlight_device *devm_of_find_backlight(struct device *dev)
681727 {
@@ -687,7 +733,7 @@ struct backlight_device *devm_of_find_backlight(struct device *dev) · 5 unmodified lines
687733 return bd;
688734 ret = devm_add_action(dev, devm_backlight_release, bd);
689735 if (ret) {
690− backlight_put(bd);
736+ put_device(&bd->dev);
691737 return ERR_PTR(ret);
692738 }
693739 return bd;
drivers/video/backlight/bd6107.c+1−6
@@ -82,12 +82,7 @@ static int bd6107_write(struct bd6107 *bd, u8 reg, u8 data) · 81 unmodified lines
8282 static int bd6107_backlight_update_status(struct backlight_device *backlight)
8383 {
8484 struct bd6107 *bd = bl_get_data(backlight);
85− int brightness = backlight->props.brightness;
86−
87− if (backlight->props.power != FB_BLANK_UNBLANK ||
88− backlight->props.fb_blank != FB_BLANK_UNBLANK ||
89− backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
90− brightness = 0;
85+ int brightness = backlight_get_brightness(backlight);
9186
9287 if (brightness) {
9388 bd6107_write(bd, BD6107_PORTSEL, BD6107_PORTSEL_LEDM(2) |
drivers/video/backlight/corgi_lcd.c+1−7
@@ -420,13 +420,7 @@ static int corgi_bl_set_intensity(struct corgi_lcd *lcd, int intensity) · 419 unmodified lines
420420 static int corgi_bl_update_status(struct backlight_device *bd)
421421 {
422422 struct corgi_lcd *lcd = bl_get_data(bd);
423− int intensity = bd->props.brightness;
424−
425− if (bd->props.power != FB_BLANK_UNBLANK)
426− intensity = 0;
427−
428− if (bd->props.fb_blank != FB_BLANK_UNBLANK)
429− intensity = 0;
423+ int intensity = backlight_get_brightness(bd);
430424
431425 if (corgibl_flags & CORGIBL_SUSPENDED)
432426 intensity = 0;
drivers/video/backlight/cr_bllcd.c+9−17
@@ -59,26 +59,18 @@ struct cr_panel { · 58 unmodified lines
5959
6060 static int cr_backlight_set_intensity(struct backlight_device *bd)
6161 {
62− int intensity = bd->props.brightness;
6362 u32 addr = gpio_bar + CRVML_PANEL_PORT;
6463 u32 cur = inl(addr);
6564
66− if (bd->props.power == FB_BLANK_UNBLANK)
67− intensity = FB_BLANK_UNBLANK;
68− if (bd->props.fb_blank == FB_BLANK_UNBLANK)
69− intensity = FB_BLANK_UNBLANK;
70− if (bd->props.power == FB_BLANK_POWERDOWN)
71− intensity = FB_BLANK_POWERDOWN;
72− if (bd->props.fb_blank == FB_BLANK_POWERDOWN)
73− intensity = FB_BLANK_POWERDOWN;
74−
75− if (intensity == FB_BLANK_UNBLANK) { /* FULL ON */
76− cur &= ~CRVML_BACKLIGHT_OFF;
77− outl(cur, addr);
78− } else if (intensity == FB_BLANK_POWERDOWN) { /* OFF */
65+ if (backlight_get_brightness(bd) == 0) {
66+ /* OFF */
7967 cur |= CRVML_BACKLIGHT_OFF;
8068 outl(cur, addr);
81− } /* anything else, don't bother */
69+ } else {
70+ /* FULL ON */
71+ cur &= ~CRVML_BACKLIGHT_OFF;
72+ outl(cur, addr);
73+ }
8274
8375 return 0;
8476 }
@@ -90,9 +82,9 @@ static int cr_backlight_get_intensity(struct backlight_device *bd) · 5 unmodified lines
9082 u8 intensity;
9183
9284 if (cur & CRVML_BACKLIGHT_OFF)
93− intensity = FB_BLANK_POWERDOWN;
85+ intensity = 0;
9486 else
95− intensity = FB_BLANK_UNBLANK;
87+ intensity = 1;
9688
9789 return intensity;
9890 }
drivers/video/backlight/da903x_bl.c+1−12
@@ -77,18 +77,7 @@ static int da903x_backlight_set(struct backlight_device *bl, int brightness) · 76 unmodified lines
7777
7878 static int da903x_backlight_update_status(struct backlight_device *bl)
7979 {
80− int brightness = bl->props.brightness;
81−
82− if (bl->props.power != FB_BLANK_UNBLANK)
83− brightness = 0;
84−
85− if (bl->props.fb_blank != FB_BLANK_UNBLANK)
86− brightness = 0;
87−
88− if (bl->props.state & BL_CORE_SUSPENDED)
89− brightness = 0;
90−
91− return da903x_backlight_set(bl, brightness);
80+ return da903x_backlight_set(bl, backlight_get_brightness(bl));
9281 }
9382
9483 static int da903x_backlight_get_brightness(struct backlight_device *bl)
drivers/video/backlight/ep93xx_bl.c+1−7
@@ -36,13 +36,7 @@ static int ep93xxbl_set(struct backlight_device *bl, int brightness) · 35 unmodified lines
3636
3737 static int ep93xxbl_update_status(struct backlight_device *bl)
3838 {
39− int brightness = bl->props.brightness;
40−
41− if (bl->props.power != FB_BLANK_UNBLANK ||
42− bl->props.fb_blank != FB_BLANK_UNBLANK)
43− brightness = 0;
44−
45− return ep93xxbl_set(bl, brightness);
39+ return ep93xxbl_set(bl, backlight_get_brightness(bl));
4640 }
4741
4842 static int ep93xxbl_get_brightness(struct backlight_device *bl)
drivers/video/backlight/generic_bl.c+0−110
@@ -1,110 +0,0 @@
1−// SPDX-License-Identifier: GPL-2.0-only
2−/*
3− * Generic Backlight Driver
4− *
5− * Copyright (c) 2004-2008 Richard Purdie
6− */
7−
8−#include <linux/module.h>
9−#include <linux/kernel.h>
10−#include <linux/init.h>
11−#include <linux/platform_device.h>
12−#include <linux/mutex.h>
13−#include <linux/fb.h>
14−#include <linux/backlight.h>
15−
16−static int genericbl_intensity;
17−static struct backlight_device *generic_backlight_device;
18−static struct generic_bl_info *bl_machinfo;
19−
20−static int genericbl_send_intensity(struct backlight_device *bd)
21−{
22− int intensity = bd->props.brightness;
23−
24− if (bd->props.power != FB_BLANK_UNBLANK)
25− intensity = 0;
26− if (bd->props.state & BL_CORE_FBBLANK)
27− intensity = 0;
28− if (bd->props.state & BL_CORE_SUSPENDED)
29− intensity = 0;
30−
31− bl_machinfo->set_bl_intensity(intensity);
32−
33− genericbl_intensity = intensity;
34−
35− if (bl_machinfo->kick_battery)
36− bl_machinfo->kick_battery();
37−
38− return 0;
39−}
40−
41−static int genericbl_get_intensity(struct backlight_device *bd)
42−{
43− return genericbl_intensity;
44−}
45−
46−static const struct backlight_ops genericbl_ops = {
47− .options = BL_CORE_SUSPENDRESUME,
48− .get_brightness = genericbl_get_intensity,
49− .update_status = genericbl_send_intensity,
50−};
51−
52−static int genericbl_probe(struct platform_device *pdev)
53−{
54− struct backlight_properties props;
55− struct generic_bl_info *machinfo = dev_get_platdata(&pdev->dev);
56− const char *name = "generic-bl";
57− struct backlight_device *bd;
58−
59− bl_machinfo = machinfo;
60− if (!machinfo->limit_mask)
61− machinfo->limit_mask = -1;
62−
63− if (machinfo->name)
64− name = machinfo->name;
65−
66− memset(&props, 0, sizeof(struct backlight_properties));
67− props.type = BACKLIGHT_RAW;
68− props.max_brightness = machinfo->max_intensity;
69− bd = devm_backlight_device_register(&pdev->dev, name, &pdev->dev,
70− NULL, &genericbl_ops, &props);
71− if (IS_ERR(bd))
72− return PTR_ERR(bd);
73−
74− platform_set_drvdata(pdev, bd);
75−
76− bd->props.power = FB_BLANK_UNBLANK;
77− bd->props.brightness = machinfo->default_intensity;
78− backlight_update_status(bd);
79−
80− generic_backlight_device = bd;
81−
82− dev_info(&pdev->dev, "Generic Backlight Driver Initialized.\n");
83− return 0;
84−}
85−
86−static int genericbl_remove(struct platform_device *pdev)
87−{
88− struct backlight_device *bd = platform_get_drvdata(pdev);
89−
90− bd->props.power = 0;
91− bd->props.brightness = 0;
92− backlight_update_status(bd);
93−
94− dev_info(&pdev->dev, "Generic Backlight Driver Unloaded\n");
95− return 0;
96−}
97−
98−static struct platform_driver genericbl_driver = {
99− .probe = genericbl_probe,
100− .remove = genericbl_remove,
101− .driver = {
102− .name = "generic-bl",
103− },
104−};
105−
106−module_platform_driver(genericbl_driver);
107−
108−MODULE_AUTHOR("Richard Purdie <rpurdie@rpsys.net>");
109−MODULE_DESCRIPTION("Generic Backlight Driver");
110−MODULE_LICENSE("GPL");
drivers/video/backlight/gpio_backlight.c+2−15
@@ -21,24 +21,11 @@ struct gpio_backlight { · 20 unmodified lines
2121 struct gpio_desc *gpiod;
2222 };
2323
24−static int gpio_backlight_get_next_brightness(struct backlight_device *bl)
25−{
26− int brightness = bl->props.brightness;
27−
28− if (bl->props.power != FB_BLANK_UNBLANK ||
29− bl->props.fb_blank != FB_BLANK_UNBLANK ||
30− bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
31− brightness = 0;
32−
33− return brightness;
34−}
35−
3624 static int gpio_backlight_update_status(struct backlight_device *bl)
3725 {
3826 struct gpio_backlight *gbl = bl_get_data(bl);
39− int brightness = gpio_backlight_get_next_brightness(bl);
4027
41− gpiod_set_value_cansleep(gbl->gpiod, brightness);
28+ gpiod_set_value_cansleep(gbl->gpiod, backlight_get_brightness(bl));
4229
4330 return 0;
4431 }
@@ -108,7 +95,7 @@ static int gpio_backlight_probe(struct platform_device *pdev) · 63 unmodified lines
10895
10996 bl->props.brightness = 1;
11097
111− init_brightness = gpio_backlight_get_next_brightness(bl);
98+ init_brightness = backlight_get_brightness(bl);
11299 ret = gpiod_direction_output(gbl->gpiod, init_brightness);
113100 if (ret) {
114101 dev_err(dev, "failed to set initial brightness\n");
drivers/video/backlight/hp680_bl.c+1−5
@@ -33,12 +33,8 @@ static void hp680bl_send_intensity(struct backlight_device *bd) · 32 unmodified lines
3333 {
3434 unsigned long flags;
3535 u16 v;
36− int intensity = bd->props.brightness;
36+ int intensity = backlight_get_brightness(bd);
3737
38− if (bd->props.power != FB_BLANK_UNBLANK)
39− intensity = 0;
40− if (bd->props.fb_blank != FB_BLANK_UNBLANK)
41− intensity = 0;
4238 if (hp680bl_suspended)
4339 intensity = 0;
4440
drivers/video/backlight/ili922x.c+6−2
@@ -107,6 +107,8 @@ · 106 unmodified lines
107107 * lower frequency when the registers are read/written.
108108 * The macro sets the frequency in the spi_transfer structure if
109109 * the frequency exceeds the maximum value.
110+ * @s: pointer to an SPI device
111+ * @x: pointer to the read/write buffer pair
110112 */
111113 #define CHECK_FREQ_REG(s, x) \
112114 do { \
@@ -121,7 +123,7 @@ · 8 unmodified lines
121123
122124 #define set_tx_byte(b) (tx_invert ? ~(b) : b)
123125
124−/**
126+/*
125127 * ili922x_id - id as set by manufacturer
126128 */
127129 static int ili922x_id = 1;
@@ -130,7 +132,7 @@ module_param(ili922x_id, int, 0); · 2 unmodified lines
130132 static int tx_invert;
131133 module_param(tx_invert, int, 0);
132134
133−/**
135+/*
134136 * driver's private structure
135137 */
136138 struct ili922x {
@@ -293,6 +295,8 @@ static int ili922x_write(struct spi_device *spi, u8 reg, u16 value) · 156 unmodified lines
293295 #ifdef DEBUG
294296 /**
295297 * ili922x_reg_dump - dump all registers
298+ *
299+ * @spi: pointer to an SPI device
296300 */
297301 static void ili922x_reg_dump(struct spi_device *spi)
298302 {
drivers/video/backlight/jornada720_bl.c+1−1
@@ -54,7 +54,7 @@ static int jornada_bl_update_status(struct backlight_device *bd) · 53 unmodified lines
5454 jornada_ssp_start();
5555
5656 /* If backlight is off then really turn it off */
57− if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) {
57+ if (backlight_is_blank(bd)) {
5858 ret = jornada_ssp_byte(BRIGHTNESSOFF);
5959 if (ret != TXDUMMY) {
6060 dev_info(&bd->dev, "brightness off timeout\n");
drivers/video/backlight/kb3886_bl.c+1−5
@@ -87,12 +87,8 @@ static const struct dmi_system_id kb3886bl_device_table[] __initconst = { · 86 unmodified lines
8787
8888 static int kb3886bl_send_intensity(struct backlight_device *bd)
8989 {
90− int intensity = bd->props.brightness;
90+ int intensity = backlight_get_brightness(bd);
9191
92− if (bd->props.power != FB_BLANK_UNBLANK)
93− intensity = 0;
94− if (bd->props.fb_blank != FB_BLANK_UNBLANK)
95− intensity = 0;
9692 if (kb3886bl_flags & KB3886BL_SUSPENDED)
9793 intensity = 0;
9894
drivers/video/backlight/lcd.c+1−0
@@ -179,6 +179,7 @@ ATTRIBUTE_GROUPS(lcd_device); · 178 unmodified lines
179179 * lcd_device_register - register a new object of lcd_device class.
180180 * @name: the name of the new object(must be the same as the name of the
181181 * respective framebuffer device).
182+ * @parent: pointer to the parent's struct device .
182183 * @devdata: an optional pointer to be stored in the device. The
183184 * methods may retrieve it by using lcd_get_data(ld).
184185 * @ops: the lcd operations structure.
drivers/video/backlight/led_bl.c+1−6
@@ -54,12 +54,7 @@ static void led_bl_power_off(struct led_bl_data *priv) · 53 unmodified lines
5454 static int led_bl_update_status(struct backlight_device *bl)
5555 {
5656 struct led_bl_data *priv = bl_get_data(bl);
57− int brightness = bl->props.brightness;
58−
59− if (bl->props.power != FB_BLANK_UNBLANK ||
60− bl->props.fb_blank != FB_BLANK_UNBLANK ||
61− bl->props.state & BL_CORE_FBBLANK)
62− brightness = 0;
57+ int brightness = backlight_get_brightness(bl);
6358
6459 if (brightness > 0)
6560 led_bl_set_brightness(priv, brightness);
drivers/video/backlight/lm3533_bl.c+2−8
@@ -39,14 +39,8 @@ static inline int lm3533_bl_get_ctrlbank_id(struct lm3533_bl *bl) · 38 unmodified lines
3939 static int lm3533_bl_update_status(struct backlight_device *bd)
4040 {
4141 struct lm3533_bl *bl = bl_get_data(bd);
42− int brightness = bd->props.brightness;
4342
44− if (bd->props.power != FB_BLANK_UNBLANK)
45− brightness = 0;
46− if (bd->props.fb_blank != FB_BLANK_UNBLANK)
47− brightness = 0;
48−
49− return lm3533_ctrlbank_set_brightness(&bl->cb, (u8)brightness);
43+ return lm3533_ctrlbank_set_brightness(&bl->cb, backlight_get_brightness(bd));
5044 }
5145
5246 static int lm3533_bl_get_brightness(struct backlight_device *bd)
@@ -235,7 +229,7 @@ static struct attribute *lm3533_bl_attributes[] = { · 182 unmodified lines
235229 static umode_t lm3533_bl_attr_is_visible(struct kobject *kobj,
236230 struct attribute *attr, int n)
237231 {
238− struct device *dev = container_of(kobj, struct device, kobj);
232+ struct device *dev = kobj_to_dev(kobj);
239233 struct lm3533_bl *bl = dev_get_drvdata(dev);
240234 umode_t mode = attr->mode;
241235
drivers/video/backlight/lm3630a_bl.c+2−2
@@ -391,7 +391,7 @@ static int lm3630a_parse_led_sources(struct fwnode_handle *node, · 390 unmodified lines
391391 return ret;
392392
393393 for (i = 0; i < num_sources; i++) {
394− if (sources[i] < LM3630A_SINK_0 || sources[i] > LM3630A_SINK_1)
394+ if (sources[i] != LM3630A_SINK_0 && sources[i] != LM3630A_SINK_1)
395395 return -EINVAL;
396396
397397 ret |= BIT(sources[i]);
@@ -412,7 +412,7 @@ static int lm3630a_parse_bank(struct lm3630a_platform_data *pdata, · 14 unmodified lines
412412 if (ret)
413413 return ret;
414414
415− if (bank < LM3630A_BANK_0 || bank > LM3630A_BANK_1)
415+ if (bank != LM3630A_BANK_0 && bank != LM3630A_BANK_1)
416416 return -EINVAL;
417417
418418 led_sources = lm3630a_parse_led_sources(node, BIT(bank));
drivers/video/backlight/lms501kf03.c+0−9
@@ -9,7 +9,6 @@ · 8 unmodified lines
99 #include <linux/backlight.h>
1010 #include <linux/delay.h>
1111 #include <linux/fb.h>
12−#include <linux/gpio.h>
1312 #include <linux/lcd.h>
1413 #include <linux/module.h>
1514 #include <linux/spi/spi.h>
@@ -89,14 +88,6 @@ static const unsigned char seq_rgb_gamma[] = { · 73 unmodified lines
8988 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9089 };
9190
92−static const unsigned char seq_up_dn[] = {
93− 0x36, 0x10,
94−};
95−
96−static const unsigned char seq_sleep_in[] = {
97− 0x10,
98−};
99−
10091 static const unsigned char seq_sleep_out[] = {
10192 0x11,
10293 };
drivers/video/backlight/locomolcd.c+1−5
@@ -111,12 +111,8 @@ static int current_intensity; · 110 unmodified lines
111111
112112 static int locomolcd_set_intensity(struct backlight_device *bd)
113113 {
114− int intensity = bd->props.brightness;
114+ int intensity = backlight_get_brightness(bd);
115115
116− if (bd->props.power != FB_BLANK_UNBLANK)
117− intensity = 0;
118− if (bd->props.fb_blank != FB_BLANK_UNBLANK)
119− intensity = 0;
120116 if (locomolcd_flags & LOCOMOLCD_SUSPENDED)
121117 intensity = 0;
122118
drivers/video/backlight/lv5207lp.c+1−6
@@ -46,12 +46,7 @@ static int lv5207lp_write(struct lv5207lp *lv, u8 reg, u8 data) · 45 unmodified lines
4646 static int lv5207lp_backlight_update_status(struct backlight_device *backlight)
4747 {
4848 struct lv5207lp *lv = bl_get_data(backlight);
49− int brightness = backlight->props.brightness;
50−
51− if (backlight->props.power != FB_BLANK_UNBLANK ||
52− backlight->props.fb_blank != FB_BLANK_UNBLANK ||
53− backlight->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
54− brightness = 0;
49+ int brightness = backlight_get_brightness(backlight);
5550
5651 if (brightness) {
5752 lv5207lp_write(lv, LV5207LP_CTRL1,
drivers/video/backlight/max8925_bl.c+1−12
@@ -64,18 +64,7 @@ out: · 63 unmodified lines
6464
6565 static int max8925_backlight_update_status(struct backlight_device *bl)
6666 {
67− int brightness = bl->props.brightness;
68−
69− if (bl->props.power != FB_BLANK_UNBLANK)
70− brightness = 0;
71−
72− if (bl->props.fb_blank != FB_BLANK_UNBLANK)
73− brightness = 0;
74−
75− if (bl->props.state & BL_CORE_SUSPENDED)
76− brightness = 0;
77−
78− return max8925_backlight_set(bl, brightness);
67+ return max8925_backlight_set(bl, backlight_get_brightness(bl));
7968 }
8069
8170 static int max8925_backlight_get_brightness(struct backlight_device *bl)
drivers/video/backlight/ot200_bl.c+0−162
@@ -1,162 +0,0 @@
1−// SPDX-License-Identifier: GPL-2.0-only
2−/*
3− * Copyright (C) 2012 Bachmann electronic GmbH
4− * Christian Gmeiner <christian.gmeiner@gmail.com>
5− *
6− * Backlight driver for ot200 visualisation device from
7− * Bachmann electronic GmbH.
8− */
9−
10−#include <linux/module.h>
11−#include <linux/fb.h>
12−#include <linux/backlight.h>
13−#include <linux/gpio.h>
14−#include <linux/platform_device.h>
15−#include <linux/cs5535.h>
16−
17−static struct cs5535_mfgpt_timer *pwm_timer;
18−
19−/* this array defines the mapping of brightness in % to pwm frequency */
20−static const u8 dim_table[101] = {0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
21− 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4,
22− 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9,
23− 10, 10, 11, 11, 12, 12, 13, 14, 15, 15, 16,
24− 17, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28,
25− 30, 31, 33, 35, 37, 39, 41, 43, 45, 47, 50,
26− 53, 55, 58, 61, 65, 68, 72, 75, 79, 84, 88,
27− 93, 97, 103, 108, 114, 120, 126, 133, 140,
28− 147, 155, 163};
29−
30−struct ot200_backlight_data {
31− int current_brightness;
32−};
33−
34−#define GPIO_DIMM 27
35−#define SCALE 1
36−#define CMP1MODE 0x2 /* compare on GE; output high on compare
37− * greater than or equal */
38−#define PWM_SETUP (SCALE | CMP1MODE << 6 | MFGPT_SETUP_CNTEN)
39−#define MAX_COMP2 163
40−
41−static int ot200_backlight_update_status(struct backlight_device *bl)
42−{
43− struct ot200_backlight_data *data = bl_get_data(bl);
44− int brightness = bl->props.brightness;
45−
46− if (bl->props.state & BL_CORE_FBBLANK)
47− brightness = 0;
48−
49− /* enable or disable PWM timer */
50− if (brightness == 0)
51− cs5535_mfgpt_write(pwm_timer, MFGPT_REG_SETUP, 0);
52− else if (data->current_brightness == 0) {
53− cs5535_mfgpt_write(pwm_timer, MFGPT_REG_COUNTER, 0);
54− cs5535_mfgpt_write(pwm_timer, MFGPT_REG_SETUP,
55− MFGPT_SETUP_CNTEN);
56− }
57−
58− /* apply new brightness value */
59− cs5535_mfgpt_write(pwm_timer, MFGPT_REG_CMP1,
60− MAX_COMP2 - dim_table[brightness]);
61− data->current_brightness = brightness;
62−
63− return 0;
64−}
65−
66−static int ot200_backlight_get_brightness(struct backlight_device *bl)
67−{
68− struct ot200_backlight_data *data = bl_get_data(bl);
69− return data->current_brightness;
70−}
71−
72−static const struct backlight_ops ot200_backlight_ops = {
73− .update_status = ot200_backlight_update_status,
74− .get_brightness = ot200_backlight_get_brightness,
75−};
76−
77−static int ot200_backlight_probe(struct platform_device *pdev)
78−{
79− struct backlight_device *bl;
80− struct ot200_backlight_data *data;
81− struct backlight_properties props;
82− int retval = 0;
83−
84− /* request gpio */
85− if (devm_gpio_request(&pdev->dev, GPIO_DIMM,
86− "ot200 backlight dimmer") < 0) {
87− dev_err(&pdev->dev, "failed to request GPIO %d\n", GPIO_DIMM);
88− return -ENODEV;
89− }
90−
91− /* request timer */
92− pwm_timer = cs5535_mfgpt_alloc_timer(7, MFGPT_DOMAIN_ANY);
93− if (!pwm_timer) {
94− dev_err(&pdev->dev, "MFGPT 7 not available\n");
95− return -ENODEV;
96− }
97−
98− data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
99− if (!data) {
100− retval = -ENOMEM;
101− goto error_devm_kzalloc;
102− }
103−
104− /* setup gpio */
105− cs5535_gpio_set(GPIO_DIMM, GPIO_OUTPUT_ENABLE);
106− cs5535_gpio_set(GPIO_DIMM, GPIO_OUTPUT_AUX1);
107−
108− /* setup timer */
109− cs5535_mfgpt_write(pwm_timer, MFGPT_REG_CMP1, 0);
110− cs5535_mfgpt_write(pwm_timer, MFGPT_REG_CMP2, MAX_COMP2);
111− cs5535_mfgpt_write(pwm_timer, MFGPT_REG_SETUP, PWM_SETUP);
112−
113− data->current_brightness = 100;
114− props.max_brightness = 100;
115− props.brightness = 100;
116− props.type = BACKLIGHT_RAW;
117−
118− bl = devm_backlight_device_register(&pdev->dev, dev_name(&pdev->dev),
119− &pdev->dev, data, &ot200_backlight_ops,
120− &props);
121− if (IS_ERR(bl)) {
122− dev_err(&pdev->dev, "failed to register backlight\n");
123− retval = PTR_ERR(bl);
124− goto error_devm_kzalloc;
125− }
126−
127− platform_set_drvdata(pdev, bl);
128−
129− return 0;
130−
131−error_devm_kzalloc:
132− cs5535_mfgpt_free_timer(pwm_timer);
133− return retval;
134−}
135−
136−static int ot200_backlight_remove(struct platform_device *pdev)
137−{
138− /* on module unload set brightness to 100% */
139− cs5535_mfgpt_write(pwm_timer, MFGPT_REG_COUNTER, 0);
140− cs5535_mfgpt_write(pwm_timer, MFGPT_REG_SETUP, MFGPT_SETUP_CNTEN);
141− cs5535_mfgpt_write(pwm_timer, MFGPT_REG_CMP1,
142− MAX_COMP2 - dim_table[100]);
143−
144− cs5535_mfgpt_free_timer(pwm_timer);
145−
146− return 0;
147−}
148−
149−static struct platform_driver ot200_backlight_driver = {
150− .driver = {
151− .name = "ot200-backlight",
152− },
153− .probe = ot200_backlight_probe,
154− .remove = ot200_backlight_remove,
155−};
156−
157−module_platform_driver(ot200_backlight_driver);
158−
159−MODULE_DESCRIPTION("backlight driver for ot200 visualisation device");
160−MODULE_AUTHOR("Christian Gmeiner <christian.gmeiner@gmail.com>");
161−MODULE_LICENSE("GPL");
162−MODULE_ALIAS("platform:ot200-backlight");
drivers/video/backlight/pwm_bl.c+1−6
@@ -108,14 +108,9 @@ static int compute_duty_cycle(struct pwm_bl_data *pb, int brightness) · 107 unmodified lines
108108 static int pwm_backlight_update_status(struct backlight_device *bl)
109109 {
110110 struct pwm_bl_data *pb = bl_get_data(bl);
111− int brightness = bl->props.brightness;
111+ int brightness = backlight_get_brightness(bl);
112112 struct pwm_state state;
113113
114− if (bl->props.power != FB_BLANK_UNBLANK ||
115− bl->props.fb_blank != FB_BLANK_UNBLANK ||
116− bl->props.state & BL_CORE_FBBLANK)
117− brightness = 0;
118−
119114 if (pb->notify)
120115 brightness = pb->notify(pb->dev, brightness);
121116
drivers/video/backlight/qcom-wled.c+1−14
@@ -433,14 +433,9 @@ static int wled5_ovp_delay(struct wled *wled) · 432 unmodified lines
433433 static int wled_update_status(struct backlight_device *bl)
434434 {
435435 struct wled *wled = bl_get_data(bl);
436− u16 brightness = bl->props.brightness;
436+ u16 brightness = backlight_get_brightness(bl);
437437 int rc = 0;
438438
439− if (bl->props.power != FB_BLANK_UNBLANK ||
440− bl->props.fb_blank != FB_BLANK_UNBLANK ||
441− bl->props.state & BL_CORE_FBBLANK)
442− brightness = 0;
443−
444439 mutex_lock(&wled->lock);
445440 if (brightness) {
446441 rc = wled->wled_set_brightness(wled, brightness);
@@ -1287,14 +1282,6 @@ static const struct wled_var_cfg wled4_string_i_limit_cfg = { · 840 unmodified lines
12871282 .size = ARRAY_SIZE(wled4_string_i_limit_values),
12881283 };
12891284
1290−static const struct wled_var_cfg wled3_string_cfg = {
1291− .size = 8,
1292−};
1293−
1294−static const struct wled_var_cfg wled4_string_cfg = {
1295− .size = 16,
1296−};
1297−
12981285 static const struct wled_var_cfg wled5_mod_sel_cfg = {
12991286 .size = 2,
13001287 };
drivers/video/backlight/sky81452-backlight.c+31−21
@@ -8,15 +8,13 @@ · 7 unmodified lines
88
99 #include <linux/backlight.h>
1010 #include <linux/err.h>
11−#include <linux/gpio.h>
11+#include <linux/gpio/consumer.h>
1212 #include <linux/init.h>
1313 #include <linux/kernel.h>
1414 #include <linux/module.h>
1515 #include <linux/of.h>
16−#include <linux/of_gpio.h>
1716 #include <linux/platform_device.h>
1817 #include <linux/regmap.h>
19−#include <linux/platform_data/sky81452-backlight.h>
2018 #include <linux/slab.h>
2119
2220 /* registers */
@@ -42,6 +40,29 @@ · 19 unmodified lines
4240 #define SKY81452_DEFAULT_NAME "lcd-backlight"
4341 #define SKY81452_MAX_BRIGHTNESS (SKY81452_CS + 1)
4442
43+/**
44+ * struct sky81452_platform_data
45+ * @name: backlight driver name.
46+ * If it is not defined, default name is lcd-backlight.
47+ * @gpiod_enable:GPIO descriptor which control EN pin
48+ * @enable: Enable mask for current sink channel 1, 2, 3, 4, 5 and 6.
49+ * @ignore_pwm: true if DPWMI should be ignored.
50+ * @dpwm_mode: true is DPWM dimming mode, otherwise Analog dimming mode.
51+ * @phase_shift:true is phase shift mode.
52+ * @short_detection_threshold: It should be one of 4, 5, 6 and 7V.
53+ * @boost_current_limit: It should be one of 2300, 2750mA.
54+ */
55+struct sky81452_bl_platform_data {
56+ const char *name;
57+ struct gpio_desc *gpiod_enable;
58+ unsigned int enable;
59+ bool ignore_pwm;
60+ bool dpwm_mode;
61+ bool phase_shift;
62+ unsigned int short_detection_threshold;
63+ unsigned int boost_current_limit;
64+};
65+
4566 #define CTZ(b) __builtin_ctz(b)
4667
4768 static int sky81452_bl_update_status(struct backlight_device *bd)
@@ -182,7 +203,7 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt( · 134 unmodified lines
182203 pdata->ignore_pwm = of_property_read_bool(np, "skyworks,ignore-pwm");
183204 pdata->dpwm_mode = of_property_read_bool(np, "skyworks,dpwm-mode");
184205 pdata->phase_shift = of_property_read_bool(np, "skyworks,phase-shift");
185− pdata->gpio_enable = of_get_gpio(np, 0);
206+ pdata->gpiod_enable = devm_gpiod_get_optional(dev, NULL, GPIOD_OUT_HIGH);
186207
187208 ret = of_property_count_u32_elems(np, "led-sources");
188209 if (ret < 0) {
@@ -252,26 +273,15 @@ static int sky81452_bl_probe(struct platform_device *pdev) · 63 unmodified lines
252273 {
253274 struct device *dev = &pdev->dev;
254275 struct regmap *regmap = dev_get_drvdata(dev->parent);
255− struct sky81452_bl_platform_data *pdata = dev_get_platdata(dev);
276+ struct sky81452_bl_platform_data *pdata;
256277 struct backlight_device *bd;
257278 struct backlight_properties props;
258279 const char *name;
259280 int ret;
260281
261− if (!pdata) {
262− pdata = sky81452_bl_parse_dt(dev);
263− if (IS_ERR(pdata))
264− return PTR_ERR(pdata);
265− }
266−
267− if (gpio_is_valid(pdata->gpio_enable)) {
268− ret = devm_gpio_request_one(dev, pdata->gpio_enable,
269− GPIOF_OUT_INIT_HIGH, "sky81452-en");
270− if (ret < 0) {
271− dev_err(dev, "failed to request GPIO. err=%d\n", ret);
272− return ret;
273− }
274− }
282+ pdata = sky81452_bl_parse_dt(dev);
283+ if (IS_ERR(pdata))
284+ return PTR_ERR(pdata);
275285
276286 ret = sky81452_bl_init_device(regmap, pdata);
277287 if (ret < 0) {
@@ -312,8 +322,8 @@ static int sky81452_bl_remove(struct platform_device *pdev) · 34 unmodified lines
312322 bd->props.brightness = 0;
313323 backlight_update_status(bd);
314324
315− if (gpio_is_valid(pdata->gpio_enable))
316− gpio_set_value_cansleep(pdata->gpio_enable, 0);
325+ if (pdata->gpiod_enable)
326+ gpiod_set_value_cansleep(pdata->gpiod_enable, 0);
317327
318328 return 0;
319329 }
drivers/video/backlight/tps65217_bl.c+1−9
@@ -77,15 +77,7 @@ static int tps65217_bl_update_status(struct backlight_device *bl) · 76 unmodified lines
7777 {
7878 struct tps65217_bl *tps65217_bl = bl_get_data(bl);
7979 int rc;
80− int brightness = bl->props.brightness;
81−
82− if (bl->props.state & BL_CORE_SUSPENDED)
83− brightness = 0;
84−
85− if ((bl->props.power != FB_BLANK_UNBLANK) ||
86− (bl->props.fb_blank != FB_BLANK_UNBLANK))
87− /* framebuffer in low power mode or blanking active */
88− brightness = 0;
80+ int brightness = backlight_get_brightness(bl);
8981
9082 if (brightness > 0) {
9183 rc = tps65217_reg_write(tps65217_bl->tps,
drivers/video/backlight/wm831x_bl.c+1−12
@@ -91,18 +91,7 @@ err: · 90 unmodified lines
9191
9292 static int wm831x_backlight_update_status(struct backlight_device *bl)
9393 {
94− int brightness = bl->props.brightness;
95−
96− if (bl->props.power != FB_BLANK_UNBLANK)
97− brightness = 0;
98−
99− if (bl->props.fb_blank != FB_BLANK_UNBLANK)
100− brightness = 0;
101−
102− if (bl->props.state & BL_CORE_SUSPENDED)
103− brightness = 0;
104−
105− return wm831x_backlight_set(bl, brightness);
94+ return wm831x_backlight_set(bl, backlight_get_brightness(bl));
10695 }
10796
10897 static int wm831x_backlight_get_brightness(struct backlight_device *bl)
include/linux/backlight.h+325−74
@@ -14,113 +14,336 @@ · 13 unmodified lines
1414 #include <linux/mutex.h>
1515 #include <linux/notifier.h>
1616
17−/* Notes on locking:
18− *
19− * backlight_device->ops_lock is an internal backlight lock protecting the
20− * ops pointer and no code outside the core should need to touch it.
21− *
22− * Access to update_status() is serialised by the update_lock mutex since
23− * most drivers seem to need this and historically get it wrong.
24− *
25− * Most drivers don't need locking on their get_brightness() method.
26− * If yours does, you need to implement it in the driver. You can use the
27− * update_lock mutex if appropriate.
17+/**
18+ * enum backlight_update_reason - what method was used to update backlight
2819 *
29− * Any other use of the locks below is probably wrong.
20+ * A driver indicates the method (reason) used for updating the backlight
21+ * when calling backlight_force_update().
3022 */
31−
3223 enum backlight_update_reason {
24+ /**
25+ * @BACKLIGHT_UPDATE_HOTKEY: The backlight was updated using a hot-key.
26+ */
3327 BACKLIGHT_UPDATE_HOTKEY,
28+
29+ /**
30+ * @BACKLIGHT_UPDATE_SYSFS: The backlight was updated using sysfs.
31+ */
3432 BACKLIGHT_UPDATE_SYSFS,
3533 };
3634
35+/**
36+ * enum backlight_type - the type of backlight control
37+ *
38+ * The type of interface used to control the backlight.
39+ */
3740 enum backlight_type {
41+ /**
42+ * @BACKLIGHT_RAW:
43+ *
44+ * The backlight is controlled using hardware registers.
45+ */
3846 BACKLIGHT_RAW = 1,
47+
48+ /**
49+ * @BACKLIGHT_PLATFORM:
50+ *
51+ * The backlight is controlled using a platform-specific interface.
52+ */
3953 BACKLIGHT_PLATFORM,
54+
55+ /**
56+ * @BACKLIGHT_FIRMWARE:
57+ *
58+ * The backlight is controlled using a standard firmware interface.
59+ */
4060 BACKLIGHT_FIRMWARE,
61+
62+ /**
63+ * @BACKLIGHT_TYPE_MAX: Number of entries.
64+ */
4165 BACKLIGHT_TYPE_MAX,
4266 };
4367
68+/**
69+ * enum backlight_notification - the type of notification
70+ *
71+ * The notifications that is used for notification sent to the receiver
72+ * that registered notifications using backlight_register_notifier().
73+ */
4474 enum backlight_notification {
75+ /**
76+ * @BACKLIGHT_REGISTERED: The backlight device is registered.
77+ */
4578 BACKLIGHT_REGISTERED,
79+
80+ /**
81+ * @BACKLIGHT_UNREGISTERED: The backlight revice is unregistered.
82+ */
4683 BACKLIGHT_UNREGISTERED,
4784 };
4885
86+/** enum backlight_scale - the type of scale used for brightness values
87+ *
88+ * The type of scale used for brightness values.
89+ */
4990 enum backlight_scale {
91+ /**
92+ * @BACKLIGHT_SCALE_UNKNOWN: The scale is unknown.
93+ */
5094 BACKLIGHT_SCALE_UNKNOWN = 0,
95+
96+ /**
97+ * @BACKLIGHT_SCALE_LINEAR: The scale is linear.
98+ *
99+ * The linear scale will increase brightness the same for each step.
100+ */
51101 BACKLIGHT_SCALE_LINEAR,
102+
103+ /**
104+ * @BACKLIGHT_SCALE_NON_LINEAR: The scale is not linear.
105+ *
106+ * This is often used when the brightness values tries to adjust to
107+ * the relative perception of the eye demanding a non-linear scale.
108+ */
52109 BACKLIGHT_SCALE_NON_LINEAR,
53110 };
54111
55112 struct backlight_device;
56113 struct fb_info;
57114
115+/**
116+ * struct backlight_ops - backlight operations
117+ *
118+ * The backlight operations are specified when the backlight device is registered.
119+ */
58120 struct backlight_ops {
121+ /**
122+ * @options: Configure how operations are called from the core.
123+ *
124+ * The options parameter is used to adjust the behaviour of the core.
125+ * Set BL_CORE_SUSPENDRESUME to get the update_status() operation called
126+ * upon suspend and resume.
127+ */
59128 unsigned int options;
60129
61130 #define BL_CORE_SUSPENDRESUME (1 << 0)
62131
63− /* Notify the backlight driver some property has changed */
132+ /**
133+ * @update_status: Operation called when properties have changed.
134+ *
135+ * Notify the backlight driver some property has changed.
136+ * The update_status operation is protected by the update_lock.
137+ *
138+ * The backlight driver is expected to use backlight_is_blank()
139+ * to check if the display is blanked and set brightness accordingly.
140+ * update_status() is called when any of the properties has changed.
141+ *
142+ * RETURNS:
143+ *
144+ * 0 on success, negative error code if any failure occurred.
145+ */
64146 int (*update_status)(struct backlight_device *);
65− /* Return the current backlight brightness (accounting for power,
66− fb_blank etc.) */
147+
148+ /**
149+ * @get_brightness: Return the current backlight brightness.
150+ *
151+ * The driver may implement this as a readback from the HW.
152+ * This operation is optional and if not present then the current
153+ * brightness property value is used.
154+ *
155+ * RETURNS:
156+ *
157+ * A brightness value which is 0 or a positive number.
158+ * On failure a negative error code is returned.
159+ */
67160 int (*get_brightness)(struct backlight_device *);
68− /* Check if given framebuffer device is the one bound to this backlight;
69− return 0 if not, !=0 if it is. If NULL, backlight always matches the fb. */
70− int (*check_fb)(struct backlight_device *, struct fb_info *);
161+
162+ /**
163+ * @check_fb: Check the framebuffer device.
164+ *
165+ * Check if given framebuffer device is the one bound to this backlight.
166+ * This operation is optional and if not implemented it is assumed that the
167+ * fbdev is always the one bound to the backlight.
168+ *
169+ * RETURNS:
170+ *
171+ * If info is NULL or the info matches the fbdev bound to the backlight return true.
172+ * If info does not match the fbdev bound to the backlight return false.
173+ */
174+ int (*check_fb)(struct backlight_device *bd, struct fb_info *info);
71175 };
72176
73−/* This structure defines all the properties of a backlight */
177+/**
178+ * struct backlight_properties - backlight properties
179+ *
180+ * This structure defines all the properties of a backlight.
181+ */
74182 struct backlight_properties {
75− /* Current User requested brightness (0 - max_brightness) */
183+ /**
184+ * @brightness: The current brightness requested by the user.
185+ *
186+ * The backlight core makes sure the range is (0 to max_brightness)
187+ * when the brightness is set via the sysfs attribute:
188+ * /sys/class/backlight/<backlight>/brightness.
189+ *
190+ * This value can be set in the backlight_properties passed
191+ * to devm_backlight_device_register() to set a default brightness
192+ * value.
193+ */
76194 int brightness;
77− /* Maximal value for brightness (read-only) */
195+
196+ /**
197+ * @max_brightness: The maximum brightness value.
198+ *
199+ * This value must be set in the backlight_properties passed to
200+ * devm_backlight_device_register() and shall not be modified by the
201+ * driver after registration.
202+ */
78203 int max_brightness;
79− /* Current FB Power mode (0: full on, 1..3: power saving
80− modes; 4: full off), see FB_BLANK_XXX */
204+
205+ /**
206+ * @power: The current power mode.
207+ *
208+ * User space can configure the power mode using the sysfs
209+ * attribute: /sys/class/backlight/<backlight>/bl_power
210+ * When the power property is updated update_status() is called.
211+ *
212+ * The possible values are: (0: full on, 1 to 3: power saving
213+ * modes; 4: full off), see FB_BLANK_XXX.
214+ *
215+ * When the backlight device is enabled @power is set
216+ * to FB_BLANK_UNBLANK. When the backlight device is disabled
217+ * @power is set to FB_BLANK_POWERDOWN.
218+ */
81219 int power;
82− /* FB Blanking active? (values as for power) */
83− /* Due to be removed, please use (state & BL_CORE_FBBLANK) */
220+
221+ /**
222+ * @fb_blank: The power state from the FBIOBLANK ioctl.
223+ *
224+ * When the FBIOBLANK ioctl is called @fb_blank is set to the
225+ * blank parameter and the update_status() operation is called.
226+ *
227+ * When the backlight device is enabled @fb_blank is set
228+ * to FB_BLANK_UNBLANK. When the backlight device is disabled
229+ * @fb_blank is set to FB_BLANK_POWERDOWN.
230+ *
231+ * Backlight drivers should avoid using this property. It has been
232+ * replaced by state & BL_CORE_FBLANK (although most drivers should
233+ * use backlight_is_blank() as the preferred means to get the blank
234+ * state).
235+ *
236+ * fb_blank is deprecated and will be removed.
237+ */
84238 int fb_blank;
85− /* Backlight type */
239+
240+ /**
241+ * @type: The type of backlight supported.
242+ *
243+ * The backlight type allows userspace to make appropriate
244+ * policy decisions based on the backlight type.
245+ *
246+ * This value must be set in the backlight_properties
247+ * passed to devm_backlight_device_register().
248+ */
86249 enum backlight_type type;
87− /* Flags used to signal drivers of state changes */
250+
251+ /**
252+ * @state: The state of the backlight core.
253+ *
254+ * The state is a bitmask. BL_CORE_FBBLANK is set when the display
255+ * is expected to be blank. BL_CORE_SUSPENDED is set when the
256+ * driver is suspended.
257+ *
258+ * backlight drivers are expected to use backlight_is_blank()
259+ * in their update_status() operation rather than reading the
260+ * state property.
261+ *
262+ * The state is maintained by the core and drivers may not modify it.
263+ */
88264 unsigned int state;
89− /* Type of the brightness scale (linear, non-linear, ...) */
90− enum backlight_scale scale;
91265
92266 #define BL_CORE_SUSPENDED (1 << 0) /* backlight is suspended */
93267 #define BL_CORE_FBBLANK (1 << 1) /* backlight is under an fb blank event */
94268
269+ /**
270+ * @scale: The type of the brightness scale.
271+ */
272+ enum backlight_scale scale;
95273 };
96274
275+/**
276+ * struct backlight_device - backlight device data
277+ *
278+ * This structure holds all data required by a backlight device.
279+ */
97280 struct backlight_device {
98− /* Backlight properties */
281+ /**
282+ * @props: Backlight properties
283+ */
99284 struct backlight_properties props;
100285
101− /* Serialise access to update_status method */
286+ /**
287+ * @update_lock: The lock used when calling the update_status() operation.
288+ *
289+ * update_lock is an internal backlight lock that serialise access
290+ * to the update_status() operation. The backlight core holds the update_lock
291+ * when calling the update_status() operation. The update_lock shall not
292+ * be used by backlight drivers.
293+ */
102294 struct mutex update_lock;
103295
104− /* This protects the 'ops' field. If 'ops' is NULL, the driver that
105− registered this device has been unloaded, and if class_get_devdata()
106− points to something in the body of that driver, it is also invalid. */
296+ /**
297+ * @ops_lock: The lock used around everything related to backlight_ops.
298+ *
299+ * ops_lock is an internal backlight lock that protects the ops pointer
300+ * and is used around all accesses to ops and when the operations are
301+ * invoked. The ops_lock shall not be used by backlight drivers.
302+ */
107303 struct mutex ops_lock;
304+
305+ /**
306+ * @ops: Pointer to the backlight operations.
307+ *
308+ * If ops is NULL, the driver that registered this device has been unloaded,
309+ * and if class_get_devdata() points to something in the body of that driver,
310+ * it is also invalid.
311+ */
108312 const struct backlight_ops *ops;
109313
110− /* The framebuffer notifier block */
314+ /**
315+ * @fb_notif: The framebuffer notifier block
316+ */
111317 struct notifier_block fb_notif;
112318
113− /* list entry of all registered backlight devices */
319+ /**
320+ * @entry: List entry of all registered backlight devices
321+ */
114322 struct list_head entry;
115323
324+ /**
325+ * @dev: Parent device.
326+ */
116327 struct device dev;
117328
118− /* Multiple framebuffers may share one backlight device */
329+ /**
330+ * @fb_bl_on: The state of individual fbdev's.
331+ *
332+ * Multiple fbdev's may share one backlight device. The fb_bl_on
333+ * records the state of the individual fbdev.
334+ */
119335 bool fb_bl_on[FB_MAX];
120336
337+ /**
338+ * @use_count: The number of uses of fb_bl_on.
339+ */
121340 int use_count;
122341 };
123342
343+/**
344+ * backlight_update_status - force an update of the backlight device status
345+ * @bd: the backlight device
346+ */
124347 static inline int backlight_update_status(struct backlight_device *bd)
125348 {
126349 int ret = -ENOENT;
@@ -166,49 +389,83 @@ static inline int backlight_disable(struct backlight_device *bd) · 39 unmodified lines
166389 }
167390
168391 /**
169− * backlight_put - Drop backlight reference
170− * @bd: the backlight device to put
392+ * backlight_is_blank - Return true if display is expected to be blank
393+ * @bd: the backlight device
394+ *
395+ * Display is expected to be blank if any of these is true::
396+ *
397+ * 1) if power in not UNBLANK
398+ * 2) if fb_blank is not UNBLANK
399+ * 3) if state indicate BLANK or SUSPENDED
400+ *
401+ * Returns true if display is expected to be blank, false otherwise.
171402 */
172−static inline void backlight_put(struct backlight_device *bd)
403+static inline bool backlight_is_blank(const struct backlight_device *bd)
173404 {
174− if (bd)
175− put_device(&bd->dev);
405+ return bd->props.power != FB_BLANK_UNBLANK ||
406+ bd->props.fb_blank != FB_BLANK_UNBLANK ||
407+ bd->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK);
176408 }
177409
178−extern struct backlight_device *backlight_device_register(const char *name,
179− struct device *dev, void *devdata, const struct backlight_ops *ops,
180− const struct backlight_properties *props);
181−extern struct backlight_device *devm_backlight_device_register(
182− struct device *dev, const char *name, struct device *parent,
183− void *devdata, const struct backlight_ops *ops,
184− const struct backlight_properties *props);
185−extern void backlight_device_unregister(struct backlight_device *bd);
186−extern void devm_backlight_device_unregister(struct device *dev,
187− struct backlight_device *bd);
188−extern void backlight_force_update(struct backlight_device *bd,
189− enum backlight_update_reason reason);
190−extern int backlight_register_notifier(struct notifier_block *nb);
191−extern int backlight_unregister_notifier(struct notifier_block *nb);
192−extern struct backlight_device *backlight_device_get_by_type(enum backlight_type type);
410+/**
411+ * backlight_get_brightness - Returns the current brightness value
412+ * @bd: the backlight device
413+ *
414+ * Returns the current brightness value, taking in consideration the current
415+ * state. If backlight_is_blank() returns true then return 0 as brightness
416+ * otherwise return the current brightness property value.
417+ *
418+ * Backlight drivers are expected to use this function in their update_status()
419+ * operation to get the brightness value.
420+ */
421+static inline int backlight_get_brightness(const struct backlight_device *bd)
422+{
423+ if (backlight_is_blank(bd))
424+ return 0;
425+ else
426+ return bd->props.brightness;
427+}
428+
429+struct backlight_device *
430+backlight_device_register(const char *name, struct device *dev, void *devdata,
431+ const struct backlight_ops *ops,
432+ const struct backlight_properties *props);
433+struct backlight_device *
434+devm_backlight_device_register(struct device *dev, const char *name,
435+ struct device *parent, void *devdata,
436+ const struct backlight_ops *ops,
437+ const struct backlight_properties *props);
438+void backlight_device_unregister(struct backlight_device *bd);
439+void devm_backlight_device_unregister(struct device *dev,
440+ struct backlight_device *bd);
441+void backlight_force_update(struct backlight_device *bd,
442+ enum backlight_update_reason reason);
443+int backlight_register_notifier(struct notifier_block *nb);
444+int backlight_unregister_notifier(struct notifier_block *nb);
193445 struct backlight_device *backlight_device_get_by_name(const char *name);
194−extern int backlight_device_set_brightness(struct backlight_device *bd, unsigned long brightness);
446+struct backlight_device *backlight_device_get_by_type(enum backlight_type type);
447+int backlight_device_set_brightness(struct backlight_device *bd,
448+ unsigned long brightness);
195449
196450 #define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
197451
452+/**
453+ * bl_get_data - access devdata
454+ * @bl_dev: pointer to backlight device
455+ *
456+ * When a backlight device is registered the driver has the possibility
457+ * to supply a void * devdata. bl_get_data() return a pointer to the
458+ * devdata.
459+ *
460+ * RETURNS:
461+ *
462+ * pointer to devdata stored while registering the backlight device.
463+ */
198464 static inline void * bl_get_data(struct backlight_device *bl_dev)
199465 {
200466 return dev_get_drvdata(&bl_dev->dev);
201467 }
202468
203−struct generic_bl_info {
204− const char *name;
205− int max_intensity;
206− int default_intensity;
207− int limit_mask;
208− void (*set_bl_intensity)(int intensity);
209− void (*kick_battery)(void);
210−};
211−
212469 #ifdef CONFIG_OF
213470 struct backlight_device *of_find_backlight_by_node(struct device_node *node);
214471 #else
@@ -220,14 +477,8 @@ of_find_backlight_by_node(struct device_node *node) · 5 unmodified lines
220477 #endif
221478
222479 #if IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE)
223−struct backlight_device *of_find_backlight(struct device *dev);
224480 struct backlight_device *devm_of_find_backlight(struct device *dev);
225481 #else
226−static inline struct backlight_device *of_find_backlight(struct device *dev)
227−{
228− return NULL;
229−}
230−
231482 static inline struct backlight_device *
232483 devm_of_find_backlight(struct device *dev)
233484 {
include/linux/mfd/sky81452.h+0−2
@@ -9,11 +9,9 @@ · 8 unmodified lines
99 #ifndef _SKY81452_H
1010 #define _SKY81452_H
1111
12−#include <linux/platform_data/sky81452-backlight.h>
1312 #include <linux/regulator/machine.h>
1413
1514 struct sky81452_platform_data {
16− struct sky81452_bl_platform_data *bl_pdata;
1715 struct regulator_init_data *regulator_init_data;
1816 };
1917
include/linux/platform_data/sky81452-backlight.h+0−35
@@ -1,35 +0,0 @@
1−/* SPDX-License-Identifier: GPL-2.0-only */
2−/*
3− * sky81452.h SKY81452 backlight driver
4− *
5− * Copyright 2014 Skyworks Solutions Inc.
6− * Author : Gyungoh Yoo <jack.yoo@skyworksinc.com>
7− */
8−
9−#ifndef _SKY81452_BACKLIGHT_H
10−#define _SKY81452_BACKLIGHT_H
11−
12−/**
13− * struct sky81452_platform_data
14− * @name: backlight driver name.
15− If it is not defined, default name is lcd-backlight.
16− * @gpio_enable:GPIO number which control EN pin
17− * @enable: Enable mask for current sink channel 1, 2, 3, 4, 5 and 6.
18− * @ignore_pwm: true if DPWMI should be ignored.
19− * @dpwm_mode: true is DPWM dimming mode, otherwise Analog dimming mode.
20− * @phase_shift:true is phase shift mode.
21− * @short_detecion_threshold: It should be one of 4, 5, 6 and 7V.
22− * @boost_current_limit: It should be one of 2300, 2750mA.
23− */
24−struct sky81452_bl_platform_data {
25− const char *name;
26− int gpio_enable;
27− unsigned int enable;
28− bool ignore_pwm;
29− bool dpwm_mode;
30− bool phase_shift;
31− unsigned int short_detection_threshold;
32− unsigned int boost_current_limit;
33−};
34−
35−#endif