apache-mynewt-bot commented on issue #2255: Add SGM4056 charger driver to
pinetime BSP
URL: https://github.com/apache/mynewt-core/pull/2255#issuecomment-606501796
## Style check summary
### Our coding style is
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
hw/drivers/chg_ctrl/sgm4056/include/sgm4056/sgm4056.h
```diff
@@ -28,24 +28,24 @@
struct sgm4056_dev {
struct os_dev dev;
#if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL)
-struct charge_control chg_ctrl;
+struct charge_control chg_ctrl;
struct os_event interrupt_event;
#endif
struct sgm4056_dev_config config;
};
/**
-* Init function for SGM4056 charger
-* @return 0 on success, non-zero on failure
-*/
+ * Init function for SGM4056 charger
+ * @return 0 on success, non-zero on failure
+ */
int sgm4056_dev_init(struct os_dev *dev, void *arg);
/**
- * Reads the state of the power presence indication. Value is 1 when the
input
+ * Reads the state of the power presence indication. Value is 1 when the
input
* voltage is above the POR threshold but below the OVP threshold and 0
otherwise.
*
* @param dev The sgm4056 device to read on
- * @param power_present Power presence indication to be returned by the
+ * @param power_present Power presence indication to be returned by the
* function (0 if input voltage is not detected, 1 if it is detected)
*
* @return 0 on success, non-zero on failure
@@ -53,11 +53,11 @@
int sgm4056_get_power_presence(struct sgm4056_dev *dev, int *power_present);
/**
- * Reads the state of the charge indication. Value is 1 when a charge cycle
+ * Reads the state of the charge indication. Value is 1 when a charge cycle
* started and will be 0 when the end-of-charge (EOC) condition is met.
*
* @param dev The sgm4056 device to read on
- * @param charging Charge indication to be returned by the
+ * @param charging Charge indication to be returned by the
* function (0 if battery is not charging, 1 if it is charging)
*
* @return 0 on success, non-zero on failure
@@ -65,7 +65,7 @@
int sgm4056_get_charge_indicator(struct sgm4056_dev *dev, int *charging);
/**
- * Reads the state of the charger. This is a combination of the power
presence
+ * Reads the state of the charger. This is a combination of the power
presence
* and charge indications. Value is either:
* - CHARGE_CONTROL_STATUS_NO_SOURCE, when no power present
* - CHARGE_CONTROL_STATUS_CHARGING, when power present and charging
```
hw/drivers/chg_ctrl/sgm4056/src/sgm4056.c
```diff
@@ -19,7 +19,7 @@
#if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL)
-static int
+static int
sgm4056_chg_ctrl_get_status(struct charge_control * chg_ctrl, int * status)
{
struct sgm4056_dev *dev;
@@ -37,10 +37,10 @@
return rc;
}
-static int
-sgm4056_chg_ctrl_read(struct charge_control * chg_ctrl,
-charge_control_type_t type, charge_control_data_func_t data_func,
-void *data_arg, uint32_t timeout)
+static int
+sgm4056_chg_ctrl_read(struct charge_control * chg_ctrl,
+ charge_control_type_t type,
charge_control_data_func_t data_func,
+ void *data_arg, uint32_t timeout)
{
int rc = 0;
int status;
@@ -51,8 +51,8 @@
goto err;
}
-if(data_func) {
-data_func(chg_ctrl, data_arg, (void*),
CHARGE_CONTROL_TYPE_STATUS);
+if (data_func) {
+data_func(chg_ctrl, data_arg, (void *),
CHARGE_CONTROL_TYPE_STATUS);
}
}
@@ -80,7 +80,7 @@
NULL, NULL, OS_TIMEOUT_NEVER);
}
-static void
+static void
sgm4056_irq_handler(void *arg)
{
struct sgm4056_dev *dev = (struct sgm4056_dev *)arg;
@@ -90,8 +90,9 @@
}
#endif
-int
-sgm4056_dev_init(struct os_dev *odev, void *arg) {
+int
+sgm4056_dev_init(struct os_dev *odev, void *arg)
+{
struct sgm4056_dev *dev = (struct sgm4056_dev *)odev;
const struct sgm4056_dev_config *cfg = arg;
int rc = 0;
@@ -107,7 +108,8 @@
dev->interrupt_event.ev_cb = sgm4056_interrupt_event_handler;
dev->interrupt_event.ev_arg = dev;
-rc = hal_gpio_irq_init(dev->config.power_presence_pin,
sgm4056_irq_handler, dev, HAL_GPIO_TRIG_BOTH, HAL_GPIO_PULL_NONE);
+rc = hal_gpio_irq_init(dev->config.power_presence_pin,
sgm4056_irq_handler, dev, HAL_GPIO_TRIG_BOTH,
+ HAL_GPIO_PULL_NONE);
hal_gpio_irq_enable(dev->config.power_presence_pin);
#else
rc = hal_gpio_init_in(dev->config.power_presence_pin,
HAL_GPIO_PULL_NONE);