Do not access ext_csd register in debugfs from storaged
Starting from Android R, platform code cannot access files in debugfs since it does not guarantee ABI stability. This CL removes the code in storaged that accesses the EMMC's ext_csd register from debugfs as a backup if it is unable to obtain the information from Health HAL. Test: build and boot. Bug: 134669095 Change-Id: I3bfeb3963de5fb5e6bb3eaa9df43baacad164816
This commit is contained in:
parent
c1c6008b78
commit
dbac204e8b
1 changed files with 3 additions and 55 deletions
|
@ -41,7 +41,6 @@ using android::hardware::health::V2_0::Result;
|
|||
using android::hardware::health::V2_0::StorageInfo;
|
||||
|
||||
const string emmc_info_t::emmc_sysfs = "/sys/bus/mmc/devices/mmc0:0001/";
|
||||
const string emmc_info_t::emmc_debugfs = "/d/mmc0/mmc0:0001/ext_csd";
|
||||
const char* emmc_info_t::emmc_ver_str[9] = {
|
||||
"4.0", "4.1", "4.2", "4.3", "Obsolete", "4.41", "4.5", "5.0", "5.1"
|
||||
};
|
||||
|
@ -62,10 +61,8 @@ storage_info_t* storage_info_t::get_storage_info(const sp<IHealth>& healthServic
|
|||
if (healthService != nullptr) {
|
||||
return new health_storage_info_t(healthService);
|
||||
}
|
||||
if (FileExists(emmc_info_t::emmc_sysfs) ||
|
||||
FileExists(emmc_info_t::emmc_debugfs)) {
|
||||
return new emmc_info_t;
|
||||
}
|
||||
if (FileExists(emmc_info_t::emmc_sysfs)) return new emmc_info_t;
|
||||
|
||||
if (FileExists(ufs_info_t::health_file)) {
|
||||
return new ufs_info_t;
|
||||
}
|
||||
|
@ -241,8 +238,7 @@ uint32_t storage_info_t::get_recent_perf() {
|
|||
|
||||
void emmc_info_t::report()
|
||||
{
|
||||
if (!report_sysfs() && !report_debugfs())
|
||||
return;
|
||||
if (!report_sysfs()) return;
|
||||
|
||||
publish();
|
||||
}
|
||||
|
@ -284,54 +280,6 @@ bool emmc_info_t::report_sysfs()
|
|||
return true;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
const size_t EXT_CSD_FILE_MIN_SIZE = 1024;
|
||||
/* 2 characters in string for each byte */
|
||||
const size_t EXT_CSD_REV_IDX = 192 * 2;
|
||||
const size_t EXT_PRE_EOL_INFO_IDX = 267 * 2;
|
||||
const size_t EXT_DEVICE_LIFE_TIME_EST_A_IDX = 268 * 2;
|
||||
const size_t EXT_DEVICE_LIFE_TIME_EST_B_IDX = 269 * 2;
|
||||
|
||||
} // namespace
|
||||
|
||||
bool emmc_info_t::report_debugfs()
|
||||
{
|
||||
string buffer;
|
||||
uint16_t rev = 0;
|
||||
|
||||
if (!ReadFileToString(emmc_debugfs, &buffer) ||
|
||||
buffer.length() < (size_t)EXT_CSD_FILE_MIN_SIZE) {
|
||||
return false;
|
||||
}
|
||||
|
||||
string str = buffer.substr(EXT_CSD_REV_IDX, 2);
|
||||
if (!ParseUint(str, &rev) ||
|
||||
rev < 7 || rev > ARRAY_SIZE(emmc_ver_str)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
version = "emmc ";
|
||||
version += emmc_ver_str[rev];
|
||||
|
||||
str = buffer.substr(EXT_PRE_EOL_INFO_IDX, 2);
|
||||
if (!ParseUint(str, &eol)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
str = buffer.substr(EXT_DEVICE_LIFE_TIME_EST_A_IDX, 2);
|
||||
if (!ParseUint(str, &lifetime_a)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
str = buffer.substr(EXT_DEVICE_LIFE_TIME_EST_B_IDX, 2);
|
||||
if (!ParseUint(str, &lifetime_b)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ufs_info_t::report()
|
||||
{
|
||||
string buffer;
|
||||
|
|
Loading…
Reference in a new issue