summaryrefslogtreecommitdiff
path: root/drivers/leds/leds-lp5523.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/leds/leds-lp5523.c')
-rw-r--r--drivers/leds/leds-lp5523.c50
1 files changed, 5 insertions, 45 deletions
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c
index b28955b72189..395c57330484 100644
--- a/drivers/leds/leds-lp5523.c
+++ b/drivers/leds/leds-lp5523.c
@@ -254,49 +254,6 @@ out:
return ret;
}
-static int lp5523_update_program_memory(struct lp55xx_chip *chip,
- const u8 *data, size_t size)
-{
- u8 pattern[LP5523_PROGRAM_LENGTH] = {0};
- unsigned int cmd;
- char c[3];
- int nrchars;
- int ret;
- int offset = 0;
- int i = 0;
-
- while ((offset < size - 1) && (i < LP5523_PROGRAM_LENGTH)) {
- /* separate sscanfs because length is working only for %s */
- ret = sscanf(data + offset, "%2s%n ", c, &nrchars);
- if (ret != 1)
- goto err;
-
- ret = sscanf(c, "%2x", &cmd);
- if (ret != 1)
- goto err;
-
- pattern[i] = (u8)cmd;
- offset += nrchars;
- i++;
- }
-
- /* Each instruction is 16bit long. Check that length is even */
- if (i % 2)
- goto err;
-
- for (i = 0; i < LP5523_PROGRAM_LENGTH; i++) {
- ret = lp55xx_write(chip, LP5523_REG_PROG_MEM + i, pattern[i]);
- if (ret)
- return -EINVAL;
- }
-
- return size;
-
-err:
- dev_err(&chip->cl->dev, "wrong pattern format\n");
- return -EINVAL;
-}
-
static void lp5523_firmware_loaded(struct lp55xx_chip *chip)
{
const struct firmware *fw = chip->fw;
@@ -314,7 +271,7 @@ static void lp5523_firmware_loaded(struct lp55xx_chip *chip)
*/
lp55xx_load_engine(chip);
- lp5523_update_program_memory(chip, fw->data, fw->size);
+ lp55xx_update_program_memory(chip, fw->data, fw->size);
}
static ssize_t show_engine_mode(struct device *dev,
@@ -496,7 +453,7 @@ static ssize_t store_engine_load(struct device *dev,
chip->engine_idx = nr;
lp55xx_load_engine(chip);
- ret = lp5523_update_program_memory(chip, buf, len);
+ ret = lp55xx_update_program_memory(chip, buf, len);
mutex_unlock(&chip->lock);
@@ -819,6 +776,9 @@ static struct lp55xx_device_config lp5523_cfg = {
.addr = LP5523_REG_ENABLE,
.val = LP5523_ENABLE,
},
+ .prog_mem_base = {
+ .addr = LP5523_REG_PROG_MEM,
+ },
.pages_per_engine = LP5523_PAGES_PER_ENGINE,
.max_channel = LP5523_MAX_LEDS,
.post_init_device = lp5523_post_init_device,