Skip to content

Commit 0b939a4

Browse files
committed
firmware: rp1: Linger on firmware failure
To avoid pointless retries, let the probe function succeed if the firmware interface is configured correctly but the firmware is incompatible. The value of the private drvdata field holds the outcome. Link: raspberrypi#6642 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
1 parent cb7a24d commit 0b939a4

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

drivers/firmware/rp1.c

+11-12
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ struct rp1_firmware *rp1_firmware_get(struct device_node *client)
157157
const char *match = rp1_firmware_of_match[0].compatible;
158158
struct platform_device *pdev;
159159
struct device_node *fwnode;
160-
struct rp1_firmware *fw;
160+
struct rp1_firmware *fw = NULL;
161161

162162
if (!client)
163163
return NULL;
@@ -166,7 +166,7 @@ struct rp1_firmware *rp1_firmware_get(struct device_node *client)
166166
return NULL;
167167
if (!of_device_is_compatible(fwnode, match)) {
168168
of_node_put(fwnode);
169-
return NULL;
169+
return ERR_PTR(-ENXIO);
170170
}
171171

172172
pdev = of_find_device_by_node(fwnode);
@@ -176,7 +176,7 @@ struct rp1_firmware *rp1_firmware_get(struct device_node *client)
176176
goto err_exit;
177177

178178
fw = platform_get_drvdata(pdev);
179-
if (!fw)
179+
if (IS_ERR_OR_NULL(fw))
180180
goto err_exit;
181181

182182
if (!kref_get_unless_zero(&fw->consumers))
@@ -188,7 +188,7 @@ struct rp1_firmware *rp1_firmware_get(struct device_node *client)
188188

189189
err_exit:
190190
put_device(&pdev->dev);
191-
return NULL;
191+
return fw;
192192
}
193193
EXPORT_SYMBOL_GPL(rp1_firmware_get);
194194

@@ -204,8 +204,8 @@ struct rp1_firmware *devm_rp1_firmware_get(struct device *dev, struct device_nod
204204
int ret;
205205

206206
fw = rp1_firmware_get(client);
207-
if (!fw)
208-
return NULL;
207+
if (IS_ERR_OR_NULL(fw))
208+
return fw;
209209

210210
ret = devm_add_action_or_reset(dev, devm_rp1_firmware_put, fw);
211211
if (ret)
@@ -270,19 +270,18 @@ static int rp1_firmware_probe(struct platform_device *pdev)
270270
init_completion(&fw->c);
271271
kref_init(&fw->consumers);
272272

273-
platform_set_drvdata(pdev, fw);
274-
275273
ret = rp1_firmware_message(fw, GET_FIRMWARE_VERSION,
276274
NULL, 0, &version, sizeof(version));
277275
if (ret == sizeof(version)) {
278276
dev_info(dev, "RP1 Firmware version %08x%08x%08x%08x%08x\n",
279277
version[0], version[1], version[2], version[3], version[4]);
280-
ret = 0;
281-
} else if (ret >= 0) {
282-
ret = -EIO;
278+
platform_set_drvdata(pdev, fw);
279+
} else {
280+
kfree(fw);
281+
platform_set_drvdata(pdev, ERR_PTR(-ENOENT));
283282
}
284283

285-
return ret;
284+
return 0;
286285
}
287286

288287
static int rp1_firmware_remove(struct platform_device *pdev)

0 commit comments

Comments
 (0)