Skip to content

Commit 515c8e2

Browse files
chaitu236gregkh
authored andcommitted
serial: 8250_ni: Fix build warning
Allocate memory on heap instead of stack to fix following warning that clang version 20.1.2 produces on W=1 build. drivers/tty/serial/8250/8250_ni.c:277:12: warning: stack frame size (1072) exceeds limit (1024) in 'ni16550_probe' [-Wframe-larger-than] 277 | static int ni16550_probe(struct platform_device *pdev) | ^ 1 warning generated. Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Cc: Jason Smith <[email protected]> Cc: Gratian Crisan <[email protected]> Signed-off-by: Chaitanya Vadrevu <[email protected]> Reviewed-by: Jiri Slaby <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 65acd0d commit 515c8e2

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

drivers/tty/serial/8250/8250_ni.c

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -277,74 +277,78 @@ static int ni16550_probe(struct platform_device *pdev)
277277
{
278278
const struct ni16550_device_info *info;
279279
struct device *dev = &pdev->dev;
280-
struct uart_8250_port uart = {};
280+
struct uart_8250_port *uart __free(kfree) = NULL;
281281
unsigned int txfifosz, rxfifosz;
282282
unsigned int prescaler;
283283
struct ni16550_data *data;
284284
const char *portmode;
285285
bool rs232_property;
286286
int ret;
287287

288+
uart = kzalloc(sizeof(*uart), GFP_KERNEL);
289+
if (!uart)
290+
return -ENOMEM;
291+
288292
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
289293
if (!data)
290294
return -ENOMEM;
291295

292-
spin_lock_init(&uart.port.lock);
296+
spin_lock_init(&uart->port.lock);
293297

294-
ret = ni16550_get_regs(pdev, &uart.port);
298+
ret = ni16550_get_regs(pdev, &uart->port);
295299
if (ret < 0)
296300
return ret;
297301

298302
/* early setup so that serial_in()/serial_out() work */
299-
serial8250_set_defaults(&uart);
303+
serial8250_set_defaults(uart);
300304

301305
info = device_get_match_data(dev);
302306

303-
uart.port.dev = dev;
304-
uart.port.flags = UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | UPF_FIXED_TYPE;
305-
uart.port.startup = ni16550_port_startup;
306-
uart.port.shutdown = ni16550_port_shutdown;
307+
uart->port.dev = dev;
308+
uart->port.flags = UPF_BOOT_AUTOCONF | UPF_FIXED_PORT | UPF_FIXED_TYPE;
309+
uart->port.startup = ni16550_port_startup;
310+
uart->port.shutdown = ni16550_port_shutdown;
307311

308312
/*
309313
* Hardware instantiation of FIFO sizes are held in registers.
310314
*/
311-
txfifosz = ni16550_read_fifo_size(&uart, NI16550_TFS_OFFSET);
312-
rxfifosz = ni16550_read_fifo_size(&uart, NI16550_RFS_OFFSET);
315+
txfifosz = ni16550_read_fifo_size(uart, NI16550_TFS_OFFSET);
316+
rxfifosz = ni16550_read_fifo_size(uart, NI16550_RFS_OFFSET);
313317

314318
dev_dbg(dev, "NI 16550 has TX FIFO size %u, RX FIFO size %u\n",
315319
txfifosz, rxfifosz);
316320

317-
uart.port.type = PORT_16550A;
318-
uart.port.fifosize = txfifosz;
319-
uart.tx_loadsz = txfifosz;
320-
uart.fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10;
321-
uart.capabilities = UART_CAP_FIFO | UART_CAP_AFE | UART_CAP_EFR;
321+
uart->port.type = PORT_16550A;
322+
uart->port.fifosize = txfifosz;
323+
uart->tx_loadsz = txfifosz;
324+
uart->fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10;
325+
uart->capabilities = UART_CAP_FIFO | UART_CAP_AFE | UART_CAP_EFR;
322326

323327
/*
324328
* Declaration of the base clock frequency can come from one of:
325329
* - static declaration in this driver (for older ACPI IDs)
326330
* - a "clock-frequency" ACPI
327331
*/
328-
uart.port.uartclk = info->uartclk;
332+
uart->port.uartclk = info->uartclk;
329333

330-
ret = uart_read_port_properties(&uart.port);
334+
ret = uart_read_port_properties(&uart->port);
331335
if (ret)
332336
return ret;
333337

334-
if (!uart.port.uartclk) {
338+
if (!uart->port.uartclk) {
335339
data->clk = devm_clk_get_enabled(dev, NULL);
336340
if (!IS_ERR(data->clk))
337-
uart.port.uartclk = clk_get_rate(data->clk);
341+
uart->port.uartclk = clk_get_rate(data->clk);
338342
}
339343

340-
if (!uart.port.uartclk)
344+
if (!uart->port.uartclk)
341345
return dev_err_probe(dev, -ENODEV, "unable to determine clock frequency!\n");
342346

343347
prescaler = info->prescaler;
344348
device_property_read_u32(dev, "clock-prescaler", &prescaler);
345349
if (prescaler) {
346-
uart.port.set_mctrl = ni16550_set_mctrl;
347-
ni16550_config_prescaler(&uart, (u8)prescaler);
350+
uart->port.set_mctrl = ni16550_set_mctrl;
351+
ni16550_config_prescaler(uart, (u8)prescaler);
348352
}
349353

350354
/*
@@ -362,7 +366,7 @@ static int ni16550_probe(struct platform_device *pdev)
362366
dev_dbg(dev, "port is in %s mode (via device property)\n",
363367
rs232_property ? "RS-232" : "RS-485");
364368
} else if (info->flags & NI_HAS_PMR) {
365-
rs232_property = is_pmr_rs232_mode(&uart);
369+
rs232_property = is_pmr_rs232_mode(uart);
366370

367371
dev_dbg(dev, "port is in %s mode (via PMR)\n",
368372
rs232_property ? "RS-232" : "RS-485");
@@ -377,10 +381,10 @@ static int ni16550_probe(struct platform_device *pdev)
377381
* Neither the 'transceiver' property nor the PMR indicate
378382
* that this is an RS-232 port, so it must be an RS-485 one.
379383
*/
380-
ni16550_rs485_setup(&uart.port);
384+
ni16550_rs485_setup(&uart->port);
381385
}
382386

383-
ret = serial8250_register_8250_port(&uart);
387+
ret = serial8250_register_8250_port(uart);
384388
if (ret < 0)
385389
return ret;
386390
data->line = ret;

0 commit comments

Comments
 (0)