mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH RESEND 1/2] mci: core: remove dev_add_param_bool error paths
@ 2024-06-17 11:41 Ahmad Fatoum
  2024-06-17 11:41 ` [PATCH RESEND 2/2] mci: core: don't add broken_cd parameter for eMMCs Ahmad Fatoum
  2024-06-18  6:20 ` [PATCH RESEND 1/2] mci: core: remove dev_add_param_bool error paths Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-06-17 11:41 UTC (permalink / raw)
  To: barebox; +Cc: ske, Ahmad Fatoum

dev_add_param_bool fails when the device already has a parameter with
the same name or if there's no memory. The first error can't happen here
and the second won't go unnoticed anyway as something critical is bound
to panic.

Remove thus the error paths, which are never triggered.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> RESEND:
  - add missing prerequisite patch
---
 drivers/mci/mci-core.c | 23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 9aa0f284fdd3..d40519f124b9 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2509,7 +2509,6 @@ int mci_register(struct mci_host *host)
 {
 	struct mci *mci;
 	struct device *hw_dev;
-	struct param_d *param;
 	int ret;
 
 	mci = xzalloc(sizeof(*mci));
@@ -2554,23 +2553,11 @@ int mci_register(struct mci_host *host)
 
 	dev_info(hw_dev, "registered as %s\n", dev_name(&mci->dev));
 
-	param = dev_add_param_bool(&mci->dev, "probe", mci_set_probe, NULL,
-				   &mci->probe, mci);
+	dev_add_param_bool(&mci->dev, "probe", mci_set_probe, NULL,
+			   &mci->probe, mci);
 
-	if (IS_ERR(param) && PTR_ERR(param) != -ENOSYS) {
-		ret = PTR_ERR(param);
-		dev_dbg(&mci->dev, "Failed to add 'probe' parameter to the MCI device\n");
-		goto err_unregister;
-	}
-
-	param = dev_add_param_bool(&mci->dev, "broken_cd", NULL, NULL,
-				   &host->broken_cd, mci);
-
-	if (IS_ERR(param) && PTR_ERR(param) != -ENOSYS) {
-		ret = PTR_ERR(param);
-		dev_dbg(&mci->dev, "Failed to add 'broken_cd' parameter to the MCI device\n");
-		goto err_unregister;
-	}
+	dev_add_param_bool(&mci->dev, "broken_cd", NULL, NULL,
+			   &host->broken_cd, mci);
 
 	if (IS_ENABLED(CONFIG_MCI_INFO))
 		mci->dev.info = mci_info;
@@ -2586,8 +2573,6 @@ int mci_register(struct mci_host *host)
 
 	return 0;
 
-err_unregister:
-	unregister_device(&mci->dev);
 err_free:
 	free(mci);
 
-- 
2.39.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH RESEND 2/2] mci: core: don't add broken_cd parameter for eMMCs
  2024-06-17 11:41 [PATCH RESEND 1/2] mci: core: remove dev_add_param_bool error paths Ahmad Fatoum
@ 2024-06-17 11:41 ` Ahmad Fatoum
  2024-06-18  6:20 ` [PATCH RESEND 1/2] mci: core: remove dev_add_param_bool error paths Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2024-06-17 11:41 UTC (permalink / raw)
  To: barebox; +Cc: ske, Ahmad Fatoum

We only register the fixup for SDs, so registering the device parameter
for eMMCs serves no purpose, thus register it for SDs only as well.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/mci/mci-core.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index d40519f124b9..cb65227af208 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -2556,9 +2556,6 @@ int mci_register(struct mci_host *host)
 	dev_add_param_bool(&mci->dev, "probe", mci_set_probe, NULL,
 			   &mci->probe, mci);
 
-	dev_add_param_bool(&mci->dev, "broken_cd", NULL, NULL,
-			   &host->broken_cd, mci);
-
 	if (IS_ENABLED(CONFIG_MCI_INFO))
 		mci->dev.info = mci_info;
 
@@ -2566,8 +2563,12 @@ int mci_register(struct mci_host *host)
 	if (IS_ENABLED(CONFIG_MCI_STARTUP))
 		mci_card_probe(mci);
 
-	if (!(host->caps2 & MMC_CAP2_NO_SD) && dev_of_node(host->hw_dev))
+	if (!(host->caps2 & MMC_CAP2_NO_SD) && dev_of_node(host->hw_dev)) {
+		dev_add_param_bool(&mci->dev, "broken_cd", NULL, NULL,
+				   &host->broken_cd, mci);
+
 		of_register_fixup(of_broken_cd_fixup, host);
+	}
 
 	list_add_tail(&mci->list, &mci_list);
 
-- 
2.39.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH RESEND 1/2] mci: core: remove dev_add_param_bool error paths
  2024-06-17 11:41 [PATCH RESEND 1/2] mci: core: remove dev_add_param_bool error paths Ahmad Fatoum
  2024-06-17 11:41 ` [PATCH RESEND 2/2] mci: core: don't add broken_cd parameter for eMMCs Ahmad Fatoum
@ 2024-06-18  6:20 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2024-06-18  6:20 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum; +Cc: ske


On Mon, 17 Jun 2024 13:41:41 +0200, Ahmad Fatoum wrote:
> dev_add_param_bool fails when the device already has a parameter with
> the same name or if there's no memory. The first error can't happen here
> and the second won't go unnoticed anyway as something critical is bound
> to panic.
> 
> Remove thus the error paths, which are never triggered.
> 
> [...]

Applied, thanks!

[1/2] mci: core: remove dev_add_param_bool error paths
      https://git.pengutronix.de/cgit/barebox/commit/?id=9783270f84c4 (link may not be stable)
[2/2] mci: core: don't add broken_cd parameter for eMMCs
      https://git.pengutronix.de/cgit/barebox/commit/?id=ac46530a035c (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-18  6:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-17 11:41 [PATCH RESEND 1/2] mci: core: remove dev_add_param_bool error paths Ahmad Fatoum
2024-06-17 11:41 ` [PATCH RESEND 2/2] mci: core: don't add broken_cd parameter for eMMCs Ahmad Fatoum
2024-06-18  6:20 ` [PATCH RESEND 1/2] mci: core: remove dev_add_param_bool error paths Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox