aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/wl.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2007-12-17 13:33:20 -0500
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2007-12-26 12:15:17 -0500
commitcdfa788acd134a35d3e5b73d1a76fca4033d8aa9 (patch)
treeccc8cbf0bad80f569d9e3bbdc7cbf9c97556f155 /drivers/mtd/ubi/wl.c
parente73f4459d969bb266f03dd4cbe21bdba8cb2732c (diff)
UBI: prepare attach and detach functions
Prepare the attach and detach functions to by used outside of module initialization: * detach function checks reference count before detaching * it kills the background thread as well Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/wl.c')
-rw-r--r--drivers/mtd/ubi/wl.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index bfc64c824165..1142aabcfc8c 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1356,7 +1356,7 @@ static void tree_destroy(struct rb_root *root)
1356 * ubi_thread - UBI background thread. 1356 * ubi_thread - UBI background thread.
1357 * @u: the UBI device description object pointer 1357 * @u: the UBI device description object pointer
1358 */ 1358 */
1359static int ubi_thread(void *u) 1359int ubi_thread(void *u)
1360{ 1360{
1361 int failures = 0; 1361 int failures = 0;
1362 struct ubi_device *ubi = u; 1362 struct ubi_device *ubi = u;
@@ -1454,18 +1454,10 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_scan_info *si)
1454 1454
1455 sprintf(ubi->bgt_name, UBI_BGT_NAME_PATTERN, ubi->ubi_num); 1455 sprintf(ubi->bgt_name, UBI_BGT_NAME_PATTERN, ubi->ubi_num);
1456 1456
1457 ubi->bgt_thread = kthread_create(ubi_thread, ubi, ubi->bgt_name);
1458 if (IS_ERR(ubi->bgt_thread)) {
1459 err = PTR_ERR(ubi->bgt_thread);
1460 ubi_err("cannot spawn \"%s\", error %d", ubi->bgt_name,
1461 err);
1462 return err;
1463 }
1464
1465 err = -ENOMEM; 1457 err = -ENOMEM;
1466 ubi->lookuptbl = kzalloc(ubi->peb_count * sizeof(void *), GFP_KERNEL); 1458 ubi->lookuptbl = kzalloc(ubi->peb_count * sizeof(void *), GFP_KERNEL);
1467 if (!ubi->lookuptbl) 1459 if (!ubi->lookuptbl)
1468 goto out_free; 1460 return err;
1469 1461
1470 list_for_each_entry_safe(seb, tmp, &si->erase, u.list) { 1462 list_for_each_entry_safe(seb, tmp, &si->erase, u.list) {
1471 cond_resched(); 1463 cond_resched();
@@ -1598,10 +1590,6 @@ static void protection_trees_destroy(struct ubi_device *ubi)
1598 */ 1590 */
1599void ubi_wl_close(struct ubi_device *ubi) 1591void ubi_wl_close(struct ubi_device *ubi)
1600{ 1592{
1601 dbg_wl("disable \"%s\"", ubi->bgt_name);
1602 if (ubi->bgt_thread)
1603 kthread_stop(ubi->bgt_thread);
1604
1605 dbg_wl("close the UBI wear-leveling unit"); 1593 dbg_wl("close the UBI wear-leveling unit");
1606 1594
1607 cancel_pending(ubi); 1595 cancel_pending(ubi);