Wrap the fastmap work scheduling code into a new function
such that it can be reused.

Signed-off-by: Richard Weinberger <[email protected]>
---
 drivers/mtd/ubi/fastmap-wl.c |  5 +----
 drivers/mtd/ubi/ubi.h        | 12 ++++++++++++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/ubi/fastmap-wl.c b/drivers/mtd/ubi/fastmap-wl.c
index b2a6653..fc0e2ff 100644
--- a/drivers/mtd/ubi/fastmap-wl.c
+++ b/drivers/mtd/ubi/fastmap-wl.c
@@ -237,10 +237,7 @@ static struct ubi_wl_entry *get_peb_for_wl(struct 
ubi_device *ubi)
                /* We cannot update the fastmap here because this
                 * function is called in atomic context.
                 * Let's fail here and refill/update it as soon as possible. */
-               if (!ubi->fm_work_scheduled) {
-                       ubi->fm_work_scheduled = 1;
-                       schedule_work(&ubi->fm_work);
-               }
+               ubi_schedule_fm_work(ubi);
                return NULL;
        }
 
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 11f8fb0..cb3dcd0 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -881,8 +881,20 @@ size_t ubi_calc_fm_size(struct ubi_device *ubi);
 int ubi_update_fastmap(struct ubi_device *ubi);
 int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
                     int fm_anchor);
+/**
+ * ubi_schedule_fm_work - Schedule UBI fastmap work
+ * @ubi: UBI device description object
+ */
+static inline void ubi_schedule_fm_work(struct ubi_device *ubi)
+{
+       if (!ubi->fm_work_scheduled) {
+               ubi->fm_work_scheduled = 1;
+               schedule_work(&ubi->fm_work);
+       }
+}
 #else
 static inline int ubi_update_fastmap(struct ubi_device *ubi) { return 0; }
+static inline void ubi_schedule_fm_work(struct ubi_device *ubi) { }
 #endif
 
 /* block.c */
-- 
1.8.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to