From 1145d1a0703f44687e599f8608c035cea95e6ae3 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Tue, 28 Jul 2026 16:44:50 +0200 Subject: [PATCH] serial: 8250_exar: use platform_device_register_full() This driver doesn't really need to split the registration of the GPIO chip into stages, as platform_device_info already provides fields for the firmware node, parent device and the software node. Use platform_device_register_full() and simplify the code. This also addresses the problem with incorrect reference count of the assigned firmware node. Signed-off-by: Bartosz Golaszewski Link: https://patch.msgid.link/20260728-exar-pdev-reg-full-v1-1-7a96e77309e1@oss.qualcomm.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_exar.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c index f9a14eaa13cb..836792e861bf 100644 --- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c @@ -1140,22 +1140,15 @@ static void setup_gpio(struct pci_dev *pcidev, u8 __iomem *p) static struct platform_device *__xr17v35x_register_gpio(struct pci_dev *pcidev, const struct software_node *node) { - struct platform_device *pdev; + struct platform_device_info pdevinfo = { + .name = "gpio_exar", + .id = PLATFORM_DEVID_AUTO, + .parent = &pcidev->dev, + .fwnode = dev_fwnode(&pcidev->dev), + .swnode = node, + }; - pdev = platform_device_alloc("gpio_exar", PLATFORM_DEVID_AUTO); - if (!pdev) - return NULL; - - pdev->dev.parent = &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) { - platform_device_put(pdev); - return NULL; - } - - return pdev; + return platform_device_register_full(&pdevinfo); } static void __xr17v35x_unregister_gpio(struct platform_device *pdev)