UBI: dispose of background.c
Subsystems (2)
RFC PATCH 1/1 UBI: dispose of background.c
Hi Artem,
this patch moves the background unit code to the wear-leveling unit. The kthread api is now used for handling the background thread.
Signed-off-by Alexander Schmidt <[email protected]>
--- drivers/mtd/ubi/Kconfig.debug | 8 - drivers/mtd/ubi/Makefile | 2 drivers/mtd/ubi/build.c | 19 -- drivers/mtd/ubi/debug.c | 23 --- drivers/mtd/ubi/debug.h | 6 drivers/mtd/ubi/eba.c | 1 drivers/mtd/ubi/sysfs.c | 30 ---- drivers/mtd/ubi/ubi.h | 139 +++++++------------ drivers/mtd/ubi/wl.c | 294 +++++++++++++++++++++++++++++++++++++++--- 9 files changed, 341 insertions(+), 181 deletions(-)
drivers/mtd/ubi/build.c +1 -18
@@ -41,8 +41,6 @@ int ubi_uif_init(struct ubi_info *ubi);void ubi_uif_close (struct ubi_info *ubi);int ubi_wl_init_scan (struct ubi_info *ubi,struct ubi_scan_info *si);void ubi_wl_close (struct ubi_info *ubi); -int ubi_bgt_init (struct ubi_info *ubi); -void ubi_bgt_close (struct ubi_info *ubi);int ubi_io_init (struct ubi_info *ubi,int mtd_num,int vid_hdr_offset,int data_offset);void ubi_io_close (const struct ubi_info *ubi);
@@ -136,12 +134,10 @@ static void detach_mtd_dev(struct ubi_indbg_bld ("detaching mtd%d from ubi%d" , mtd_num, ubi_num); -ubi_bgt_kill_thread (ubi);ubi_uif_close (ubi);ubi_eba_close (ubi);ubi_wl_close (ubi);ubi_vmt_close (ubi); -ubi_bgt_close (ubi);ubi_io_close (ubi);kfree (ubis[ubi_num]); ubis[ubi_num] =NULL ;
@@ -228,17 +224,10 @@ static int attach_mtd_dev(const char *mt goto out_free; } - err =ubi_bgt_init (ubi); -if (err) { -dbg_err ("failed to initialize background thread unit, error %d" , - err); - goto out_io; - } - err =attach_by_scanning (ubi);if (err) {dbg_err ("failed to attach MTD device, error %d" , err); - goto out_bgt; + goto out_io; } err =ubi_beb_init (ubi);
@@ -279,18 +268,12 @@ static int attach_mtd_dev(const char *mtubi_msg ("number of PEBs reserved for bad PEB handling: %d" , ubi->beb.reserved_pebs); -if (!DBG_DISABLE_BGT && !ubi->io.ro_mode) -ubi_bgt_enable (ubi); -return 0 ; out_detach:ubi_eba_close (ubi);ubi_wl_close (ubi);ubi_vmt_close (ubi); -out_bgt: -ubi_bgt_kill_thread (ubi); -ubi_bgt_close (ubi); out_io:ubi_io_close (ubi); out_free:
drivers/mtd/ubi/ubi.h +55 -84
183 lines not on this page · raw message
drivers/mtd/ubi/sysfs.c +6 -24
@@ -75,8 +75,6 @@ static ssize_t dev_bad_peb_count_show(ststatic ssize_t dev_max_vol_count_show (struct class_device *dev,char *buf);static ssize_t dev_min_io_size_show (struct class_device *dev,char *buf);static ssize_t dev_bgt_enabled_show (struct class_device *dev,char *buf); -static ssize_t dev_bgt_enabled_store (struct class_device *dev,const char *buf, -size_t count);/* * Class device attributes corresponding to files in '/<sysfs>/class/ubi/ubiX'.
@@ -100,8 +98,7 @@ static struct class_device_attribute devstatic struct class_device_attribute dev_min_io_size =__ATTR (min_io_size,S_IRUGO , dev_min_io_size_show,NULL );static struct class_device_attribute dev_bgt_enabled = -__ATTR (bgt_enabled,S_IRUGO |S_IWUSR , - dev_bgt_enabled_show, dev_bgt_enabled_store); +__ATTR (bgt_enabled,S_IRUGO , dev_bgt_enabled_show,NULL );/** * ubi_sysfs_init - initialize sysfs for an UBI device.
@@ -395,29 +392,14 @@ static ssize_t dev_min_io_size_show(strustatic ssize_t dev_bgt_enabled_show (struct class_device *dev,char *buf) {const struct ubi_info *ubi =dev2ubi (dev); +int enabled; -return sprintf (buf,"%d\n" , ubi->bgt.enabled); -} - -static ssize_t dev_bgt_enabled_store (struct class_device *dev,const char *buf, -size_t count) -{ -struct ubi_info *ubi =dev2ubi (dev); - -if (count >2 ) -return -EINVAL ; - -if (count ==2 && buf[1 ] !='\n' ) -return -EINVAL ; - -if (buf[0 ] =='1' ) -ubi_bgt_enable (ubi); -else if (buf[0 ] =='0' ) -ubi_bgt_disable (ubi); +if (DBG_DISABLE_BGT || ubi->io.ro_mode) + enabled =0 ;else -return -EINVAL ; + enabled =1 ; -return count; +return sprintf (buf,"%d\n" , enabled); }/**
drivers/mtd/ubi/Makefile +1 -1
@@ -1,7 +1,7 @@ obj-$(CONFIG_MTD_UBI) += ubi.o ubi-y += badeb.o upd.o sysfs.o cdev.o uif.o vtbl.o volmgmt.o eba.o io.o wl.o -ubi-y += scan.o background.o build.o account.o misc.o +ubi-y += scan.o build.o account.o misc.o ubi-$(CONFIG_MTD_UBI_DEBUG) += debug.o ubi-$(CONFIG_MTD_UBI_GLUEBI) += gluebi.o
drivers/mtd/ubi/debug.h +0 -6
@@ -63,9 +63,6 @@/* Wear-leveling unit */ #define dbg_wl (fmt, ...) \ ubi_dbg_print(UBI_DBG_WL, __FUNCTION__, fmt, ##__VA_ARGS__) -/* Background thread unit */ -#define dbg_bgt (fmt, ...) \ - ubi_dbg_print(UBI_DBG_BGT, __FUNCTION__, fmt, ##__VA_ARGS__)/* Input/output unit */ #define dbg_io (fmt, ...) \ ubi_dbg_print(UBI_DBG_IO, __FUNCTION__, fmt, ##__VA_ARGS__)
@@ -86,7 +83,6 @@* @UBI_DBG_ACC: a debugging message from the accounting unit * @UBI_DBG_EBA: a debugging message from the eraseblock association unit * @UBI_DBG_WL: a debugging message from the wear-leveling unit -* @UBI_DBG_BGT: a debugging message from the background thread unit * @UBI_DBG_IO: a debugging message from the input/output unit * @UBI_DBG_BLD: a UBI build debugging message from the build unit * @UBI_DBG_SCAN: a debugging message from the scanning unit
@@ -99,7 +95,6 @@ enum {UBI_DBG_ACC ,UBI_DBG_EBA ,UBI_DBG_WL , -UBI_DBG_BGT ,UBI_DBG_IO ,UBI_DBG_BLD ,UBI_DBG_SCAN
@@ -137,7 +132,6 @@ void __exit ubi_dbg_close(void);#define dbg_acc (fmt, ...) ({})#define dbg_eba (fmt, ...) ({})#define dbg_wl (fmt, ...) ({}) -#define dbg_bgt (fmt, ...) ({})#define dbg_io (fmt, ...) ({})#define dbg_bld (fmt, ...) ({})#define dbg_scan (fmt, ...) ({})
drivers/mtd/ubi/wl.c +277 -17
421 lines not on this page · raw message
drivers/mtd/ubi/debug.c +1 -22
@@ -36,7 +36,6 @@#define UBI_DBG_ACC_PREF "[UBI DBG acc]"#define UBI_DBG_EBA_PREF "[UBI DBG eba]"#define UBI_DBG_WL_PREF "[UBI DBG wl]" -#define UBI_DBG_BGT_PREF "[UBI DBG bgt]"#define UBI_DBG_IO_PREF "[UBI DBG io]"#define UBI_DBG_BLD_PREF "[UBI DBG bld]"#define UBI_DBG_SCAN_PREF "[UBI DBG scan]"
@@ -76,11 +75,6 @@ static int wl_prints = 1;#else static int wl_prints;#endif -#ifdef CONFIG_MTD_UBI_DEBUG_MSG_BGT -static int bgt_prints =1 ; -#else -static int bgt_prints; -#endif #ifdef CONFIG_MTD_UBI_DEBUG_MSG_IO static int io_prints =1 ;#else
@@ -136,8 +130,6 @@ static struct dentry *debugfs_acc_printsstatic struct dentry *debugfs_eba_prints;/* <debugfs>/ubi/wl_prints */ static struct dentry *debugfs_wl_prints; -/* <debugfs>/ubi/bgt_prints */ -static struct dentry *debugfs_bgt_prints;/* <debugfs>/ubi/io_prints */ static struct dentry *debugfs_io_prints;/* <debugfs>/ubi/bld_prints */
@@ -199,15 +191,10 @@ int __init ubi_dbg_init(void)if (!debugfs_wl_prints ||IS_ERR (debugfs_wl_prints)) goto out_eba; - debugfs_bgt_prints =debugfs_create_bool ("bgt_prints" , -S_IFREG |S_IRUGO |S_IWUGO , debugfs_root, &bgt_prints); -if (!debugfs_bgt_prints ||IS_ERR (debugfs_bgt_prints)) - goto out_wl; - debugfs_io_prints =debugfs_create_bool ("io_prints" ,S_IFREG |S_IRUGO |S_IWUGO , debugfs_root, &io_prints);if (!debugfs_io_prints ||IS_ERR (debugfs_io_prints)) - goto out_bgt; + goto out_wl; debugfs_bld_prints =debugfs_create_bool ("bld_prints" ,S_IFREG |S_IRUGO |S_IWUGO , debugfs_root, &bld_prints);
@@ -225,8 +212,6 @@ out_bld:debugfs_remove (debugfs_bld_prints); out_io:debugfs_remove (debugfs_io_prints); -out_bgt: -debugfs_remove (debugfs_bgt_prints); out_wl:debugfs_remove (debugfs_wl_prints); out_eba:
@@ -255,7 +240,6 @@ void __exit ubi_dbg_close(void)debugfs_remove (debugfs_scan_prints);debugfs_remove (debugfs_bld_prints);debugfs_remove (debugfs_io_prints); -debugfs_remove (debugfs_bgt_prints);debugfs_remove (debugfs_wl_prints);debugfs_remove (debugfs_eba_prints);debugfs_remove (debugfs_acc_prints);
@@ -333,11 +317,6 @@ static void ubi_dbg_vprint_nolock(int tyreturn ; prefix =UBI_DBG_WL_PREF ;break ; -case UBI_DBG_BGT : -if (!bgt_prints) -return ; - prefix =UBI_DBG_BGT_PREF ; -break ;case UBI_DBG_IO :if (!io_prints)return ;
drivers/mtd/ubi/eba.c +0 -1
@@ -941,7 +941,6 @@ int ubi_eba_leb_is_mapped(const struct u*/ void ubi_eba_ro_mode (struct ubi_info *ubi) { -ubi_bgt_disable (ubi); ubi->io.ro_mode =1 ;ubi_warn ("switched to read-only mode" ); }
drivers/mtd/ubi/Kconfig.debug +0 -8
@@ -123,14 +123,6 @@ config MTD_UBI_DEBUG_MSG_WL This option enables debugging messages from the UBI wear-leveling unit. -config MTD_UBI_DEBUG_MSG_BGT - bool "Background thread unit messages" - default n - depends on MTD_UBI_DEBUG - help - This option enables debugging messages from the UBI background thread - unit. - config MTD_UBI_DEBUG_MSG_IO bool "Input/output unit messages" default n
Quoted 2 lines · Alexander Schmidt
this patch moves the background unit code to the wear-leveling unit. The kthread api is now used for handling the background thread.
Thank, applies.
Signature · 2 lines
Best regards, Artem Bityutskiy (Битюцкий Артём)