mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-23 09:47:35 +08:00
Merge branch 'perf_cleanup'
This commit is contained in:
@@ -529,6 +529,11 @@ PX4IO::~PX4IO()
|
||||
if (_interface != nullptr)
|
||||
delete _interface;
|
||||
|
||||
/* deallocate perfs */
|
||||
perf_free(_perf_update);
|
||||
perf_free(_perf_write);
|
||||
perf_free(_perf_chan_count);
|
||||
|
||||
g_dev = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,12 +142,9 @@ struct at24c_dev_s {
|
||||
uint16_t pagesize; /* 32, 63 */
|
||||
uint16_t npages; /* 128, 256, 512, 1024 */
|
||||
|
||||
perf_counter_t perf_reads;
|
||||
perf_counter_t perf_writes;
|
||||
perf_counter_t perf_resets;
|
||||
perf_counter_t perf_read_retries;
|
||||
perf_counter_t perf_read_errors;
|
||||
perf_counter_t perf_write_errors;
|
||||
perf_counter_t perf_transfers;
|
||||
perf_counter_t perf_resets_retries;
|
||||
perf_counter_t perf_errors;
|
||||
};
|
||||
|
||||
/************************************************************************************
|
||||
@@ -298,9 +295,9 @@ static ssize_t at24c_bread(FAR struct mtd_dev_s *dev, off_t startblock,
|
||||
|
||||
for (;;) {
|
||||
|
||||
perf_begin(priv->perf_reads);
|
||||
perf_begin(priv->perf_transfers);
|
||||
ret = I2C_TRANSFER(priv->dev, &msgv[0], 2);
|
||||
perf_end(priv->perf_reads);
|
||||
perf_end(priv->perf_transfers);
|
||||
|
||||
if (ret >= 0)
|
||||
break;
|
||||
@@ -314,10 +311,10 @@ static ssize_t at24c_bread(FAR struct mtd_dev_s *dev, off_t startblock,
|
||||
* XXX maybe do special first-read handling with optional
|
||||
* bus reset as well?
|
||||
*/
|
||||
perf_count(priv->perf_read_retries);
|
||||
perf_count(priv->perf_resets_retries);
|
||||
|
||||
if (--tries == 0) {
|
||||
perf_count(priv->perf_read_errors);
|
||||
perf_count(priv->perf_errors);
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
@@ -383,9 +380,9 @@ static ssize_t at24c_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t
|
||||
|
||||
for (;;) {
|
||||
|
||||
perf_begin(priv->perf_writes);
|
||||
perf_begin(priv->perf_transfers);
|
||||
ret = I2C_TRANSFER(priv->dev, &msgv[0], 1);
|
||||
perf_end(priv->perf_writes);
|
||||
perf_end(priv->perf_transfers);
|
||||
|
||||
if (ret >= 0)
|
||||
break;
|
||||
@@ -397,7 +394,7 @@ static ssize_t at24c_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t
|
||||
* poll for write completion.
|
||||
*/
|
||||
if (--tries == 0) {
|
||||
perf_count(priv->perf_write_errors);
|
||||
perf_count(priv->perf_errors);
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
@@ -521,12 +518,9 @@ FAR struct mtd_dev_s *at24c_initialize(FAR struct i2c_dev_s *dev) {
|
||||
priv->mtd.ioctl = at24c_ioctl;
|
||||
priv->dev = dev;
|
||||
|
||||
priv->perf_reads = perf_alloc(PC_ELAPSED, "EEPROM read");
|
||||
priv->perf_writes = perf_alloc(PC_ELAPSED, "EEPROM write");
|
||||
priv->perf_resets = perf_alloc(PC_COUNT, "EEPROM reset");
|
||||
priv->perf_read_retries = perf_alloc(PC_COUNT, "EEPROM read retries");
|
||||
priv->perf_read_errors = perf_alloc(PC_COUNT, "EEPROM read errors");
|
||||
priv->perf_write_errors = perf_alloc(PC_COUNT, "EEPROM write errors");
|
||||
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");
|
||||
}
|
||||
|
||||
/* attempt to read to validate device is present */
|
||||
@@ -548,9 +542,9 @@ FAR struct mtd_dev_s *at24c_initialize(FAR struct i2c_dev_s *dev) {
|
||||
}
|
||||
};
|
||||
|
||||
perf_begin(priv->perf_reads);
|
||||
perf_begin(priv->perf_transfers);
|
||||
int ret = I2C_TRANSFER(priv->dev, &msgv[0], 2);
|
||||
perf_end(priv->perf_reads);
|
||||
perf_end(priv->perf_transfers);
|
||||
|
||||
if (ret < 0) {
|
||||
return NULL;
|
||||
|
||||
Reference in New Issue
Block a user