[PATCH 2/2] efi-block: detect when the block device is a USB Disk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



use usbdisk as a basename

This will be usefull as example when we want to search for a usb disk for
failsafe update or install.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@xxxxxxxxxxxx>
---
 drivers/block/efi-block-io.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/block/efi-block-io.c b/drivers/block/efi-block-io.c
index a4d9d3a95..2bbeb99e6 100644
--- a/drivers/block/efi-block-io.c
+++ b/drivers/block/efi-block-io.c
@@ -130,6 +130,18 @@ static void efi_bio_print_info(struct efi_bio_priv *priv)
 			media->optimal_transfer_length_granularity);
 }
 
+static int is_bio_usbdev(struct efi_device *efidev)
+{
+	int i;
+
+	for (i = 0; i < efidev->num_guids; i++) {
+		if (!efi_guidcmp(efidev->guids[i], EFI_USB_IO_PROTOCOL_GUID))
+			return 1;
+	}
+
+	return 0;
+}
+
 int efi_bio_probe(struct efi_device *efidev)
 {
 	int ret;
@@ -147,7 +159,10 @@ int efi_bio_probe(struct efi_device *efidev)
 	efi_bio_print_info(priv);
 	priv->dev = &efidev->dev;
 
-	priv->blk.cdev.name = xasprintf("disk%d", cdev_find_free_index("disk"));
+	if (is_bio_usbdev(efidev))
+		priv->blk.cdev.name = xasprintf("usbdisk%d", cdev_find_free_index("usbdisk"));
+	else
+		priv->blk.cdev.name = xasprintf("disk%d", cdev_find_free_index("disk"));
 	priv->blk.blockbits = ffs(media->block_size) - 1;
 	priv->blk.num_blocks = media->last_block + 1;
 	priv->blk.ops = &efi_bio_ops;
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux