Attaching a UBI partition may take a while, since scanning the memory is
required.
It thus makes sense to avoid a detach/scan/attach cycle when the right
partition is already attached, and let the calling process call 'detach'
beforehand if it needs it.
This commit checks for the currently attached UBI partition, and skips
reattaching if not needed, showing an information.
Signed-off-by: Alexandre Besnard <alexandre.besnard@softathome.com>
struct mtd_info *mtd;
int err = 0;
+ if (ubi && ubi->mtd && !strcmp(ubi->mtd->name, part_name)) {
+ printf("UBI partition '%s' already selected\n", part_name);
+ return 0;
+ }
+
ubi_detach();
mtd_probe_devices();