Skip to content

Commit

Permalink
drivers/sensors: Remove unnecessary heap allocation for bmi270
Browse files Browse the repository at this point in the history
Remove temporary heap allocation and fix memory leak.
  • Loading branch information
SPRESENSE committed Sep 8, 2023
1 parent 285e1a3 commit c727e2e
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions drivers/sensors/bmi270.c
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,6 @@ static void bmi270_set_normal_imu(FAR struct bmi270_dev_s *priv)

static int bmi270_init_seq(FAR struct bmi270_dev_s *priv)
{
FAR uint8_t *tmp = NULL;
uint8_t regval = 0;

/* Check if initialization already done */
Expand All @@ -1258,21 +1257,10 @@ static int bmi270_init_seq(FAR struct bmi270_dev_s *priv)

bmi270_putreg8(priv, BMI270_INIT_CTRL, 0);

/* Copy configuration to RAM */

tmp = malloc(sizeof(g_bmi270_config_file));
if (tmp == NULL)
{
snerr("Failed to allocate memory for configuration file\n");
return -ENOMEM;
}

memcpy(tmp, g_bmi270_config_file, sizeof(g_bmi270_config_file));

/* Load configuration - start with byte 0 */

bmi270_putregs(priv, BMI270_INIT_DATA,
tmp,
(FAR uint8_t *)g_bmi270_config_file,
sizeof(g_bmi270_config_file));

/* Complete config load INIT_CTRL=0x01 */
Expand Down

0 comments on commit c727e2e

Please sign in to comment.