[PATCH] serial: 8250_exar: use platform_device_register_full()

Bartosz Golaszewski <[email protected]> Tue, 28 Jul 2026 16:44:50 +0200
Newsgroups gmane.linux.serial,gmane.linux.kernel
Message-ID <[email protected]>
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 <[email protected]>
---
 drivers/tty/serial/8250/8250_exar.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index f9a14eaa13cba85f2424c351510be093f52fd6a1..836792e861bfc742a14de90640a6252dca1bd226 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;
-
-	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;
+	struct platform_device_info pdevinfo = {
+		.name = "gpio_exar",
+		.id = PLATFORM_DEVID_AUTO,
+		.parent = &pcidev->dev,
+		.fwnode = dev_fwnode(&pcidev->dev),
+		.swnode = node,
+	};
+
+	return platform_device_register_full(&pdevinfo);
 }
 
 static void __xr17v35x_unregister_gpio(struct platform_device *pdev)

---
base-commit: 0d33d21e47d9dc66f91e44da3fc9220c74d93df7
change-id: 20260728-exar-pdev-reg-full-e31a2447b4b3

Best regards,
-- 
Bartosz Golaszewski <[email protected]>