All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/6] Raspberry Pi auxiliary UART fixes & cleanups
@ 2020-01-16 12:14 Lukas Wunner
  2020-01-16 12:14 ` [PATCH 1/6] serial: 8250_bcm2835aux: Fix line mismatch on driver unbind Lukas Wunner
                   ` (6 more replies)
  0 siblings, 7 replies; 12+ messages in thread
From: Lukas Wunner @ 2020-01-16 12:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Nicolas Saenz Julienne, linux-serial,
	linux-rpi-kernel, Martin Sperl, Phil Elwell

Here's a collection of fixes & cleanups for the Raspberry Pi auxiliary UART
to prepare for upcoming feature work on the driver.

With compliments from Revolution Pi labs (https://revolution.kunbus.com/).

Lukas Wunner (5):
  serial: 8250_bcm2835aux: Fix line mismatch on driver unbind
  serial: 8250_bcm2835aux: Suppress register_port error on -EPROBE_DEFER
  serial: 8250_bcm2835aux: Allocate uart_8250_port on stack
  serial: 8250_bcm2835aux: Use generic remapping code
  serial: 8250_bcm2835aux: Document struct bcm2835aux_data

Phil Elwell (1):
  serial: 8250_bcm2835aux: Suppress clk_get error on -EPROBE_DEFER

 drivers/tty/serial/8250/8250_bcm2835aux.c | 50 ++++++++++++-----------
 1 file changed, 26 insertions(+), 24 deletions(-)

-- 
2.24.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/6] serial: 8250_bcm2835aux: Fix line mismatch on driver unbind
  2020-01-16 12:14 [PATCH 0/6] Raspberry Pi auxiliary UART fixes & cleanups Lukas Wunner
@ 2020-01-16 12:14 ` Lukas Wunner
  2020-01-16 12:14 ` [PATCH 2/6] serial: 8250_bcm2835aux: Suppress clk_get error on -EPROBE_DEFER Lukas Wunner
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 12+ messages in thread
From: Lukas Wunner @ 2020-01-16 12:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Nicolas Saenz Julienne, linux-serial,
	linux-rpi-kernel, Martin Sperl

Unbinding the bcm2835aux UART driver raises the following error if the
maximum number of 8250 UARTs is set to 1 (via the 8250.nr_uarts module
parameter or CONFIG_SERIAL_8250_RUNTIME_UARTS):

(NULL device *): Removing wrong port: a6f80333 != fa20408b

That's because bcm2835aux_serial_probe() retrieves UART line number 1
from the devicetree and stores it in data->uart.port.line, while
serial8250_register_8250_port() instead uses UART line number 0,
which is stored in data->line.

On driver unbind, bcm2835aux_serial_remove() uses data->uart.port.line,
which contains the wrong number.  Fix it.

The issue does not occur if the maximum number of 8250 UARTs is >= 2.

Fixes: bdc5f3009580 ("serial: bcm2835: add driver for bcm2835-aux-uart")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: stable@vger.kernel.org # v4.6+
Cc: Martin Sperl <kernel@martin.sperl.org>
---
 drivers/tty/serial/8250/8250_bcm2835aux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
index 8ce700c1a7fc..4997c519ebb3 100644
--- a/drivers/tty/serial/8250/8250_bcm2835aux.c
+++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
@@ -113,7 +113,7 @@ static int bcm2835aux_serial_remove(struct platform_device *pdev)
 {
 	struct bcm2835aux_data *data = platform_get_drvdata(pdev);
 
-	serial8250_unregister_port(data->uart.port.line);
+	serial8250_unregister_port(data->line);
 	clk_disable_unprepare(data->clk);
 
 	return 0;
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/6] serial: 8250_bcm2835aux: Suppress clk_get error on -EPROBE_DEFER
  2020-01-16 12:14 [PATCH 0/6] Raspberry Pi auxiliary UART fixes & cleanups Lukas Wunner
  2020-01-16 12:14 ` [PATCH 1/6] serial: 8250_bcm2835aux: Fix line mismatch on driver unbind Lukas Wunner
@ 2020-01-16 12:14 ` Lukas Wunner
  2020-01-16 12:58   ` Matthias Brugger
  2020-01-16 12:14 ` [PATCH 3/6] serial: 8250_bcm2835aux: Suppress register_port " Lukas Wunner
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Lukas Wunner @ 2020-01-16 12:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Nicolas Saenz Julienne, linux-serial,
	linux-rpi-kernel, Martin Sperl, Phil Elwell

From: Phil Elwell <phil@raspberrypi.org>

Suppress a gratuitous error message if devm_clk_get() returns
-EPROBE_DEFER.

Signed-off-by: Phil Elwell <phil@raspberrypi.org>
[lukas: extend commit message]
Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
 drivers/tty/serial/8250/8250_bcm2835aux.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
index 4997c519ebb3..33da68341c3a 100644
--- a/drivers/tty/serial/8250/8250_bcm2835aux.c
+++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
@@ -50,7 +50,8 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
 	data->clk = devm_clk_get(&pdev->dev, NULL);
 	ret = PTR_ERR_OR_ZERO(data->clk);
 	if (ret) {
-		dev_err(&pdev->dev, "could not get clk: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(&pdev->dev, "could not get clk: %d\n", ret);
 		return ret;
 	}
 
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/6] serial: 8250_bcm2835aux: Suppress register_port error on -EPROBE_DEFER
  2020-01-16 12:14 [PATCH 0/6] Raspberry Pi auxiliary UART fixes & cleanups Lukas Wunner
  2020-01-16 12:14 ` [PATCH 1/6] serial: 8250_bcm2835aux: Fix line mismatch on driver unbind Lukas Wunner
  2020-01-16 12:14 ` [PATCH 2/6] serial: 8250_bcm2835aux: Suppress clk_get error on -EPROBE_DEFER Lukas Wunner
@ 2020-01-16 12:14 ` Lukas Wunner
  2020-01-16 12:58   ` Matthias Brugger
  2020-01-16 12:14 ` [PATCH 4/6] serial: 8250_bcm2835aux: Allocate uart_8250_port on stack Lukas Wunner
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Lukas Wunner @ 2020-01-16 12:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Nicolas Saenz Julienne, linux-serial,
	linux-rpi-kernel, Martin Sperl

Suppress a gratuitous error message if serial8250_register_8250_port()
returns -EPROBE_DEFER.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
 drivers/tty/serial/8250/8250_bcm2835aux.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
index 33da68341c3a..fb850d0ad643 100644
--- a/drivers/tty/serial/8250/8250_bcm2835aux.c
+++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
@@ -95,8 +95,9 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
 	/* register the port */
 	ret = serial8250_register_8250_port(&data->uart);
 	if (ret < 0) {
-		dev_err(&pdev->dev, "unable to register 8250 port - %d\n",
-			ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(&pdev->dev,
+				"unable to register 8250 port - %d\n", ret);
 		goto dis_clk;
 	}
 	data->line = ret;
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/6] serial: 8250_bcm2835aux: Allocate uart_8250_port on stack
  2020-01-16 12:14 [PATCH 0/6] Raspberry Pi auxiliary UART fixes & cleanups Lukas Wunner
                   ` (2 preceding siblings ...)
  2020-01-16 12:14 ` [PATCH 3/6] serial: 8250_bcm2835aux: Suppress register_port " Lukas Wunner
@ 2020-01-16 12:14 ` Lukas Wunner
  2020-01-16 13:06   ` Matthias Brugger
  2020-01-16 12:14 ` [PATCH 5/6] serial: 8250_bcm2835aux: Use generic remapping code Lukas Wunner
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 12+ messages in thread
From: Lukas Wunner @ 2020-01-16 12:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Nicolas Saenz Julienne, linux-serial,
	linux-rpi-kernel, Martin Sperl

The bcm2835aux UART driver stores a struct uart_8250_port in its private
data even though it's only passed once to serial8250_register_8250_port()
(which copies all relevant data) and becomes obsolete afterwards.
Allocate the struct on the stack instead for simplicity and to conserve
memory.

The driver also initializes a spinlock in the struct which is never used.
Drop that as well.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: Martin Sperl <kernel@martin.sperl.org>
---
 drivers/tty/serial/8250/8250_bcm2835aux.c | 33 +++++++++++------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
index fb850d0ad643..f03d38e7c3a7 100644
--- a/drivers/tty/serial/8250/8250_bcm2835aux.c
+++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
@@ -17,13 +17,13 @@
 #include "8250.h"
 
 struct bcm2835aux_data {
-	struct uart_8250_port uart;
 	struct clk *clk;
 	int line;
 };
 
 static int bcm2835aux_serial_probe(struct platform_device *pdev)
 {
+	struct uart_8250_port up = { };
 	struct bcm2835aux_data *data;
 	struct resource *res;
 	int ret;
@@ -34,17 +34,14 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	/* initialize data */
-	spin_lock_init(&data->uart.port.lock);
-	data->uart.capabilities = UART_CAP_FIFO | UART_CAP_MINI;
-	data->uart.port.dev = &pdev->dev;
-	data->uart.port.regshift = 2;
-	data->uart.port.type = PORT_16550;
-	data->uart.port.iotype = UPIO_MEM;
-	data->uart.port.fifosize = 8;
-	data->uart.port.flags = UPF_SHARE_IRQ |
-				UPF_FIXED_PORT |
-				UPF_FIXED_TYPE |
-				UPF_SKIP_TEST;
+	up.capabilities = UART_CAP_FIFO | UART_CAP_MINI;
+	up.port.dev = &pdev->dev;
+	up.port.regshift = 2;
+	up.port.type = PORT_16550;
+	up.port.iotype = UPIO_MEM;
+	up.port.fifosize = 8;
+	up.port.flags = UPF_SHARE_IRQ | UPF_FIXED_PORT | UPF_FIXED_TYPE |
+			UPF_SKIP_TEST;
 
 	/* get the clock - this also enables the HW */
 	data->clk = devm_clk_get(&pdev->dev, NULL);
@@ -59,7 +56,7 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
 	ret = platform_get_irq(pdev, 0);
 	if (ret < 0)
 		return ret;
-	data->uart.port.irq = ret;
+	up.port.irq = ret;
 
 	/* map the main registers */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -67,15 +64,15 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "memory resource not found");
 		return -EINVAL;
 	}
-	data->uart.port.membase = devm_ioremap_resource(&pdev->dev, res);
-	ret = PTR_ERR_OR_ZERO(data->uart.port.membase);
+	up.port.membase = devm_ioremap_resource(&pdev->dev, res);
+	ret = PTR_ERR_OR_ZERO(up.port.membase);
 	if (ret)
 		return ret;
 
 	/* Check for a fixed line number */
 	ret = of_alias_get_id(pdev->dev.of_node, "serial");
 	if (ret >= 0)
-		data->uart.port.line = ret;
+		up.port.line = ret;
 
 	/* enable the clock as a last step */
 	ret = clk_prepare_enable(data->clk);
@@ -90,10 +87,10 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
 	 * so we have to multiply the actual clock by 2
 	 * to get identical baudrates.
 	 */
-	data->uart.port.uartclk = clk_get_rate(data->clk) * 2;
+	up.port.uartclk = clk_get_rate(data->clk) * 2;
 
 	/* register the port */
-	ret = serial8250_register_8250_port(&data->uart);
+	ret = serial8250_register_8250_port(&up);
 	if (ret < 0) {
 		if (ret != -EPROBE_DEFER)
 			dev_err(&pdev->dev,
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/6] serial: 8250_bcm2835aux: Use generic remapping code
  2020-01-16 12:14 [PATCH 0/6] Raspberry Pi auxiliary UART fixes & cleanups Lukas Wunner
                   ` (3 preceding siblings ...)
  2020-01-16 12:14 ` [PATCH 4/6] serial: 8250_bcm2835aux: Allocate uart_8250_port on stack Lukas Wunner
@ 2020-01-16 12:14 ` Lukas Wunner
  2020-01-16 12:14 ` [PATCH 6/6] serial: 8250_bcm2835aux: Document struct bcm2835aux_data Lukas Wunner
  2020-01-16 16:11 ` [PATCH 0/6] Raspberry Pi auxiliary UART fixes & cleanups Nicolas Saenz Julienne
  6 siblings, 0 replies; 12+ messages in thread
From: Lukas Wunner @ 2020-01-16 12:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Nicolas Saenz Julienne, linux-serial,
	linux-rpi-kernel, Martin Sperl

On probe the bcm2835aux UART driver misreports the register base address
as 0x0:

ttyS0 at MMIO 0x0 (irq = 53, base_baud = 50000000) is a 16550

That's because the driver remaps the registers itself.  Take advantage
of the generic remapping code in serial8250_request_std_resource() to
get a message with the correct address and to simplify the driver.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: Martin Sperl <kernel@martin.sperl.org>
---
 drivers/tty/serial/8250/8250_bcm2835aux.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
index f03d38e7c3a7..d21460c9ef4b 100644
--- a/drivers/tty/serial/8250/8250_bcm2835aux.c
+++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
@@ -41,7 +41,7 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
 	up.port.iotype = UPIO_MEM;
 	up.port.fifosize = 8;
 	up.port.flags = UPF_SHARE_IRQ | UPF_FIXED_PORT | UPF_FIXED_TYPE |
-			UPF_SKIP_TEST;
+			UPF_SKIP_TEST | UPF_IOREMAP;
 
 	/* get the clock - this also enables the HW */
 	data->clk = devm_clk_get(&pdev->dev, NULL);
@@ -64,10 +64,8 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "memory resource not found");
 		return -EINVAL;
 	}
-	up.port.membase = devm_ioremap_resource(&pdev->dev, res);
-	ret = PTR_ERR_OR_ZERO(up.port.membase);
-	if (ret)
-		return ret;
+	up.port.mapbase = res->start;
+	up.port.mapsize = resource_size(res);
 
 	/* Check for a fixed line number */
 	ret = of_alias_get_id(pdev->dev.of_node, "serial");
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 6/6] serial: 8250_bcm2835aux: Document struct bcm2835aux_data
  2020-01-16 12:14 [PATCH 0/6] Raspberry Pi auxiliary UART fixes & cleanups Lukas Wunner
                   ` (4 preceding siblings ...)
  2020-01-16 12:14 ` [PATCH 5/6] serial: 8250_bcm2835aux: Use generic remapping code Lukas Wunner
@ 2020-01-16 12:14 ` Lukas Wunner
  2020-01-16 13:02   ` Matthias Brugger
  2020-01-16 16:11 ` [PATCH 0/6] Raspberry Pi auxiliary UART fixes & cleanups Nicolas Saenz Julienne
  6 siblings, 1 reply; 12+ messages in thread
From: Lukas Wunner @ 2020-01-16 12:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Jiri Slaby, Nicolas Saenz Julienne, linux-serial,
	linux-rpi-kernel, Martin Sperl

Document the driver private data of the BCM2835 auxiliary UART so that
upcoming commits may add further members with proper kerneldoc.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
 drivers/tty/serial/8250/8250_bcm2835aux.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
index d21460c9ef4b..e70e3cc30050 100644
--- a/drivers/tty/serial/8250/8250_bcm2835aux.c
+++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
@@ -16,6 +16,11 @@
 
 #include "8250.h"
 
+/**
+ * struct bcm2835aux_data - driver private data of BCM2835 auxiliary UART
+ * @clk: clock producer of the port's uartclk
+ * @line: index of the port's serial8250_ports[] entry
+ */
 struct bcm2835aux_data {
 	struct clk *clk;
 	int line;
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/6] serial: 8250_bcm2835aux: Suppress clk_get error on -EPROBE_DEFER
  2020-01-16 12:14 ` [PATCH 2/6] serial: 8250_bcm2835aux: Suppress clk_get error on -EPROBE_DEFER Lukas Wunner
@ 2020-01-16 12:58   ` Matthias Brugger
  0 siblings, 0 replies; 12+ messages in thread
From: Matthias Brugger @ 2020-01-16 12:58 UTC (permalink / raw)
  To: Lukas Wunner, Greg Kroah-Hartman
  Cc: linux-rpi-kernel, linux-serial, Jiri Slaby



On 16/01/2020 13:14, Lukas Wunner wrote:
> From: Phil Elwell <phil@raspberrypi.org>
> 
> Suppress a gratuitous error message if devm_clk_get() returns
> -EPROBE_DEFER.
> 
> Signed-off-by: Phil Elwell <phil@raspberrypi.org>
> [lukas: extend commit message]
> Signed-off-by: Lukas Wunner <lukas@wunner.de>

Reviewed-by: Matthias Brugger <mbrugger@suse.com>

> ---
>  drivers/tty/serial/8250/8250_bcm2835aux.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
> index 4997c519ebb3..33da68341c3a 100644
> --- a/drivers/tty/serial/8250/8250_bcm2835aux.c
> +++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
> @@ -50,7 +50,8 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
>  	data->clk = devm_clk_get(&pdev->dev, NULL);
>  	ret = PTR_ERR_OR_ZERO(data->clk);
>  	if (ret) {
> -		dev_err(&pdev->dev, "could not get clk: %d\n", ret);
> +		if (ret != -EPROBE_DEFER)
> +			dev_err(&pdev->dev, "could not get clk: %d\n", ret);
>  		return ret;
>  	}
>  
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 3/6] serial: 8250_bcm2835aux: Suppress register_port error on -EPROBE_DEFER
  2020-01-16 12:14 ` [PATCH 3/6] serial: 8250_bcm2835aux: Suppress register_port " Lukas Wunner
@ 2020-01-16 12:58   ` Matthias Brugger
  0 siblings, 0 replies; 12+ messages in thread
From: Matthias Brugger @ 2020-01-16 12:58 UTC (permalink / raw)
  To: Lukas Wunner, Greg Kroah-Hartman
  Cc: linux-rpi-kernel, linux-serial, Jiri Slaby



On 16/01/2020 13:14, Lukas Wunner wrote:
> Suppress a gratuitous error message if serial8250_register_8250_port()
> returns -EPROBE_DEFER.
> 
> Signed-off-by: Lukas Wunner <lukas@wunner.de>

Reviewed-by: Matthias Brugger <mbrugger@suse.com>

> ---
>  drivers/tty/serial/8250/8250_bcm2835aux.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
> index 33da68341c3a..fb850d0ad643 100644
> --- a/drivers/tty/serial/8250/8250_bcm2835aux.c
> +++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
> @@ -95,8 +95,9 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
>  	/* register the port */
>  	ret = serial8250_register_8250_port(&data->uart);
>  	if (ret < 0) {
> -		dev_err(&pdev->dev, "unable to register 8250 port - %d\n",
> -			ret);
> +		if (ret != -EPROBE_DEFER)
> +			dev_err(&pdev->dev,
> +				"unable to register 8250 port - %d\n", ret);
>  		goto dis_clk;
>  	}
>  	data->line = ret;
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 6/6] serial: 8250_bcm2835aux: Document struct bcm2835aux_data
  2020-01-16 12:14 ` [PATCH 6/6] serial: 8250_bcm2835aux: Document struct bcm2835aux_data Lukas Wunner
@ 2020-01-16 13:02   ` Matthias Brugger
  0 siblings, 0 replies; 12+ messages in thread
From: Matthias Brugger @ 2020-01-16 13:02 UTC (permalink / raw)
  To: Lukas Wunner, Greg Kroah-Hartman
  Cc: linux-rpi-kernel, linux-serial, Jiri Slaby



On 16/01/2020 13:14, Lukas Wunner wrote:
> Document the driver private data of the BCM2835 auxiliary UART so that
> upcoming commits may add further members with proper kerneldoc.
> 
> Signed-off-by: Lukas Wunner <lukas@wunner.de>

Reviewed-by: Matthias Brugger <mbrugger@suse.com>

> ---
>  drivers/tty/serial/8250/8250_bcm2835aux.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
> index d21460c9ef4b..e70e3cc30050 100644
> --- a/drivers/tty/serial/8250/8250_bcm2835aux.c
> +++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
> @@ -16,6 +16,11 @@
>  
>  #include "8250.h"
>  
> +/**
> + * struct bcm2835aux_data - driver private data of BCM2835 auxiliary UART
> + * @clk: clock producer of the port's uartclk
> + * @line: index of the port's serial8250_ports[] entry
> + */
>  struct bcm2835aux_data {
>  	struct clk *clk;
>  	int line;
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 4/6] serial: 8250_bcm2835aux: Allocate uart_8250_port on stack
  2020-01-16 12:14 ` [PATCH 4/6] serial: 8250_bcm2835aux: Allocate uart_8250_port on stack Lukas Wunner
@ 2020-01-16 13:06   ` Matthias Brugger
  0 siblings, 0 replies; 12+ messages in thread
From: Matthias Brugger @ 2020-01-16 13:06 UTC (permalink / raw)
  To: Lukas Wunner, Greg Kroah-Hartman
  Cc: linux-rpi-kernel, linux-serial, Jiri Slaby



On 16/01/2020 13:14, Lukas Wunner wrote:
> The bcm2835aux UART driver stores a struct uart_8250_port in its private
> data even though it's only passed once to serial8250_register_8250_port()
> (which copies all relevant data) and becomes obsolete afterwards.
> Allocate the struct on the stack instead for simplicity and to conserve
> memory.
> 
> The driver also initializes a spinlock in the struct which is never used.
> Drop that as well.
> 
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> Cc: Martin Sperl <kernel@martin.sperl.org>

Reviewed-by: Matthias Brugger <mbrugger@suse.com>

> ---
>  drivers/tty/serial/8250/8250_bcm2835aux.c | 33 +++++++++++------------
>  1 file changed, 15 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_bcm2835aux.c b/drivers/tty/serial/8250/8250_bcm2835aux.c
> index fb850d0ad643..f03d38e7c3a7 100644
> --- a/drivers/tty/serial/8250/8250_bcm2835aux.c
> +++ b/drivers/tty/serial/8250/8250_bcm2835aux.c
> @@ -17,13 +17,13 @@
>  #include "8250.h"
>  
>  struct bcm2835aux_data {
> -	struct uart_8250_port uart;
>  	struct clk *clk;
>  	int line;
>  };
>  
>  static int bcm2835aux_serial_probe(struct platform_device *pdev)
>  {
> +	struct uart_8250_port up = { };
>  	struct bcm2835aux_data *data;
>  	struct resource *res;
>  	int ret;
> @@ -34,17 +34,14 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  
>  	/* initialize data */
> -	spin_lock_init(&data->uart.port.lock);
> -	data->uart.capabilities = UART_CAP_FIFO | UART_CAP_MINI;
> -	data->uart.port.dev = &pdev->dev;
> -	data->uart.port.regshift = 2;
> -	data->uart.port.type = PORT_16550;
> -	data->uart.port.iotype = UPIO_MEM;
> -	data->uart.port.fifosize = 8;
> -	data->uart.port.flags = UPF_SHARE_IRQ |
> -				UPF_FIXED_PORT |
> -				UPF_FIXED_TYPE |
> -				UPF_SKIP_TEST;
> +	up.capabilities = UART_CAP_FIFO | UART_CAP_MINI;
> +	up.port.dev = &pdev->dev;
> +	up.port.regshift = 2;
> +	up.port.type = PORT_16550;
> +	up.port.iotype = UPIO_MEM;
> +	up.port.fifosize = 8;
> +	up.port.flags = UPF_SHARE_IRQ | UPF_FIXED_PORT | UPF_FIXED_TYPE |
> +			UPF_SKIP_TEST;
>  
>  	/* get the clock - this also enables the HW */
>  	data->clk = devm_clk_get(&pdev->dev, NULL);
> @@ -59,7 +56,7 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
>  	ret = platform_get_irq(pdev, 0);
>  	if (ret < 0)
>  		return ret;
> -	data->uart.port.irq = ret;
> +	up.port.irq = ret;
>  
>  	/* map the main registers */
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> @@ -67,15 +64,15 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
>  		dev_err(&pdev->dev, "memory resource not found");
>  		return -EINVAL;
>  	}
> -	data->uart.port.membase = devm_ioremap_resource(&pdev->dev, res);
> -	ret = PTR_ERR_OR_ZERO(data->uart.port.membase);
> +	up.port.membase = devm_ioremap_resource(&pdev->dev, res);
> +	ret = PTR_ERR_OR_ZERO(up.port.membase);
>  	if (ret)
>  		return ret;
>  
>  	/* Check for a fixed line number */
>  	ret = of_alias_get_id(pdev->dev.of_node, "serial");
>  	if (ret >= 0)
> -		data->uart.port.line = ret;
> +		up.port.line = ret;
>  
>  	/* enable the clock as a last step */
>  	ret = clk_prepare_enable(data->clk);
> @@ -90,10 +87,10 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
>  	 * so we have to multiply the actual clock by 2
>  	 * to get identical baudrates.
>  	 */
> -	data->uart.port.uartclk = clk_get_rate(data->clk) * 2;
> +	up.port.uartclk = clk_get_rate(data->clk) * 2;
>  
>  	/* register the port */
> -	ret = serial8250_register_8250_port(&data->uart);
> +	ret = serial8250_register_8250_port(&up);
>  	if (ret < 0) {
>  		if (ret != -EPROBE_DEFER)
>  			dev_err(&pdev->dev,
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 0/6] Raspberry Pi auxiliary UART fixes & cleanups
  2020-01-16 12:14 [PATCH 0/6] Raspberry Pi auxiliary UART fixes & cleanups Lukas Wunner
                   ` (5 preceding siblings ...)
  2020-01-16 12:14 ` [PATCH 6/6] serial: 8250_bcm2835aux: Document struct bcm2835aux_data Lukas Wunner
@ 2020-01-16 16:11 ` Nicolas Saenz Julienne
  6 siblings, 0 replies; 12+ messages in thread
From: Nicolas Saenz Julienne @ 2020-01-16 16:11 UTC (permalink / raw)
  To: Lukas Wunner, Greg Kroah-Hartman
  Cc: Jiri Slaby, linux-serial, linux-rpi-kernel, Martin Sperl, Phil Elwell

[-- Attachment #1: Type: text/plain, Size: 1010 bytes --]

Hi Lukas,

On Thu, 2020-01-16 at 13:14 +0100, Lukas Wunner wrote:
> Here's a collection of fixes & cleanups for the Raspberry Pi auxiliary UART
> to prepare for upcoming feature work on the driver.
> 
> With compliments from Revolution Pi labs (https://revolution.kunbus.com/).
> 
> Lukas Wunner (5):
>   serial: 8250_bcm2835aux: Fix line mismatch on driver unbind
>   serial: 8250_bcm2835aux: Suppress register_port error on -EPROBE_DEFER
>   serial: 8250_bcm2835aux: Allocate uart_8250_port on stack
>   serial: 8250_bcm2835aux: Use generic remapping code
>   serial: 8250_bcm2835aux: Document struct bcm2835aux_data
> 
> Phil Elwell (1):
>   serial: 8250_bcm2835aux: Suppress clk_get error on -EPROBE_DEFER
> 
>  drivers/tty/serial/8250/8250_bcm2835aux.c | 50 ++++++++++++-----------
>  1 file changed, 26 insertions(+), 24 deletions(-)
> 

Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

Thanks!
Nicolas


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-01-16 16:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-16 12:14 [PATCH 0/6] Raspberry Pi auxiliary UART fixes & cleanups Lukas Wunner
2020-01-16 12:14 ` [PATCH 1/6] serial: 8250_bcm2835aux: Fix line mismatch on driver unbind Lukas Wunner
2020-01-16 12:14 ` [PATCH 2/6] serial: 8250_bcm2835aux: Suppress clk_get error on -EPROBE_DEFER Lukas Wunner
2020-01-16 12:58   ` Matthias Brugger
2020-01-16 12:14 ` [PATCH 3/6] serial: 8250_bcm2835aux: Suppress register_port " Lukas Wunner
2020-01-16 12:58   ` Matthias Brugger
2020-01-16 12:14 ` [PATCH 4/6] serial: 8250_bcm2835aux: Allocate uart_8250_port on stack Lukas Wunner
2020-01-16 13:06   ` Matthias Brugger
2020-01-16 12:14 ` [PATCH 5/6] serial: 8250_bcm2835aux: Use generic remapping code Lukas Wunner
2020-01-16 12:14 ` [PATCH 6/6] serial: 8250_bcm2835aux: Document struct bcm2835aux_data Lukas Wunner
2020-01-16 13:02   ` Matthias Brugger
2020-01-16 16:11 ` [PATCH 0/6] Raspberry Pi auxiliary UART fixes & cleanups Nicolas Saenz Julienne

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.