public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port.
@ 2019-12-04 10:36 Peng Ma
  2019-12-04 10:36 ` [PATCH 2/3] ata: fsl_sata: " Peng Ma
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Peng Ma @ 2019-12-04 10:36 UTC (permalink / raw)
  To: u-boot

 In the initialization of sata driver, we want to initialize all port
 probes, Therefore, any detection failure between of them should continue
 initialization by skipping the current port instead of exit.

Signed-off-by: Peng Ma <peng.ma@nxp.com>
---
 drivers/ata/sata_sil.c | 60 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 56 insertions(+), 4 deletions(-)

diff --git a/drivers/ata/sata_sil.c b/drivers/ata/sata_sil.c
index d06d7a079d..bbba98f9a6 100644
--- a/drivers/ata/sata_sil.c
+++ b/drivers/ata/sata_sil.c
@@ -19,6 +19,7 @@
 #if CONFIG_IS_ENABLED(BLK)
 #include <dm.h>
 #include <blk.h>
+#include <dm/device-internal.h>
 #endif
 
 #include "sata_sil.h"
@@ -762,15 +763,33 @@ U_BOOT_DRIVER(sata_sil_driver) = {
 	.platdata_auto_alloc_size = sizeof(struct sil_sata_priv),
 };
 
+static int sil_unbind_device(struct udevice *dev)
+{
+	int ret;
+
+	ret = device_remove(dev, DM_REMOVE_NORMAL);
+	if (ret)
+		return ret;
+
+	ret = device_unbind(dev);
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
 static int sil_pci_probe(struct udevice *dev)
 {
 	struct udevice *blk;
+	int failed_number;
 	char sata_name[10];
 	pci_dev_t devno;
 	u16 word;
 	int ret;
 	int i;
 
+	failed_number = 0;
+
 	/* Get PCI device number */
 	devno = dm_pci_get_bdf(dev);
 	if (devno == -1)
@@ -823,12 +842,44 @@ static int sil_pci_probe(struct udevice *dev)
 		}
 
 		ret = sil_init_sata(blk, i);
-		if (ret)
-			return -ENODEV;
+		if (ret) {
+			ret = sil_unbind_device(blk);
+			if (ret)
+				return ret;
+
+			failed_number++;
+			continue;
+		}
 
 		ret = scan_sata(blk, i);
-		if (ret)
-			return -ENODEV;
+		if (ret) {
+			ret = sil_unbind_device(blk);
+			if (ret)
+				return ret;
+
+			failed_number++;
+			continue;
+		}
+	}
+
+	if (failed_number == sata_info.maxport)
+		return -ENODEV;
+	else
+		return 0;
+}
+
+static int sil_pci_remove(struct udevice *dev)
+{
+	int i;
+	struct sil_sata *sata;
+	struct sil_sata_priv *priv;
+
+	priv = dev_get_priv(dev);
+
+	for (i = sata_info.portbase; i < sata_info.maxport; i++) {
+		sata = priv->sil_sata_desc[i];
+		if (sata)
+			free(sata);
 	}
 
 	return 0;
@@ -856,6 +907,7 @@ U_BOOT_DRIVER(sil_ahci_pci) = {
 	.of_match = sil_pci_ids,
 	.ops = &sata_sil_ops,
 	.probe = sil_pci_probe,
+	.remove = sil_pci_remove,
 	.priv_auto_alloc_size = sizeof(struct sil_sata_priv),
 };
 
-- 
2.17.1

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

end of thread, other threads:[~2020-01-28  0:56 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-04 10:36 [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port Peng Ma
2019-12-04 10:36 ` [PATCH 2/3] ata: fsl_sata: " Peng Ma
2019-12-28  2:26   ` Simon Glass
2019-12-30  7:32     ` [EXT] " Peng Ma
2020-01-08 20:12   ` Tom Rini
2019-12-04 10:36 ` [PATCH 3/3] cmd: sata: Add block unbind device function Peng Ma
2019-12-28  2:26   ` Simon Glass
2019-12-30  7:19     ` [EXT] " Peng Ma
2020-01-08 20:12   ` Tom Rini
2020-01-08 21:49     ` Anatolij Gustschin
2020-01-08 21:57       ` Tom Rini
2020-01-28  0:56   ` Tom Rini
2019-12-28  2:26 ` [PATCH 1/3] ata: sata_sil: Continue probing other sata port when failed current port Simon Glass
2019-12-30  7:27   ` [EXT] " Peng Ma
2020-01-08 20:12 ` Tom Rini
2020-01-09  2:22   ` [EXT] " Peng Ma

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