Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2055db4 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ubi: Fix ubi_io_write_vid_hdr so it can be used before wl init"

parents c911d770 a9e78113
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -712,13 +712,26 @@ struct ubi_ainf_peb *ubi_early_get_peb(struct ubi_device *ubi,
	int err = 0;
	struct ubi_ainf_peb *aeb, *tmp_aeb;

	if (!list_empty(&ai->free)) {
		aeb = list_entry(ai->free.next, struct ubi_ainf_peb, u.list);
	list_for_each_entry_safe(aeb, tmp_aeb, &ai->free, u.list) {
		list_del(&aeb->u.list);
		if (aeb->ec == UBI_UNKNOWN) {
			ubi_err(ubi, "PEB %d in freelist has unknown EC",
				aeb->pnum);
			aeb->ec = ai->mean_ec;
		}
		err = early_erase_peb(ubi, ai, aeb->pnum, aeb->ec+1);
		if (err) {
			ubi_err(ubi, "Erase failed for PEB %d in freelist",
				aeb->pnum);
			list_add(&aeb->u.list, &ai->erase);
			continue;
		}
		aeb->ec += 1;
		dbg_bld("return free PEB %d, EC %d", aeb->pnum, aeb->ec);
		return aeb;
	}


	/*
	 * We try to erase the first physical eraseblock from the erase list
	 * and pick it if we succeed, or try to erase the next one if not. And
+8 −4
Original line number Diff line number Diff line
@@ -1105,9 +1105,11 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
	 * Re-erase the PEB before using it. This should minimize any issues
	 * from decay of charge in this block.
	 */
	if (ubi->wl_is_inited) {
		err = ubi_wl_erase_peb(ubi, pnum);
		if (err)
			return err;
	}

	err = self_check_peb_ec_hdr(ubi, pnum);
	if (err)
@@ -1128,8 +1130,10 @@ int ubi_io_write_vid_hdr(struct ubi_device *ubi, int pnum,
	p = (char *)vid_hdr - ubi->vid_hdr_shift;
	err = ubi_io_write(ubi, p, pnum, ubi->vid_hdr_aloffset,
			   ubi->vid_hdr_alsize);
	if (!err)

	if (!err && ubi->wl_is_inited)
		ubi_wl_update_peb_sqnum(ubi, pnum, vid_hdr);

	return err;
}

+1 −0
Original line number Diff line number Diff line
@@ -598,6 +598,7 @@ struct ubi_device {
	char bgt_name[sizeof(UBI_BGT_NAME_PATTERN)+2];
	bool scrub_in_progress;
	atomic_t scrub_work_count;
	int wl_is_inited;

	/* I/O sub-system's stuff */
	long long flash_size;
+1 −0
Original line number Diff line number Diff line
@@ -1873,6 +1873,7 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
	if (err)
		goto out_free;

	ubi->wl_is_inited = 1;
	return 0;

out_free: