Skip to content

Commit d2f38a3

Browse files
committed
Merge tag 'backlight-next-5.16' of git://git.kernel.org/pub/scm/linux/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
2 parents 3a9b0a4 + 3976e97 commit d2f38a3

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

drivers/video/backlight/backlight.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,13 @@ static ssize_t actual_brightness_show(struct device *dev,
292292
struct backlight_device *bd = to_backlight_device(dev);
293293

294294
mutex_lock(&bd->ops_lock);
295-
if (bd->ops && bd->ops->get_brightness)
296-
rc = sprintf(buf, "%d\n", bd->ops->get_brightness(bd));
297-
else
295+
if (bd->ops && bd->ops->get_brightness) {
296+
rc = bd->ops->get_brightness(bd);
297+
if (rc >= 0)
298+
rc = sprintf(buf, "%d\n", rc);
299+
} else {
298300
rc = sprintf(buf, "%d\n", bd->props.brightness);
301+
}
299302
mutex_unlock(&bd->ops_lock);
300303

301304
return rc;
@@ -381,9 +384,18 @@ ATTRIBUTE_GROUPS(bl_device);
381384
void backlight_force_update(struct backlight_device *bd,
382385
enum backlight_update_reason reason)
383386
{
387+
int brightness;
388+
384389
mutex_lock(&bd->ops_lock);
385-
if (bd->ops && bd->ops->get_brightness)
386-
bd->props.brightness = bd->ops->get_brightness(bd);
390+
if (bd->ops && bd->ops->get_brightness) {
391+
brightness = bd->ops->get_brightness(bd);
392+
if (brightness >= 0)
393+
bd->props.brightness = brightness;
394+
else
395+
dev_err(&bd->dev,
396+
"Could not update brightness from device: %pe\n",
397+
ERR_PTR(brightness));
398+
}
387399
mutex_unlock(&bd->ops_lock);
388400
backlight_generate_event(bd, reason);
389401
}
@@ -688,12 +700,6 @@ static struct backlight_device *of_find_backlight(struct device *dev)
688700
of_node_put(np);
689701
if (!bd)
690702
return ERR_PTR(-EPROBE_DEFER);
691-
/*
692-
* Note: gpio_backlight uses brightness as
693-
* power state during probe
694-
*/
695-
if (!bd->props.brightness)
696-
bd->props.brightness = bd->props.max_brightness;
697703
}
698704
}
699705

drivers/video/backlight/ili9320.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,9 @@ int ili9320_probe_spi(struct spi_device *spi,
251251
}
252252
EXPORT_SYMBOL_GPL(ili9320_probe_spi);
253253

254-
int ili9320_remove(struct ili9320 *ili)
254+
void ili9320_remove(struct ili9320 *ili)
255255
{
256256
ili9320_power(ili, FB_BLANK_POWERDOWN);
257-
return 0;
258257
}
259258
EXPORT_SYMBOL_GPL(ili9320_remove);
260259

drivers/video/backlight/ili9320.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ extern int ili9320_write_regs(struct ili9320 *ili,
6868
extern int ili9320_probe_spi(struct spi_device *spi,
6969
struct ili9320_client *cli);
7070

71-
extern int ili9320_remove(struct ili9320 *lcd);
71+
extern void ili9320_remove(struct ili9320 *lcd);
7272
extern void ili9320_shutdown(struct ili9320 *lcd);
7373

7474
/* PM */

drivers/video/backlight/vgg2432a4.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ static int vgg2432a4_probe(struct spi_device *spi)
235235

236236
static int vgg2432a4_remove(struct spi_device *spi)
237237
{
238-
return ili9320_remove(spi_get_drvdata(spi));
238+
ili9320_remove(spi_get_drvdata(spi));
239+
240+
return 0;
239241
}
240242

241243
static void vgg2432a4_shutdown(struct spi_device *spi)

0 commit comments

Comments
 (0)