serial: 8250_exar: A few updates to the driver
v2 cover serial: 8250_exar: A few updates to the driver
A few updates to the 8250 Exar driver as per new in-kernel APIs appeared.
In v2:
- fixed link error, i.e. missing imported namespace (LKP, Greg)
- added a couple of new patches at the beginning of the series
Andy Shevchenko (7):
serial: 8250_exar: Don't remove GPIO device on suspend
serial: 8250_exar: Use dev_get_drvdata() directly in PM callbacks
serial: 8250_exar: Clear interrupts before registering handler
serial: 8250_exar: Use generic function to set firmware node
serial: 8250_exar: switch to DEFINE_SIMPLE_DEV_PM_OPS()
serial: 8250_exar: Use 8250 PCI library to map and assign resources
serial: 8250_exar: Don't use "proxy" headers
drivers/tty/serial/8250/8250_exar.c | 52 +++++++++++++++-------------- drivers/tty/serial/8250/Kconfig | 1 + 2 files changed, 28 insertions(+), 25 deletions(-)
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v2 1/7 serial: 8250_exar: Don't remove GPIO device on suspend
It seems a copy&paste mistake that suspend callback removes the GPIO device. There is no counterpart of this action, means once suspended there is no more GPIO device available untile full unbind-bind cycle is performed. Remove suspicious GPIO device removal in suspend.
--- drivers/tty/serial/8250/8250_exar.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/tty/serial/8250/8250_exar.c +1 -4
@@ -741,6 +741,7 @@ static void exar_pci_remove(struct pci_dev *pcidev)for (i =0 ; i < priv->nr; i++)serial8250_unregister_port (priv->line[i]); +/* Ensure that every init quirk is properly torn down */ if (priv->board->exit) priv->board->exit (pcidev); }
@@ -755,10 +756,6 @@ static int __maybe_unused exar_suspend(struct device *dev)if (priv->line[i] >=0 )serial8250_suspend_port (priv->line[i]); -/* Ensure that every init quirk is properly torn down */ -if (priv->board->exit) - priv->board->exit (pcidev); -return 0 ; }
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v2 2/7 serial: 8250_exar: Use dev_get_drvdata() directly in PM callbacks
In reply to Andy ShevchenkoPM callbacks take struct device pointer as a parameter, use dev_get_drvdata() to retrieve it instead of unneeded double loop of referencing via pci_get_drvdata(to_pci_dev(dev)).
--- drivers/tty/serial/8250/8250_exar.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/tty/serial/8250/8250_exar.c +1 -2
@@ -748,8 +748,7 @@ static void exar_pci_remove(struct pci_dev *pcidev)static int __maybe_unused exar_suspend (struct device *dev) { -struct pci_dev *pcidev =to_pci_dev (dev); -struct exar8250 *priv =pci_get_drvdata (pcidev); +struct exar8250 *priv =dev_get_drvdata (dev);unsigned int i;for (i =0 ; i < priv->nr; i++)
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v2 3/7 serial: 8250_exar: Clear interrupts before registering handler
In reply to Andy ShevchenkoWhile now there is no issue if IRQ is fired before we clearing the interrupts as the handler does the same, but strictly speaking it might be problematic if IRQ handler wants to do something more.
Move clearing interrupt code to be called before registering the IRQ handler.
--- drivers/tty/serial/8250/8250_exar.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/tty/serial/8250/8250_exar.c +3 -3
@@ -701,14 +701,14 @@ exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent) uart.port.irq =pci_irq_vector (pcidev,0 ); uart.port.dev = &pcidev->dev; +/* Clear interrupts */ +exar_misc_clear (priv); + rc =devm_request_irq (&pcidev->dev, uart.port.irq, exar_misc_handler,IRQF_SHARED ,"exar_uart" , priv);if (rc)return rc; -/* Clear interrupts */ -exar_misc_clear (priv); -for (i =0 ; i < nr_ports && i < maxnr; i++) { rc = board->setup (priv, pcidev, &uart, i);if (rc) {
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v2 4/7 serial: 8250_exar: Use generic function to set firmware node
In reply to Andy ShevchenkoUse generic function to set firmware node instead of ACPI specific one.
--- drivers/tty/serial/8250/8250_exar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_exar.c +2 -2
@@ -6,12 +6,12 @@* * Copyright (C) 2017 Sudip Mukherjee, All Rights Reserved. */ -#include <linux/acpi.h> #include <linux/dmi.h> #include <linux/io.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/pci.h> +#include <linux/platform_device.h> #include <linux/property.h> #include <linux/serial_core.h> #include <linux/serial_reg.h>
@@ -363,7 +363,7 @@ static struct platform_device *__xr17v35x_register_gpio(struct pci_dev *pcidev,return NULL ; pdev->dev.parent = &pcidev->dev; -ACPI_COMPANION_SET (&pdev->dev,ACPI_COMPANION (&pcidev->dev)); +device_set_node (&pdev->dev,dev_fwnode (&pcidev->dev));if (device_add_software_node (&pdev->dev, node) <0 ||platform_device_add (pdev) <0 ) {
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v2 5/7 serial: 8250_exar: switch to DEFINE_SIMPLE_DEV_PM_OPS()
In reply to Andy ShevchenkoSIMPLE_DEV_PM_OPS() is deprecated, replace it with DEFINE_SIMPLE_DEV_PM_OPS() and use pm_sleep_ptr() for setting the driver's PM routines. We can now remove the __maybe_unused qualifier in the suspend and resume functions.
--- drivers/tty/serial/8250/8250_exar.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/tty/serial/8250/8250_exar.c +5 -4
@@ -12,6 +12,7 @@#include <linux/module.h> #include <linux/pci.h> #include <linux/platform_device.h> +#include <linux/pm.h> #include <linux/property.h> #include <linux/serial_core.h> #include <linux/serial_reg.h>
@@ -746,7 +747,7 @@ static void exar_pci_remove(struct pci_dev *pcidev) priv->board->exit (pcidev); } -static int __maybe_unused exar_suspend (struct device *dev) +static int exar_suspend (struct device *dev) {struct exar8250 *priv =dev_get_drvdata (dev);unsigned int i;
@@ -758,7 +759,7 @@ static int __maybe_unused exar_suspend(struct device *dev)return 0 ; } -static int __maybe_unused exar_resume (struct device *dev) +static int exar_resume (struct device *dev) {struct exar8250 *priv =dev_get_drvdata (dev);unsigned int i;
@@ -772,7 +773,7 @@ static int __maybe_unused exar_resume(struct device *dev)return 0 ; } -static SIMPLE_DEV_PM_OPS(exar_pci_pm, exar_suspend, exar_resume); +static DEFINE_SIMPLE_DEV_PM_OPS(exar_pci_pm, exar_suspend, exar_resume);static const struct exar8250_board pbn_fastcom335_2 = { .num_ports =2 ,
@@ -922,7 +923,7 @@ static struct pci_driver exar_pci_driver = { .probe = exar_pci_probe, .remove = exar_pci_remove, .driver = { - .pm = &exar_pci_pm, + .pm = pm_sleep_ptr(&exar_pci_pm), }, .id_table = exar_pci_tbl, };
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v2 6/7 serial: 8250_exar: Use 8250 PCI library to map and assign resources
In reply to Andy Shevchenko8250 PCI library provides a common code to map and assign resources. Use it in order to deduplicate existing code and support IO port variants.
--- drivers/tty/serial/8250/8250_exar.c | 11 ++++++----- drivers/tty/serial/8250/Kconfig | 1 + 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/tty/serial/8250/8250_exar.c +6 -5
@@ -24,6 +24,7 @@#include <asm/byteorder.h> #include "8250.h" +#include "8250_pcilib.h" #define PCI_DEVICE_ID_ACCESSIO_COM_2S 0x1052#define PCI_DEVICE_ID_ACCESSIO_COM_4S 0x105d
@@ -219,13 +220,12 @@ static int default_setup(struct exar8250 *priv, struct pci_dev *pcidev, struct uart_8250_port *port) {const struct exar8250_board *board = priv->board; -unsigned int bar =0 ;unsigned char status; +int err; - port->port.iotype =UPIO_MEM ; - port->port.mapbase =pci_resource_start (pcidev, bar) + offset; - port->port.membase = priv->virt + offset; - port->port.regshift = board->reg_shift; + err =serial8250_pci_setup_port (pcidev, port,0 , offset, board->reg_shift); +if (err) +return err;/* * XR17V35x UARTs have an extra divisor register, DLD that gets enabled
@@ -929,6 +929,7 @@ static struct pci_driver exar_pci_driver = { };module_pci_driver (exar_pci_driver); +MODULE_IMPORT_NS (SERIAL_8250_PCI );MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Exar Serial Driver" );MODULE_AUTHOR ("Sudip Mukherjee <[email protected]>" );
drivers/tty/serial/8250/Kconfig +1 -0
@@ -149,6 +149,7 @@ config SERIAL_8250_PCI config SERIAL_8250_EXAR tristate "8250/16550 Exar/Commtech PCI/PCIe device support" depends on SERIAL_8250 && PCI + select SERIAL_8250_PCILIB default SERIAL_8250 help This builds support for XR17C1xx, XR17V3xx and some Commtech
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v2 7/7 serial: 8250_exar: Don't use "proxy" headers
In reply to Andy ShevchenkoUpdate header inclusions to follow IWYU (Include What You Use) principle.
--- drivers/tty/serial/8250/8250_exar.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/tty/serial/8250/8250_exar.c +9 -5
@@ -6,20 +6,24 @@* * Copyright (C) 2017 Sudip Mukherjee, All Rights Reserved. */ +#include <linux/bits.h> +#include <linux/delay.h> +#include <linux/device.h> #include <linux/dmi.h> +#include <linux/interrupt.h> #include <linux/io.h> -#include <linux/kernel.h> +#include <linux/math.h> #include <linux/module.h> #include <linux/pci.h> #include <linux/platform_device.h> #include <linux/pm.h> #include <linux/property.h> +#include <linux/string.h> +#include <linux/types.h> + +#include <linux/serial_8250.h> #include <linux/serial_core.h> #include <linux/serial_reg.h> -#include <linux/slab.h> -#include <linux/string.h> -#include <linux/tty.h> -#include <linux/delay.h> #include <asm/byteorder.h>
Signature · 1 line
2.43.0.rc1.1.gbec44491f096