From: Matthias Brugger <mbrugger@suse.com>
To: Lukas Wunner <lukas@wunner.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-rpi-kernel@lists.infradead.org,
linux-serial@vger.kernel.org, Jiri Slaby <jslaby@suse.com>
Subject: Re: [PATCH 4/6] serial: 8250_bcm2835aux: Allocate uart_8250_port on stack
Date: Thu, 16 Jan 2020 14:06:32 +0100 [thread overview]
Message-ID: <92cca672-fc00-c0bb-9d67-15da7d6d6319@suse.com> (raw)
In-Reply-To: <421d3aed4c34cc8447ac9c26c320961f1b787f11.1579175223.git.lukas@wunner.de>
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,
>
next prev parent reply other threads:[~2020-01-16 13:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=92cca672-fc00-c0bb-9d67-15da7d6d6319@suse.com \
--to=mbrugger@suse.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=linux-serial@vger.kernel.org \
--cc=lukas@wunner.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).