* [U-Boot] [PATCH] usb: ums - expose selected partition/s v2
@ 2016-04-11 21:00 John Tobias
2016-04-13 14:59 ` Lukasz Majewski
0 siblings, 1 reply; 3+ messages in thread
From: John Tobias @ 2016-04-11 21:00 UTC (permalink / raw)
To: u-boot
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 14eed98..0b49e87 100644
--- a/cmd/usb_mass_storage.c
+++ b/cmd/usb_mass_storage.c
@@ -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_str)
{
- char *s, *t, *devnum, *name;
+ char *s, *t, *devnum_part_str, *name;
struct blk_desc *block_dev;
+ disk_partition_t info;
+ int partnum;
int ret;
struct ums *ums_new;
- s = strdup(devnums);
+ s = strdup(devnums_part_str);
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_str = strsep(&t, ",");
+ if (!devnum_part_str)
break;
- ret = blk_get_device_by_str(devtype, devnum, &block_dev);
- if (ret < 0)
+ partnum = blk_get_device_part_str(devtype, devnum_part_str,
+ &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"
);
--
2.8.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] usb: ums - expose selected partition/s v2
2016-04-11 21:00 [U-Boot] [PATCH] usb: ums - expose selected partition/s v2 John Tobias
@ 2016-04-13 14:59 ` Lukasz Majewski
2016-04-13 15:32 ` John Tobias
0 siblings, 1 reply; 3+ messages in thread
From: Lukasz Majewski @ 2016-04-13 14:59 UTC (permalink / raw)
To: u-boot
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
During testing, I've found one issue with this code:
Traditionally the ums command was invoked as:
'ums 0 0'
or
'ums 0 mmc 0'
which exposed all SD|eMMC partitions.
Now, when I run 'ums 0 mmc 0' I can only see the first partition.
Could you add some code to preserve the legacy behavior?
I mean all partitions should be exposed when one types:
'ums 0 0' or 'ums 0 mmc 0' or '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 14eed98..0b49e87 100644
> --- a/cmd/usb_mass_storage.c
> +++ b/cmd/usb_mass_storage.c
> @@ -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_str) {
> - char *s, *t, *devnum, *name;
> + char *s, *t, *devnum_part_str, *name;
> struct blk_desc *block_dev;
> + disk_partition_t info;
> + int partnum;
> int ret;
> struct ums *ums_new;
>
> - s = strdup(devnums);
> + s = strdup(devnums_part_str);
> 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_str = strsep(&t, ",");
> + if (!devnum_part_str)
> break;
>
> - ret = blk_get_device_by_str(devtype, devnum,
> &block_dev);
> - if (ret < 0)
> + partnum = blk_get_device_part_str(devtype,
> devnum_part_str,
> + &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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] usb: ums - expose selected partition/s v2
2016-04-13 14:59 ` Lukasz Majewski
@ 2016-04-13 15:32 ` John Tobias
0 siblings, 0 replies; 3+ messages in thread
From: John Tobias @ 2016-04-13 15:32 UTC (permalink / raw)
To: u-boot
Hi Lukas,
Sure. I will fix it.
Regards,
John
On Wed, Apr 13, 2016 at 7:59 AM, Lukasz Majewski <l.majewski@samsung.com>
wrote:
> 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
>
> During testing, I've found one issue with this code:
>
> Traditionally the ums command was invoked as:
>
> 'ums 0 0'
>
> or
>
> 'ums 0 mmc 0'
>
> which exposed all SD|eMMC partitions.
>
> Now, when I run 'ums 0 mmc 0' I can only see the first partition.
>
> Could you add some code to preserve the legacy behavior?
>
> I mean all partitions should be exposed when one types:
>
> 'ums 0 0' or 'ums 0 mmc 0' or '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 14eed98..0b49e87 100644
> > --- a/cmd/usb_mass_storage.c
> > +++ b/cmd/usb_mass_storage.c
> > @@ -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_str) {
> > - char *s, *t, *devnum, *name;
> > + char *s, *t, *devnum_part_str, *name;
> > struct blk_desc *block_dev;
> > + disk_partition_t info;
> > + int partnum;
> > int ret;
> > struct ums *ums_new;
> >
> > - s = strdup(devnums);
> > + s = strdup(devnums_part_str);
> > 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_str = strsep(&t, ",");
> > + if (!devnum_part_str)
> > break;
> >
> > - ret = blk_get_device_by_str(devtype, devnum,
> > &block_dev);
> > - if (ret < 0)
> > + partnum = blk_get_device_part_str(devtype,
> > devnum_part_str,
> > + &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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-04-13 15:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-11 21:00 [U-Boot] [PATCH] usb: ums - expose selected partition/s v2 John Tobias
2016-04-13 14:59 ` Lukasz Majewski
2016-04-13 15:32 ` John Tobias
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.