Commit 0a4be726 authored by Thomas Zimmermann's avatar Thomas Zimmermann Committed by Lee Jones

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: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Link: https://lore.kernel.org/r/20240305162425.23845-11-tzimmermann@suse.deSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent 79294467
......@@ -112,7 +112,7 @@ static int fb_notifier_callback(struct notifier_block *self,
if (!bd->ops)
goto out;
if (bd->ops->check_fb && !bd->ops->check_fb(bd, info))
if (bd->ops->controls_device && !bd->ops->controls_device(bd, info->device))
goto out;
if (fb_bd && fb_bd != bd)
goto out;
......
......@@ -99,18 +99,18 @@ static int bd6107_backlight_update_status(struct backlight_device *backlight)
return 0;
}
static int bd6107_backlight_check_fb(struct backlight_device *backlight,
struct fb_info *info)
static bool bd6107_backlight_controls_device(struct backlight_device *backlight,
struct device *display_dev)
{
struct bd6107 *bd = bl_get_data(backlight);
return !bd->pdata->dev || bd->pdata->dev == info->device;
return !bd->pdata->dev || bd->pdata->dev == display_dev;
}
static const struct backlight_ops bd6107_backlight_ops = {
.options = BL_CORE_SUSPENDRESUME,
.update_status = bd6107_backlight_update_status,
.check_fb = bd6107_backlight_check_fb,
.options = BL_CORE_SUSPENDRESUME,
.update_status = bd6107_backlight_update_status,
.controls_device = bd6107_backlight_controls_device,
};
static int bd6107_probe(struct i2c_client *client)
......
......@@ -30,18 +30,18 @@ static int gpio_backlight_update_status(struct backlight_device *bl)
return 0;
}
static int gpio_backlight_check_fb(struct backlight_device *bl,
struct fb_info *info)
static bool gpio_backlight_controls_device(struct backlight_device *bl,
struct device *display_dev)
{
struct gpio_backlight *gbl = bl_get_data(bl);
return !gbl->dev || gbl->dev == info->device;
return !gbl->dev || gbl->dev == display_dev;
}
static const struct backlight_ops gpio_backlight_ops = {
.options = BL_CORE_SUSPENDRESUME,
.update_status = gpio_backlight_update_status,
.check_fb = gpio_backlight_check_fb,
.options = BL_CORE_SUSPENDRESUME,
.update_status = gpio_backlight_update_status,
.controls_device = gpio_backlight_controls_device,
};
static int gpio_backlight_probe(struct platform_device *pdev)
......
......@@ -62,18 +62,18 @@ static int lv5207lp_backlight_update_status(struct backlight_device *backlight)
return 0;
}
static int lv5207lp_backlight_check_fb(struct backlight_device *backlight,
struct fb_info *info)
static bool lv5207lp_backlight_controls_device(struct backlight_device *backlight,
struct device *display_dev)
{
struct lv5207lp *lv = bl_get_data(backlight);
return !lv->pdata->dev || lv->pdata->dev == info->device;
return !lv->pdata->dev || lv->pdata->dev == display_dev;
}
static const struct backlight_ops lv5207lp_backlight_ops = {
.options = BL_CORE_SUSPENDRESUME,
.update_status = lv5207lp_backlight_update_status,
.check_fb = lv5207lp_backlight_check_fb,
.options = BL_CORE_SUSPENDRESUME,
.update_status = lv5207lp_backlight_update_status,
.controls_device = lv5207lp_backlight_controls_device,
};
static int lv5207lp_probe(struct i2c_client *client)
......
......@@ -13,6 +13,7 @@
#include <linux/fb.h>
#include <linux/mutex.h>
#include <linux/notifier.h>
#include <linux/types.h>
/**
* enum backlight_update_reason - what method was used to update backlight
......@@ -110,7 +111,6 @@ enum backlight_scale {
};
struct backlight_device;
struct fb_info;
/**
* struct backlight_ops - backlight operations
......@@ -160,18 +160,18 @@ struct backlight_ops {
int (*get_brightness)(struct backlight_device *);
/**
* @check_fb: Check the framebuffer device.
* @controls_device: Check against the display 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.
* Check if the backlight controls the given display device. This
* operation is optional and if not implemented it is assumed that
* the display is always the one controlled by 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.
* If display_dev is NULL or display_dev matches the device controlled by
* the backlight, return true. Otherwise return false.
*/
int (*check_fb)(struct backlight_device *bd, struct fb_info *info);
bool (*controls_device)(struct backlight_device *bd, struct device *display_dev);
};
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment