treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / mips / lasat / serial.c
blob16b242713420fb36ca8a1dbe58106fb32fd5e058
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Registration of Lasat UART platform device.
5 * Copyright (C) 2007 Brian Murphy <brian@murphy.dk>
6 */
7 #include <linux/errno.h>
8 #include <linux/init.h>
9 #include <linux/ioport.h>
10 #include <linux/platform_device.h>
11 #include <linux/serial_8250.h>
13 #include <asm/lasat/lasat.h>
14 #include <asm/lasat/serial.h>
16 static struct resource lasat_serial_res[2] __initdata;
18 static struct plat_serial8250_port lasat_serial8250_port[] = {
20 .iotype = UPIO_MEM,
21 .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF |
22 UPF_SKIP_TEST,
24 {},
27 static __init int lasat_uart_add(void)
29 struct platform_device *pdev;
30 int retval;
32 pdev = platform_device_alloc("serial8250", -1);
33 if (!pdev)
34 return -ENOMEM;
36 if (!IS_LASAT_200()) {
37 lasat_serial_res[0].start = KSEG1ADDR(LASAT_UART_REGS_BASE_100);
38 lasat_serial_res[0].end = lasat_serial_res[0].start + LASAT_UART_REGS_SHIFT_100 * 8 - 1;
39 lasat_serial_res[0].flags = IORESOURCE_MEM;
40 lasat_serial_res[1].start = LASATINT_UART_100;
41 lasat_serial_res[1].end = LASATINT_UART_100;
42 lasat_serial_res[1].flags = IORESOURCE_IRQ;
44 lasat_serial8250_port[0].mapbase = LASAT_UART_REGS_BASE_100;
45 lasat_serial8250_port[0].uartclk = LASAT_BASE_BAUD_100 * 16;
46 lasat_serial8250_port[0].regshift = LASAT_UART_REGS_SHIFT_100;
47 lasat_serial8250_port[0].irq = LASATINT_UART_100;
48 } else {
49 lasat_serial_res[0].start = KSEG1ADDR(LASAT_UART_REGS_BASE_200);
50 lasat_serial_res[0].end = lasat_serial_res[0].start + LASAT_UART_REGS_SHIFT_200 * 8 - 1;
51 lasat_serial_res[0].flags = IORESOURCE_MEM;
52 lasat_serial_res[1].start = LASATINT_UART_200;
53 lasat_serial_res[1].end = LASATINT_UART_200;
54 lasat_serial_res[1].flags = IORESOURCE_IRQ;
56 lasat_serial8250_port[0].mapbase = LASAT_UART_REGS_BASE_200;
57 lasat_serial8250_port[0].uartclk = LASAT_BASE_BAUD_200 * 16;
58 lasat_serial8250_port[0].regshift = LASAT_UART_REGS_SHIFT_200;
59 lasat_serial8250_port[0].irq = LASATINT_UART_200;
62 pdev->id = PLAT8250_DEV_PLATFORM;
63 pdev->dev.platform_data = lasat_serial8250_port;
65 retval = platform_device_add_resources(pdev, lasat_serial_res, ARRAY_SIZE(lasat_serial_res));
66 if (retval)
67 goto err_free_device;
69 retval = platform_device_add(pdev);
70 if (retval)
71 goto err_free_device;
73 return 0;
75 err_free_device:
76 platform_device_put(pdev);
78 return retval;
80 device_initcall(lasat_uart_add);