Skip to content

Commit 7bf0b49

Browse files
committed
misc: rp1-pio: Defer for out-of-order probing
In the event that a client of the rp1-pio driver is probed before it, return -EPROBE_DEFER from pio_open to allow it to be retried. Otherwise, return an error code on error, not a NULL pointer, as that is what clients are expecting. See: raspberrypi#7211 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
1 parent 1298a98 commit 7bf0b49

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

drivers/misc/rp1-pio.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,9 @@ struct rp1_pio_client *rp1_pio_open(void)
10351035
struct rp1_pio_client *client;
10361036

10371037
if (!g_pio)
1038-
return ERR_PTR(-ENOENT);
1038+
return ERR_PTR(-EPROBE_DEFER);
1039+
if (IS_ERR(g_pio))
1040+
return ERR_CAST(g_pio);
10391041

10401042
client = kzalloc(sizeof(*client), GFP_KERNEL);
10411043
if (!client)
@@ -1292,15 +1294,18 @@ static int rp1_pio_probe(struct platform_device *pdev)
12921294
return dev_err_probe(dev, -EPROBE_DEFER, "failed to find RP1 firmware driver\n");
12931295
if (IS_ERR(fw)) {
12941296
dev_warn(dev, "failed to contact RP1 firmware\n");
1295-
return PTR_ERR(fw);
1297+
ret = PTR_ERR(fw);
1298+
goto out_err;
12961299
}
12971300
ret = rp1_firmware_get_feature(fw, FOURCC_PIO, &op_base, &op_count);
12981301
if (ret < 0)
1299-
return ret;
1302+
goto out_err;
13001303

13011304
pio = devm_kzalloc(&pdev->dev, sizeof(*pio), GFP_KERNEL);
1302-
if (!pio)
1303-
return -ENOMEM;
1305+
if (!pio) {
1306+
ret = -ENOMEM;
1307+
goto out_err;
1308+
}
13041309

13051310
platform_set_drvdata(pdev, pio);
13061311
pio->fw_pio_base = op_base;
@@ -1311,8 +1316,10 @@ static int rp1_pio_probe(struct platform_device *pdev)
13111316
mutex_init(&pio->instr_mutex);
13121317

13131318
p = devm_platform_get_and_ioremap_resource(pdev, 0, &ioresource);
1314-
if (IS_ERR(p))
1315-
return PTR_ERR(p);
1319+
if (IS_ERR(p)) {
1320+
ret = PTR_ERR(p);
1321+
goto out_err;
1322+
}
13161323

13171324
pio->phys_addr = ioresource->start;
13181325

@@ -1359,6 +1366,7 @@ static int rp1_pio_probe(struct platform_device *pdev)
13591366
unregister_chrdev_region(pio->dev_num, 1);
13601367

13611368
out_err:
1369+
g_pio = ERR_PTR(ret);
13621370
return ret;
13631371
}
13641372

0 commit comments

Comments
 (0)