vrahane closed pull request #1269: Fix bq27z561 and adp5061 charge control 
interface
URL: https://github.com/apache/mynewt-core/pull/1269
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/hw/drivers/bq27z561/src/bq27z561.c 
b/hw/drivers/bq27z561/src/bq27z561.c
index 64ac9cb101..860bd0b02d 100644
--- a/hw/drivers/bq27z561/src/bq27z561.c
+++ b/hw/drivers/bq27z561/src/bq27z561.c
@@ -170,7 +170,7 @@ bq27z561_rd_std_reg_word(struct bq27z561 *dev, uint8_t reg, 
uint16_t *val)
 
     rc = hal_i2c_master_write(dev->bq27_itf.itf_num, &i2c, OS_TICKS_PER_SEC, 
0);
     if (rc != 0) {
-        BQ27Z561_ERROR("I2C reg read (wr) failed 0x%02X\n", reg);
+        BQ27Z561_LOG(ERROR, "I2C reg read (wr) failed 0x%02X\n", reg);
         goto err;
     }
 
@@ -178,7 +178,7 @@ bq27z561_rd_std_reg_word(struct bq27z561 *dev, uint8_t reg, 
uint16_t *val)
     i2c.buffer = (uint8_t *)val;
     rc = hal_i2c_master_read(dev->bq27_itf.itf_num, &i2c, OS_TICKS_PER_SEC, 1);
     if (rc != 0) {
-        BQ27Z561_ERROR("I2C reg read (rd) failed 0x%02X\n", reg);
+        BQ27Z561_LOG(ERROR, "I2C reg read (rd) failed 0x%02X\n", reg);
         goto err;
     }
 
@@ -206,7 +206,7 @@ bq27z561_wr_std_reg_byte(struct bq27z561 *dev, uint8_t reg, 
uint8_t val)
 
     rc = hal_i2c_master_write(dev->bq27_itf.itf_num, &i2c, OS_TICKS_PER_SEC, 
1);
     if (rc != 0) {
-        BQ27Z561_ERROR("I2C reg write 0x%02X failed\n", reg);
+        BQ27Z561_LOG(ERROR, "I2C reg write 0x%02X failed\n", reg);
         return rc;
     }
 
diff --git a/hw/drivers/chg_ctrl/adp5061/src/adp5061.c 
b/hw/drivers/chg_ctrl/adp5061/src/adp5061.c
index 9fe106628c..3d936df75d 100644
--- a/hw/drivers/chg_ctrl/adp5061/src/adp5061.c
+++ b/hw/drivers/chg_ctrl/adp5061/src/adp5061.c
@@ -586,6 +586,7 @@ adp5061_init(struct os_dev *dev, void *arg)
 {
     struct adp5061_dev *adp5061 = (struct adp5061_dev *)dev;
     struct charge_control *cc;
+    struct charge_control_itf *cci;
     const struct adp5061_config *cfg;
     uint8_t device_id;
     int rc;
@@ -597,13 +598,14 @@ adp5061_init(struct os_dev *dev, void *arg)
 
     cc = &adp5061->a_chg_ctrl;
 
+    cci = (struct charge_control_itf *)arg;
+
     rc = charge_control_init(cc, dev);
     if (rc) {
         goto err;
     }
-    cc->cc_itf.cci_addr = ADP5061_ADDR;
-    cc->cc_itf.cci_num = MYNEWT_VAL(ADP5061_I2C_NUM);
-    cc->cc_itf.cci_type = CHARGE_CONTROL_ITF_I2C;
+
+    charge_control_set_interface(cc, cci);
 
     /* Add the driver with all the supported types */
     rc = charge_control_set_driver(cc, CHARGE_CONTROL_TYPE_STATUS,
@@ -614,11 +616,8 @@ adp5061_init(struct os_dev *dev, void *arg)
 
     charge_control_set_type_mask(cc,
             CHARGE_CONTROL_TYPE_STATUS | CHARGE_CONTROL_TYPE_FAULT);
-    if (arg) {
-        cfg = (struct adp5061_config *)(arg);
-    } else {
-        cfg = &default_config;
-    }
+
+    cfg = &default_config;
 
     rc = adp5061_get_device_id(adp5061, &device_id);
     if (rc) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to