Skip to content

Commit

Permalink
Merge tag 'backlight-next-5.16' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/lee/backlight

Pull backlight updates from Lee Jones:
 "Fix-ups:
   - Standardise *_exit() and *_remove() return values in ili9320 and
     vgg2432a4

  Bug Fixes:
   - Do not override maximum brightness
   - Propagate errors from get_brightness()"

* tag 'backlight-next-5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight:
  video: backlight: ili9320: Make ili9320_remove() return void
  backlight: Propagate errors from get_brightness()
  video: backlight: Drop maximum brightness override for brightness zero
  • Loading branch information
torvalds committed Nov 8, 2021
2 parents 3a9b0a4 + 3976e97 commit d2f38a3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
28 changes: 17 additions & 11 deletions drivers/video/backlight/backlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,13 @@ static ssize_t actual_brightness_show(struct device *dev,
struct backlight_device *bd = to_backlight_device(dev);

mutex_lock(&bd->ops_lock);
if (bd->ops && bd->ops->get_brightness)
rc = sprintf(buf, "%d\n", bd->ops->get_brightness(bd));
else
if (bd->ops && bd->ops->get_brightness) {
rc = bd->ops->get_brightness(bd);
if (rc >= 0)
rc = sprintf(buf, "%d\n", rc);
} else {
rc = sprintf(buf, "%d\n", bd->props.brightness);
}
mutex_unlock(&bd->ops_lock);

return rc;
Expand Down Expand Up @@ -381,9 +384,18 @@ ATTRIBUTE_GROUPS(bl_device);
void backlight_force_update(struct backlight_device *bd,
enum backlight_update_reason reason)
{
int brightness;

mutex_lock(&bd->ops_lock);
if (bd->ops && bd->ops->get_brightness)
bd->props.brightness = bd->ops->get_brightness(bd);
if (bd->ops && bd->ops->get_brightness) {
brightness = bd->ops->get_brightness(bd);
if (brightness >= 0)
bd->props.brightness = brightness;
else
dev_err(&bd->dev,
"Could not update brightness from device: %pe\n",
ERR_PTR(brightness));
}
mutex_unlock(&bd->ops_lock);
backlight_generate_event(bd, reason);
}
Expand Down Expand Up @@ -688,12 +700,6 @@ static struct backlight_device *of_find_backlight(struct device *dev)
of_node_put(np);
if (!bd)
return ERR_PTR(-EPROBE_DEFER);
/*
* Note: gpio_backlight uses brightness as
* power state during probe
*/
if (!bd->props.brightness)
bd->props.brightness = bd->props.max_brightness;
}
}

Expand Down
3 changes: 1 addition & 2 deletions drivers/video/backlight/ili9320.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,9 @@ int ili9320_probe_spi(struct spi_device *spi,
}
EXPORT_SYMBOL_GPL(ili9320_probe_spi);

int ili9320_remove(struct ili9320 *ili)
void ili9320_remove(struct ili9320 *ili)
{
ili9320_power(ili, FB_BLANK_POWERDOWN);
return 0;
}
EXPORT_SYMBOL_GPL(ili9320_remove);

Expand Down
2 changes: 1 addition & 1 deletion drivers/video/backlight/ili9320.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ extern int ili9320_write_regs(struct ili9320 *ili,
extern int ili9320_probe_spi(struct spi_device *spi,
struct ili9320_client *cli);

extern int ili9320_remove(struct ili9320 *lcd);
extern void ili9320_remove(struct ili9320 *lcd);
extern void ili9320_shutdown(struct ili9320 *lcd);

/* PM */
Expand Down
4 changes: 3 additions & 1 deletion drivers/video/backlight/vgg2432a4.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ static int vgg2432a4_probe(struct spi_device *spi)

static int vgg2432a4_remove(struct spi_device *spi)
{
return ili9320_remove(spi_get_drvdata(spi));
ili9320_remove(spi_get_drvdata(spi));

return 0;
}

static void vgg2432a4_shutdown(struct spi_device *spi)
Expand Down

0 comments on commit d2f38a3

Please sign in to comment.