public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] usb: ums - expose selected partition/s
Date: Mon, 11 Apr 2016 12:28:46 +0200	[thread overview]
Message-ID: <20160411122846.6c585cc3@amdc2363> (raw)
In-Reply-To: <1460144978-89023-1-git-send-email-john.tobias.ph@gmail.com>

Hi John,

> By applying this patch, it will give us some flexibility to expose
> a selected partition/s.
> 
> e.g:
> 1. To expose several partitions
> ums 0 mmc 0:1,0:6
> 
> 2. To expose the all partitions
> ums 0 mmc 0:0
> 
> 3. To expose multiple partititions on several devices
> ums 0 mmc 0:1,1:6
> 
> Signed-off-by: John Tobias <john.tobias.ph@gmail.com>
> ---
>  cmd/usb_mass_storage.c | 32 ++++++++++++++++++++++----------
>  1 file changed, 22 insertions(+), 10 deletions(-)
> 
> diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
> index 0415591..3e6ec50 100644
> --- a/cmd/usb_mass_storage.c
> +++ b/cmd/usb_mass_storage.c

Could you rebase this patch on top of newest mailine? 

Simon Glass did some work on this file - to be precise:

dm: Drop the block_dev_desc_t typedef
4101f6879256720b30df712089a3df18565f9203

and your patch doesn't apply anymore.

Thanks in advance,
?ukasz Majewski

> @@ -50,14 +50,16 @@ static void ums_fini(void)
>  
>  #define UMS_NAME_LEN 16
>  
> -static int ums_init(const char *devtype, const char *devnums)
> +static int ums_init(const char *devtype, const char *devnums_part)
>  {
> -	char *s, *t, *devnum, *name;
> +	char *s, *t, *devnum_part, *name;
>  	block_dev_desc_t *block_dev;
> +	disk_partition_t info;
> +	int partnum;
>  	int ret;
>  	struct ums *ums_new;
>  
> -	s = strdup(devnums);
> +	s = strdup(devnums_part);
>  	if (!s)
>  		return -1;
>  
> @@ -65,12 +67,14 @@ static int ums_init(const char *devtype, const
> char *devnums) ums_count = 0;
>  
>  	for (;;) {
> -		devnum = strsep(&t, ",");
> -		if (!devnum)
> +		devnum_part = strsep(&t, ",");
> +		if (!devnum_part)
>  			break;
>  
> -		ret = get_device(devtype, devnum, &block_dev);
> -		if (ret < 0)
> +		partnum = get_device_and_partition(devtype,
> devnum_part,
> +                &block_dev, &info, 1);
> +
> +		if (partnum < 0)
>  			goto cleanup;
>  
>  		/* f_mass_storage.c assumes SECTOR_SIZE sectors */
> @@ -86,10 +90,18 @@ static int ums_init(const char *devtype, const
> char *devnums) }
>  		ums = ums_new;
>  
> +		/* if partnum = 0, expose the whole device */
> +		if (partnum == 0) {
> +			ums[ums_count].start_sector = 0;
> +			ums[ums_count].num_sectors = block_dev->lba;
> +		} else {
> +			ums[ums_count].start_sector = info.start;
> +			ums[ums_count].num_sectors = info.size;
> +		}
> +
>  		ums[ums_count].read_sector = ums_read_sector;
>  		ums[ums_count].write_sector = ums_write_sector;
> -		ums[ums_count].start_sector = 0;
> -		ums[ums_count].num_sectors = block_dev->lba;
> +
>  		name = malloc(UMS_NAME_LEN);
>  		if (!name) {
>  			ret = -1;
> @@ -230,6 +242,6 @@ cleanup_ums_init:
>  
>  U_BOOT_CMD(ums, 4, 1, do_usb_mass_storage,
>  	"Use the UMS [USB Mass Storage]",
> -	"<USB_controller> [<devtype>] <devnum>  e.g. ums 0 mmc 0\n"
> +	"<USB_controller> [<devtype>] <dev[:part]>  e.g. ums 0 mmc
> 0:0\n" "    devtype defaults to mmc"
>  );



-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

      reply	other threads:[~2016-04-11 10:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-08 19:49 [U-Boot] [PATCH] usb: ums - expose selected partition/s John Tobias
2016-04-11 10:28 ` Lukasz Majewski [this message]

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=20160411122846.6c585cc3@amdc2363 \
    --to=l.majewski@samsung.com \
    --cc=u-boot@lists.denx.de \
    /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