Skip to content

Commit a0b0a6e

Browse files
committed
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>
1 parent b94b470 commit a0b0a6e

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

drivers/misc/rp1-pio.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,10 @@ static int rp1_pio_probe(struct platform_device *pdev)
11531153
return -EINVAL;
11541154
}
11551155

1156+
pdev->id = of_alias_get_id(pdev->dev.of_node, "pio");
1157+
if (pdev->id < 0)
1158+
return dev_err_probe(dev, pdev->id, "alias is missing\n");
1159+
11561160
fw = devm_rp1_firmware_get(dev, dev->of_node);
11571161
if (IS_ERR(fw))
11581162
return PTR_ERR(fw);
@@ -1185,44 +1189,39 @@ static int rp1_pio_probe(struct platform_device *pdev)
11851189
goto out_err;
11861190
}
11871191

1188-
cdev_init(&pio->cdev, &rp1_pio_fops);
1189-
ret = cdev_add(&pio->cdev, pio->dev_num, 1);
1190-
if (ret) {
1191-
dev_err(dev, "cdev_add failed (err %d)\n", ret);
1192-
goto out_unregister;
1193-
}
1194-
11951192
pio->dev_class = class_create(DRIVER_NAME);
11961193
if (IS_ERR(pio->dev_class)) {
11971194
ret = PTR_ERR(pio->dev_class);
11981195
dev_err(dev, "class_create failed (err %d)\n", ret);
1199-
goto out_cdev_del;
1196+
goto out_unregister;
12001197
}
1201-
pdev->id = of_alias_get_id(pdev->dev.of_node, "pio");
1202-
if (pdev->id < 0) {
1203-
dev_err(dev, "alias is missing\n");
1204-
return -EINVAL;
1198+
1199+
cdev_init(&pio->cdev, &rp1_pio_fops);
1200+
ret = cdev_add(&pio->cdev, pio->dev_num, 1);
1201+
if (ret) {
1202+
dev_err(dev, "cdev_add failed (err %d)\n", ret);
12051203
goto out_class_destroy;
12061204
}
1205+
12071206
sprintf(dev_name, "pio%d", pdev->id);
12081207
cdev = device_create(pio->dev_class, NULL, pio->dev_num, NULL, dev_name);
12091208
if (IS_ERR(cdev)) {
12101209
ret = PTR_ERR(cdev);
12111210
dev_err(dev, "%s: device_create failed (err %d)\n", __func__, ret);
1212-
goto out_class_destroy;
1211+
goto out_cdev_del;
12131212
}
12141213

12151214
g_pio = pio;
12161215

12171216
dev_info(dev, "Created instance as %s\n", dev_name);
12181217
return 0;
12191218

1220-
out_class_destroy:
1221-
class_destroy(pio->dev_class);
1222-
12231219
out_cdev_del:
12241220
cdev_del(&pio->cdev);
12251221

1222+
out_class_destroy:
1223+
class_destroy(pio->dev_class);
1224+
12261225
out_unregister:
12271226
unregister_chrdev_region(pio->dev_num, 1);
12281227

0 commit comments

Comments
 (0)