openwrt/target/linux/bcm27xx/patches-6.6/950-1473-misc-rp1-pio-More-logical-probe-sequence.patch

82 lines
2.2 KiB
Diff
Raw Normal View History

From 468b525d45a726e4ba704b33c4eba53de47ac684 Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Thu, 5 Dec 2024 16:03:39 +0000
Subject: [PATCH 1473/1482] misc: rp1-pio: More logical probe sequence
Sort the probe function initialisation into a more logical order.
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
drivers/misc/rp1-pio.c | 31 +++++++++++++++----------------
1 file changed, 15 insertions(+), 16 deletions(-)
--- a/drivers/misc/rp1-pio.c
+++ b/drivers/misc/rp1-pio.c
@@ -1153,6 +1153,10 @@ static int rp1_pio_probe(struct platform
return -EINVAL;
}
+ pdev->id = of_alias_get_id(pdev->dev.of_node, "pio");
+ if (pdev->id < 0)
+ return dev_err_probe(dev, pdev->id, "alias is missing\n");
+
fw = devm_rp1_firmware_get(dev, dev->of_node);
if (IS_ERR(fw))
return PTR_ERR(fw);
@@ -1185,31 +1189,26 @@ static int rp1_pio_probe(struct platform
goto out_err;
}
- cdev_init(&pio->cdev, &rp1_pio_fops);
- ret = cdev_add(&pio->cdev, pio->dev_num, 1);
- if (ret) {
- dev_err(dev, "cdev_add failed (err %d)\n", ret);
- goto out_unregister;
- }
-
pio->dev_class = class_create(DRIVER_NAME);
if (IS_ERR(pio->dev_class)) {
ret = PTR_ERR(pio->dev_class);
dev_err(dev, "class_create failed (err %d)\n", ret);
- goto out_cdev_del;
+ goto out_unregister;
}
- pdev->id = of_alias_get_id(pdev->dev.of_node, "pio");
- if (pdev->id < 0) {
- dev_err(dev, "alias is missing\n");
- return -EINVAL;
+
+ cdev_init(&pio->cdev, &rp1_pio_fops);
+ ret = cdev_add(&pio->cdev, pio->dev_num, 1);
+ if (ret) {
+ dev_err(dev, "cdev_add failed (err %d)\n", ret);
goto out_class_destroy;
}
+
sprintf(dev_name, "pio%d", pdev->id);
cdev = device_create(pio->dev_class, NULL, pio->dev_num, NULL, dev_name);
if (IS_ERR(cdev)) {
ret = PTR_ERR(cdev);
dev_err(dev, "%s: device_create failed (err %d)\n", __func__, ret);
- goto out_class_destroy;
+ goto out_cdev_del;
}
g_pio = pio;
@@ -1217,12 +1216,12 @@ static int rp1_pio_probe(struct platform
dev_info(dev, "Created instance as %s\n", dev_name);
return 0;
-out_class_destroy:
- class_destroy(pio->dev_class);
-
out_cdev_del:
cdev_del(&pio->cdev);
+out_class_destroy:
+ class_destroy(pio->dev_class);
+
out_unregister:
unregister_chrdev_region(pio->dev_num, 1);