/* ubi_calculate_reserved - calculate how many PEBs must be reserved for bad eraseblock handling. @ubi: UBI device description object  */
void ubi_calculate_reserved(struct ubi_device *ubi)
/* ubi_calculate_reserved - calculate how many PEBs must be reserved for bad eraseblock handling. @ubi: UBI device description object  */
void ubi_calculate_reserved(struct ubi_device *ubi)
{
	ubi->beb_rsvd_level = ubi->bad_peb_limit - ubi->bad_peb_count;
	if (ubi->beb_rsvd_level < 0) {
		ubi->beb_rsvd_level = 0;
		ubi_warn(ubi, "number of bad PEBs (%d) is above the expected limit (%d), not reserving any PEBs for bad PEB handling, will use available PEBs (if any)",
			 ubi->bad_peb_count, ubi->bad_peb_limit);
	}
}