mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Olbrich <m.olbrich@pengutronix.de>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/2] efi-block: detect when the block device is a USB Disk
Date: Thu, 2 Nov 2017 12:03:03 +0100	[thread overview]
Message-ID: <20171102110303.xl4hdyjw2lzlrwye@pengutronix.de> (raw)
In-Reply-To: <1509087948-15969-2-git-send-email-plagnioj@jcrosoft.com>

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@jcrosoft.com>
> ---
>  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@lists.infradead.org
> 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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2017-11-02 11:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-27  7:05 [PATCH 1/2] efi-gui: add USB IO Protocol GUID definition Jean-Christophe PLAGNIOL-VILLARD
2017-10-27  7:05 ` [PATCH 2/2] efi-block: detect when the block device is a USB Disk Jean-Christophe PLAGNIOL-VILLARD
2017-11-02 11:03   ` Michael Olbrich [this message]
2017-11-03 11:27     ` Sascha Hauer
2017-10-27  8:58 ` [PATCH 1/2] efi-gui: add USB IO Protocol GUID definition Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171102110303.xl4hdyjw2lzlrwye@pengutronix.de \
    --to=m.olbrich@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=plagnioj@jcrosoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox