1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 23:22:37 +02:00

linux_mtd: drop 'mtd_' prefix from variable/field names

BUG=b:161951062
BRANCH=none
TEST=builds

Change-Id: I2503c98e9111d1fecd911473f65eeea7031cfdc3
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/53953
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
This commit is contained in:
Nikolai Artemiev 2021-05-09 11:37:38 +10:00 committed by Edward O'Callaghan
parent af26c9675d
commit 3dc5af7e09

View File

@ -33,13 +33,13 @@
struct linux_mtd_data { struct linux_mtd_data {
FILE *dev_fp; FILE *dev_fp;
int mtd_device_is_writeable; int device_is_writeable;
int mtd_no_erase; int no_erase;
/* Size info is presented in bytes in sysfs. */ /* Size info is presented in bytes in sysfs. */
unsigned long int mtd_total_size; unsigned long int total_size;
unsigned long int mtd_numeraseregions; unsigned long int numeraseregions;
/* only valid if numeraseregions is 0 */ /* only valid if numeraseregions is 0 */
unsigned long int mtd_erasesize; unsigned long int erasesize;
}; };
/* read a string from a sysfs file and sanitize it */ /* read a string from a sysfs file and sanitize it */
@ -123,51 +123,51 @@ static int popcnt(unsigned int u)
static int get_mtd_info(const char *sysfs_path, struct linux_mtd_data *data) static int get_mtd_info(const char *sysfs_path, struct linux_mtd_data *data)
{ {
unsigned long int tmp; unsigned long int tmp;
char mtd_device_name[32]; char device_name[32];
/* Flags */ /* Flags */
if (read_sysfs_int(sysfs_path, "flags", &tmp)) if (read_sysfs_int(sysfs_path, "flags", &tmp))
return 1; return 1;
if (tmp & MTD_WRITEABLE) { if (tmp & MTD_WRITEABLE) {
/* cache for later use by write function */ /* cache for later use by write function */
data->mtd_device_is_writeable = 1; data->device_is_writeable = 1;
} }
if (tmp & MTD_NO_ERASE) { if (tmp & MTD_NO_ERASE) {
data->mtd_no_erase = 1; data->no_erase = 1;
} }
/* Device name */ /* Device name */
if (read_sysfs_string(sysfs_path, "name", mtd_device_name, sizeof(mtd_device_name))) if (read_sysfs_string(sysfs_path, "name", device_name, sizeof(device_name)))
return 1; return 1;
/* Total size */ /* Total size */
if (read_sysfs_int(sysfs_path, "size", &data->mtd_total_size)) if (read_sysfs_int(sysfs_path, "size", &data->total_size))
return 1; return 1;
if (popcnt(data->mtd_total_size) != 1) { if (popcnt(data->total_size) != 1) {
msg_perr("MTD size is not a power of 2\n"); msg_perr("MTD size is not a power of 2\n");
return 1; return 1;
} }
/* Erase size */ /* Erase size */
if (read_sysfs_int(sysfs_path, "erasesize", &data->mtd_erasesize)) if (read_sysfs_int(sysfs_path, "erasesize", &data->erasesize))
return 1; return 1;
if (popcnt(data->mtd_erasesize) != 1) { if (popcnt(data->erasesize) != 1) {
msg_perr("MTD erase size is not a power of 2\n"); msg_perr("MTD erase size is not a power of 2\n");
return 1; return 1;
} }
/* Erase regions */ /* Erase regions */
if (read_sysfs_int(sysfs_path, "numeraseregions", &data->mtd_numeraseregions)) if (read_sysfs_int(sysfs_path, "numeraseregions", &data->numeraseregions))
return 1; return 1;
if (data->mtd_numeraseregions != 0) { if (data->numeraseregions != 0) {
msg_perr("Non-uniform eraseblock size is unsupported.\n"); msg_perr("Non-uniform eraseblock size is unsupported.\n");
return 1; return 1;
} }
msg_pdbg("%s: device_name: \"%s\", is_writeable: %d, " msg_pdbg("%s: device_name: \"%s\", is_writeable: %d, "
"numeraseregions: %lu, total_size: %lu, erasesize: %lu\n", "numeraseregions: %lu, total_size: %lu, erasesize: %lu\n",
__func__, mtd_device_name, data->mtd_device_is_writeable, __func__, device_name, data->device_is_writeable,
data->mtd_numeraseregions, data->mtd_total_size, data->mtd_erasesize); data->numeraseregions, data->total_size, data->erasesize);
return 0; return 0;
} }
@ -176,13 +176,13 @@ static int linux_mtd_probe(struct flashctx *flash)
{ {
struct linux_mtd_data *data = flash->mst->opaque.data; struct linux_mtd_data *data = flash->mst->opaque.data;
if (data->mtd_no_erase) if (data->no_erase)
flash->chip->feature_bits |= FEATURE_NO_ERASE; flash->chip->feature_bits |= FEATURE_NO_ERASE;
flash->chip->tested = TEST_OK_PREW; flash->chip->tested = TEST_OK_PREW;
flash->chip->total_size = data->mtd_total_size / 1024; /* bytes -> kB */ flash->chip->total_size = data->total_size / 1024; /* bytes -> kB */
flash->chip->block_erasers[0].eraseblocks[0].size = data->mtd_erasesize; flash->chip->block_erasers[0].eraseblocks[0].size = data->erasesize;
flash->chip->block_erasers[0].eraseblocks[0].count = flash->chip->block_erasers[0].eraseblocks[0].count =
data->mtd_total_size / data->mtd_erasesize; data->total_size / data->erasesize;
return 1; return 1;
} }
@ -227,7 +227,7 @@ static int linux_mtd_write(struct flashctx *flash, const uint8_t *buf,
unsigned int chunksize = flash->chip->block_erasers[0].eraseblocks[0].size; unsigned int chunksize = flash->chip->block_erasers[0].eraseblocks[0].size;
unsigned int i; unsigned int i;
if (!data->mtd_device_is_writeable) if (!data->device_is_writeable)
return 1; return 1;
if (fseek(data->dev_fp, start, SEEK_SET) != 0) { if (fseek(data->dev_fp, start, SEEK_SET) != 0) {
@ -267,23 +267,23 @@ static int linux_mtd_erase(struct flashctx *flash,
struct linux_mtd_data *data = flash->mst->opaque.data; struct linux_mtd_data *data = flash->mst->opaque.data;
uint32_t u; uint32_t u;
if (data->mtd_no_erase) { if (data->no_erase) {
msg_perr("%s: device does not support erasing. Please file a " msg_perr("%s: device does not support erasing. Please file a "
"bug report at flashrom@flashrom.org\n", __func__); "bug report at flashrom@flashrom.org\n", __func__);
return 1; return 1;
} }
if (data->mtd_numeraseregions != 0) { if (data->numeraseregions != 0) {
/* TODO: Support non-uniform eraseblock size using /* TODO: Support non-uniform eraseblock size using
use MEMGETREGIONCOUNT/MEMGETREGIONINFO ioctls */ use MEMGETREGIONCOUNT/MEMGETREGIONINFO ioctls */
msg_perr("%s: mtd_numeraseregions must be 0\n", __func__); msg_perr("%s: numeraseregions must be 0\n", __func__);
return 1; return 1;
} }
for (u = 0; u < len; u += data->mtd_erasesize) { for (u = 0; u < len; u += data->erasesize) {
struct erase_info_user erase_info = { struct erase_info_user erase_info = {
.start = start + u, .start = start + u,
.length = data->mtd_erasesize, .length = data->erasesize,
}; };
if (ioctl(fileno(data->dev_fp), MEMERASE, &erase_info) == -1) { if (ioctl(fileno(data->dev_fp), MEMERASE, &erase_info) == -1) {