diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-11-16 13:36:46 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-11-16 13:36:46 -0500 |
| commit | 9c7a867ebdef0d484a4c9329007179fbbd08affc (patch) | |
| tree | 0f172745fff4b5fee1086d83982257ac1c2a5cf3 | |
| parent | d3092e4e9937bdc7e3444fea1b47132e53c9cd41 (diff) | |
| parent | 29fae2c1db242a39c5c7c49434fb183f990df2f8 (diff) | |
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
| -rw-r--r-- | drivers/video/backlight/ili922x.c | 3 | ||||
| -rw-r--r-- | drivers/video/backlight/pwm_bl.c | 7 | ||||
| -rw-r--r-- | drivers/video/backlight/tps65217_bl.c | 3 |
3 files changed, 7 insertions, 6 deletions
diff --git a/drivers/video/backlight/ili922x.c b/drivers/video/backlight/ili922x.c index a9e9cef20ed6..2b6c6aaf4e14 100644 --- a/drivers/video/backlight/ili922x.c +++ b/drivers/video/backlight/ili922x.c | |||
| @@ -251,7 +251,7 @@ static int ili922x_write(struct spi_device *spi, u8 reg, u16 value) | |||
| 251 | struct spi_transfer xfer_regindex, xfer_regvalue; | 251 | struct spi_transfer xfer_regindex, xfer_regvalue; |
| 252 | unsigned char tbuf[CMD_BUFSIZE]; | 252 | unsigned char tbuf[CMD_BUFSIZE]; |
| 253 | unsigned char rbuf[CMD_BUFSIZE]; | 253 | unsigned char rbuf[CMD_BUFSIZE]; |
| 254 | int ret, len = 0; | 254 | int ret; |
| 255 | 255 | ||
| 256 | memset(&xfer_regindex, 0, sizeof(struct spi_transfer)); | 256 | memset(&xfer_regindex, 0, sizeof(struct spi_transfer)); |
| 257 | memset(&xfer_regvalue, 0, sizeof(struct spi_transfer)); | 257 | memset(&xfer_regvalue, 0, sizeof(struct spi_transfer)); |
| @@ -273,7 +273,6 @@ static int ili922x_write(struct spi_device *spi, u8 reg, u16 value) | |||
| 273 | ret = spi_sync(spi, &msg); | 273 | ret = spi_sync(spi, &msg); |
| 274 | 274 | ||
| 275 | spi_message_init(&msg); | 275 | spi_message_init(&msg); |
| 276 | len = 0; | ||
| 277 | tbuf[0] = set_tx_byte(START_BYTE(ili922x_id, START_RS_REG, | 276 | tbuf[0] = set_tx_byte(START_BYTE(ili922x_id, START_RS_REG, |
| 278 | START_RW_WRITE)); | 277 | START_RW_WRITE)); |
| 279 | tbuf[1] = set_tx_byte((value & 0xFF00) >> 8); | 278 | tbuf[1] = set_tx_byte((value & 0xFF00) >> 8); |
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c index 9bd17682655a..1c2289ddd555 100644 --- a/drivers/video/backlight/pwm_bl.c +++ b/drivers/video/backlight/pwm_bl.c | |||
| @@ -79,14 +79,17 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb) | |||
| 79 | static int compute_duty_cycle(struct pwm_bl_data *pb, int brightness) | 79 | static int compute_duty_cycle(struct pwm_bl_data *pb, int brightness) |
| 80 | { | 80 | { |
| 81 | unsigned int lth = pb->lth_brightness; | 81 | unsigned int lth = pb->lth_brightness; |
| 82 | int duty_cycle; | 82 | u64 duty_cycle; |
| 83 | 83 | ||
| 84 | if (pb->levels) | 84 | if (pb->levels) |
| 85 | duty_cycle = pb->levels[brightness]; | 85 | duty_cycle = pb->levels[brightness]; |
| 86 | else | 86 | else |
| 87 | duty_cycle = brightness; | 87 | duty_cycle = brightness; |
| 88 | 88 | ||
| 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; | ||
| 90 | } | 93 | } |
| 91 | 94 | ||
| 92 | static int pwm_backlight_update_status(struct backlight_device *bl) | 95 | static int pwm_backlight_update_status(struct backlight_device *bl) |
diff --git a/drivers/video/backlight/tps65217_bl.c b/drivers/video/backlight/tps65217_bl.c index 5ce8791f4523..380917c86276 100644 --- a/drivers/video/backlight/tps65217_bl.c +++ b/drivers/video/backlight/tps65217_bl.c | |||
| @@ -239,8 +239,7 @@ tps65217_bl_parse_dt(struct platform_device *pdev) | |||
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | if (!of_property_read_u32(node, "default-brightness", &val)) { | 241 | if (!of_property_read_u32(node, "default-brightness", &val)) { |
| 242 | if (val < 0 || | 242 | if (val > 100) { |
| 243 | val > 100) { | ||
| 244 | dev_err(&pdev->dev, | 243 | dev_err(&pdev->dev, |
| 245 | "invalid 'default-brightness' value in the device tree\n"); | 244 | "invalid 'default-brightness' value in the device tree\n"); |
| 246 | err = ERR_PTR(-EINVAL); | 245 | err = ERR_PTR(-EINVAL); |
