Skip to content

Commit 8c3cde5

Browse files
l1kgregkh
authored andcommitted
serial: 8250_bcm2835aux: Allocate uart_8250_port on stack
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 <[email protected]> Cc: Martin Sperl <[email protected]> Reviewed-by: Matthias Brugger <[email protected]> Reviewed-by: Nicolas Saenz Julienne <[email protected]> Tested-by: Nicolas Saenz Julienne <[email protected]> Link: https://lore.kernel.org/r/421d3aed4c34cc8447ac9c26c320961f1b787f11.1579175223.git.lukas@wunner.de Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e2f2a99 commit 8c3cde5

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

drivers/tty/serial/8250/8250_bcm2835aux.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
#include "8250.h"
1818

1919
struct bcm2835aux_data {
20-
struct uart_8250_port uart;
2120
struct clk *clk;
2221
int line;
2322
};
2423

2524
static int bcm2835aux_serial_probe(struct platform_device *pdev)
2625
{
26+
struct uart_8250_port up = { };
2727
struct bcm2835aux_data *data;
2828
struct resource *res;
2929
int ret;
@@ -34,17 +34,14 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
3434
return -ENOMEM;
3535

3636
/* initialize data */
37-
spin_lock_init(&data->uart.port.lock);
38-
data->uart.capabilities = UART_CAP_FIFO | UART_CAP_MINI;
39-
data->uart.port.dev = &pdev->dev;
40-
data->uart.port.regshift = 2;
41-
data->uart.port.type = PORT_16550;
42-
data->uart.port.iotype = UPIO_MEM;
43-
data->uart.port.fifosize = 8;
44-
data->uart.port.flags = UPF_SHARE_IRQ |
45-
UPF_FIXED_PORT |
46-
UPF_FIXED_TYPE |
47-
UPF_SKIP_TEST;
37+
up.capabilities = UART_CAP_FIFO | UART_CAP_MINI;
38+
up.port.dev = &pdev->dev;
39+
up.port.regshift = 2;
40+
up.port.type = PORT_16550;
41+
up.port.iotype = UPIO_MEM;
42+
up.port.fifosize = 8;
43+
up.port.flags = UPF_SHARE_IRQ | UPF_FIXED_PORT | UPF_FIXED_TYPE |
44+
UPF_SKIP_TEST;
4845

4946
/* get the clock - this also enables the HW */
5047
data->clk = devm_clk_get(&pdev->dev, NULL);
@@ -59,23 +56,23 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
5956
ret = platform_get_irq(pdev, 0);
6057
if (ret < 0)
6158
return ret;
62-
data->uart.port.irq = ret;
59+
up.port.irq = ret;
6360

6461
/* map the main registers */
6562
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
6663
if (!res) {
6764
dev_err(&pdev->dev, "memory resource not found");
6865
return -EINVAL;
6966
}
70-
data->uart.port.membase = devm_ioremap_resource(&pdev->dev, res);
71-
ret = PTR_ERR_OR_ZERO(data->uart.port.membase);
67+
up.port.membase = devm_ioremap_resource(&pdev->dev, res);
68+
ret = PTR_ERR_OR_ZERO(up.port.membase);
7269
if (ret)
7370
return ret;
7471

7572
/* Check for a fixed line number */
7673
ret = of_alias_get_id(pdev->dev.of_node, "serial");
7774
if (ret >= 0)
78-
data->uart.port.line = ret;
75+
up.port.line = ret;
7976

8077
/* enable the clock as a last step */
8178
ret = clk_prepare_enable(data->clk);
@@ -90,10 +87,10 @@ static int bcm2835aux_serial_probe(struct platform_device *pdev)
9087
* so we have to multiply the actual clock by 2
9188
* to get identical baudrates.
9289
*/
93-
data->uart.port.uartclk = clk_get_rate(data->clk) * 2;
90+
up.port.uartclk = clk_get_rate(data->clk) * 2;
9491

9592
/* register the port */
96-
ret = serial8250_register_8250_port(&data->uart);
93+
ret = serial8250_register_8250_port(&up);
9794
if (ret < 0) {
9895
if (ret != -EPROBE_DEFER)
9996
dev_err(&pdev->dev,

0 commit comments

Comments
 (0)