Browse Source

[at24c] free perf counter if px4_at24c_initialize fails

- add driver prefix to perf counter naming
release/1.12
Daniel Agar 4 years ago
parent
commit
6dd0a58302
  1. 14
      platforms/nuttx/src/px4/common/px4_24xxxx_mtd.c

14
platforms/nuttx/src/px4/common/px4_24xxxx_mtd.c

@ -567,9 +567,9 @@ FAR struct mtd_dev_s *px4_at24c_initialize(FAR struct i2c_master_s *dev, @@ -567,9 +567,9 @@ FAR struct mtd_dev_s *px4_at24c_initialize(FAR struct i2c_master_s *dev,
priv->mtd.ioctl = at24c_ioctl;
priv->dev = dev;
priv->perf_transfers = perf_alloc(PC_ELAPSED, "eeprom_trans");
priv->perf_resets_retries = perf_alloc(PC_COUNT, "eeprom_rst");
priv->perf_errors = perf_alloc(PC_COUNT, "eeprom_errs");
priv->perf_transfers = perf_alloc(PC_ELAPSED, "[at24c] eeprom transfer");
priv->perf_resets_retries = perf_alloc(PC_COUNT, "[at24c] eeprom reset");
priv->perf_errors = perf_alloc(PC_COUNT, "[at24c] eeprom errors");
}
/* attempt to read to validate device is present */
@ -600,6 +600,14 @@ FAR struct mtd_dev_s *px4_at24c_initialize(FAR struct i2c_master_s *dev, @@ -600,6 +600,14 @@ FAR struct mtd_dev_s *px4_at24c_initialize(FAR struct i2c_master_s *dev,
perf_end(priv->perf_transfers);
if (ret < 0) {
perf_free(priv->perf_transfers);
perf_free(priv->perf_resets_retries);
perf_free(priv->perf_errors);
priv->perf_transfers = NULL;
priv->perf_resets_retries = NULL;
priv->perf_errors = NULL;
return NULL;
}

Loading…
Cancel
Save