/* This function tries to make a free PEB by means of synchronous execution of pending works. This may be needed if, for example the background thread is disabled. Returns zero in case of success and a negative error code in case of failure.  */
static int produce_free_peb(struct ubi_device *ubi)
/* This function tries to make a free PEB by means of synchronous execution of pending works. This may be needed if, for example the background thread is disabled. Returns zero in case of success and a negative error code in case of failure.  */
static int produce_free_peb(struct ubi_device *ubi)
{
	int err;
	while (!ubi->free.rb_node && ubi->works_count) {
		dbg_wl("do one work synchronously");
		err = do_work(ubi);
		if (err)
			return err;
	}
	return 0;
}