[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1410873998-2955-3-git-send-email-richard@nod.at>
Date: Tue, 16 Sep 2014 15:26:38 +0200
From: Richard Weinberger <richard@....at>
To: dedekind1@...il.com
Cc: linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org,
Richard Weinberger <richard@....at>
Subject: [PATCH 2/2] UBI: Get rid of __schedule_ubi_work()
As we got rid of work_sem held in workers we can remove
__schedule_ubi_work() too.
Signed-off-by: Richard Weinberger <richard@....at>
---
drivers/mtd/ubi/wl.c | 35 +++++++++--------------------------
1 file changed, 9 insertions(+), 26 deletions(-)
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index b1e2ed1..ba15d33 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -830,15 +830,16 @@ repeat:
}
/**
- * __schedule_ubi_work - schedule a work.
+ * schedule_ubi_work - schedule a work.
* @ubi: UBI device description object
* @wrk: the work to schedule
*
* This function adds a work defined by @wrk to the tail of the pending works
- * list. Can only be used of ubi->work_sem is already held in read mode!
+ * list.
*/
-static void __schedule_ubi_work(struct ubi_device *ubi, struct ubi_work *wrk)
+static void schedule_ubi_work(struct ubi_device *ubi, struct ubi_work *wrk)
{
+ down_read(&ubi->work_sem);
spin_lock(&ubi->wl_lock);
list_add_tail(&wrk->list, &ubi->works);
ubi_assert(ubi->works_count >= 0);
@@ -846,20 +847,6 @@ static void __schedule_ubi_work(struct ubi_device *ubi, struct ubi_work *wrk)
if (ubi->thread_enabled && !ubi_dbg_is_bgt_disabled(ubi))
wake_up_process(ubi->bgt_thread);
spin_unlock(&ubi->wl_lock);
-}
-
-/**
- * schedule_ubi_work - schedule a work.
- * @ubi: UBI device description object
- * @wrk: the work to schedule
- *
- * This function adds a work defined by @wrk to the tail of the pending works
- * list.
- */
-static void schedule_ubi_work(struct ubi_device *ubi, struct ubi_work *wrk)
-{
- down_read(&ubi->work_sem);
- __schedule_ubi_work(ubi, wrk);
up_read(&ubi->work_sem);
}
@@ -1304,13 +1291,12 @@ out_cancel:
/**
* ensure_wear_leveling - schedule wear-leveling if it is needed.
* @ubi: UBI device description object
- * @nested: set to non-zero if this function is called from UBI worker
*
* This function checks if it is time to start wear-leveling and schedules it
* if yes. This function returns zero in case of success and a negative error
* code in case of failure.
*/
-static int ensure_wear_leveling(struct ubi_device *ubi, int nested)
+static int ensure_wear_leveling(struct ubi_device *ubi)
{
int err = 0;
struct ubi_wl_entry *e1;
@@ -1357,10 +1343,7 @@ static int ensure_wear_leveling(struct ubi_device *ubi, int nested)
wrk->anchor = 0;
wrk->func = &wear_leveling_worker;
- if (nested)
- __schedule_ubi_work(ubi, wrk);
- else
- schedule_ubi_work(ubi, wrk);
+ schedule_ubi_work(ubi, wrk);
return err;
out_cancel:
@@ -1452,7 +1435,7 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
serve_prot_queue(ubi);
/* And take care about wear-leveling */
- err = ensure_wear_leveling(ubi, 0);
+ err = ensure_wear_leveling(ubi);
return err;
}
@@ -1690,7 +1673,7 @@ retry:
* Technically scrubbing is the same as wear-leveling, so it is done
* by the WL worker.
*/
- return ensure_wear_leveling(ubi, 0);
+ return ensure_wear_leveling(ubi);
}
/**
@@ -1991,7 +1974,7 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
ubi->rsvd_pebs += reserved_pebs;
/* Schedule wear-leveling if needed */
- err = ensure_wear_leveling(ubi, 0);
+ err = ensure_wear_leveling(ubi);
if (err)
goto out_free;
--
1.8.4.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists