summaryrefslogtreecommitdiffstats
path: root/drivers/block/efi-block-io.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/efi-block-io.c')
-rw-r--r--drivers/block/efi-block-io.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/block/efi-block-io.c b/drivers/block/efi-block-io.c
index d167d81..39dbfb0 100644
--- a/drivers/block/efi-block-io.c
+++ b/drivers/block/efi-block-io.c
@@ -14,6 +14,7 @@
#include <disks.h>
#include <efi/efi.h>
#include <efi/efi-device.h>
+#include <bootsource.h>
#define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001
#define EFI_BLOCK_IO_PROTOCOL_REVISION3 ((2<<16) | (31))
@@ -145,6 +146,7 @@ static int is_bio_usbdev(struct efi_device *efidev)
static int efi_bio_probe(struct efi_device *efidev)
{
int ret;
+ int instance;
struct efi_bio_priv *priv;
struct efi_block_io_media *media;
@@ -159,10 +161,14 @@ static int efi_bio_probe(struct efi_device *efidev)
efi_bio_print_info(priv);
priv->dev = &efidev->dev;
- 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"));
+ if (is_bio_usbdev(efidev)) {
+ instance = cdev_find_free_index("usbdisk");
+ priv->blk.cdev.name = xasprintf("usbdisk%d", instance);
+ } else {
+ instance = cdev_find_free_index("disk");
+ priv->blk.cdev.name = xasprintf("disk%d", instance);
+ }
+
priv->blk.blockbits = ffs(media->block_size) - 1;
priv->blk.num_blocks = media->last_block + 1;
priv->blk.ops = &efi_bio_ops;
@@ -174,6 +180,9 @@ static int efi_bio_probe(struct efi_device *efidev)
if (ret)
return ret;
+ if (efi_get_bootsource() == efidev)
+ bootsource_set_instance(instance);
+
parse_partition_table(&priv->blk);
return 0;