mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-29 23:53:32 +00:00
backlight: jornada720: Minimise code duplication and handle errors better
Rickard Strandqvi's ran a code analysis application which found that jornada_lcd_get_contrast(() and jornada_lcd_set_contrast() contained some code duplication (calling the same functions during various code execution paths) and failed to return errors in a consistent manner. This patch aims to simplify the code, coercing it into behaving at a level expected of a driver in the Linux kernel. Suggested-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> Acked-by: Jingoo Han <jg1.han@samsung.com> Reviewed-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se> Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
parent
b3de3402e5
commit
1e3b097012
1 changed files with 19 additions and 18 deletions
|
@ -43,37 +43,38 @@ static int jornada_lcd_get_contrast(struct lcd_device *ld)
|
||||||
|
|
||||||
jornada_ssp_start();
|
jornada_ssp_start();
|
||||||
|
|
||||||
if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY) {
|
if (jornada_ssp_byte(GETCONTRAST) == TXDUMMY) {
|
||||||
dev_err(&ld->dev, "get contrast failed\n");
|
|
||||||
jornada_ssp_end();
|
|
||||||
return -ETIMEDOUT;
|
|
||||||
} else {
|
|
||||||
ret = jornada_ssp_byte(TXDUMMY);
|
ret = jornada_ssp_byte(TXDUMMY);
|
||||||
jornada_ssp_end();
|
goto success;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dev_err(&ld->dev, "failed to set contrast\n");
|
||||||
|
ret = -ETIMEDOUT;
|
||||||
|
|
||||||
|
success:
|
||||||
|
jornada_ssp_end();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int jornada_lcd_set_contrast(struct lcd_device *ld, int value)
|
static int jornada_lcd_set_contrast(struct lcd_device *ld, int value)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret = 0;
|
||||||
|
|
||||||
jornada_ssp_start();
|
jornada_ssp_start();
|
||||||
|
|
||||||
/* start by sending our set contrast cmd to mcu */
|
/* start by sending our set contrast cmd to mcu */
|
||||||
ret = jornada_ssp_byte(SETCONTRAST);
|
if (jornada_ssp_byte(SETCONTRAST) == TXDUMMY) {
|
||||||
|
/* if successful push the new value */
|
||||||
/* push the new value */
|
if (jornada_ssp_byte(value) == TXDUMMY)
|
||||||
if (jornada_ssp_byte(value) != TXDUMMY) {
|
goto success;
|
||||||
dev_err(&ld->dev, "set contrast failed\n");
|
|
||||||
jornada_ssp_end();
|
|
||||||
return -ETIMEDOUT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we get here we can assume everything went well */
|
dev_err(&ld->dev, "failed to set contrast\n");
|
||||||
jornada_ssp_end();
|
ret = -ETIMEDOUT;
|
||||||
|
|
||||||
return 0;
|
success:
|
||||||
|
jornada_ssp_end();
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int jornada_lcd_set_power(struct lcd_device *ld, int power)
|
static int jornada_lcd_set_power(struct lcd_device *ld, int power)
|
||||||
|
|
Loading…
Reference in a new issue