* [PATCH v3 1/5] Revert "drivers/tty/serial: make 8250/8250_mtk.c explicitly non-modular"
2016-02-17 15:02 [PATCH v3 0/5] serial: 8250: fixes for modular build Arnd Bergmann
@ 2016-02-17 15:02 ` Arnd Bergmann
2016-02-17 17:19 ` Matthias Brugger
2016-02-17 15:02 ` [PATCH v3 2/5] Revert "drivers/tty/serial: make 8250/8250_ingenic.c " Arnd Bergmann
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2016-02-17 15:02 UTC (permalink / raw)
To: linux-arm-kernel
This reverts commit d72d391c126e ("drivers/tty/serial: make
8250/8250_mtk.c explicitly non-modular"), which intended to remove dead
code but did not have the desired effect when the main 8250 driver was
a module itself.
This would normally result in a link error, but as the entire
drivers/tty/serial/8250/ directory is only entered when CONFIG_SERIAL_8250
is set, we never notice that the driver does not get built in this
configuration.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/tty/serial/8250/8250_mtk.c | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
index 9038843cadc7..6ecc6e3e82dc 100644
--- a/drivers/tty/serial/8250/8250_mtk.c
+++ b/drivers/tty/serial/8250/8250_mtk.c
@@ -16,7 +16,7 @@
*/
#include <linux/clk.h>
#include <linux/io.h>
-#include <linux/init.h>
+#include <linux/module.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
@@ -245,6 +245,23 @@ static int mtk8250_probe(struct platform_device *pdev)
return 0;
}
+static int mtk8250_remove(struct platform_device *pdev)
+{
+ struct mtk8250_data *data = platform_get_drvdata(pdev);
+
+ pm_runtime_get_sync(&pdev->dev);
+
+ serial8250_unregister_port(data->line);
+
+ pm_runtime_disable(&pdev->dev);
+ pm_runtime_put_noidle(&pdev->dev);
+
+ if (!pm_runtime_status_suspended(&pdev->dev))
+ mtk8250_runtime_suspend(&pdev->dev);
+
+ return 0;
+}
+
static int __maybe_unused mtk8250_suspend(struct device *dev)
{
struct mtk8250_data *data = dev_get_drvdata(dev);
@@ -273,18 +290,18 @@ static const struct of_device_id mtk8250_of_match[] = {
{ .compatible = "mediatek,mt6577-uart" },
{ /* Sentinel */ }
};
+MODULE_DEVICE_TABLE(of, mtk8250_of_match);
static struct platform_driver mtk8250_platform_driver = {
.driver = {
- .name = "mt6577-uart",
- .pm = &mtk8250_pm_ops,
- .of_match_table = mtk8250_of_match,
- .suppress_bind_attrs = true,
-
+ .name = "mt6577-uart",
+ .pm = &mtk8250_pm_ops,
+ .of_match_table = mtk8250_of_match,
},
.probe = mtk8250_probe,
+ .remove = mtk8250_remove,
};
-builtin_platform_driver(mtk8250_platform_driver);
+module_platform_driver(mtk8250_platform_driver);
#ifdef CONFIG_SERIAL_8250_CONSOLE
static int __init early_mtk8250_setup(struct earlycon_device *device,
@@ -300,3 +317,7 @@ static int __init early_mtk8250_setup(struct earlycon_device *device,
OF_EARLYCON_DECLARE(mtk8250, "mediatek,mt6577-uart", early_mtk8250_setup);
#endif
+
+MODULE_AUTHOR("Matthias Brugger");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Mediatek 8250 serial port driver");
--
2.7.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 1/5] Revert "drivers/tty/serial: make 8250/8250_mtk.c explicitly non-modular"
2016-02-17 15:02 ` [PATCH v3 1/5] Revert "drivers/tty/serial: make 8250/8250_mtk.c explicitly non-modular" Arnd Bergmann
@ 2016-02-17 17:19 ` Matthias Brugger
0 siblings, 0 replies; 7+ messages in thread
From: Matthias Brugger @ 2016-02-17 17:19 UTC (permalink / raw)
To: linux-arm-kernel
On 17/02/16 16:02, Arnd Bergmann wrote:
> This reverts commit d72d391c126e ("drivers/tty/serial: make
> 8250/8250_mtk.c explicitly non-modular"), which intended to remove dead
> code but did not have the desired effect when the main 8250 driver was
> a module itself.
>
> This would normally result in a link error, but as the entire
> drivers/tty/serial/8250/ directory is only entered when CONFIG_SERIAL_8250
> is set, we never notice that the driver does not get built in this
> configuration.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
Acked-by: Matthias Brugger <matthias.bgg@gmail.com>
> drivers/tty/serial/8250/8250_mtk.c | 35 ++++++++++++++++++++++++++++-------
> 1 file changed, 28 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
> index 9038843cadc7..6ecc6e3e82dc 100644
> --- a/drivers/tty/serial/8250/8250_mtk.c
> +++ b/drivers/tty/serial/8250/8250_mtk.c
> @@ -16,7 +16,7 @@
> */
> #include <linux/clk.h>
> #include <linux/io.h>
> -#include <linux/init.h>
> +#include <linux/module.h>
> #include <linux/of_irq.h>
> #include <linux/of_platform.h>
> #include <linux/platform_device.h>
> @@ -245,6 +245,23 @@ static int mtk8250_probe(struct platform_device *pdev)
> return 0;
> }
>
> +static int mtk8250_remove(struct platform_device *pdev)
> +{
> + struct mtk8250_data *data = platform_get_drvdata(pdev);
> +
> + pm_runtime_get_sync(&pdev->dev);
> +
> + serial8250_unregister_port(data->line);
> +
> + pm_runtime_disable(&pdev->dev);
> + pm_runtime_put_noidle(&pdev->dev);
> +
> + if (!pm_runtime_status_suspended(&pdev->dev))
> + mtk8250_runtime_suspend(&pdev->dev);
> +
> + return 0;
> +}
> +
> static int __maybe_unused mtk8250_suspend(struct device *dev)
> {
> struct mtk8250_data *data = dev_get_drvdata(dev);
> @@ -273,18 +290,18 @@ static const struct of_device_id mtk8250_of_match[] = {
> { .compatible = "mediatek,mt6577-uart" },
> { /* Sentinel */ }
> };
> +MODULE_DEVICE_TABLE(of, mtk8250_of_match);
>
> static struct platform_driver mtk8250_platform_driver = {
> .driver = {
> - .name = "mt6577-uart",
> - .pm = &mtk8250_pm_ops,
> - .of_match_table = mtk8250_of_match,
> - .suppress_bind_attrs = true,
> -
> + .name = "mt6577-uart",
> + .pm = &mtk8250_pm_ops,
> + .of_match_table = mtk8250_of_match,
> },
> .probe = mtk8250_probe,
> + .remove = mtk8250_remove,
> };
> -builtin_platform_driver(mtk8250_platform_driver);
> +module_platform_driver(mtk8250_platform_driver);
>
> #ifdef CONFIG_SERIAL_8250_CONSOLE
> static int __init early_mtk8250_setup(struct earlycon_device *device,
> @@ -300,3 +317,7 @@ static int __init early_mtk8250_setup(struct earlycon_device *device,
>
> OF_EARLYCON_DECLARE(mtk8250, "mediatek,mt6577-uart", early_mtk8250_setup);
> #endif
> +
> +MODULE_AUTHOR("Matthias Brugger");
> +MODULE_LICENSE("GPL");
> +MODULE_DESCRIPTION("Mediatek 8250 serial port driver");
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3 2/5] Revert "drivers/tty/serial: make 8250/8250_ingenic.c explicitly non-modular"
2016-02-17 15:02 [PATCH v3 0/5] serial: 8250: fixes for modular build Arnd Bergmann
2016-02-17 15:02 ` [PATCH v3 1/5] Revert "drivers/tty/serial: make 8250/8250_mtk.c explicitly non-modular" Arnd Bergmann
@ 2016-02-17 15:02 ` Arnd Bergmann
2016-02-17 15:02 ` [PATCH v3 3/5] serial: 8250/uniphier: fix modular build Arnd Bergmann
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2016-02-17 15:02 UTC (permalink / raw)
To: linux-arm-kernel
This reverts commit cafe1ac64023 ("drivers/tty: make serial
8250_ingenic.c explicitly non-modular"), which attempted to remove dead
code but did not have the desired effect when the main 8250 driver was
a loadable module itself.
This would normally result in a link error, but as the entire
drivers/tty/serial/8250/ directory is only entered when CONFIG_SERIAL_8250
is set, we never notice that the driver does not get built in this
configuration.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/tty/serial/8250/8250_ingenic.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_ingenic.c b/drivers/tty/serial/8250/8250_ingenic.c
index b4e1d39805b2..97b78558caed 100644
--- a/drivers/tty/serial/8250/8250_ingenic.c
+++ b/drivers/tty/serial/8250/8250_ingenic.c
@@ -4,8 +4,6 @@
*
* Ingenic SoC UART support
*
- * Author: Paul Burton <paul.burton@imgtec.com>
- *
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
@@ -20,7 +18,7 @@
#include <linux/console.h>
#include <linux/io.h>
#include <linux/libfdt.h>
-#include <linux/init.h>
+#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
#include <linux/of_device.h>
@@ -303,6 +301,16 @@ out:
return err;
}
+static int ingenic_uart_remove(struct platform_device *pdev)
+{
+ struct ingenic_uart_data *data = platform_get_drvdata(pdev);
+
+ serial8250_unregister_port(data->line);
+ clk_disable_unprepare(data->clk_module);
+ clk_disable_unprepare(data->clk_baud);
+ return 0;
+}
+
static const struct ingenic_uart_config jz4740_uart_config = {
.tx_loadsz = 8,
.fifosize = 16,
@@ -325,13 +333,19 @@ static const struct of_device_id of_match[] = {
{ .compatible = "ingenic,jz4780-uart", .data = &jz4780_uart_config },
{ /* sentinel */ }
};
+MODULE_DEVICE_TABLE(of, of_match);
static struct platform_driver ingenic_uart_platform_driver = {
.driver = {
- .name = "ingenic-uart",
- .of_match_table = of_match,
- .suppress_bind_attrs = true,
+ .name = "ingenic-uart",
+ .of_match_table = of_match,
},
.probe = ingenic_uart_probe,
+ .remove = ingenic_uart_remove,
};
-builtin_platform_driver(ingenic_uart_platform_driver);
+
+module_platform_driver(ingenic_uart_platform_driver);
+
+MODULE_AUTHOR("Paul Burton");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Ingenic SoC UART driver");
--
2.7.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 3/5] serial: 8250/uniphier: fix modular build
2016-02-17 15:02 [PATCH v3 0/5] serial: 8250: fixes for modular build Arnd Bergmann
2016-02-17 15:02 ` [PATCH v3 1/5] Revert "drivers/tty/serial: make 8250/8250_mtk.c explicitly non-modular" Arnd Bergmann
2016-02-17 15:02 ` [PATCH v3 2/5] Revert "drivers/tty/serial: make 8250/8250_ingenic.c " Arnd Bergmann
@ 2016-02-17 15:02 ` Arnd Bergmann
2016-02-17 15:02 ` [PATCH v3 4/5] serial: 8250/ingenic: fix building with SERIAL_8250=m Arnd Bergmann
2016-02-17 15:02 ` [PATCH v3 5/5] serial: 8250/mediatek: " Arnd Bergmann
4 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2016-02-17 15:02 UTC (permalink / raw)
To: linux-arm-kernel
The newly added uniphier serial port driver fails to build as
a loadable module when the base 8250 driver is built-in and
its console support enabled:
ERROR: "early_serial8250_setup" [drivers/tty/serial/8250/8250_uniphier.ko] undefined!
This changes the driver to only provide the early console support
if it is built-in itself as well.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/tty/serial/8250/8250_uniphier.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_uniphier.c b/drivers/tty/serial/8250/8250_uniphier.c
index bab6b3ae2540..1b7bd26555b7 100644
--- a/drivers/tty/serial/8250/8250_uniphier.c
+++ b/drivers/tty/serial/8250/8250_uniphier.c
@@ -35,7 +35,7 @@ struct uniphier8250_priv {
spinlock_t atomic_write_lock;
};
-#ifdef CONFIG_SERIAL_8250_CONSOLE
+#if defined(CONFIG_SERIAL_8250_CONSOLE) && !defined(MODULE)
static int __init uniphier_early_console_setup(struct earlycon_device *device,
const char *options)
{
--
2.7.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 4/5] serial: 8250/ingenic: fix building with SERIAL_8250=m
2016-02-17 15:02 [PATCH v3 0/5] serial: 8250: fixes for modular build Arnd Bergmann
` (2 preceding siblings ...)
2016-02-17 15:02 ` [PATCH v3 3/5] serial: 8250/uniphier: fix modular build Arnd Bergmann
@ 2016-02-17 15:02 ` Arnd Bergmann
2016-02-17 15:02 ` [PATCH v3 5/5] serial: 8250/mediatek: " Arnd Bergmann
4 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2016-02-17 15:02 UTC (permalink / raw)
To: linux-arm-kernel
The Ingenic 8250 driver has a 'bool' Kconfig symbol, but that
breaks when SERIAL_8250 is a loadable module:
drivers/tty/built-in.o: In function `ingenic_uart_probe':
8250_ingenic.c:(.text+0x1c1a0): undefined reference to `serial8250_register_8250_port'
This changes the symbol to a 'tristate', plus a dependency on
SERIAL_8250, which makes it work again. Unlike the other
soc-specific backends, this one has no dependency on an
architecture or a platform. I'm adding a dependency on
MIPS || COMPILE_TEST as well here, to avoid showing the driver
on architectures that are not interested in it.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/tty/serial/8250/8250_ingenic.c | 2 +-
drivers/tty/serial/8250/Kconfig | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_ingenic.c b/drivers/tty/serial/8250/8250_ingenic.c
index 97b78558caed..b0677f610863 100644
--- a/drivers/tty/serial/8250/8250_ingenic.c
+++ b/drivers/tty/serial/8250/8250_ingenic.c
@@ -48,7 +48,7 @@ static const struct of_device_id of_match[];
#define UART_MCR_MDCE BIT(7)
#define UART_MCR_FCM BIT(6)
-#ifdef CONFIG_SERIAL_EARLYCON
+#if defined(CONFIG_SERIAL_EARLYCON) && !defined(MODULE)
static struct earlycon_device *early_device;
static uint8_t __init early_in(struct uart_port *port, int offset)
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig
index 67ad6b0d595b..1b0638511ac1 100644
--- a/drivers/tty/serial/8250/Kconfig
+++ b/drivers/tty/serial/8250/Kconfig
@@ -384,9 +384,10 @@ config SERIAL_8250_UNIPHIER
serial ports, say Y to this option. If unsure, say N.
config SERIAL_8250_INGENIC
- bool "Support for Ingenic SoC serial ports"
- depends on OF_FLATTREE
- select LIBFDT
+ tristate "Support for Ingenic SoC serial ports"
+ depends on SERIAL_8250
+ depends on (OF_FLATTREE && SERIAL_8250_CONSOLE) || !SERIAL_EARLYCON
+ depends on MIPS || COMPILE_TEST
help
If you have a system using an Ingenic SoC and wish to make use of
its UARTs, say Y to this option. If unsure, say N.
--
2.7.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v3 5/5] serial: 8250/mediatek: fix building with SERIAL_8250=m
2016-02-17 15:02 [PATCH v3 0/5] serial: 8250: fixes for modular build Arnd Bergmann
` (3 preceding siblings ...)
2016-02-17 15:02 ` [PATCH v3 4/5] serial: 8250/ingenic: fix building with SERIAL_8250=m Arnd Bergmann
@ 2016-02-17 15:02 ` Arnd Bergmann
4 siblings, 0 replies; 7+ messages in thread
From: Arnd Bergmann @ 2016-02-17 15:02 UTC (permalink / raw)
To: linux-arm-kernel
The Mediatek 8250 driver has a 'bool' Kconfig symbol, but that
breaks when SERIAL_8250 is a loadable module:
drivers/tty/built-in.o: In function `mtk8250_set_termios':
:(.text+0x1bee8): undefined reference to `serial8250_do_set_termios'
:(.text+0x1bf10): undefined reference to `uart_get_baud_rate'
:(.text+0x1c09c): undefined reference to `uart_get_divisor'
drivers/tty/built-in.o: In function `mtk8250_do_pm':
:(.text+0x1c0d0): undefined reference to `serial8250_do_pm'
drivers/tty/built-in.o: In function `mtk8250_probe':
:(.text+0x1c2e4): undefined reference to `serial8250_register_8250_port'
serial/8250/8250_mtk.c:287:242: error: data definition has no type or storage class [-Werror]
serial/8250/8250_mtk.c:287:122: error: 'mtk8250_platform_driver_init' defined but not used [-Werror=unused-function]
This changes the symbol to a 'tristate', so the dependency on
SERIAL_8250 also works when that is set to 'm'.
To actually build the driver, we also need to include <linux/module.h>.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Matthias Brugger <matthias.bgg@gmail.com>
---
drivers/tty/serial/8250/8250_mtk.c | 2 +-
drivers/tty/serial/8250/Kconfig | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
index 6ecc6e3e82dc..a0294f3de4f8 100644
--- a/drivers/tty/serial/8250/8250_mtk.c
+++ b/drivers/tty/serial/8250/8250_mtk.c
@@ -303,7 +303,7 @@ static struct platform_driver mtk8250_platform_driver = {
};
module_platform_driver(mtk8250_platform_driver);
-#ifdef CONFIG_SERIAL_8250_CONSOLE
+#if defined(CONFIG_SERIAL_8250_CONSOLE) && !defined(MODULE)
static int __init early_mtk8250_setup(struct earlycon_device *device,
const char *options)
{
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig
index 1b0638511ac1..c45a02a7f9e2 100644
--- a/drivers/tty/serial/8250/Kconfig
+++ b/drivers/tty/serial/8250/Kconfig
@@ -370,7 +370,7 @@ config SERIAL_8250_LPC18XX
serial port, say Y to this option. If unsure, say Y.
config SERIAL_8250_MT6577
- bool "Mediatek serial port support"
+ tristate "Mediatek serial port support"
depends on SERIAL_8250 && ARCH_MEDIATEK
help
If you have a Mediatek based board and want to use the
--
2.7.0
^ permalink raw reply related [flat|nested] 7+ messages in thread