[PATCH] Staging: Android: logger: module_exit implementation
This patch creates the module_exit for the android logger so that it can be loaded and unloaded as a module. The android logger is already declared as a tristate in the Kconfig but the module_exit function was missing. device_initcall works also with modprobe since include/linux/init.h: #define module_init(x) __initcall(x); ... #define __initcall(fn) device_initcall(fn) Tested against f4a75d2eb7b1e2206094b901be09adb31ba63681 Linux 3.7-rc6 Signed-off-by: Luca Clementi --- drivers/staging/android/logger.c | 21 + 1 file changed, 21 insertions(+) diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c index 1d5ed47..dbc63cb 100644 --- a/drivers/staging/android/logger.c +++ b/drivers/staging/android/logger.c @@ -676,4 +676,25 @@ static int __init logger_init(void) out: return ret; } + +static void __exit logger_exit(void) +{ + struct logger_log *current_log, *next_log; + + list_for_each_entry_safe(current_log, next_log, _list, logs) { + /* we have to delete all the entry inside log_list */ + misc_deregister(_log->misc); + vfree(current_log->buffer); + kfree(current_log->misc.name); + list_del(_log->logs); + kfree(current_log); + } +} + + device_initcall(logger_init); +module_exit(logger_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Robert Love, "); +MODULE_DESCRIPTION("Android Logger"); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Staging: Android: logger: module_exit implementation
This patch creates the module_exit for the android logger so that it can be loaded and unloaded as a module. The android logger is already declared as a tristate in the Kconfig but the module_exit function was missing. device_initcall works also with modprobe since include/linux/init.h: #define module_init(x) __initcall(x); ... #define __initcall(fn) device_initcall(fn) Tested against f4a75d2eb7b1e2206094b901be09adb31ba63681 Linux 3.7-rc6 Signed-off-by: Luca Clementi luca.cleme...@gmail.com --- drivers/staging/android/logger.c | 21 + 1 file changed, 21 insertions(+) diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c index 1d5ed47..dbc63cb 100644 --- a/drivers/staging/android/logger.c +++ b/drivers/staging/android/logger.c @@ -676,4 +676,25 @@ static int __init logger_init(void) out: return ret; } + +static void __exit logger_exit(void) +{ + struct logger_log *current_log, *next_log; + + list_for_each_entry_safe(current_log, next_log, log_list, logs) { + /* we have to delete all the entry inside log_list */ + misc_deregister(current_log-misc); + vfree(current_log-buffer); + kfree(current_log-misc.name); + list_del(current_log-logs); + kfree(current_log); + } +} + + device_initcall(logger_init); +module_exit(logger_exit); + +MODULE_LICENSE(GPL); +MODULE_AUTHOR(Robert Love, rl...@google.com); +MODULE_DESCRIPTION(Android Logger); -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] Staging: Android: logger: module_exit implementation
On 02/11/12 17:15, Luca Clementi wrote: > Created the module_exit for the android logger so that > it can be loaded and unloaded as a module. Fixed > module_init and some other minor issues. > > Signed-off-by: Luca Clementi > Cc: Greg Kroah-Hartman > Cc: Brian Swetland > --- > drivers/staging/android/logger.c | 30 +- > 1 file changed, 29 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/android/logger.c > b/drivers/staging/android/logger.c > index 1d5ed47..050be01 100644 > --- a/drivers/staging/android/logger.c > +++ b/drivers/staging/android/logger.c > @@ -676,4 +676,32 @@ static int __init logger_init(void) > out: > return ret; > } > -device_initcall(logger_init); > + > +static void __exit logger_exit(void) > +{ > + struct logger_log *current_log, *next_log; > + > + list_for_each_entry_safe(current_log, next_log, _list, logs) { > + /* we have to delete all the entry inside log_list */ > + ret = misc_deregister(_log->misc); ret is undeclared? Has this been tested? > + if (unlikely(ret)) { > + pr_err("failed to deregister misc device for log > '%s'!\n", > + current_log->misc.name); > + } Don't need braces on single line if statements, and unlikely is not needed here (it isn't a hotpath). The whole error can probably just be removed since it looks like misc_deregister already does a WARN_ON if it fails. > + pr_info("removed loggger '%s'\n", current_log->misc.name); Don't spam the log with stuff like this. Either change to pr_debug, or probably just remove it. > + vfree(current_log->buffer); > + kfree(current_log->misc.name); > + kfree(current_log); Missing: list_del(_log->logs); ? > + } > + > + return; This is pointless. > +} > + > + > +module_init(logger_init); > +module_exit(logger_exit); Nitpick - Blank line here. > +MODULE_LICENSE("GPL"); > +MODULE_AUTHOR("Brian Swetland, "); Should be Robert Love according to the header comment. > +MODULE_DESCRIPTION("Android Logger"); > + > + Don't need extra blank lines at the end of the file. ~Ryan -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] Staging: Android: logger: module_exit implementation
On 02/11/12 17:15, Luca Clementi wrote: Created the module_exit for the android logger so that it can be loaded and unloaded as a module. Fixed module_init and some other minor issues. Signed-off-by: Luca Clementi luca.cleme...@gmail.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Cc: Brian Swetland swetl...@google.com --- drivers/staging/android/logger.c | 30 +- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c index 1d5ed47..050be01 100644 --- a/drivers/staging/android/logger.c +++ b/drivers/staging/android/logger.c @@ -676,4 +676,32 @@ static int __init logger_init(void) out: return ret; } -device_initcall(logger_init); + +static void __exit logger_exit(void) +{ + struct logger_log *current_log, *next_log; + + list_for_each_entry_safe(current_log, next_log, log_list, logs) { + /* we have to delete all the entry inside log_list */ + ret = misc_deregister(current_log-misc); ret is undeclared? Has this been tested? + if (unlikely(ret)) { + pr_err(failed to deregister misc device for log '%s'!\n, + current_log-misc.name); + } Don't need braces on single line if statements, and unlikely is not needed here (it isn't a hotpath). The whole error can probably just be removed since it looks like misc_deregister already does a WARN_ON if it fails. + pr_info(removed loggger '%s'\n, current_log-misc.name); Don't spam the log with stuff like this. Either change to pr_debug, or probably just remove it. + vfree(current_log-buffer); + kfree(current_log-misc.name); + kfree(current_log); Missing: list_del(current_log-logs); ? + } + + return; This is pointless. +} + + +module_init(logger_init); +module_exit(logger_exit); Nitpick - Blank line here. +MODULE_LICENSE(GPL); +MODULE_AUTHOR(Brian Swetland, swetl...@google.com); Should be Robert Love according to the header comment. +MODULE_DESCRIPTION(Android Logger); + + Don't need extra blank lines at the end of the file. ~Ryan -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Staging: Android: logger: module_exit implementation
Created the module_exit for the android logger so that it can be loaded and unloaded as a module. Fixed module_init and some other minor issues. Signed-off-by: Luca Clementi Cc: Greg Kroah-Hartman Cc: Brian Swetland --- drivers/staging/android/logger.c | 30 +- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c index 1d5ed47..050be01 100644 --- a/drivers/staging/android/logger.c +++ b/drivers/staging/android/logger.c @@ -676,4 +676,32 @@ static int __init logger_init(void) out: return ret; } -device_initcall(logger_init); + +static void __exit logger_exit(void) +{ + struct logger_log *current_log, *next_log; + + list_for_each_entry_safe(current_log, next_log, _list, logs) { + /* we have to delete all the entry inside log_list */ + ret = misc_deregister(_log->misc); + if (unlikely(ret)) { + pr_err("failed to deregister misc device for log '%s'!\n", + current_log->misc.name); + } + pr_info("removed loggger '%s'\n", current_log->misc.name); + vfree(current_log->buffer); + kfree(current_log->misc.name); + kfree(current_log); + } + + return; +} + + +module_init(logger_init); +module_exit(logger_exit); +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Brian Swetland, "); +MODULE_DESCRIPTION("Android Logger"); + + -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Staging: Android: logger: module_exit implementation
Created the module_exit for the android logger so that it can be loaded and unloaded as a module. Fixed module_init and some other minor issues. Signed-off-by: Luca Clementi luca.cleme...@gmail.com Cc: Greg Kroah-Hartman gre...@linuxfoundation.org Cc: Brian Swetland swetl...@google.com --- drivers/staging/android/logger.c | 30 +- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/staging/android/logger.c b/drivers/staging/android/logger.c index 1d5ed47..050be01 100644 --- a/drivers/staging/android/logger.c +++ b/drivers/staging/android/logger.c @@ -676,4 +676,32 @@ static int __init logger_init(void) out: return ret; } -device_initcall(logger_init); + +static void __exit logger_exit(void) +{ + struct logger_log *current_log, *next_log; + + list_for_each_entry_safe(current_log, next_log, log_list, logs) { + /* we have to delete all the entry inside log_list */ + ret = misc_deregister(current_log-misc); + if (unlikely(ret)) { + pr_err(failed to deregister misc device for log '%s'!\n, + current_log-misc.name); + } + pr_info(removed loggger '%s'\n, current_log-misc.name); + vfree(current_log-buffer); + kfree(current_log-misc.name); + kfree(current_log); + } + + return; +} + + +module_init(logger_init); +module_exit(logger_exit); +MODULE_LICENSE(GPL); +MODULE_AUTHOR(Brian Swetland, swetl...@google.com); +MODULE_DESCRIPTION(Android Logger); + + -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/