// SPDX-License-Identifier: GPL-2.0 #define pr_fmt(fmt) "[rename_ubi] " fmt #include #include #include #include "avm_mtd_helper.h" struct name_info { const char *old; const char *new; }; static const struct name_info rename_infos[] = { { "avm_filesys_0", "filesystem0" }, { "avm_filesys_1", "filesystem1" }, { "avm_config", "config" }, { "avm_userdata", "nand-filesystem" }, }; static const char *get_new_name(struct mtd_info *mtd) { int i; for (i = 0; i < ARRAY_SIZE(rename_infos); i++) if (strcmp(mtd->name, rename_infos[i].old) == 0) return rename_infos[i].new; return NULL; } static void rename_ubi_add_notifier(struct mtd_info *mtd) { const char *new_name; if (!mtd->name) return; if (mtd->type != MTD_UBIVOLUME) return; new_name = get_new_name(mtd); if (!new_name) return; rename_mtd(mtd, new_name); } static void rename_ubi_rm_notifier(struct mtd_info *mtd) { } struct mtd_notifier avm_mtd_rename_ubi_notifier = { .add = rename_ubi_add_notifier, .remove = rename_ubi_rm_notifier, };