summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2013-10-02 18:01:02 +0200
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2018-03-28 18:39:50 +0200
commitc3fb2cec492d1bd67c9204fc45f1e517e2fa4f53 (patch)
treef07b065f2ec68f63e9d2818b3d5701a7ae050571 /drivers
parent7a3b733c6b3739708cb8d7c05be75903bbbdaffd (diff)
pwm-backlight: Track enable state
Follow up patches will add support for more complex means of powering the backlight on and off such as using a regulator. To prevent calls to the regulator API from becoming unbalanced, keep track of the enabled state internally. Signed-off-by: Thierry Reding <treding@nvidia.com> (cherry picked from commit 97c38437115aa0c3fb2d50c488814b503ba529e0)
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/backlight/pwm_bl.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index bf7891552ee6..42a1af6aeba6 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -27,6 +27,7 @@ struct pwm_bl_data {
unsigned int period;
unsigned int lth_brightness;
unsigned int *levels;
+ bool enabled;
int (*notify)(struct device *,
int brightness);
void (*notify_after)(struct device *,
@@ -40,6 +41,9 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness,
{
int duty_cycle, err;
+ if (pb->enabled)
+ return;
+
if (pb->levels) {
duty_cycle = pb->levels[brightness];
max = pb->levels[max];
@@ -52,12 +56,18 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness,
pwm_config(pb->pwm, duty_cycle, pb->period);
pwm_enable(pb->pwm);
+ pb->enabled = true;
}
static void pwm_backlight_power_off(struct pwm_bl_data *pb)
{
+ if (!pb->enabled)
+ return;
+
pwm_config(pb->pwm, 0, pb->period);
pwm_disable(pb->pwm);
+
+ pb->enabled = false;
}
static int pwm_backlight_update_status(struct backlight_device *bl)
@@ -216,6 +226,7 @@ static int pwm_backlight_probe(struct platform_device *pdev)
pb->check_fb = data->check_fb;
pb->exit = data->exit;
pb->dev = &pdev->dev;
+ pb->enabled = false;
pb->pwm = devm_pwm_get(&pdev->dev, NULL);
if (IS_ERR(pb->pwm)) {