On 07/06/16 15:33, Paul Gortmaker wrote: > [[PATCH] serial: mps2-uart: make driver explicitly non-modular] On 07/06/2016 (Tue 14:47) Vladimir Murzin wrote: > >> mps2-uart is currently selected by the arch code, which implies is not >> being built as a module by anyone. > > Maybe "depends on" is more accurate, since we have: > > > config SERIAL_MPS2_UART > bool "MPS2 UART port" > depends on ARM || COMPILE_TEST > > ...so even if people are not using ARM, they can still build it if they > have selected COMPILE_TEST. > >> >> Follow 89ebc27 "drivers/tty: make serial/mvebu-uart.c explicitly >> non-modular" as an example of moving modular code to non-modular. > > It is good to reference other commits, but the commit message should > give enough detail to have the full meaning stand-alone even if someone > doesn't have reference to cited ones. > Ok. Just wanted to avoid copy-and-paste, since there is nothing new except s/module_init/arch_initcall :) > Also it is good to give at least 12/40 chars of the existing commit ID > since the kernel has so many commits now that any less than 12 has a > risk of being ambiguous. There is ./scripts/checkpatch.pl that some > people find useful for detecting common oversights. Hmm... it is what I got from checkpatch total: 0 errors, 0 warnings, 61 lines checked Anyway, thanks for feedback - I'll update and send v2 shortly. Cheers Vladimir > >> >> Reported-by: Paul Gortmaker <paul.gortmaker@xxxxxxxxxxxxx> >> Signed-off-by: Vladimir Murzin <vladimir.murzin@xxxxxxx> >> --- >> drivers/tty/serial/mps2-uart.c | 29 ++++------------------------- >> 1 file changed, 4 insertions(+), 25 deletions(-) >> >> diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c >> index da9e27d..492ec4b 100644 >> --- a/drivers/tty/serial/mps2-uart.c >> +++ b/drivers/tty/serial/mps2-uart.c >> @@ -1,4 +1,6 @@ >> /* >> + * MPS2 UART driver >> + * >> * Copyright (C) 2015 ARM Limited >> * >> * Author: Vladimir Murzin <vladimir.murzin@xxxxxxx> >> @@ -17,7 +19,6 @@ >> #include <linux/console.h> >> #include <linux/io.h> >> #include <linux/kernel.h> >> -#include <linux/module.h> > > You should replace this with init.h since your driver uses "__init" and > the file does not have that include already. We shouldn't rely on any > implicit include paths, even if they just happen to work. > >> #include <linux/of_device.h> >> #include <linux/of.h> >> #include <linux/platform_device.h> >> @@ -569,30 +570,20 @@ static int mps2_serial_probe(struct platform_device *pdev) >> return 0; >> } >> >> -static int mps2_serial_remove(struct platform_device *pdev) >> -{ >> - struct mps2_uart_port *mps_port = platform_get_drvdata(pdev); >> - >> - uart_remove_one_port(&mps2_uart_driver, &mps_port->port); >> - >> - return 0; >> -} >> - >> #ifdef CONFIG_OF >> static const struct of_device_id mps2_match[] = { >> { .compatible = "arm,mps2-uart", }, >> {}, >> }; >> -MODULE_DEVICE_TABLE(of, mps2_match); >> #endif >> >> static struct platform_driver mps2_serial_driver = { >> .probe = mps2_serial_probe, >> - .remove = mps2_serial_remove, >> >> .driver = { >> .name = DRIVER_NAME, >> .of_match_table = of_match_ptr(mps2_match), >> + .suppress_bind_attrs = true, >> }, >> }; >> >> @@ -610,16 +601,4 @@ static int __init mps2_uart_init(void) >> >> return ret; >> } >> -module_init(mps2_uart_init); >> - >> -static void __exit mps2_uart_exit(void) >> -{ >> - platform_driver_unregister(&mps2_serial_driver); >> - uart_unregister_driver(&mps2_uart_driver); >> -} >> -module_exit(mps2_uart_exit); >> - >> -MODULE_AUTHOR("Vladimir Murzin <vladimir.murzin@xxxxxxx>"); >> -MODULE_DESCRIPTION("MPS2 UART driver"); >> -MODULE_LICENSE("GPL v2"); >> -MODULE_ALIAS("platform:" DRIVER_NAME); >> +arch_initcall(mps2_uart_init); > > The "module_init" maps onto "device_initcall" and since this is a device > driver, that seems like the appropriate mapping. By moving it to > arch_initcall, you've changed it to be earlier and that may not be good. > > The arch_initcall is more meant for things like poking registers to > enable some arch/platform specific MMIO bus mapping of devices or > similar. If you look at include/linux/init.h and the ordering of the > calls there, it will probably make more sense to you then to leave it as > device_initcall. > > > #define pure_initcall(fn) __define_initcall(fn, 0) > #define core_initcall(fn) __define_initcall(fn, 1) > #define postcore_initcall(fn) __define_initcall(fn, 2) > #define arch_initcall(fn) __define_initcall(fn, 3) <--- > #define subsys_initcall(fn) __define_initcall(fn, 4) > #define fs_initcall(fn) __define_initcall(fn, 5) > #define device_initcall(fn) __define_initcall(fn, 6) <--- > #define late_initcall(fn) __define_initcall(fn, 7) > > > Thanks. > Paul. > -- > >> -- >> 1.7.9.5 >> > -- To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html