Skip to contentSkip to conversation

serial: 8250_exar: use platform_device_register_full()

PATCH New Bartosz Golaszewski 1 participant 1 message Jul 28 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/tty/serial/8250/8250_exar.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)
drivers/tty/serial/8250/8250_exar.c +9 -16
index f9a14eaa13cba85f2424c351510be093f52fd6a1..836792e861bfc742a14de90640a6252dca1bd226 100644
@@ -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,

Signature · 1 line
Bartosz Golaszewski <[email protected]>