Commit 243a4f81 authored by Richard Weinberger's avatar Richard Weinberger

ubi: Introduce vol_ignored()

This makes the logic more easy to follow.
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent d139d300
...@@ -803,6 +803,20 @@ static int check_corruption(struct ubi_device *ubi, struct ubi_vid_hdr *vid_hdr, ...@@ -803,6 +803,20 @@ static int check_corruption(struct ubi_device *ubi, struct ubi_vid_hdr *vid_hdr,
return err; return err;
} }
static bool vol_ignored(int vol_id)
{
switch (vol_id) {
case UBI_LAYOUT_VOLUME_ID:
return true;
}
#ifdef CONFIG_MTD_UBI_FASTMAP
return ubi_is_fm_vol(vol_id);
#else
return false;
#endif
}
/** /**
* scan_peb - scan and process UBI headers of a PEB. * scan_peb - scan and process UBI headers of a PEB.
* @ubi: UBI device description object * @ubi: UBI device description object
...@@ -995,17 +1009,15 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -995,17 +1009,15 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
*vid = vol_id; *vid = vol_id;
if (sqnum) if (sqnum)
*sqnum = be64_to_cpu(vidh->sqnum); *sqnum = be64_to_cpu(vidh->sqnum);
if (vol_id > UBI_MAX_VOLUMES && vol_id != UBI_LAYOUT_VOLUME_ID) { if (vol_id > UBI_MAX_VOLUMES && !vol_ignored(vol_id)) {
int lnum = be32_to_cpu(vidh->lnum); int lnum = be32_to_cpu(vidh->lnum);
/* Unsupported internal volume */ /* Unsupported internal volume */
switch (vidh->compat) { switch (vidh->compat) {
case UBI_COMPAT_DELETE: case UBI_COMPAT_DELETE:
if (vol_id != UBI_FM_SB_VOLUME_ID ubi_msg(ubi, "\"delete\" compatible internal volume %d:%d found, will remove it",
&& vol_id != UBI_FM_DATA_VOLUME_ID) { vol_id, lnum);
ubi_msg(ubi, "\"delete\" compatible internal volume %d:%d found, will remove it",
vol_id, lnum);
}
err = add_to_list(ai, pnum, vol_id, lnum, err = add_to_list(ai, pnum, vol_id, lnum,
ec, 1, &ai->erase); ec, 1, &ai->erase);
if (err) if (err)
......
...@@ -1105,4 +1105,19 @@ static inline int idx2vol_id(const struct ubi_device *ubi, int idx) ...@@ -1105,4 +1105,19 @@ static inline int idx2vol_id(const struct ubi_device *ubi, int idx)
return idx; return idx;
} }
/**
* ubi_is_fm_vol - check whether a volume ID is a Fastmap volume.
* @vol_id: volume ID
*/
static inline bool ubi_is_fm_vol(int vol_id)
{
switch (vol_id) {
case UBI_FM_SB_VOLUME_ID:
case UBI_FM_DATA_VOLUME_ID:
return true;
}
return false;
}
#endif /* !__UBI_UBI_H__ */ #endif /* !__UBI_UBI_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment