Skip to content

Commit 52dfb2b

Browse files
drivers: sensor: bmm350: run clang-format
Run clang-format on files Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
1 parent e9b6825 commit 52dfb2b

File tree

2 files changed

+78
-86
lines changed

2 files changed

+78
-86
lines changed

drivers/sensor/bosch/bmm350/bmm350.c

Lines changed: 55 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ static int bmm350_otp_dump_after_boot(const struct device *dev)
229229
* @brief This API gets the PMU command status 0 value
230230
*/
231231
static int bmm350_get_pmu_cmd_status_0(const struct device *dev,
232-
struct bmm350_pmu_cmd_status_0 *pmu_cmd_stat_0)
232+
struct bmm350_pmu_cmd_status_0 *pmu_cmd_stat_0)
233233
{
234234
/* Variable to store the function result */
235235
int ret;
@@ -247,10 +247,8 @@ static int bmm350_get_pmu_cmd_status_0(const struct device *dev,
247247
pmu_cmd_stat_0->avr_ovwr = BMM350_GET_BITS(rx_buf[2], BMM350_AVG_OVWR);
248248
pmu_cmd_stat_0->pwr_mode_is_normal =
249249
BMM350_GET_BITS(rx_buf[2], BMM350_PWR_MODE_IS_NORMAL);
250-
pmu_cmd_stat_0->cmd_is_illegal =
251-
BMM350_GET_BITS(rx_buf[2], BMM350_CMD_IS_ILLEGAL);
252-
pmu_cmd_stat_0->pmu_cmd_value =
253-
BMM350_GET_BITS(rx_buf[2], BMM350_PMU_CMD_VALUE);
250+
pmu_cmd_stat_0->cmd_is_illegal = BMM350_GET_BITS(rx_buf[2], BMM350_CMD_IS_ILLEGAL);
251+
pmu_cmd_stat_0->pmu_cmd_value = BMM350_GET_BITS(rx_buf[2], BMM350_PMU_CMD_VALUE);
254252
}
255253

256254
return ret;
@@ -426,7 +424,7 @@ static int bmm350_magnetic_reset_and_wait(const struct device *dev)
426424
* @brief This API is used to read uncompensated mag and temperature data.
427425
*/
428426
static int bmm350_read_uncomp_mag_temp_data(const struct device *dev,
429-
struct bmm350_raw_mag_data *raw_data)
427+
struct bmm350_raw_mag_data *raw_data)
430428
{
431429
struct bmm350_data *data = dev->data;
432430
int rslt;
@@ -440,13 +438,13 @@ static int bmm350_read_uncomp_mag_temp_data(const struct device *dev,
440438

441439
if (rslt == 0) {
442440
raw_mag_x = (uint32_t)mag_data[2] + ((uint32_t)mag_data[3] << 8) +
443-
((uint32_t)mag_data[4] << 16);
441+
((uint32_t)mag_data[4] << 16);
444442
raw_mag_y = (uint32_t)mag_data[5] + ((uint32_t)mag_data[6] << 8) +
445-
((uint32_t)mag_data[7] << 16);
443+
((uint32_t)mag_data[7] << 16);
446444
raw_mag_z = (uint32_t)mag_data[8] + ((uint32_t)mag_data[9] << 8) +
447-
((uint32_t)mag_data[10] << 16);
445+
((uint32_t)mag_data[10] << 16);
448446
raw_temp = (uint32_t)mag_data[11] + ((uint32_t)mag_data[12] << 8) +
449-
((uint32_t)mag_data[13] << 16);
447+
((uint32_t)mag_data[13] << 16);
450448

451449
if ((data->axis_en & BMM350_EN_X_MSK) == BMM350_DISABLE) {
452450
raw_data->raw_xdata = BMM350_DISABLE;
@@ -484,13 +482,13 @@ static int read_out_raw_data(const struct device *dev, int32_t *out_data)
484482
if (rslt == 0) {
485483
/* Convert mag lsb to uT and temp lsb to degC */
486484
out_data[0] = ((raw_data.raw_xdata * BMM350_LSB_TO_UT_XY_COEFF) /
487-
BMM350_LSB_TO_UT_COEFF_DIV);
485+
BMM350_LSB_TO_UT_COEFF_DIV);
488486
out_data[1] = ((raw_data.raw_ydata * BMM350_LSB_TO_UT_XY_COEFF) /
489-
BMM350_LSB_TO_UT_COEFF_DIV);
487+
BMM350_LSB_TO_UT_COEFF_DIV);
490488
out_data[2] = ((raw_data.raw_zdata * BMM350_LSB_TO_UT_Z_COEFF) /
491-
BMM350_LSB_TO_UT_COEFF_DIV);
489+
BMM350_LSB_TO_UT_COEFF_DIV);
492490
out_data[3] = ((raw_data.raw_data_temp * BMM350_LSB_TO_UT_TEMP_COEFF) /
493-
BMM350_LSB_TO_UT_COEFF_DIV);
491+
BMM350_LSB_TO_UT_COEFF_DIV);
494492

495493
if (out_data[3] > 0) {
496494
temp = (out_data[3] - (2549 / 100));
@@ -523,11 +521,11 @@ int8_t bmm350_get_compensated_mag_xyz_temp_data_fixed(const struct device *dev,
523521

524522
if (rslt == 0) {
525523
/* Apply compensation to temperature reading */
526-
out_data[3] = (((BMM350_MAG_COMP_COEFF_SCALING +
527-
data->mag_comp.dut_sensit_coef.t_sens) *
528-
out_data[3]) +
529-
data->mag_comp.dut_offset_coef.t_offs) /
530-
BMM350_MAG_COMP_COEFF_SCALING;
524+
out_data[3] =
525+
(((BMM350_MAG_COMP_COEFF_SCALING + data->mag_comp.dut_sensit_coef.t_sens) *
526+
out_data[3]) +
527+
data->mag_comp.dut_offset_coef.t_offs) /
528+
BMM350_MAG_COMP_COEFF_SCALING;
531529

532530
/* Store magnetic compensation structure to an array */
533531
dut_offset_coef[0] = data->mag_comp.dut_offset_coef.offset_x;
@@ -548,50 +546,45 @@ int8_t bmm350_get_compensated_mag_xyz_temp_data_fixed(const struct device *dev,
548546

549547
/* Compensate raw magnetic data */
550548
for (indx = 0; indx < 3; indx++) {
551-
out_data[indx] = (out_data[indx] * (BMM350_MAG_COMP_COEFF_SCALING +
552-
dut_sensit_coef[indx])) /
553-
BMM350_MAG_COMP_COEFF_SCALING;
549+
out_data[indx] = (out_data[indx] *
550+
(BMM350_MAG_COMP_COEFF_SCALING + dut_sensit_coef[indx])) /
551+
BMM350_MAG_COMP_COEFF_SCALING;
554552
out_data[indx] = (out_data[indx] + dut_offset_coef[indx]);
555-
out_data[indx] =
556-
((out_data[indx] * BMM350_MAG_COMP_COEFF_SCALING) +
557-
(dut_tco[indx] * (out_data[3] - data->mag_comp.dut_t0))) /
558-
BMM350_MAG_COMP_COEFF_SCALING;
559-
out_data[indx] =
560-
(out_data[indx] * BMM350_MAG_COMP_COEFF_SCALING) /
561-
(BMM350_MAG_COMP_COEFF_SCALING +
562-
(dut_tcs[indx] * (out_data[3] - data->mag_comp.dut_t0)));
553+
out_data[indx] = ((out_data[indx] * BMM350_MAG_COMP_COEFF_SCALING) +
554+
(dut_tco[indx] * (out_data[3] - data->mag_comp.dut_t0))) /
555+
BMM350_MAG_COMP_COEFF_SCALING;
556+
out_data[indx] = (out_data[indx] * BMM350_MAG_COMP_COEFF_SCALING) /
557+
(BMM350_MAG_COMP_COEFF_SCALING +
558+
(dut_tcs[indx] * (out_data[3] - data->mag_comp.dut_t0)));
563559
}
564560

565-
cr_ax_comp_x =
566-
((((out_data[0] * BMM350_MAG_COMP_COEFF_SCALING) -
567-
(data->mag_comp.cross_axis.cross_x_y * out_data[1])) *
568-
BMM350_MAG_COMP_COEFF_SCALING) /
561+
cr_ax_comp_x = ((((out_data[0] * BMM350_MAG_COMP_COEFF_SCALING) -
562+
(data->mag_comp.cross_axis.cross_x_y * out_data[1])) *
563+
BMM350_MAG_COMP_COEFF_SCALING) /
569564
((BMM350_MAG_COMP_COEFF_SCALING * BMM350_MAG_COMP_COEFF_SCALING) -
570-
(data->mag_comp.cross_axis.cross_y_x *
571-
data->mag_comp.cross_axis.cross_x_y)));
565+
(data->mag_comp.cross_axis.cross_y_x *
566+
data->mag_comp.cross_axis.cross_x_y)));
572567

573-
cr_ax_comp_y =
574-
((((out_data[1] * BMM350_MAG_COMP_COEFF_SCALING) -
575-
(data->mag_comp.cross_axis.cross_y_x * out_data[0])) *
576-
BMM350_MAG_COMP_COEFF_SCALING) /
568+
cr_ax_comp_y = ((((out_data[1] * BMM350_MAG_COMP_COEFF_SCALING) -
569+
(data->mag_comp.cross_axis.cross_y_x * out_data[0])) *
570+
BMM350_MAG_COMP_COEFF_SCALING) /
577571
((BMM350_MAG_COMP_COEFF_SCALING * BMM350_MAG_COMP_COEFF_SCALING) -
578-
(data->mag_comp.cross_axis.cross_y_x *
579-
data->mag_comp.cross_axis.cross_x_y)));
572+
(data->mag_comp.cross_axis.cross_y_x *
573+
data->mag_comp.cross_axis.cross_x_y)));
580574

581575
cr_ax_comp_z =
582576
(out_data[2] +
583-
(((out_data[0] * ((data->mag_comp.cross_axis.cross_y_x *
584-
data->mag_comp.cross_axis.cross_z_y) -
585-
(data->mag_comp.cross_axis.cross_z_x *
586-
BMM350_MAG_COMP_COEFF_SCALING))) -
587-
(out_data[1] * ((data->mag_comp.cross_axis.cross_z_y *
588-
BMM350_MAG_COMP_COEFF_SCALING) -
589-
(data->mag_comp.cross_axis.cross_x_y *
590-
data->mag_comp.cross_axis.cross_z_x))))) /
591-
(((BMM350_MAG_COMP_COEFF_SCALING *
592-
BMM350_MAG_COMP_COEFF_SCALING) -
593-
data->mag_comp.cross_axis.cross_y_x *
594-
data->mag_comp.cross_axis.cross_x_y)));
577+
(((out_data[0] * ((data->mag_comp.cross_axis.cross_y_x *
578+
data->mag_comp.cross_axis.cross_z_y) -
579+
(data->mag_comp.cross_axis.cross_z_x *
580+
BMM350_MAG_COMP_COEFF_SCALING))) -
581+
(out_data[1] *
582+
((data->mag_comp.cross_axis.cross_z_y * BMM350_MAG_COMP_COEFF_SCALING) -
583+
(data->mag_comp.cross_axis.cross_x_y *
584+
data->mag_comp.cross_axis.cross_z_x))))) /
585+
(((BMM350_MAG_COMP_COEFF_SCALING * BMM350_MAG_COMP_COEFF_SCALING) -
586+
data->mag_comp.cross_axis.cross_y_x *
587+
data->mag_comp.cross_axis.cross_x_y)));
595588

596589
out_data[0] = (int32_t)cr_ax_comp_x;
597590
out_data[1] = (int32_t)cr_ax_comp_y;
@@ -723,8 +716,8 @@ static uint8_t mag_osr_to_reg(const struct sensor_value *val)
723716
* @brief This API sets the ODR and averaging factor.
724717
*/
725718
static int bmm350_set_odr_performance(enum bmm350_data_rates odr,
726-
enum bmm350_performance_parameters performance,
727-
const struct device *dev)
719+
enum bmm350_performance_parameters performance,
720+
const struct device *dev)
728721
{
729722
/* Variable to store the function result */
730723
int rslt;
@@ -1109,13 +1102,12 @@ static int bmm350_init(const struct device *dev)
11091102

11101103
/* Initializes a struct bmm350_config for an instance on an I2C bus. */
11111104
#define BMM350_CONFIG_I2C(inst) .bus.i2c = I2C_DT_SPEC_INST_GET(inst), .bus_io = &bmm350_bus_io_i2c,
1112-
#define BMM350_INT_CFG(inst) \
1113-
.drdy_int = GPIO_DT_SPEC_INST_GET_OR(inst, drdy_gpios, {0}), \
1114-
.int_flags = FIELD_PREP(BMM350_INT_CTRL_INT_POL_MSK, \
1115-
DT_INST_PROP(inst, active_high_int)) | \
1116-
FIELD_PREP(BMM350_INT_CTRL_INT_OD_MSK, DT_INST_PROP(inst, push_pull_int)) | \
1117-
BMM350_INT_CTRL_DRDY_DATA_REG_EN_MSK | \
1118-
BMM350_INT_CTRL_INT_OUTPUT_EN_MSK,
1105+
#define BMM350_INT_CFG(inst) \
1106+
.drdy_int = GPIO_DT_SPEC_INST_GET_OR(inst, drdy_gpios, {0}), \
1107+
.int_flags = \
1108+
FIELD_PREP(BMM350_INT_CTRL_INT_POL_MSK, DT_INST_PROP(inst, active_high_int)) | \
1109+
FIELD_PREP(BMM350_INT_CTRL_INT_OD_MSK, DT_INST_PROP(inst, push_pull_int)) | \
1110+
BMM350_INT_CTRL_DRDY_DATA_REG_EN_MSK | BMM350_INT_CTRL_INT_OUTPUT_EN_MSK,
11191111

11201112
#define BMM350_DEFINE(inst) \
11211113
static struct bmm350_data bmm350_data_##inst; \

drivers/sensor/bosch/bmm350/bmm350.h

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -256,31 +256,31 @@ enum bmm350_signed_bit {
256256
#define BMM350_SENS_CORR_Y 1
257257
#define BMM350_TCS_CORR_Z 1
258258

259-
#define BMM350_EN_X_MSK UINT8_C(0x01)
260-
#define BMM350_EN_X_POS UINT8_C(0x0)
261-
#define BMM350_EN_Y_MSK UINT8_C(0x02)
262-
#define BMM350_EN_Y_POS UINT8_C(0x1)
263-
#define BMM350_EN_Z_MSK UINT8_C(0x04)
264-
#define BMM350_EN_Z_POS UINT8_C(0x2)
265-
#define BMM350_EN_XYZ_MSK UINT8_C(0x7)
266-
#define BMM350_EN_XYZ_POS UINT8_C(0x0)
259+
#define BMM350_EN_X_MSK UINT8_C(0x01)
260+
#define BMM350_EN_X_POS UINT8_C(0x0)
261+
#define BMM350_EN_Y_MSK UINT8_C(0x02)
262+
#define BMM350_EN_Y_POS UINT8_C(0x1)
263+
#define BMM350_EN_Z_MSK UINT8_C(0x04)
264+
#define BMM350_EN_Z_POS UINT8_C(0x2)
265+
#define BMM350_EN_XYZ_MSK UINT8_C(0x7)
266+
#define BMM350_EN_XYZ_POS UINT8_C(0x0)
267267
/************************ Averaging macros **********************/
268-
#define BMM350_AVG_NO_AVG 0x0
269-
#define BMM350_AVG_2 0x1
270-
#define BMM350_AVG_4 0x2
271-
#define BMM350_AVG_8 0x3
268+
#define BMM350_AVG_NO_AVG 0x0
269+
#define BMM350_AVG_2 0x1
270+
#define BMM350_AVG_4 0x2
271+
#define BMM350_AVG_8 0x3
272272
/******************************* ODR **************************/
273-
#define BMM350_ODR_400HZ UINT8_C(0x2)
274-
#define BMM350_ODR_200HZ UINT8_C(0x3)
275-
#define BMM350_ODR_100HZ UINT8_C(0x4)
276-
#define BMM350_ODR_50HZ UINT8_C(0x5)
277-
#define BMM350_ODR_25HZ UINT8_C(0x6)
278-
#define BMM350_ODR_12_5HZ UINT8_C(0x7)
279-
#define BMM350_ODR_6_25HZ UINT8_C(0x8)
280-
#define BMM350_ODR_3_125HZ UINT8_C(0x9)
281-
#define BMM350_ODR_1_5625HZ UINT8_C(0xA)
282-
#define BMM350_ODR_MSK UINT8_C(0xf)
283-
#define BMM350_ODR_POS UINT8_C(0x0)
273+
#define BMM350_ODR_400HZ UINT8_C(0x2)
274+
#define BMM350_ODR_200HZ UINT8_C(0x3)
275+
#define BMM350_ODR_100HZ UINT8_C(0x4)
276+
#define BMM350_ODR_50HZ UINT8_C(0x5)
277+
#define BMM350_ODR_25HZ UINT8_C(0x6)
278+
#define BMM350_ODR_12_5HZ UINT8_C(0x7)
279+
#define BMM350_ODR_6_25HZ UINT8_C(0x8)
280+
#define BMM350_ODR_3_125HZ UINT8_C(0x9)
281+
#define BMM350_ODR_1_5625HZ UINT8_C(0xA)
282+
#define BMM350_ODR_MSK UINT8_C(0xf)
283+
#define BMM350_ODR_POS UINT8_C(0x0)
284284

285285
/* Macro to SET and GET BITS of a register*/
286286
#define BMM350_SET_BITS(reg_data, bitname, data) \

0 commit comments

Comments
 (0)