Re: [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]

 



On Fri, Oct 27, 2017 at 09:05:48AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> 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.

I understand the use-case, but this breaks a different setup: Until now
'disk0' is usually the 'boot' device (the one barebox was loaded from). So
it was rather simple to create one image with bootloader, kernel and rootfs
that can be booted from USB and SATA.

Regards,
Michael

> 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
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
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