backlight: s6e63m0: replace EFAULT with EINVAL
[pandora-kernel.git] / drivers / video / backlight / s6e63m0.c
index 3e1c113..87831bb 100644 (file)
@@ -43,8 +43,6 @@
 #define MIN_BRIGHTNESS         0
 #define MAX_BRIGHTNESS         10
 
-#define POWER_IS_ON(pwr)       ((pwr) <= FB_BLANK_NORMAL)
-
 struct s6e63m0 {
        struct device                   *dev;
        struct spi_device               *spi;
@@ -57,7 +55,7 @@ struct s6e63m0 {
        struct lcd_platform_data        *lcd_pd;
 };
 
-static const unsigned short SEQ_PANEL_CONDITION_SET[] = {
+static const unsigned short seq_panel_condition_set[] = {
        0xF8, 0x01,
        DATA_ONLY, 0x27,
        DATA_ONLY, 0x27,
@@ -76,7 +74,7 @@ static const unsigned short SEQ_PANEL_CONDITION_SET[] = {
        ENDDEF, 0x0000
 };
 
-static const unsigned short SEQ_DISPLAY_CONDITION_SET[] = {
+static const unsigned short seq_display_condition_set[] = {
        0xf2, 0x02,
        DATA_ONLY, 0x03,
        DATA_ONLY, 0x1c,
@@ -90,7 +88,7 @@ static const unsigned short SEQ_DISPLAY_CONDITION_SET[] = {
        ENDDEF, 0x0000
 };
 
-static const unsigned short SEQ_GAMMA_SETTING[] = {
+static const unsigned short seq_gamma_setting[] = {
        0xfa, 0x00,
        DATA_ONLY, 0x18,
        DATA_ONLY, 0x08,
@@ -119,7 +117,7 @@ static const unsigned short SEQ_GAMMA_SETTING[] = {
        ENDDEF, 0x0000
 };
 
-static const unsigned short SEQ_ETC_CONDITION_SET[] = {
+static const unsigned short seq_etc_condition_set[] = {
        0xf6, 0x00,
        DATA_ONLY, 0x8c,
        DATA_ONLY, 0x07,
@@ -318,47 +316,47 @@ static const unsigned short SEQ_ETC_CONDITION_SET[] = {
        ENDDEF, 0x0000
 };
 
-static const unsigned short SEQ_ACL_ON[] = {
+static const unsigned short seq_acl_on[] = {
        /* ACL on */
        0xc0, 0x01,
 
        ENDDEF, 0x0000
 };
 
-static const unsigned short SEQ_ACL_OFF[] = {
+static const unsigned short seq_acl_off[] = {
        /* ACL off */
        0xc0, 0x00,
 
        ENDDEF, 0x0000
 };
 
-static const unsigned short SEQ_ELVSS_ON[] = {
+static const unsigned short seq_elvss_on[] = {
        /* ELVSS on */
        0xb1, 0x0b,
 
        ENDDEF, 0x0000
 };
 
-static const unsigned short SEQ_ELVSS_OFF[] = {
+static const unsigned short seq_elvss_off[] = {
        /* ELVSS off */
        0xb1, 0x0a,
 
        ENDDEF, 0x0000
 };
 
-static const unsigned short SEQ_STAND_BY_OFF[] = {
+static const unsigned short seq_stand_by_off[] = {
        0x11, COMMAND_ONLY,
 
        ENDDEF, 0x0000
 };
 
-static const unsigned short SEQ_STAND_BY_ON[] = {
+static const unsigned short seq_stand_by_on[] = {
        0x10, COMMAND_ONLY,
 
        ENDDEF, 0x0000
 };
 
-static const unsigned short SEQ_DISPLAY_ON[] = {
+static const unsigned short seq_display_on[] = {
        0x29, COMMAND_ONLY,
 
        ENDDEF, 0x0000
@@ -406,8 +404,9 @@ static int s6e63m0_panel_send_sequence(struct s6e63m0 *lcd,
                        ret = s6e63m0_spi_write(lcd, wbuf[i], wbuf[i+1]);
                        if (ret)
                                break;
-               } else
-                       udelay(wbuf[i+1]*1000);
+               } else {
+                       msleep(wbuf[i+1]);
+               }
                i += 2;
        }
 
@@ -457,12 +456,12 @@ static int s6e63m0_ldi_init(struct s6e63m0 *lcd)
 {
        int ret, i;
        const unsigned short *init_seq[] = {
-               SEQ_PANEL_CONDITION_SET,
-               SEQ_DISPLAY_CONDITION_SET,
-               SEQ_GAMMA_SETTING,
-               SEQ_ETC_CONDITION_SET,
-               SEQ_ACL_ON,
-               SEQ_ELVSS_ON,
+               seq_panel_condition_set,
+               seq_display_condition_set,
+               seq_gamma_setting,
+               seq_etc_condition_set,
+               seq_acl_on,
+               seq_elvss_on,
        };
 
        for (i = 0; i < ARRAY_SIZE(init_seq); i++) {
@@ -478,8 +477,8 @@ static int s6e63m0_ldi_enable(struct s6e63m0 *lcd)
 {
        int ret = 0, i;
        const unsigned short *enable_seq[] = {
-               SEQ_STAND_BY_OFF,
-               SEQ_DISPLAY_ON,
+               seq_stand_by_off,
+               seq_display_on,
        };
 
        for (i = 0; i < ARRAY_SIZE(enable_seq); i++) {
@@ -495,43 +494,39 @@ static int s6e63m0_ldi_disable(struct s6e63m0 *lcd)
 {
        int ret;
 
-       ret = s6e63m0_panel_send_sequence(lcd, SEQ_STAND_BY_ON);
+       ret = s6e63m0_panel_send_sequence(lcd, seq_stand_by_on);
 
        return ret;
 }
 
+static int s6e63m0_power_is_on(int power)
+{
+       return power <= FB_BLANK_NORMAL;
+}
+
 static int s6e63m0_power_on(struct s6e63m0 *lcd)
 {
        int ret = 0;
-       struct lcd_platform_data *pd = NULL;
-       struct backlight_device *bd = NULL;
+       struct lcd_platform_data *pd;
+       struct backlight_device *bd;
 
        pd = lcd->lcd_pd;
-       if (!pd) {
-               dev_err(lcd->dev, "platform data is NULL.\n");
-               return -EFAULT;
-       }
-
        bd = lcd->bd;
-       if (!bd) {
-               dev_err(lcd->dev, "backlight device is NULL.\n");
-               return -EFAULT;
-       }
 
        if (!pd->power_on) {
                dev_err(lcd->dev, "power_on is NULL.\n");
-               return -EFAULT;
+               return -EINVAL;
        } else {
                pd->power_on(lcd->ld, 1);
-               mdelay(pd->power_on_delay);
+               msleep(pd->power_on_delay);
        }
 
        if (!pd->reset) {
                dev_err(lcd->dev, "reset is NULL.\n");
-               return -EFAULT;
+               return -EINVAL;
        } else {
                pd->reset(lcd->ld);
-               mdelay(pd->reset_delay);
+               msleep(pd->reset_delay);
        }
 
        ret = s6e63m0_ldi_init(lcd);
@@ -558,14 +553,10 @@ static int s6e63m0_power_on(struct s6e63m0 *lcd)
 
 static int s6e63m0_power_off(struct s6e63m0 *lcd)
 {
-       int ret = 0;
-       struct lcd_platform_data *pd = NULL;
+       int ret;
+       struct lcd_platform_data *pd;
 
        pd = lcd->lcd_pd;
-       if (!pd) {
-               dev_err(lcd->dev, "platform data is NULL.\n");
-               return -EFAULT;
-       }
 
        ret = s6e63m0_ldi_disable(lcd);
        if (ret) {
@@ -573,13 +564,9 @@ static int s6e63m0_power_off(struct s6e63m0 *lcd)
                return -EIO;
        }
 
-       mdelay(pd->power_off_delay);
+       msleep(pd->power_off_delay);
 
-       if (!pd->power_on) {
-               dev_err(lcd->dev, "power_on is NULL.\n");
-               return -EFAULT;
-       } else
-               pd->power_on(lcd->ld, 0);
+       pd->power_on(lcd->ld, 0);
 
        return 0;
 }
@@ -588,9 +575,9 @@ static int s6e63m0_power(struct s6e63m0 *lcd, int power)
 {
        int ret = 0;
 
-       if (POWER_IS_ON(power) && !POWER_IS_ON(lcd->power))
+       if (s6e63m0_power_is_on(power) && !s6e63m0_power_is_on(lcd->power))
                ret = s6e63m0_power_on(lcd);
-       else if (!POWER_IS_ON(power) && POWER_IS_ON(lcd->power))
+       else if (!s6e63m0_power_is_on(power) && s6e63m0_power_is_on(lcd->power))
                ret = s6e63m0_power_off(lcd);
 
        if (!ret)
@@ -760,7 +747,7 @@ static int s6e63m0_probe(struct spi_device *spi)
        lcd->lcd_pd = spi->dev.platform_data;
        if (!lcd->lcd_pd) {
                dev_err(&spi->dev, "platform data is NULL.\n");
-               return -EFAULT;
+               return -EINVAL;
        }
 
        ld = lcd_device_register("s6e63m0", &spi->dev, lcd, &s6e63m0_lcd_ops);
@@ -811,8 +798,9 @@ static int s6e63m0_probe(struct spi_device *spi)
                lcd->power = FB_BLANK_POWERDOWN;
 
                s6e63m0_power(lcd, FB_BLANK_UNBLANK);
-       } else
+       } else {
                lcd->power = FB_BLANK_UNBLANK;
+       }
 
        dev_set_drvdata(&spi->dev, lcd);