Skip to content

Commit cfc3a3b

Browse files
tristan-googlefabiobaltieri
authored andcommitted
sensors: max17262: Run clang-format
Format the file `drivers/sensor/max17262/max17262.c` but exclude the regsiter lookup table in `max17262_sample_fetch()` Signed-off-by: Tristan Honscheid <[email protected]>
1 parent ef5899e commit cfc3a3b

File tree

1 file changed

+24
-29
lines changed

1 file changed

+24
-29
lines changed

drivers/sensor/max17262/max17262.c

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ LOG_MODULE_REGISTER(max17262, CONFIG_SENSOR_LOG_LEVEL);
2525
* @param valp Place to put the value on success
2626
* @return 0 if successful, or negative error code from I2C API
2727
*/
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)
3029
{
3130
const struct max17262_config *cfg = dev->config;
3231
uint8_t i2c_data[2];
@@ -52,8 +51,7 @@ static int max17262_reg_read(const struct device *dev, uint8_t reg_addr,
5251
* @param val Register value to write
5352
* @return 0 if successful, or negative error code from I2C API
5453
*/
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)
5755
{
5856
const struct max17262_config *cfg = dev->config;
5957
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)
8280
* @return 0 if successful
8381
* @return -ENOTSUP for unsupported channels
8482
*/
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,
8784
struct sensor_value *valp)
8885
{
8986
const struct max17262_config *const config = dev->config;
@@ -178,10 +175,11 @@ static int max17262_channel_get(const struct device *dev,
178175
* @param dev MAX17262 device to access
179176
* @return 0 if successful, or negative error code from I2C API
180177
*/
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)
183179
{
184180
struct max17262_data *data = dev->data;
181+
182+
/* clang-format off */
185183
struct {
186184
int reg_addr;
187185
int16_t *dest;
@@ -199,6 +197,7 @@ static int max17262_sample_fetch(const struct device *dev,
199197
{ DESIGN_CAP, &data->design_cap },
200198
{ COULOMB_COUNTER, &data->coulomb_counter },
201199
};
200+
/* clang-format on */
202201

203202
__ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL);
204203
for (size_t i = 0; i < ARRAY_SIZE(regs); i++) {
@@ -369,26 +368,22 @@ static const struct sensor_driver_api max17262_battery_driver_api = {
369368
.channel_get = max17262_channel_get,
370369
};
371370

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);
393388

394389
DT_INST_FOREACH_STATUS_OKAY(MAX17262_INIT)

0 commit comments

Comments
 (0)