All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/8] ums: support block devices not MMC devices
@ 2014-04-30 21:13 Stephen Warren
  2014-04-30 21:13 ` [U-Boot] [PATCH 2/8] ums: remove UMS_{NUM, START}_SECTORS + UMS_START_SECTOR Stephen Warren
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Stephen Warren @ 2014-04-30 21:13 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

The USB Mass Storage function could equally well support a SATA device
as support an MMC device. Update struct ums to contain a block device
descriptor, not an MMC device descriptor.

Cc: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 board/samsung/common/ums.c | 7 ++++---
 include/usb_mass_storage.h | 4 ++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/board/samsung/common/ums.c b/board/samsung/common/ums.c
index dc155ad0e5b3..60e7d2a2bd6e 100644
--- a/board/samsung/common/ums.c
+++ b/board/samsung/common/ums.c
@@ -7,12 +7,13 @@
 
 #include <common.h>
 #include <usb_mass_storage.h>
+#include <mmc.h>
 #include <part.h>
 
 static int ums_read_sector(struct ums *ums_dev,
 			   ulong start, lbaint_t blkcnt, void *buf)
 {
-	block_dev_desc_t *block_dev = &ums_dev->mmc->block_dev;
+	block_dev_desc_t *block_dev = ums_dev->block_dev;
 	lbaint_t blkstart = start + ums_dev->start_sector;
 	int dev_num = block_dev->dev;
 
@@ -22,7 +23,7 @@ static int ums_read_sector(struct ums *ums_dev,
 static int ums_write_sector(struct ums *ums_dev,
 			    ulong start, lbaint_t blkcnt, const void *buf)
 {
-	block_dev_desc_t *block_dev = &ums_dev->mmc->block_dev;
+	block_dev_desc_t *block_dev = ums_dev->block_dev;
 	lbaint_t blkstart = start + ums_dev->start_sector;
 	int dev_num = block_dev->dev;
 
@@ -45,7 +46,7 @@ static struct ums *ums_disk_init(struct mmc *mmc)
 		return NULL;
 	}
 
-	ums_dev.mmc = mmc;
+	ums_dev.block_dev = &mmc->block_dev;
 
 	if (ums_end_sector <= mmc_end_sector) {
 		ums_dev.start_sector = UMS_START_SECTOR;
diff --git a/include/usb_mass_storage.h b/include/usb_mass_storage.h
index 058dcf117404..12fbae447c09 100644
--- a/include/usb_mass_storage.h
+++ b/include/usb_mass_storage.h
@@ -9,7 +9,7 @@
 #define __USB_MASS_STORAGE_H__
 
 #define SECTOR_SIZE		0x200
-#include <mmc.h>
+#include <part.h>
 #include <linux/usb/composite.h>
 
 #ifndef UMS_START_SECTOR
@@ -31,7 +31,7 @@ struct ums {
 	unsigned int start_sector;
 	unsigned int num_sectors;
 	const char *name;
-	struct mmc *mmc;
+	block_dev_desc_t *block_dev;
 };
 
 extern struct ums *ums;
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 2/8] ums: remove UMS_{NUM, START}_SECTORS + UMS_START_SECTOR
  2014-04-30 21:13 [U-Boot] [PATCH 1/8] ums: support block devices not MMC devices Stephen Warren
@ 2014-04-30 21:13 ` Stephen Warren
  2014-04-30 21:13 ` [U-Boot] [PATCH 3/8] ums: remove error-checking of MMC device size Stephen Warren
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Stephen Warren @ 2014-04-30 21:13 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

These values aren't set anywhere at present, and hence have no effect.
The concept of a single global offset/number of sectors to expose through
USB Mass Storage doesn't even make sense in the face of multiple storage
devices. Remove these defines to simplify the code.

Cc: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 board/samsung/common/ums.c | 14 ++------------
 include/usb_mass_storage.h |  8 --------
 2 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/board/samsung/common/ums.c b/board/samsung/common/ums.c
index 60e7d2a2bd6e..d78c8e763a5d 100644
--- a/board/samsung/common/ums.c
+++ b/board/samsung/common/ums.c
@@ -39,7 +39,6 @@ static struct ums ums_dev = {
 static struct ums *ums_disk_init(struct mmc *mmc)
 {
 	uint64_t mmc_end_sector = mmc->capacity / SECTOR_SIZE;
-	uint64_t ums_end_sector = UMS_NUM_SECTORS + UMS_START_SECTOR;
 
 	if (!mmc_end_sector) {
 		error("MMC capacity is not valid");
@@ -47,17 +46,8 @@ static struct ums *ums_disk_init(struct mmc *mmc)
 	}
 
 	ums_dev.block_dev = &mmc->block_dev;
-
-	if (ums_end_sector <= mmc_end_sector) {
-		ums_dev.start_sector = UMS_START_SECTOR;
-		if (UMS_NUM_SECTORS)
-			ums_dev.num_sectors = UMS_NUM_SECTORS;
-		else
-			ums_dev.num_sectors = mmc_end_sector - UMS_START_SECTOR;
-	} else {
-		ums_dev.num_sectors = mmc_end_sector;
-		puts("UMS: defined bad disk parameters. Using default.\n");
-	}
+	ums_dev.start_sector = 0;
+	ums_dev.num_sectors = mmc_end_sector;
 
 	printf("UMS: disk start sector: %#x, count: %#x\n",
 	       ums_dev.start_sector, ums_dev.num_sectors);
diff --git a/include/usb_mass_storage.h b/include/usb_mass_storage.h
index 12fbae447c09..6fcc51d1264d 100644
--- a/include/usb_mass_storage.h
+++ b/include/usb_mass_storage.h
@@ -12,14 +12,6 @@
 #include <part.h>
 #include <linux/usb/composite.h>
 
-#ifndef UMS_START_SECTOR
-#define UMS_START_SECTOR	0
-#endif
-
-#ifndef UMS_NUM_SECTORS
-#define UMS_NUM_SECTORS		0
-#endif
-
 /* Wait at maximum 60 seconds for cable connection */
 #define UMS_CABLE_READY_TIMEOUT	60
 
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 3/8] ums: remove error-checking of MMC device size
  2014-04-30 21:13 [U-Boot] [PATCH 1/8] ums: support block devices not MMC devices Stephen Warren
  2014-04-30 21:13 ` [U-Boot] [PATCH 2/8] ums: remove UMS_{NUM, START}_SECTORS + UMS_START_SECTOR Stephen Warren
@ 2014-04-30 21:13 ` Stephen Warren
  2014-05-01 20:00   ` Stephen Warren
  2014-04-30 21:13 ` [U-Boot] [PATCH 4/8] ums: remove ums_disk_init() Stephen Warren
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Stephen Warren @ 2014-04-30 21:13 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

There's no reason to believe that an MMC device will incorrectly report
its capacity. Remove error checking of this value from ums_disk_init()
to simplify it.

Cc: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 board/samsung/common/ums.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/board/samsung/common/ums.c b/board/samsung/common/ums.c
index d78c8e763a5d..14e3640e355f 100644
--- a/board/samsung/common/ums.c
+++ b/board/samsung/common/ums.c
@@ -38,16 +38,9 @@ static struct ums ums_dev = {
 
 static struct ums *ums_disk_init(struct mmc *mmc)
 {
-	uint64_t mmc_end_sector = mmc->capacity / SECTOR_SIZE;
-
-	if (!mmc_end_sector) {
-		error("MMC capacity is not valid");
-		return NULL;
-	}
-
 	ums_dev.block_dev = &mmc->block_dev;
 	ums_dev.start_sector = 0;
-	ums_dev.num_sectors = mmc_end_sector;
+	ums_dev.num_sectors = mmc->capacity / SECTOR_SIZE;
 
 	printf("UMS: disk start sector: %#x, count: %#x\n",
 	       ums_dev.start_sector, ums_dev.num_sectors);
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 4/8] ums: remove ums_disk_init()
  2014-04-30 21:13 [U-Boot] [PATCH 1/8] ums: support block devices not MMC devices Stephen Warren
  2014-04-30 21:13 ` [U-Boot] [PATCH 2/8] ums: remove UMS_{NUM, START}_SECTORS + UMS_START_SECTOR Stephen Warren
  2014-04-30 21:13 ` [U-Boot] [PATCH 3/8] ums: remove error-checking of MMC device size Stephen Warren
@ 2014-04-30 21:13 ` Stephen Warren
  2014-04-30 21:13 ` [U-Boot] [PATCH 5/8] ums: move IO support code to common location Stephen Warren
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Stephen Warren @ 2014-04-30 21:13 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

Now that ums_disk_init() is so simple, there's no need for it to be a
separate function. Instead, just add it to the tail end of ums_init().

Cc: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 board/samsung/common/ums.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/board/samsung/common/ums.c b/board/samsung/common/ums.c
index 14e3640e355f..68b9f26cac4e 100644
--- a/board/samsung/common/ums.c
+++ b/board/samsung/common/ums.c
@@ -36,8 +36,14 @@ static struct ums ums_dev = {
 	.name = "UMS disk",
 };
 
-static struct ums *ums_disk_init(struct mmc *mmc)
+struct ums *ums_init(unsigned int dev_num)
 {
+	struct mmc *mmc = NULL;
+
+	mmc = find_mmc_device(dev_num);
+	if (!mmc)
+		return NULL;
+
 	ums_dev.block_dev = &mmc->block_dev;
 	ums_dev.start_sector = 0;
 	ums_dev.num_sectors = mmc->capacity / SECTOR_SIZE;
@@ -47,14 +53,3 @@ static struct ums *ums_disk_init(struct mmc *mmc)
 
 	return &ums_dev;
 }
-
-struct ums *ums_init(unsigned int dev_num)
-{
-	struct mmc *mmc = NULL;
-
-	mmc = find_mmc_device(dev_num);
-	if (!mmc)
-		return NULL;
-
-	return ums_disk_init(mmc);
-}
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 5/8] ums: move IO support code to common location
  2014-04-30 21:13 [U-Boot] [PATCH 1/8] ums: support block devices not MMC devices Stephen Warren
                   ` (2 preceding siblings ...)
  2014-04-30 21:13 ` [U-Boot] [PATCH 4/8] ums: remove ums_disk_init() Stephen Warren
@ 2014-04-30 21:13 ` Stephen Warren
  2014-04-30 21:13 ` [U-Boot] [PATCH 6/8] ums: use get_device() not find_mmc_device(); Stephen Warren
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Stephen Warren @ 2014-04-30 21:13 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

There's nothing Samsung-/board-specfic about the implementation of
ums_init(). Move the code into cmd_usb_mass_storage.c, so that it can
be shared by any user of that command.

Cc: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 board/samsung/common/Makefile |  1 -
 board/samsung/common/ums.c    | 55 -------------------------------------------
 common/cmd_usb_mass_storage.c | 46 ++++++++++++++++++++++++++++++++++++
 include/usb_mass_storage.h    |  1 -
 4 files changed, 46 insertions(+), 57 deletions(-)
 delete mode 100644 board/samsung/common/ums.c

diff --git a/board/samsung/common/Makefile b/board/samsung/common/Makefile
index 7d2bb8c4a2f3..41d0cc381494 100644
--- a/board/samsung/common/Makefile
+++ b/board/samsung/common/Makefile
@@ -7,7 +7,6 @@
 
 obj-$(CONFIG_SOFT_I2C_MULTI_BUS) += multi_i2c.o
 obj-$(CONFIG_THOR_FUNCTION) += thor.o
-obj-$(CONFIG_CMD_USB_MASS_STORAGE) += ums.o
 obj-$(CONFIG_MISC_COMMON) += misc.o
 
 ifndef CONFIG_SPL_BUILD
diff --git a/board/samsung/common/ums.c b/board/samsung/common/ums.c
deleted file mode 100644
index 68b9f26cac4e..000000000000
--- a/board/samsung/common/ums.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2013 Samsung Electronics
- * Lukasz Majewski <l.majewski@samsung.com>
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#include <common.h>
-#include <usb_mass_storage.h>
-#include <mmc.h>
-#include <part.h>
-
-static int ums_read_sector(struct ums *ums_dev,
-			   ulong start, lbaint_t blkcnt, void *buf)
-{
-	block_dev_desc_t *block_dev = ums_dev->block_dev;
-	lbaint_t blkstart = start + ums_dev->start_sector;
-	int dev_num = block_dev->dev;
-
-	return block_dev->block_read(dev_num, blkstart, blkcnt, buf);
-}
-
-static int ums_write_sector(struct ums *ums_dev,
-			    ulong start, lbaint_t blkcnt, const void *buf)
-{
-	block_dev_desc_t *block_dev = ums_dev->block_dev;
-	lbaint_t blkstart = start + ums_dev->start_sector;
-	int dev_num = block_dev->dev;
-
-	return block_dev->block_write(dev_num, blkstart, blkcnt, buf);
-}
-
-static struct ums ums_dev = {
-	.read_sector = ums_read_sector,
-	.write_sector = ums_write_sector,
-	.name = "UMS disk",
-};
-
-struct ums *ums_init(unsigned int dev_num)
-{
-	struct mmc *mmc = NULL;
-
-	mmc = find_mmc_device(dev_num);
-	if (!mmc)
-		return NULL;
-
-	ums_dev.block_dev = &mmc->block_dev;
-	ums_dev.start_sector = 0;
-	ums_dev.num_sectors = mmc->capacity / SECTOR_SIZE;
-
-	printf("UMS: disk start sector: %#x, count: %#x\n",
-	       ums_dev.start_sector, ums_dev.num_sectors);
-
-	return &ums_dev;
-}
diff --git a/common/cmd_usb_mass_storage.c b/common/cmd_usb_mass_storage.c
index 2f69a53acc67..5ec5da6d4f04 100644
--- a/common/cmd_usb_mass_storage.c
+++ b/common/cmd_usb_mass_storage.c
@@ -9,9 +9,55 @@
 #include <common.h>
 #include <command.h>
 #include <g_dnl.h>
+#include <mmc.h>
+#include <part.h>
 #include <usb.h>
 #include <usb_mass_storage.h>
 
+static int ums_read_sector(struct ums *ums_dev,
+			   ulong start, lbaint_t blkcnt, void *buf)
+{
+	block_dev_desc_t *block_dev = ums_dev->block_dev;
+	lbaint_t blkstart = start + ums_dev->start_sector;
+	int dev_num = block_dev->dev;
+
+	return block_dev->block_read(dev_num, blkstart, blkcnt, buf);
+}
+
+static int ums_write_sector(struct ums *ums_dev,
+			    ulong start, lbaint_t blkcnt, const void *buf)
+{
+	block_dev_desc_t *block_dev = ums_dev->block_dev;
+	lbaint_t blkstart = start + ums_dev->start_sector;
+	int dev_num = block_dev->dev;
+
+	return block_dev->block_write(dev_num, blkstart, blkcnt, buf);
+}
+
+static struct ums ums_dev = {
+	.read_sector = ums_read_sector,
+	.write_sector = ums_write_sector,
+	.name = "UMS disk",
+};
+
+struct ums *ums_init(unsigned int dev_num)
+{
+	struct mmc *mmc = NULL;
+
+	mmc = find_mmc_device(dev_num);
+	if (!mmc)
+		return NULL;
+
+	ums_dev.block_dev = &mmc->block_dev;
+	ums_dev.start_sector = 0;
+	ums_dev.num_sectors = mmc->capacity / SECTOR_SIZE;
+
+	printf("UMS: disk start sector: %#x, count: %#x\n",
+	       ums_dev.start_sector, ums_dev.num_sectors);
+
+	return &ums_dev;
+}
+
 int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
 			       int argc, char * const argv[])
 {
diff --git a/include/usb_mass_storage.h b/include/usb_mass_storage.h
index 6fcc51d1264d..ce0af27d51cf 100644
--- a/include/usb_mass_storage.h
+++ b/include/usb_mass_storage.h
@@ -30,7 +30,6 @@ extern struct ums *ums;
 
 int fsg_init(struct ums *);
 void fsg_cleanup(void);
-struct ums *ums_init(unsigned int);
 int fsg_main_thread(void *);
 
 #ifdef CONFIG_USB_GADGET_MASS_STORAGE
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 6/8] ums: use get_device() not find_mmc_device();
  2014-04-30 21:13 [U-Boot] [PATCH 1/8] ums: support block devices not MMC devices Stephen Warren
                   ` (3 preceding siblings ...)
  2014-04-30 21:13 ` [U-Boot] [PATCH 5/8] ums: move IO support code to common location Stephen Warren
@ 2014-04-30 21:13 ` Stephen Warren
  2014-04-30 21:13 ` [U-Boot] [PATCH 7/8] ums: move all variable declarations to the start of the block Stephen Warren
  2014-04-30 21:13 ` [U-Boot] [PATCH 8/8] ums: allow the user to specify the device type Stephen Warren
  6 siblings, 0 replies; 16+ messages in thread
From: Stephen Warren @ 2014-04-30 21:13 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

get_device() is a generic routine that will support any type of block
device. Use this instead of the type-specific find_mmc_device(), for
future flexibility.

Cc: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 common/cmd_usb_mass_storage.c | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/common/cmd_usb_mass_storage.c b/common/cmd_usb_mass_storage.c
index 5ec5da6d4f04..b08f1e5be141 100644
--- a/common/cmd_usb_mass_storage.c
+++ b/common/cmd_usb_mass_storage.c
@@ -9,7 +9,6 @@
 #include <common.h>
 #include <command.h>
 #include <g_dnl.h>
-#include <mmc.h>
 #include <part.h>
 #include <usb.h>
 #include <usb_mass_storage.h>
@@ -40,17 +39,22 @@ static struct ums ums_dev = {
 	.name = "UMS disk",
 };
 
-struct ums *ums_init(unsigned int dev_num)
+struct ums *ums_init(const char *devtype, const char *devnum)
 {
-	struct mmc *mmc = NULL;
+	block_dev_desc_t *block_dev;
+	int ret;
 
-	mmc = find_mmc_device(dev_num);
-	if (!mmc)
+	ret = get_device(devtype, devnum, &block_dev);
+	if (ret < 0)
 		return NULL;
 
-	ums_dev.block_dev = &mmc->block_dev;
+	/* f_mass_storage.c assumes SECTOR_SIZE sectors */
+	if (block_dev->blksz != SECTOR_SIZE)
+		return NULL;
+
+	ums_dev.block_dev = block_dev;
 	ums_dev.start_sector = 0;
-	ums_dev.num_sectors = mmc->capacity / SECTOR_SIZE;
+	ums_dev.num_sectors = block_dev->lba;
 
 	printf("UMS: disk start sector: %#x, count: %#x\n",
 	       ums_dev.start_sector, ums_dev.num_sectors);
@@ -65,11 +69,10 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
 		return CMD_RET_USAGE;
 
 	const char *usb_controller = argv[1];
-	const char *mmc_devstring  = argv[2];
-
-	unsigned int dev_num = simple_strtoul(mmc_devstring, NULL, 0);
+	const char *devtype = "mmc";
+	const char *devnum  = argv[2];
 
-	struct ums *ums = ums_init(dev_num);
+	struct ums *ums = ums_init(devtype, devnum);
 	if (!ums)
 		return CMD_RET_FAILURE;
 
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 7/8] ums: move all variable declarations to the start of the block
  2014-04-30 21:13 [U-Boot] [PATCH 1/8] ums: support block devices not MMC devices Stephen Warren
                   ` (4 preceding siblings ...)
  2014-04-30 21:13 ` [U-Boot] [PATCH 6/8] ums: use get_device() not find_mmc_device(); Stephen Warren
@ 2014-04-30 21:13 ` Stephen Warren
  2014-05-01 10:51   ` Marek Vasut
  2014-04-30 21:13 ` [U-Boot] [PATCH 8/8] ums: allow the user to specify the device type Stephen Warren
  6 siblings, 1 reply; 16+ messages in thread
From: Stephen Warren @ 2014-04-30 21:13 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

It's easier to assign values to the variables inside an if statement body
if the assignment and declaration are separate.

Cc: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 common/cmd_usb_mass_storage.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/common/cmd_usb_mass_storage.c b/common/cmd_usb_mass_storage.c
index b08f1e5be141..31dd37c7c66f 100644
--- a/common/cmd_usb_mass_storage.c
+++ b/common/cmd_usb_mass_storage.c
@@ -65,25 +65,33 @@ struct ums *ums_init(const char *devtype, const char *devnum)
 int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
 			       int argc, char * const argv[])
 {
+	const char *usb_controller;
+	const char *devtype;
+	const char *devnum;
+	struct ums *ums;
+	unsigned int controller_index;
+	int rc;
+	int cable_ready_timeout __maybe_unused;
+
 	if (argc < 3)
 		return CMD_RET_USAGE;
 
-	const char *usb_controller = argv[1];
-	const char *devtype = "mmc";
-	const char *devnum  = argv[2];
+	usb_controller = argv[1];
+	devtype = "mmc";
+	devnum  = argv[2];
 
-	struct ums *ums = ums_init(devtype, devnum);
+	ums = ums_init(devtype, devnum);
 	if (!ums)
 		return CMD_RET_FAILURE;
 
-	unsigned int controller_index = (unsigned int)(simple_strtoul(
-					usb_controller,	NULL, 0));
+	controller_index = (unsigned int)(simple_strtoul(
+				usb_controller,	NULL, 0));
 	if (board_usb_init(controller_index, USB_INIT_DEVICE)) {
 		error("Couldn't init USB controller.");
 		return CMD_RET_FAILURE;
 	}
 
-	int rc = fsg_init(ums);
+	rc = fsg_init(ums);
 	if (rc) {
 		error("fsg_init failed");
 		return CMD_RET_FAILURE;
@@ -93,7 +101,7 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
 
 #ifdef CONFIG_USB_CABLE_CHECK
 	/* Timeout unit: seconds */
-	int cable_ready_timeout = UMS_CABLE_READY_TIMEOUT;
+	cable_ready_timeout = UMS_CABLE_READY_TIMEOUT;
 
 	if (!usb_cable_connected()) {
 		puts("Please connect USB cable.\n");
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 8/8] ums: allow the user to specify the device type
  2014-04-30 21:13 [U-Boot] [PATCH 1/8] ums: support block devices not MMC devices Stephen Warren
                   ` (5 preceding siblings ...)
  2014-04-30 21:13 ` [U-Boot] [PATCH 7/8] ums: move all variable declarations to the start of the block Stephen Warren
@ 2014-04-30 21:13 ` Stephen Warren
  6 siblings, 0 replies; 16+ messages in thread
From: Stephen Warren @ 2014-04-30 21:13 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

Allow an optional devtype parameter to the ums command, which specifies
the type of the device to be exported. This could allow exporting a SATA
or even another USB device.

Cc: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 common/cmd_usb_mass_storage.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/common/cmd_usb_mass_storage.c b/common/cmd_usb_mass_storage.c
index 31dd37c7c66f..2ef5c0912e9c 100644
--- a/common/cmd_usb_mass_storage.c
+++ b/common/cmd_usb_mass_storage.c
@@ -77,8 +77,13 @@ int do_usb_mass_storage(cmd_tbl_t *cmdtp, int flag,
 		return CMD_RET_USAGE;
 
 	usb_controller = argv[1];
-	devtype = "mmc";
-	devnum  = argv[2];
+	if (argc >= 4) {
+		devtype = argv[2];
+		devnum  = argv[3];
+	} else {
+		devtype = "mmc";
+		devnum  = argv[2];
+	}
 
 	ums = ums_init(devtype, devnum);
 	if (!ums)
@@ -146,7 +151,8 @@ exit:
 	return CMD_RET_SUCCESS;
 }
 
-U_BOOT_CMD(ums, CONFIG_SYS_MAXARGS, 1, do_usb_mass_storage,
+U_BOOT_CMD(ums, 4, 1, do_usb_mass_storage,
 	"Use the UMS [User Mass Storage]",
-	"ums <USB_controller> <mmc_dev>  e.g. ums 0 0"
+	"ums <USB_controller> [<devtype>] <devnum>  e.g. ums 0 mmc 0\n"
+	"    devtype defaults to mmc"
 );
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 7/8] ums: move all variable declarations to the start of the block
  2014-04-30 21:13 ` [U-Boot] [PATCH 7/8] ums: move all variable declarations to the start of the block Stephen Warren
@ 2014-05-01 10:51   ` Marek Vasut
  2014-05-01 16:58     ` Stephen Warren
  0 siblings, 1 reply; 16+ messages in thread
From: Marek Vasut @ 2014-05-01 10:51 UTC (permalink / raw)
  To: u-boot

On Wednesday, April 30, 2014 at 11:13:21 PM, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> It's easier to assign values to the variables inside an if statement body
> if the assignment and declaration are separate.
> 
> Cc: Przemyslaw Marczak <p.marczak@samsung.com>
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
>  common/cmd_usb_mass_storage.c | 24 ++++++++++++++++--------
>  1 file changed, 16 insertions(+), 8 deletions(-)

This doesn't apply on u-boot-usb/master, sorry.

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 7/8] ums: move all variable declarations to the start of the block
  2014-05-01 10:51   ` Marek Vasut
@ 2014-05-01 16:58     ` Stephen Warren
  2014-05-01 19:43       ` Lukasz Majewski
  2014-05-02  4:45       ` Marek Vasut
  0 siblings, 2 replies; 16+ messages in thread
From: Stephen Warren @ 2014-05-01 16:58 UTC (permalink / raw)
  To: u-boot

On 05/01/2014 04:51 AM, Marek Vasut wrote:
> On Wednesday, April 30, 2014 at 11:13:21 PM, Stephen Warren wrote:
>> From: Stephen Warren <swarren@nvidia.com>
>>
>> It's easier to assign values to the variables inside an if statement body
>> if the assignment and declaration are separate.
>>
>> Cc: Przemyslaw Marczak <p.marczak@samsung.com>
>> Cc: Lukasz Majewski <l.majewski@samsung.com>
>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>> ---
>>  common/cmd_usb_mass_storage.c | 24 ++++++++++++++++--------
>>  1 file changed, 16 insertions(+), 8 deletions(-)
> 
> This doesn't apply on u-boot-usb/master, sorry.

Is this the first patch in the series which doesn't apply? Did you apply
any of the earlier patches? I guess I'll go try to rebase the series and
find out myself...

This is why we need a "uboot-next" just like linux-next, and stricter
controls on which git repos take patches that touch subsystem code, to
avoid cross-repo conflicts:-(

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 7/8] ums: move all variable declarations to the start of the block
  2014-05-01 16:58     ` Stephen Warren
@ 2014-05-01 19:43       ` Lukasz Majewski
  2014-05-01 21:47         ` Stephen Warren
  2014-05-02  4:45       ` Marek Vasut
  1 sibling, 1 reply; 16+ messages in thread
From: Lukasz Majewski @ 2014-05-01 19:43 UTC (permalink / raw)
  To: u-boot

Hi Stephen,

> 
> On 05/01/2014 04:51 AM, Marek Vasut wrote:
> > On Wednesday, April 30, 2014 at 11:13:21 PM, Stephen Warren wrote:
> >> From: Stephen Warren <swarren@nvidia.com>
> >>
> >> It's easier to assign values to the variables inside an if
> >> statement body if the assignment and declaration are separate.
> >>
> >> Cc: Przemyslaw Marczak <p.marczak@samsung.com>
> >> Cc: Lukasz Majewski <l.majewski@samsung.com>
> >> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> >> ---
> >>  common/cmd_usb_mass_storage.c | 24 ++++++++++++++++--------
> >>  1 file changed, 16 insertions(+), 8 deletions(-)
> > 
> > This doesn't apply on u-boot-usb/master, sorry.
> 
> Is this the first patch in the series which doesn't apply? Did you
> apply any of the earlier patches? I guess I'll go try to rebase the
> series and find out myself...
> 
> This is why we need a "uboot-next" just like linux-next, and stricter
> controls on which git repos take patches that touch subsystem code, to
> avoid cross-repo conflicts:-(

+1

Yesterday Marek and I agreed that some patches regarding DFU and
gadgets (patches 1 to 8) done by Mateusz:

http://patchwork.ozlabs.org/patch/343517/

will be go through u-boot-dfu tree, which will be rebased on top of
u-boot-usb tree. Afterwards I will send PR to Marek.

Unfortunately I didn't manage to add them to u-boot-denx tree yesterday.
I will do it on Monday as well as the review regarding your ums work. I
hope, that you can wait until then.


Best regards,
Lukasz Majewski

> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140501/506ce407/attachment.pgp>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 3/8] ums: remove error-checking of MMC device size
  2014-04-30 21:13 ` [U-Boot] [PATCH 3/8] ums: remove error-checking of MMC device size Stephen Warren
@ 2014-05-01 20:00   ` Stephen Warren
  0 siblings, 0 replies; 16+ messages in thread
From: Stephen Warren @ 2014-05-01 20:00 UTC (permalink / raw)
  To: u-boot

On 04/30/2014 03:13 PM, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> There's no reason to believe that an MMC device will incorrectly report
> its capacity. Remove error checking of this value from ums_disk_init()
> to simplify it.

Hmm. I guess this check might trigger if you tried to export an SD card
slot over UMS, yet there was no SD card present. Still, patch 6/8 in
this series resolves this, since at least for MMC devices, get_device()
calls mmc_init() internally, and hence returns an error in this case.
This is more direct that checking the device size.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 7/8] ums: move all variable declarations to the start of the block
  2014-05-01 19:43       ` Lukasz Majewski
@ 2014-05-01 21:47         ` Stephen Warren
  2014-05-05  9:16           ` Przemyslaw Marczak
  0 siblings, 1 reply; 16+ messages in thread
From: Stephen Warren @ 2014-05-01 21:47 UTC (permalink / raw)
  To: u-boot

On 05/01/2014 01:43 PM, Lukasz Majewski wrote:
> Hi Stephen,
> 
>>
>> On 05/01/2014 04:51 AM, Marek Vasut wrote:
>>> On Wednesday, April 30, 2014 at 11:13:21 PM, Stephen Warren wrote:
>>>> From: Stephen Warren <swarren@nvidia.com>
>>>>
>>>> It's easier to assign values to the variables inside an if
>>>> statement body if the assignment and declaration are separate.
>>>>
>>>> Cc: Przemyslaw Marczak <p.marczak@samsung.com>
>>>> Cc: Lukasz Majewski <l.majewski@samsung.com>
>>>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>>>> ---
>>>>  common/cmd_usb_mass_storage.c | 24 ++++++++++++++++--------
>>>>  1 file changed, 16 insertions(+), 8 deletions(-)
>>>
>>> This doesn't apply on u-boot-usb/master, sorry.
>>
>> Is this the first patch in the series which doesn't apply? Did you
>> apply any of the earlier patches? I guess I'll go try to rebase the
>> series and find out myself...
>>
>> This is why we need a "uboot-next" just like linux-next, and stricter
>> controls on which git repos take patches that touch subsystem code, to
>> avoid cross-repo conflicts:-(
> 
> +1
> 
> Yesterday Marek and I agreed that some patches regarding DFU and
> gadgets (patches 1 to 8) done by Mateusz:
> 
> http://patchwork.ozlabs.org/patch/343517/
> 
> will be go through u-boot-dfu tree, which will be rebased on top of
> u-boot-usb tree. Afterwards I will send PR to Marek.
> 
> Unfortunately I didn't manage to add them to u-boot-denx tree yesterday.
> I will do it on Monday as well as the review regarding your ums work. I
> hope, that you can wait until then.

OK, that's fine.

FWIW, I have applied that series locally and rebased my patches on top
of it. If you want to see the latest version, feel free to look at:

git://github.com/swarren/u-boot.git tegra_dev

Note that branch gets rebased as I do local development.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 7/8] ums: move all variable declarations to the start of the block
  2014-05-01 16:58     ` Stephen Warren
  2014-05-01 19:43       ` Lukasz Majewski
@ 2014-05-02  4:45       ` Marek Vasut
  1 sibling, 0 replies; 16+ messages in thread
From: Marek Vasut @ 2014-05-02  4:45 UTC (permalink / raw)
  To: u-boot

On Thursday, May 01, 2014 at 06:58:50 PM, Stephen Warren wrote:
> On 05/01/2014 04:51 AM, Marek Vasut wrote:
> > On Wednesday, April 30, 2014 at 11:13:21 PM, Stephen Warren wrote:
> >> From: Stephen Warren <swarren@nvidia.com>
> >> 
> >> It's easier to assign values to the variables inside an if statement
> >> body if the assignment and declaration are separate.
> >> 
> >> Cc: Przemyslaw Marczak <p.marczak@samsung.com>
> >> Cc: Lukasz Majewski <l.majewski@samsung.com>
> >> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> >> ---
> >> 
> >>  common/cmd_usb_mass_storage.c | 24 ++++++++++++++++--------
> >>  1 file changed, 16 insertions(+), 8 deletions(-)
> > 
> > This doesn't apply on u-boot-usb/master, sorry.
> 
> Is this the first patch in the series which doesn't apply? Did you apply
> any of the earlier patches? I guess I'll go try to rebase the series and
> find out myself...

7/8 doesn't apply .

> This is why we need a "uboot-next" just like linux-next, and stricter
> controls on which git repos take patches that touch subsystem code, to
> avoid cross-repo conflicts:-(

Yep, u-boot-next would be nice and so would be u-boot-stable . Volunteers 
welcome ;-)

Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 7/8] ums: move all variable declarations to the start of the block
  2014-05-01 21:47         ` Stephen Warren
@ 2014-05-05  9:16           ` Przemyslaw Marczak
  2014-05-05 16:33             ` Stephen Warren
  0 siblings, 1 reply; 16+ messages in thread
From: Przemyslaw Marczak @ 2014-05-05  9:16 UTC (permalink / raw)
  To: u-boot

Hello Stephen,

On 05/01/2014 11:47 PM, Stephen Warren wrote:
> On 05/01/2014 01:43 PM, Lukasz Majewski wrote:
>> Hi Stephen,
>>
>>>
>>> On 05/01/2014 04:51 AM, Marek Vasut wrote:
>>>> On Wednesday, April 30, 2014 at 11:13:21 PM, Stephen Warren wrote:
>>>>> From: Stephen Warren <swarren@nvidia.com>
>>>>>
>>>>> It's easier to assign values to the variables inside an if
>>>>> statement body if the assignment and declaration are separate.
>>>>>
>>>>> Cc: Przemyslaw Marczak <p.marczak@samsung.com>
>>>>> Cc: Lukasz Majewski <l.majewski@samsung.com>
>>>>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>>>>> ---
>>>>>   common/cmd_usb_mass_storage.c | 24 ++++++++++++++++--------
>>>>>   1 file changed, 16 insertions(+), 8 deletions(-)
>>>>
>>>> This doesn't apply on u-boot-usb/master, sorry.
>>>
>>> Is this the first patch in the series which doesn't apply? Did you
>>> apply any of the earlier patches? I guess I'll go try to rebase the
>>> series and find out myself...
>>>
>>> This is why we need a "uboot-next" just like linux-next, and stricter
>>> controls on which git repos take patches that touch subsystem code, to
>>> avoid cross-repo conflicts:-(
>>
>> +1
>>
>> Yesterday Marek and I agreed that some patches regarding DFU and
>> gadgets (patches 1 to 8) done by Mateusz:
>>
>> http://patchwork.ozlabs.org/patch/343517/
>>
>> will be go through u-boot-dfu tree, which will be rebased on top of
>> u-boot-usb tree. Afterwards I will send PR to Marek.
>>
>> Unfortunately I didn't manage to add them to u-boot-denx tree yesterday.
>> I will do it on Monday as well as the review regarding your ums work. I
>> hope, that you can wait until then.
>
> OK, that's fine.
>
> FWIW, I have applied that series locally and rebased my patches on top
> of it. If you want to see the latest version, feel free to look at:
>
> git://github.com/swarren/u-boot.git tegra_dev
>
> Note that branch gets rebased as I do local development.
>

I tested your tegra_dev branch on trats2 and also on goni(after apply 
the rest of Mateusz Zalega patches) and it works fine.

So for this patch set:
Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>

Thanks,
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [U-Boot] [PATCH 7/8] ums: move all variable declarations to the start of the block
  2014-05-05  9:16           ` Przemyslaw Marczak
@ 2014-05-05 16:33             ` Stephen Warren
  0 siblings, 0 replies; 16+ messages in thread
From: Stephen Warren @ 2014-05-05 16:33 UTC (permalink / raw)
  To: u-boot

On 05/05/2014 03:16 AM, Przemyslaw Marczak wrote:
...
>>>>> On Wednesday, April 30, 2014 at 11:13:21 PM, Stephen Warren wrote:
>>>>>> It's easier to assign values to the variables inside an if
>>>>>> statement body if the assignment and declaration are separate.
...
>> FWIW, I have applied that series locally and rebased my patches on top
>> of it. If you want to see the latest version, feel free to look at:
>>
>> git://github.com/swarren/u-boot.git tegra_dev
...
> I tested your tegra_dev branch on trats2 and also on goni(after apply
> the rest of Mateusz Zalega patches) and it works fine.
> 
> So for this patch set:
> Acked-by: Przemyslaw Marczak <p.marczak@samsung.com>

Good new:-) Thanks for the testing.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-05-05 16:33 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-30 21:13 [U-Boot] [PATCH 1/8] ums: support block devices not MMC devices Stephen Warren
2014-04-30 21:13 ` [U-Boot] [PATCH 2/8] ums: remove UMS_{NUM, START}_SECTORS + UMS_START_SECTOR Stephen Warren
2014-04-30 21:13 ` [U-Boot] [PATCH 3/8] ums: remove error-checking of MMC device size Stephen Warren
2014-05-01 20:00   ` Stephen Warren
2014-04-30 21:13 ` [U-Boot] [PATCH 4/8] ums: remove ums_disk_init() Stephen Warren
2014-04-30 21:13 ` [U-Boot] [PATCH 5/8] ums: move IO support code to common location Stephen Warren
2014-04-30 21:13 ` [U-Boot] [PATCH 6/8] ums: use get_device() not find_mmc_device(); Stephen Warren
2014-04-30 21:13 ` [U-Boot] [PATCH 7/8] ums: move all variable declarations to the start of the block Stephen Warren
2014-05-01 10:51   ` Marek Vasut
2014-05-01 16:58     ` Stephen Warren
2014-05-01 19:43       ` Lukasz Majewski
2014-05-01 21:47         ` Stephen Warren
2014-05-05  9:16           ` Przemyslaw Marczak
2014-05-05 16:33             ` Stephen Warren
2014-05-02  4:45       ` Marek Vasut
2014-04-30 21:13 ` [U-Boot] [PATCH 8/8] ums: allow the user to specify the device type Stephen Warren

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.