diff mbox series

[RFC,01/22] scsi: call device_probe() after scanning

Message ID 20211001050228.55183-3-takahiro.akashi@linaro.org
State Superseded
Headers show
Series [RFC,01/22] scsi: call device_probe() after scanning | expand

Commit Message

AKASHI Takahiro Oct. 1, 2021, 5:01 a.m. UTC
Every time a scsi bus/port is scanned and a new block device is detected,
we want to call device_probe() as it will give us a chance to run additional
post-processings for some purposes.

In particular, support for creating partitions on a device will be added.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

---
 drivers/scsi/scsi.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

-- 
2.33.0

Comments

Simon Glass Oct. 10, 2021, 2:14 p.m. UTC | #1
On Thu, 30 Sept 2021 at 23:02, AKASHI Takahiro
<takahiro.akashi@linaro.org> wrote:
>

> Every time a scsi bus/port is scanned and a new block device is detected,

> we want to call device_probe() as it will give us a chance to run additional

> post-processings for some purposes.

>

> In particular, support for creating partitions on a device will be added.

>

> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>

> ---

>  drivers/scsi/scsi.c | 10 ++++++++++

>  1 file changed, 10 insertions(+)


Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index d93d24192853..4865b5a86fd5 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -595,6 +595,16 @@  static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose)
 		ata_swap_buf_le16((u16 *)&bdesc->revision, sizeof(bd.revision) / 2);
 	}
 
+	ret = device_probe(bdev);
+	if (ret < 0) {
+		debug("Can't probe\n");
+		/* TODO: undo create */
+
+		ret = device_unbind(bdev);
+
+		return ret;
+	}
+
 	if (verbose) {
 		printf("  Device %d: ", bdesc->devnum);
 		dev_print(bdesc);