You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2018/11/22 20:18:48 UTC

[mynewt-core] 01/02: hw/drivers/lp5523: Fix invalid payload in set_n_regs

This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 961b60a3d58be6d0abeef0a73c1af35c62a64195
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Thu Nov 22 18:19:28 2018 +0100

    hw/drivers/lp5523: Fix invalid payload in set_n_regs
---
 hw/drivers/led/lp5523/src/lp5523.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/hw/drivers/led/lp5523/src/lp5523.c b/hw/drivers/led/lp5523/src/lp5523.c
index 894a5fc..1525cca 100644
--- a/hw/drivers/led/lp5523/src/lp5523.c
+++ b/hw/drivers/led/lp5523/src/lp5523.c
@@ -129,17 +129,16 @@ lp5523_set_n_regs(struct led_itf *itf, enum lp5523_registers addr,
     uint8_t *vals, uint8_t len)
 {
     int rc;
-    uint8_t regs[LP5523_MAX_PAYLOAD] = {0};
+    uint8_t payload[LP5523_MAX_PAYLOAD] = {0};
 
     struct hal_i2c_master_data data_struct = {
         .address = itf->li_addr,
         .len = len + 1,
-        .buffer = regs
+        .buffer = payload,
     };
 
-    memcpy(regs, vals, len + 1);
-
-    regs[0] = addr;
+    payload[0] = addr;
+    memcpy(&payload[1], vals, len);
 
     rc = led_itf_lock(itf, MYNEWT_VAL(LP5523_ITF_LOCK_TMO));
     if (rc) {
@@ -151,7 +150,7 @@ lp5523_set_n_regs(struct led_itf *itf, enum lp5523_registers addr,
 
     if (rc) {
         LP5523_LOG(ERROR, "Failed to write to 0x%02X:0x%02X\n", itf->li_addr,
-                   regs[0]);
+                   addr);
         STATS_INC(g_lp5523stats, read_errors);
     }