From 82539171d2868e3b3a00e5d899e73ef35a3f0489 Mon Sep 17 00:00:00 2001 From: Alastair Bain Date: Mon, 7 Nov 2022 11:04:22 +1300 Subject: [PATCH 1/2] Consting --- bmi270.c | 2 +- bmi2_defs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bmi270.c b/bmi270.c index 9ad7cda..31f2657 100644 --- a/bmi270.c +++ b/bmi270.c @@ -516,7 +516,7 @@ const struct bmi2_feature_config bmi270_feat_out[BMI270_MAX_FEAT_OUT] = { }; /*! @name Global array that stores the feature interrupts of BMI270 */ -struct bmi2_map_int bmi270_map_int[BMI270_MAX_INT_MAP] = { +const struct bmi2_map_int bmi270_map_int[BMI270_MAX_INT_MAP] = { { .type = BMI2_SIG_MOTION, .sens_map_int = BMI270_INT_SIG_MOT_MASK }, { .type = BMI2_STEP_COUNTER, .sens_map_int = BMI270_INT_STEP_COUNTER_MASK }, { .type = BMI2_STEP_DETECTOR, .sens_map_int = BMI270_INT_STEP_DETECTOR_MASK }, diff --git a/bmi2_defs.h b/bmi2_defs.h index 08f89d6..347dbad 100644 --- a/bmi2_defs.h +++ b/bmi2_defs.h @@ -2409,7 +2409,7 @@ struct bmi2_dev bmi2_tap_fptr_t set_tap_config; /*! Array of feature interrupts configuration structure */ - struct bmi2_map_int *map_int; + const struct bmi2_map_int *map_int; /*! To define maximum number of interrupts */ uint8_t sens_int_map; From c4b230c2295be7accef7e31b2c3a9169bed96439 Mon Sep 17 00:00:00 2001 From: Alastair Bain Date: Mon, 7 Nov 2022 11:04:30 +1300 Subject: [PATCH 2/2] Disable null check --- bmi270.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bmi270.c b/bmi270.c index 31f2657..8262f7e 100644 --- a/bmi270.c +++ b/bmi270.c @@ -542,7 +542,15 @@ const struct bmi2_map_int bmi270_map_int[BMI270_MAX_INT_MAP] = { * @retval 0 -> Success * @retval < 0 -> Fail */ +#ifdef CONFIG_BMI270_CHECK_NULL_PTR static int8_t null_ptr_check(const struct bmi2_dev *dev); +#else +static inline int8_t null_ptr_check(const struct bmi2_dev *dev) +{ + return BMI2_OK; +} +#endif + /*! * @brief This internal API enables the selected sensor/features. @@ -1385,7 +1393,6 @@ int8_t bmi270_sensor_disable(const uint8_t *sens_list, uint8_t n_sens, struct bm { rslt = BMI2_E_NULL_PTR; } - return rslt; } @@ -1913,6 +1920,7 @@ int8_t bmi270_map_feat_int(const struct bmi2_sens_int_config *sens_int, uint8_t * @brief This internal API is used to validate the device structure pointer for * null conditions. */ +#ifdef CONFIG_BMI270_CHECK_NULL_PTR static int8_t null_ptr_check(const struct bmi2_dev *dev) { /* Variable to define error */ @@ -1926,6 +1934,7 @@ static int8_t null_ptr_check(const struct bmi2_dev *dev) return rslt; } +#endif /*! * @brief This internal API selects the sensor/features to be enabled or