diff mbox series

[14/19] firmware: turris-mox-rwtm: Rearrange probe calls

Message ID 20240612135443.30239-15-kabel@kernel.org (mailing list archive)
State Superseded
Headers show
Series Updates for turris-mox-rwtm driver | expand

Commit Message

Marek Behún June 12, 2024, 1:54 p.m. UTC
Rearrange probe calls:
- create the kobject (and corresponding sysfs files) only after the
  mailbox is created and board info is read
- initialize the completion before mailbox channel is requested

Signed-off-by: Marek Behún <kabel@kernel.org>
---
 drivers/firmware/turris-mox-rwtm.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index 3c3f8ae23809..b9be3c806695 100644
--- a/drivers/firmware/turris-mox-rwtm.c
+++ b/drivers/firmware/turris-mox-rwtm.c
@@ -479,14 +479,10 @@  static int turris_mox_rwtm_probe(struct platform_device *pdev)
 	if (!rwtm->buf)
 		return -ENOMEM;
 
-	ret = mox_kobj_create(rwtm);
-	if (ret < 0)
-		return dev_err_probe(dev, ret,
-				     "Cannot create turris-mox-rwtm kobject!\n");
-
 	platform_set_drvdata(pdev, rwtm);
 
 	mutex_init(&rwtm->busy);
+	init_completion(&rwtm->cmd_done);
 
 	rwtm->mbox_client.dev = dev;
 	rwtm->mbox_client.rx_callback = mox_rwtm_rx_callback;
@@ -505,12 +501,15 @@  static int turris_mox_rwtm_probe(struct platform_device *pdev)
 	if (ret < 0)
 		return ret;
 
-	init_completion(&rwtm->cmd_done);
-
 	ret = mox_get_board_info(rwtm);
 	if (ret < 0)
 		dev_warn(dev, "Cannot read board information: %i\n", ret);
 
+	ret = mox_kobj_create(rwtm);
+	if (ret < 0)
+		return dev_err_probe(dev, ret,
+				     "Cannot create turris-mox-rwtm kobject!\n");
+
 	ret = check_get_random_support(rwtm);
 	if (ret < 0) {
 		dev_notice(dev,