Skip to content

Commit 9c7a867

Browse files
committed
Merge tag 'backlight-next-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight
Pull backlight updates from Lee Jones: - handle 32bit overflow in pwm_bl - remove redundant code/checks in tps65217_bl and ili922x * tag 'backlight-next-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight: backlight: ili922x: Remove redundant variable len backlight: tps65217_bl: Remove unnecessary default brightness check backlight: pwm_bl: Fix overflow condition
2 parents d3092e4 + 29fae2c commit 9c7a867

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎drivers/video/backlight/ili922x.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static int ili922x_write(struct spi_device *spi, u8 reg, u16 value)
251251
struct spi_transfer xfer_regindex, xfer_regvalue;
252252
unsigned char tbuf[CMD_BUFSIZE];
253253
unsigned char rbuf[CMD_BUFSIZE];
254-
int ret, len = 0;
254+
int ret;
255255

256256
memset(&xfer_regindex, 0, sizeof(struct spi_transfer));
257257
memset(&xfer_regvalue, 0, sizeof(struct spi_transfer));
@@ -273,7 +273,6 @@ static int ili922x_write(struct spi_device *spi, u8 reg, u16 value)
273273
ret = spi_sync(spi, &msg);
274274

275275
spi_message_init(&msg);
276-
len = 0;
277276
tbuf[0] = set_tx_byte(START_BYTE(ili922x_id, START_RS_REG,
278277
START_RW_WRITE));
279278
tbuf[1] = set_tx_byte((value & 0xFF00) >> 8);

‎drivers/video/backlight/pwm_bl.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,17 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb)
7979
static int compute_duty_cycle(struct pwm_bl_data *pb, int brightness)
8080
{
8181
unsigned int lth = pb->lth_brightness;
82-
int duty_cycle;
82+
u64 duty_cycle;
8383

8484
if (pb->levels)
8585
duty_cycle = pb->levels[brightness];
8686
else
8787
duty_cycle = brightness;
8888

89-
return (duty_cycle * (pb->period - lth) / pb->scale) + lth;
89+
duty_cycle *= pb->period - lth;
90+
do_div(duty_cycle, pb->scale);
91+
92+
return duty_cycle + lth;
9093
}
9194

9295
static int pwm_backlight_update_status(struct backlight_device *bl)

‎drivers/video/backlight/tps65217_bl.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ tps65217_bl_parse_dt(struct platform_device *pdev)
239239
}
240240

241241
if (!of_property_read_u32(node, "default-brightness", &val)) {
242-
if (val < 0 ||
243-
val > 100) {
242+
if (val > 100) {
244243
dev_err(&pdev->dev,
245244
"invalid 'default-brightness' value in the device tree\n");
246245
err = ERR_PTR(-EINVAL);

0 commit comments

Comments
 (0)