Skip to content

Commit c7596f9

Browse files
committed
firmware: microchip: fail auto-update probe if no flash found
There's no point letting the driver probe if there is no flash, as trying to do a firmware upload will fail. Move the code that attempts to get the flash from firmware upload to probe, and let it emit a message to users stating why auto-update is not supported. The code currently could have a problem if there's a flash in devicetree, but the system controller driver fails to get a pointer to it from the mtd subsystem, which will cause mpfs_sys_controller_get_flash() to return an error. Check for errors and null, instead of just null, in the new clause. CC: stable@vger.kernel.org Fixes: ec5b0f1 ("firmware: microchip: add PolarFire SoC Auto Update support") Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
1 parent 3bfc213 commit c7596f9

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

drivers/firmware/microchip/mpfs-auto-update.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ static enum fw_upload_err mpfs_auto_update_prepare(struct fw_upload *fw_uploader
113113
* be added here.
114114
*/
115115

116-
priv->flash = mpfs_sys_controller_get_flash(priv->sys_controller);
117-
if (!priv->flash)
118-
return FW_UPLOAD_ERR_HW_ERROR;
119-
120116
erase_size = round_up(erase_size, (u64)priv->flash->erasesize);
121117

122118
/*
@@ -427,6 +423,12 @@ static int mpfs_auto_update_probe(struct platform_device *pdev)
427423
return dev_err_probe(dev, PTR_ERR(priv->sys_controller),
428424
"Could not register as a sub device of the system controller\n");
429425

426+
priv->flash = mpfs_sys_controller_get_flash(priv->sys_controller);
427+
if (IS_ERR_OR_NULL(priv->flash)) {
428+
dev_dbg(dev, "No flash connected to the system controller, auto-update not supported\n");
429+
return -ENODEV;
430+
}
431+
430432
priv->dev = dev;
431433
platform_set_drvdata(pdev, priv);
432434

0 commit comments

Comments
 (0)