[PATCH 1/1] nandsim: add names parameter
Tj
tj.iam.tj at proton.me
Thu Sep 25 09:18:58 PDT 2025
Allow naming of partitions.
Useful for simulating an embedded device even on a different
architecture and with the help of qemu-user debugging tools such as
flash updaters that expect partitions to have defined names.
Signed-off-by: Tj <tj.iam.tj at proton.me>
---
drivers/mtd/nand/raw/nandsim.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c
index df48b7d01d16c..085b5e2b8a0a6 100644
--- a/drivers/mtd/nand/raw/nandsim.c
+++ b/drivers/mtd/nand/raw/nandsim.c
@@ -103,7 +103,10 @@ static u_char id_bytes[8] = {
[3] = CONFIG_NANDSIM_FOURTH_ID_BYTE,
[4 ... 7] = 0xFF,
};
+static char *names[CONFIG_NANDSIM_MAX_PARTS] = { [0 ... (CONFIG_NANDSIM_MAX_PARTS-1)] = NULL };
+static uint names_num;
+module_param_array(names, charp, &names_num, 0400);
module_param_array(id_bytes, byte, NULL, 0400);
module_param_named(first_id_byte, id_bytes[0], byte, 0400);
module_param_named(second_id_byte, id_bytes[1], byte, 0400);
@@ -129,6 +132,7 @@ module_param(cache_file, charp, 0400);
module_param(bbt, uint, 0400);
module_param(bch, uint, 0400);
+MODULE_PARM_DESC(names, "Array of name strings");
MODULE_PARM_DESC(id_bytes, "The ID bytes returned by NAND Flash 'read ID' command");
MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID) (obsolete)");
MODULE_PARM_DESC(second_id_byte, "The second byte returned by NAND Flash 'read ID' command (chip ID) (obsolete)");
@@ -629,6 +633,9 @@ static void ns_free_device(struct nandsim *ns)
static char __init *ns_get_partition_name(int i)
{
+ if (i < names_num)
+ return names[i];
+
return kasprintf(GFP_KERNEL, "NAND simulator partition %d", i);
}
--
2.39.5
More information about the linux-mtd
mailing list