mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-08-22 00:42:01 +02:00

The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> # 8250_bcm* Link: https://lore.kernel.org/r/20231110152927.70601-4-u.kleine-koenig@pengutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
98 lines
2.3 KiB
C
98 lines
2.3 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* SGI IOC3 8250 UART driver
|
|
*
|
|
* Copyright (C) 2019 Thomas Bogendoerfer <tbogendoerfer@suse.de>
|
|
*
|
|
* based on code Copyright (C) 2005 Stanislaw Skowronek <skylark@unaligned.org>
|
|
* Copyright (C) 2014 Joshua Kinard <kumba@gentoo.org>
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/io.h>
|
|
#include <linux/platform_device.h>
|
|
|
|
#include "8250.h"
|
|
|
|
#define IOC3_UARTCLK (22000000 / 3)
|
|
|
|
struct ioc3_8250_data {
|
|
int line;
|
|
};
|
|
|
|
static unsigned int ioc3_serial_in(struct uart_port *p, int offset)
|
|
{
|
|
return readb(p->membase + (offset ^ 3));
|
|
}
|
|
|
|
static void ioc3_serial_out(struct uart_port *p, int offset, int value)
|
|
{
|
|
writeb(value, p->membase + (offset ^ 3));
|
|
}
|
|
|
|
static int serial8250_ioc3_probe(struct platform_device *pdev)
|
|
{
|
|
struct ioc3_8250_data *data;
|
|
struct uart_8250_port up;
|
|
struct resource *r;
|
|
void __iomem *membase;
|
|
int irq, line;
|
|
|
|
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
if (!r)
|
|
return -ENODEV;
|
|
|
|
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
|
|
if (!data)
|
|
return -ENOMEM;
|
|
|
|
membase = devm_ioremap(&pdev->dev, r->start, resource_size(r));
|
|
if (!membase)
|
|
return -ENOMEM;
|
|
|
|
irq = platform_get_irq(pdev, 0);
|
|
if (irq < 0)
|
|
irq = 0; /* no interrupt -> use polling */
|
|
|
|
/* Register serial ports with 8250.c */
|
|
memset(&up, 0, sizeof(struct uart_8250_port));
|
|
up.port.iotype = UPIO_MEM;
|
|
up.port.uartclk = IOC3_UARTCLK;
|
|
up.port.type = PORT_16550A;
|
|
up.port.irq = irq;
|
|
up.port.flags = (UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ);
|
|
up.port.dev = &pdev->dev;
|
|
up.port.membase = membase;
|
|
up.port.mapbase = r->start;
|
|
up.port.serial_in = ioc3_serial_in;
|
|
up.port.serial_out = ioc3_serial_out;
|
|
line = serial8250_register_8250_port(&up);
|
|
if (line < 0)
|
|
return line;
|
|
|
|
platform_set_drvdata(pdev, data);
|
|
return 0;
|
|
}
|
|
|
|
static void serial8250_ioc3_remove(struct platform_device *pdev)
|
|
{
|
|
struct ioc3_8250_data *data = platform_get_drvdata(pdev);
|
|
|
|
serial8250_unregister_port(data->line);
|
|
}
|
|
|
|
static struct platform_driver serial8250_ioc3_driver = {
|
|
.probe = serial8250_ioc3_probe,
|
|
.remove_new = serial8250_ioc3_remove,
|
|
.driver = {
|
|
.name = "ioc3-serial8250",
|
|
}
|
|
};
|
|
|
|
module_platform_driver(serial8250_ioc3_driver);
|
|
|
|
MODULE_AUTHOR("Thomas Bogendoerfer <tbogendoerfer@suse.de>");
|
|
MODULE_DESCRIPTION("SGI IOC3 8250 UART driver");
|
|
MODULE_LICENSE("GPL");
|