@@ -25,8 +25,7 @@ LOG_MODULE_REGISTER(max17262, CONFIG_SENSOR_LOG_LEVEL);
25
25
* @param valp Place to put the value on success
26
26
* @return 0 if successful, or negative error code from I2C API
27
27
*/
28
- static int max17262_reg_read (const struct device * dev , uint8_t reg_addr ,
29
- int16_t * valp )
28
+ static int max17262_reg_read (const struct device * dev , uint8_t reg_addr , int16_t * valp )
30
29
{
31
30
const struct max17262_config * cfg = dev -> config ;
32
31
uint8_t i2c_data [2 ];
@@ -52,8 +51,7 @@ static int max17262_reg_read(const struct device *dev, uint8_t reg_addr,
52
51
* @param val Register value to write
53
52
* @return 0 if successful, or negative error code from I2C API
54
53
*/
55
- static int max17262_reg_write (const struct device * dev , uint8_t reg_addr ,
56
- int16_t val )
54
+ static int max17262_reg_write (const struct device * dev , uint8_t reg_addr , int16_t val )
57
55
{
58
56
const struct max17262_config * cfg = dev -> config ;
59
57
uint8_t i2c_data [3 ] = {reg_addr , val & 0xFF , (uint16_t )val >> 8 };
@@ -82,8 +80,7 @@ static void convert_millis(struct sensor_value *val, int32_t val_millis)
82
80
* @return 0 if successful
83
81
* @return -ENOTSUP for unsupported channels
84
82
*/
85
- static int max17262_channel_get (const struct device * dev ,
86
- enum sensor_channel chan ,
83
+ static int max17262_channel_get (const struct device * dev , enum sensor_channel chan ,
87
84
struct sensor_value * valp )
88
85
{
89
86
const struct max17262_config * const config = dev -> config ;
@@ -178,10 +175,11 @@ static int max17262_channel_get(const struct device *dev,
178
175
* @param dev MAX17262 device to access
179
176
* @return 0 if successful, or negative error code from I2C API
180
177
*/
181
- static int max17262_sample_fetch (const struct device * dev ,
182
- enum sensor_channel chan )
178
+ static int max17262_sample_fetch (const struct device * dev , enum sensor_channel chan )
183
179
{
184
180
struct max17262_data * data = dev -> data ;
181
+
182
+ /* clang-format off */
185
183
struct {
186
184
int reg_addr ;
187
185
int16_t * dest ;
@@ -199,6 +197,7 @@ static int max17262_sample_fetch(const struct device *dev,
199
197
{ DESIGN_CAP , & data -> design_cap },
200
198
{ COULOMB_COUNTER , & data -> coulomb_counter },
201
199
};
200
+ /* clang-format on */
202
201
203
202
__ASSERT_NO_MSG (chan == SENSOR_CHAN_ALL );
204
203
for (size_t i = 0 ; i < ARRAY_SIZE (regs ); i ++ ) {
@@ -369,26 +368,22 @@ static const struct sensor_driver_api max17262_battery_driver_api = {
369
368
.channel_get = max17262_channel_get ,
370
369
};
371
370
372
- #define MAX17262_INIT (n ) \
373
- static struct max17262_data max17262_data_##n; \
374
- \
375
- static const struct max17262_config max17262_config_##n = { \
376
- .i2c = I2C_DT_SPEC_INST_GET(n), \
377
- .design_voltage = DT_INST_PROP(n, design_voltage), \
378
- .desired_voltage = DT_INST_PROP(n, desired_voltage), \
379
- .desired_charging_current = \
380
- DT_INST_PROP(n, desired_charging_current), \
381
- .design_cap = DT_INST_PROP(n, design_cap), \
382
- .empty_voltage = DT_INST_PROP(n, empty_voltage), \
383
- .recovery_voltage = DT_INST_PROP(n, recovery_voltage), \
384
- .charge_voltage = DT_INST_PROP(n, charge_voltage), \
385
- }; \
386
- \
387
- SENSOR_DEVICE_DT_INST_DEFINE(n, &max17262_gauge_init, \
388
- NULL, \
389
- &max17262_data_##n, \
390
- &max17262_config_##n, POST_KERNEL, \
391
- CONFIG_SENSOR_INIT_PRIORITY, \
392
- &max17262_battery_driver_api);
371
+ #define MAX17262_INIT (n ) \
372
+ static struct max17262_data max17262_data_##n; \
373
+ \
374
+ static const struct max17262_config max17262_config_##n = { \
375
+ .i2c = I2C_DT_SPEC_INST_GET(n), \
376
+ .design_voltage = DT_INST_PROP(n, design_voltage), \
377
+ .desired_voltage = DT_INST_PROP(n, desired_voltage), \
378
+ .desired_charging_current = DT_INST_PROP(n, desired_charging_current), \
379
+ .design_cap = DT_INST_PROP(n, design_cap), \
380
+ .empty_voltage = DT_INST_PROP(n, empty_voltage), \
381
+ .recovery_voltage = DT_INST_PROP(n, recovery_voltage), \
382
+ .charge_voltage = DT_INST_PROP(n, charge_voltage), \
383
+ }; \
384
+ \
385
+ SENSOR_DEVICE_DT_INST_DEFINE(n, &max17262_gauge_init, NULL, &max17262_data_##n, \
386
+ &max17262_config_##n, POST_KERNEL, \
387
+ CONFIG_SENSOR_INIT_PRIORITY, &max17262_battery_driver_api);
393
388
394
389
DT_INST_FOREACH_STATUS_OKAY (MAX17262_INIT )
0 commit comments