jffs2: Use function instead of macro when initialize compressors

The initialized compressors should be released if one of them
initialize fail, this is the pre-patch for fix the problem, use
function instead of the macro in jffs2_compressors_init() to
simplify the codes, no functional change intended.

Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
Zhang Xiaoxu 2022-10-27 20:49:05 +08:00 committed by Richard Weinberger
parent 7198c9c003
commit d5711ae52d
2 changed files with 21 additions and 22 deletions

View File

@ -365,19 +365,12 @@ void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig)
int __init jffs2_compressors_init(void) int __init jffs2_compressors_init(void)
{ {
/* Registering compressors */ /* Registering compressors */
#ifdef CONFIG_JFFS2_ZLIB
jffs2_zlib_init(); jffs2_zlib_init();
#endif
#ifdef CONFIG_JFFS2_RTIME
jffs2_rtime_init(); jffs2_rtime_init();
#endif
#ifdef CONFIG_JFFS2_RUBIN
jffs2_rubinmips_init(); jffs2_rubinmips_init();
jffs2_dynrubin_init(); jffs2_dynrubin_init();
#endif
#ifdef CONFIG_JFFS2_LZO
jffs2_lzo_init(); jffs2_lzo_init();
#endif
/* Setting default compression mode */ /* Setting default compression mode */
#ifdef CONFIG_JFFS2_CMODE_NONE #ifdef CONFIG_JFFS2_CMODE_NONE
jffs2_compression_mode = JFFS2_COMPR_MODE_NONE; jffs2_compression_mode = JFFS2_COMPR_MODE_NONE;
@ -401,18 +394,10 @@ int __init jffs2_compressors_init(void)
int jffs2_compressors_exit(void) int jffs2_compressors_exit(void)
{ {
/* Unregistering compressors */ /* Unregistering compressors */
#ifdef CONFIG_JFFS2_LZO
jffs2_lzo_exit(); jffs2_lzo_exit();
#endif
#ifdef CONFIG_JFFS2_RUBIN
jffs2_dynrubin_exit(); jffs2_dynrubin_exit();
jffs2_rubinmips_exit(); jffs2_rubinmips_exit();
#endif
#ifdef CONFIG_JFFS2_RTIME
jffs2_rtime_exit(); jffs2_rtime_exit();
#endif
#ifdef CONFIG_JFFS2_ZLIB
jffs2_zlib_exit(); jffs2_zlib_exit();
#endif
return 0; return 0;
} }

View File

@ -88,18 +88,32 @@ int jffs2_rubinmips_init(void);
void jffs2_rubinmips_exit(void); void jffs2_rubinmips_exit(void);
int jffs2_dynrubin_init(void); int jffs2_dynrubin_init(void);
void jffs2_dynrubin_exit(void); void jffs2_dynrubin_exit(void);
#else
static inline int jffs2_rubinmips_init(void) { return 0; }
static inline void jffs2_rubinmips_exit(void) {}
static inline int jffs2_dynrubin_init(void) { return 0; }
static inline void jffs2_dynrubin_exit(void) {}
#endif #endif
#ifdef CONFIG_JFFS2_RTIME #ifdef CONFIG_JFFS2_RTIME
int jffs2_rtime_init(void); extern int jffs2_rtime_init(void);
void jffs2_rtime_exit(void); extern void jffs2_rtime_exit(void);
#else
static inline int jffs2_rtime_init(void) { return 0; }
static inline void jffs2_rtime_exit(void) {}
#endif #endif
#ifdef CONFIG_JFFS2_ZLIB #ifdef CONFIG_JFFS2_ZLIB
int jffs2_zlib_init(void); extern int jffs2_zlib_init(void);
void jffs2_zlib_exit(void); extern void jffs2_zlib_exit(void);
#else
static inline int jffs2_zlib_init(void) { return 0; }
static inline void jffs2_zlib_exit(void) {}
#endif #endif
#ifdef CONFIG_JFFS2_LZO #ifdef CONFIG_JFFS2_LZO
int jffs2_lzo_init(void); extern int jffs2_lzo_init(void);
void jffs2_lzo_exit(void); extern void jffs2_lzo_exit(void);
#else
static inline int jffs2_lzo_init(void) { return 0; }
static inline void jffs2_lzo_exit(void) {}
#endif #endif
#endif /* __JFFS2_COMPR_H__ */ #endif /* __JFFS2_COMPR_H__ */