Skip to content

Commit

Permalink
drivers/video/backlight/lcd.c: return ENXIO when ops functions cannot…
Browse files Browse the repository at this point in the history
… be called

Previously, when ops functions cannot be called, lcd_show_contrast() and
lcd_store_contrast() returned 0, instead of ENXIO.

Thus, in this case, a local variable 'rc' for return value should be
initialized as ENXIO, after kstrtoul() is called.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Jingoo Han authored and Linus Torvalds committed Dec 18, 2012
1 parent 2fe2380 commit 424e06e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/video/backlight/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,16 @@ static ssize_t lcd_show_power(struct device *dev, struct device_attribute *attr,
static ssize_t lcd_store_power(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int rc = -ENXIO;
int rc;
struct lcd_device *ld = to_lcd_device(dev);
unsigned long power;

rc = kstrtoul(buf, 0, &power);
if (rc)
return rc;

rc = -ENXIO;

mutex_lock(&ld->ops_lock);
if (ld->ops && ld->ops->set_power) {
pr_debug("set power to %lu\n", power);
Expand Down Expand Up @@ -144,14 +146,16 @@ static ssize_t lcd_show_contrast(struct device *dev,
static ssize_t lcd_store_contrast(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
int rc = -ENXIO;
int rc;
struct lcd_device *ld = to_lcd_device(dev);
unsigned long contrast;

rc = kstrtoul(buf, 0, &contrast);
if (rc)
return rc;

rc = -ENXIO;

mutex_lock(&ld->ops_lock);
if (ld->ops && ld->ops->set_contrast) {
pr_debug("set contrast to %lu\n", contrast);
Expand Down

0 comments on commit 424e06e

Please sign in to comment.