Skip to content

Commit 0a4be72

Browse files
Thomas Zimmermannlag-linaro
authored andcommitted
backlight: Add controls_device callback to struct backlight_ops
Replace check_fb with controls_device in struct backlight_ops. The new callback interface takes a Linux device instead of a framebuffer. Resolves one of the dependencies of backlight.h on fb.h. The few drivers that had custom implementations of check_fb can easily use the framebuffer's Linux device instead. Update them accordingly. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20240305162425.23845-11-tzimmermann@suse.de Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 7929446 commit 0a4be72

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

drivers/video/backlight/backlight.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static int fb_notifier_callback(struct notifier_block *self,
112112

113113
if (!bd->ops)
114114
goto out;
115-
if (bd->ops->check_fb && !bd->ops->check_fb(bd, info))
115+
if (bd->ops->controls_device && !bd->ops->controls_device(bd, info->device))
116116
goto out;
117117
if (fb_bd && fb_bd != bd)
118118
goto out;

drivers/video/backlight/bd6107.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,18 @@ static int bd6107_backlight_update_status(struct backlight_device *backlight)
9999
return 0;
100100
}
101101

102-
static int bd6107_backlight_check_fb(struct backlight_device *backlight,
103-
struct fb_info *info)
102+
static bool bd6107_backlight_controls_device(struct backlight_device *backlight,
103+
struct device *display_dev)
104104
{
105105
struct bd6107 *bd = bl_get_data(backlight);
106106

107-
return !bd->pdata->dev || bd->pdata->dev == info->device;
107+
return !bd->pdata->dev || bd->pdata->dev == display_dev;
108108
}
109109

110110
static const struct backlight_ops bd6107_backlight_ops = {
111-
.options = BL_CORE_SUSPENDRESUME,
112-
.update_status = bd6107_backlight_update_status,
113-
.check_fb = bd6107_backlight_check_fb,
111+
.options = BL_CORE_SUSPENDRESUME,
112+
.update_status = bd6107_backlight_update_status,
113+
.controls_device = bd6107_backlight_controls_device,
114114
};
115115

116116
static int bd6107_probe(struct i2c_client *client)

drivers/video/backlight/gpio_backlight.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,18 @@ static int gpio_backlight_update_status(struct backlight_device *bl)
3030
return 0;
3131
}
3232

33-
static int gpio_backlight_check_fb(struct backlight_device *bl,
34-
struct fb_info *info)
33+
static bool gpio_backlight_controls_device(struct backlight_device *bl,
34+
struct device *display_dev)
3535
{
3636
struct gpio_backlight *gbl = bl_get_data(bl);
3737

38-
return !gbl->dev || gbl->dev == info->device;
38+
return !gbl->dev || gbl->dev == display_dev;
3939
}
4040

4141
static const struct backlight_ops gpio_backlight_ops = {
42-
.options = BL_CORE_SUSPENDRESUME,
43-
.update_status = gpio_backlight_update_status,
44-
.check_fb = gpio_backlight_check_fb,
42+
.options = BL_CORE_SUSPENDRESUME,
43+
.update_status = gpio_backlight_update_status,
44+
.controls_device = gpio_backlight_controls_device,
4545
};
4646

4747
static int gpio_backlight_probe(struct platform_device *pdev)

drivers/video/backlight/lv5207lp.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,18 @@ static int lv5207lp_backlight_update_status(struct backlight_device *backlight)
6262
return 0;
6363
}
6464

65-
static int lv5207lp_backlight_check_fb(struct backlight_device *backlight,
66-
struct fb_info *info)
65+
static bool lv5207lp_backlight_controls_device(struct backlight_device *backlight,
66+
struct device *display_dev)
6767
{
6868
struct lv5207lp *lv = bl_get_data(backlight);
6969

70-
return !lv->pdata->dev || lv->pdata->dev == info->device;
70+
return !lv->pdata->dev || lv->pdata->dev == display_dev;
7171
}
7272

7373
static const struct backlight_ops lv5207lp_backlight_ops = {
74-
.options = BL_CORE_SUSPENDRESUME,
75-
.update_status = lv5207lp_backlight_update_status,
76-
.check_fb = lv5207lp_backlight_check_fb,
74+
.options = BL_CORE_SUSPENDRESUME,
75+
.update_status = lv5207lp_backlight_update_status,
76+
.controls_device = lv5207lp_backlight_controls_device,
7777
};
7878

7979
static int lv5207lp_probe(struct i2c_client *client)

include/linux/backlight.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/fb.h>
1414
#include <linux/mutex.h>
1515
#include <linux/notifier.h>
16+
#include <linux/types.h>
1617

1718
/**
1819
* enum backlight_update_reason - what method was used to update backlight
@@ -110,7 +111,6 @@ enum backlight_scale {
110111
};
111112

112113
struct backlight_device;
113-
struct fb_info;
114114

115115
/**
116116
* struct backlight_ops - backlight operations
@@ -160,18 +160,18 @@ struct backlight_ops {
160160
int (*get_brightness)(struct backlight_device *);
161161

162162
/**
163-
* @check_fb: Check the framebuffer device.
163+
* @controls_device: Check against the display device
164164
*
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.
165+
* Check if the backlight controls the given display device. This
166+
* operation is optional and if not implemented it is assumed that
167+
* the display is always the one controlled by the backlight.
168168
*
169169
* RETURNS:
170170
*
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.
171+
* If display_dev is NULL or display_dev matches the device controlled by
172+
* the backlight, return true. Otherwise return false.
173173
*/
174-
int (*check_fb)(struct backlight_device *bd, struct fb_info *info);
174+
bool (*controls_device)(struct backlight_device *bd, struct device *display_dev);
175175
};
176176

177177
/**

0 commit comments

Comments
 (0)