Skip to content

Commit cc04428

Browse files
andy-shevgregkh
authored andcommitted
serial: 8250_platform: Refactor serial8250_probe()
Make it clear that it supports two cases, pure platform device and ACPI. With this in mind, split serial8250_probe() to two functions and rename the ACPI case accordingly. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20240812154901.1068407-7-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4596d2b commit cc04428

1 file changed

Lines changed: 27 additions & 16 deletions

File tree

drivers/tty/serial/8250/8250_platform.c

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void __init serial8250_isa_init_ports(void)
105105
/*
106106
* Generic 16550A platform devices
107107
*/
108-
static int serial8250_platform_probe(struct platform_device *pdev)
108+
static int serial8250_probe_acpi(struct platform_device *pdev)
109109
{
110110
struct device *dev = &pdev->dev;
111111
struct uart_8250_port uart = { };
@@ -157,25 +157,11 @@ static int serial8250_platform_probe(struct platform_device *pdev)
157157
return 0;
158158
}
159159

160-
/*
161-
* Register a set of serial devices attached to a platform device. The
162-
* list is terminated with a zero flags entry, which means we expect
163-
* all entries to have at least UPF_BOOT_AUTOCONF set.
164-
*/
165-
static int serial8250_probe(struct platform_device *dev)
160+
static int serial8250_probe_platform(struct platform_device *dev, struct plat_serial8250_port *p)
166161
{
167-
struct plat_serial8250_port *p = dev_get_platdata(&dev->dev);
168162
struct uart_8250_port uart;
169163
int ret, i, irqflag = 0;
170164

171-
/*
172-
* Probe platform UART devices defined using standard hardware
173-
* discovery mechanism like ACPI or DT. Support only ACPI based
174-
* serial device for now.
175-
*/
176-
if (!p && has_acpi_companion(&dev->dev))
177-
return serial8250_platform_probe(dev);
178-
179165
memset(&uart, 0, sizeof(uart));
180166

181167
if (share_irqs)
@@ -220,6 +206,31 @@ static int serial8250_probe(struct platform_device *dev)
220206
return 0;
221207
}
222208

209+
/*
210+
* Register a set of serial devices attached to a platform device. The
211+
* list is terminated with a zero flags entry, which means we expect
212+
* all entries to have at least UPF_BOOT_AUTOCONF set.
213+
*/
214+
static int serial8250_probe(struct platform_device *pdev)
215+
{
216+
struct device *dev = &pdev->dev;
217+
struct plat_serial8250_port *p;
218+
219+
p = dev_get_platdata(dev);
220+
if (p)
221+
return serial8250_probe_platform(pdev, p);
222+
223+
/*
224+
* Probe platform UART devices defined using standard hardware
225+
* discovery mechanism like ACPI or DT. Support only ACPI based
226+
* serial device for now.
227+
*/
228+
if (has_acpi_companion(dev))
229+
return serial8250_probe_acpi(pdev);
230+
231+
return 0;
232+
}
233+
223234
/*
224235
* Remove serial ports registered against a platform device.
225236
*/

0 commit comments

Comments
 (0)