diff options
| -rw-r--r-- | drivers/usb/gadget/function/f_fs.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index b6f4790ffc08..bb02b3be17f7 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -46,7 +46,8 @@ static void *ffs_ipc_log; #define ffs_log(fmt, ...) do { \ - ipc_log_string(ffs_ipc_log, "%s: " fmt, __func__, \ + if (ffs_ipc_log) \ + ipc_log_string(ffs_ipc_log, "%s: " fmt, __func__, \ ##__VA_ARGS__); \ pr_debug(fmt, ##__VA_ARGS__); \ } while (0) @@ -1610,10 +1611,6 @@ static int functionfs_init(void) else pr_err("failed registering file system (%d)\n", ret); - ffs_ipc_log = ipc_log_context_create(NUM_PAGES, "f_fs", 0); - if (IS_ERR_OR_NULL(ffs_ipc_log)) - ffs_ipc_log = NULL; - return ret; } @@ -1623,14 +1620,8 @@ static void functionfs_cleanup(void) pr_info("unloading\n"); unregister_filesystem(&ffs_fs_type); - - if (ffs_ipc_log) { - ipc_log_context_destroy(ffs_ipc_log); - ffs_ipc_log = NULL; - } } - /* ffs_data and ffs_function construction and destruction code **************/ static void ffs_data_clear(struct ffs_data *ffs); @@ -4063,5 +4054,28 @@ static char *ffs_prepare_buffer(const char __user *buf, size_t len) } DECLARE_USB_FUNCTION_INIT(ffs, ffs_alloc_inst, ffs_alloc); + +static int ffs_init(void) +{ + ffs_ipc_log = ipc_log_context_create(NUM_PAGES, "f_fs", 0); + if (IS_ERR_OR_NULL(ffs_ipc_log)) { + ffs_ipc_log = NULL; + pr_err("%s: Create IPC log context failure\n", + __func__); + } + + return 0; +} +module_init(ffs_init); + +static void __exit ffs_exit(void) +{ + if (ffs_ipc_log) { + ipc_log_context_destroy(ffs_ipc_log); + ffs_ipc_log = NULL; + } +} +module_exit(ffs_exit); + MODULE_LICENSE("GPL"); MODULE_AUTHOR("Michal Nazarewicz"); |
