[PATCH 02/10] firmware: firmware-zynqmp: Probe driver before use

Stefan Herbrechtsmeier stefan.herbrechtsmeier-oss at weidmueller.com
Wed Jun 8 18:20:45 CEST 2022


From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier at weidmueller.com>

Probe the driver before use to ensure that the global data are valid.

Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier at weidmueller.com>
---

 drivers/firmware/firmware-zynqmp.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/firmware/firmware-zynqmp.c b/drivers/firmware/firmware-zynqmp.c
index 341d7cf135..64b0873ed0 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -281,6 +281,20 @@ U_BOOT_DRIVER(zynqmp_power) = {
 };
 #endif
 
+static int __maybe_unused do_pm_probe(void)
+{
+	struct udevice *dev;
+	int ret;
+
+	ret = uclass_get_device_by_driver(UCLASS_FIRMWARE,
+					  DM_DRIVER_GET(zynqmp_power),
+					  &dev);
+	if (ret)
+		debug("%s: Probing device failed: %d\n", __func__, ret);
+
+	return ret;
+}
+
 int __maybe_unused xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2,
 				     u32 arg3, u32 *ret_payload)
 {
@@ -296,6 +310,10 @@ int __maybe_unused xilinx_pm_request(u32 api_id, u32 arg0, u32 arg1, u32 arg2,
 		u32 regs[] = {api_id, arg0, arg1, arg2, arg3};
 		int ret;
 
+		ret = do_pm_probe();
+		if (ret)
+			return ret;
+
 		if (api_id == PM_FPGA_LOAD) {
 			/* Swap addr_hi/low because of incompatibility */
 			u32 temp = regs[1];
-- 
2.30.2



More information about the U-Boot mailing list