leds: lp8550: don't save register values to NVM
authorJames Wylder <james.wylder@motorola.com>
Sun, 16 Jan 2011 20:56:44 +0000 (14:56 -0600)
committerRebecca Schultz Zavin <rebecca@android.com>
Tue, 18 Jan 2011 21:11:14 +0000 (13:11 -0800)
Reinitialize the backlight registers on each boot
rather than save them to non-volatile memory.  Any
errors in the NVM can make the module unrecoverable.

Change-Id: Ibae4c0cc27c872dff4072f132402b06e815232de
Signed-off-by: James Wylder <james.wylder@motorola.com>
drivers/leds/leds-lp8550.c

index cdf48a47b24ada0fc61648c9fa2057281a147220..8ea437da157473085951a7a683a724ddd529612d 100755 (executable)
@@ -160,46 +160,18 @@ static int lp8550_write_reg(struct lp8550_data *led_data, uint8_t reg,
 
 static int ld_lp8550_init_registers(struct lp8550_data *led_data)
 {
-       unsigned i, n, reg_count, reg_addr;
+       unsigned i, reg_addr;
        uint8_t value = 0;
 
-       /* Check the EEPROM values and update if neccessary */
-       reg_count = 8;
-       reg_addr = LP8550_EEPROM_A0;
-       for (i = 0, n = 0; i < reg_count; i++) {
-               lp8550_read_reg(led_data, reg_addr, &value);
-               if (lp8550_debug)
-                       pr_info("%s:Register 0x%x value 0x%X\n", __func__,
-                               reg_addr, value);
-               if (value != led_data->led_pdata->eeprom_table[n].eeprom_data) {
-                       if (lp8550_debug)
-                               pr_info("%s:Writing 0x%x to 0x%X\n", __func__,
-                               led_data->led_pdata->eeprom_table[n].eeprom_data,
-                               reg_addr);
-                       if (lp8550_write_reg(led_data, LP8550_DEVICE_CTRL,
-                                       0x05))
-                               pr_err("%s:Register initialization failed\n",
-                                       __func__);
-                       if (lp8550_write_reg(led_data, reg_addr,
-                               led_data->led_pdata->eeprom_table[n].eeprom_data))
-                               pr_err("%s:Register initialization failed\n",
-                                       __func__);
-                       if (lp8550_write_reg(led_data, LP8550_EEPROM_CTRL,
-                                       0x04))
-                               pr_err("%s:Register initialization failed\n",
+       if (lp8550_write_reg(led_data, LP8550_DEVICE_CTRL, 0x05))
+               pr_err("%s:Register initialization failed\n",
                                        __func__);
-                       if (lp8550_write_reg(led_data, LP8550_EEPROM_CTRL,
-                                       0x02))
-                               pr_err("%s:Register initialization failed\n",
-                                       __func__);
-                       msleep(200);
-                       if (lp8550_write_reg(led_data, LP8550_EEPROM_CTRL,
-                                       0x00))
-                               pr_err("%s:Register initialization failed\n",
-                                       __func__);
-               }
-               n++;
-               reg_addr++;
+
+       for (i = 0; i < led_data->led_pdata->eeprom_tbl_sz; i++) {
+               reg_addr = LP8550_EEPROM_A0 + i;
+               value = led_data->led_pdata->eeprom_table[i].eeprom_data;
+               if (lp8550_write_reg(led_data, reg_addr, value))
+                       pr_err("%s:Register initialization failed\n", __func__);
        }
 
        if (lp8550_write_reg(led_data, LP8550_DEVICE_CTRL,