All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] disk: Provide API to get partition by name for specific type
@ 2017-09-21 22:51 Sam Protsenko
  2017-09-21 22:51 ` [U-Boot] [PATCH 2/2] omap: Fix warning when looking for userdata part Sam Protsenko
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Sam Protsenko @ 2017-09-21 22:51 UTC (permalink / raw)
  To: u-boot

There is already existing function part_get_info_by_name().
But sometimes user is particularly interested in looking for only
specific partition type. This patch implements such an API that
provides partition searching by name for specified partition type.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
 disk/part.c    | 15 +++++++++++++--
 include/part.h | 15 +++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/disk/part.c b/disk/part.c
index aa9183d696..66b8101f98 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -21,6 +21,9 @@
 #define PRINTF(fmt,args...)
 #endif
 
+/* Check all partition types */
+#define PART_TYPE_ALL		-1
+
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef HAVE_BLOCK_DEVICE
@@ -626,8 +629,8 @@ cleanup:
 	return ret;
 }
 
-int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
-	disk_partition_t *info)
+int part_get_info_by_name_type(struct blk_desc *dev_desc, const char *name,
+			       disk_partition_t *info, int part_type)
 {
 	struct part_driver *first_drv =
 		ll_entry_start(struct part_driver, part_driver);
@@ -638,6 +641,8 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
 		int ret;
 		int i;
 		for (i = 1; i < part_drv->max_entries; i++) {
+			if (part_type >= 0 && part_type != part_drv->part_type)
+				break;
 			ret = part_drv->get_info(dev_desc, i, info);
 			if (ret != 0) {
 				/* no more entries in table */
@@ -652,6 +657,12 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
 	return -1;
 }
 
+int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
+			  disk_partition_t *info)
+{
+	return part_get_info_by_name_type(dev_desc, name, info, PART_TYPE_ALL);
+}
+
 void part_set_generic_name(const struct blk_desc *dev_desc,
 	int part_num, char *name)
 {
diff --git a/include/part.h b/include/part.h
index 86117a7ce5..1a61518722 100644
--- a/include/part.h
+++ b/include/part.h
@@ -173,6 +173,21 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 			    struct blk_desc **dev_desc,
 			    disk_partition_t *info, int allow_whole_dev);
 
+/**
+ * part_get_info_by_name_type() - Search for a partition by name
+ *                                for only specified partition type
+ *
+ * @param dev_desc - block device descriptor
+ * @param gpt_name - the specified table entry name
+ * @param info - returns the disk partition info
+ * @param part_type - only search in partitions of this type
+ *
+ * @return - the partition number on match (starting on 1), -1 on no match,
+ * otherwise error
+ */
+int part_get_info_by_name_type(struct blk_desc *dev_desc, const char *name,
+			       disk_partition_t *info, int part_type);
+
 /**
  * part_get_info_by_name() - Search for a partition by name
  *                           among all available registered partitions
-- 
2.14.1

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

* [U-Boot] [PATCH 2/2] omap: Fix warning when looking for userdata part
  2017-09-21 22:51 [U-Boot] [PATCH 1/2] disk: Provide API to get partition by name for specific type Sam Protsenko
@ 2017-09-21 22:51 ` Sam Protsenko
  2017-09-25  2:14   ` Simon Glass
  2017-10-07 13:08   ` [U-Boot] [U-Boot, " Tom Rini
  2017-09-25  2:14 ` [U-Boot] [PATCH 1/2] disk: Provide API to get partition by name for specific type Simon Glass
  2017-10-07 13:08 ` [U-Boot] [U-Boot, " Tom Rini
  2 siblings, 2 replies; 7+ messages in thread
From: Sam Protsenko @ 2017-09-21 22:51 UTC (permalink / raw)
  To: u-boot

When eMMC was formattaed for Linux partition table, "userdata" partition
is missing. In this case, part_get_info_by_name() iterates over all
registered drivers (which are PART_TYPE_EFI, PART_TYPE_DOS and
PART_TYPE_ISO). And when it comes to PART_TYPE_ISO (which has empty
partition table), we can see next warning in U-Boot output:

    ** First descriptor is NOT a primary desc on 1:1 **

This patch switches to part_get_info_by_name_type() API in order to
check only EFI partitions for "userdata" partitions. This eliminates
mentioned warning.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
---
 arch/arm/mach-omap2/utils.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/utils.c b/arch/arm/mach-omap2/utils.c
index 3892853c7e..e36dd8398f 100644
--- a/arch/arm/mach-omap2/utils.c
+++ b/arch/arm/mach-omap2/utils.c
@@ -91,7 +91,8 @@ static u32 omap_mmc_get_part_size(const char *part)
 		return 0;
 	}
 
-	res = part_get_info_by_name(dev_desc, part, &info);
+	/* Check only for EFI (GPT) partition table */
+	res = part_get_info_by_name_type(dev_desc, part, &info, PART_TYPE_EFI);
 	if (res < 0)
 		return 0;
 
-- 
2.14.1

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

* [U-Boot] [PATCH 1/2] disk: Provide API to get partition by name for specific type
  2017-09-21 22:51 [U-Boot] [PATCH 1/2] disk: Provide API to get partition by name for specific type Sam Protsenko
  2017-09-21 22:51 ` [U-Boot] [PATCH 2/2] omap: Fix warning when looking for userdata part Sam Protsenko
@ 2017-09-25  2:14 ` Simon Glass
  2017-09-25 18:11   ` Sam Protsenko
  2017-10-07 13:08 ` [U-Boot] [U-Boot, " Tom Rini
  2 siblings, 1 reply; 7+ messages in thread
From: Simon Glass @ 2017-09-25  2:14 UTC (permalink / raw)
  To: u-boot

Hi Sam,

On 21 September 2017 at 16:51, Sam Protsenko <semen.protsenko@linaro.org> wrote:
> There is already existing function part_get_info_by_name().
> But sometimes user is particularly interested in looking for only
> specific partition type. This patch implements such an API that
> provides partition searching by name for specified partition type.
>
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---
>  disk/part.c    | 15 +++++++++++++--
>  include/part.h | 15 +++++++++++++++
>  2 files changed, 28 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

nit below

>
> diff --git a/disk/part.c b/disk/part.c
> index aa9183d696..66b8101f98 100644
> --- a/disk/part.c
> +++ b/disk/part.c
> @@ -21,6 +21,9 @@
>  #define PRINTF(fmt,args...)
>  #endif
>
> +/* Check all partition types */
> +#define PART_TYPE_ALL          -1
> +
>  DECLARE_GLOBAL_DATA_PTR;
>
>  #ifdef HAVE_BLOCK_DEVICE
> @@ -626,8 +629,8 @@ cleanup:
>         return ret;
>  }
>
> -int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
> -       disk_partition_t *info)
> +int part_get_info_by_name_type(struct blk_desc *dev_desc, const char *name,
> +                              disk_partition_t *info, int part_type)
>  {
>         struct part_driver *first_drv =
>                 ll_entry_start(struct part_driver, part_driver);
> @@ -638,6 +641,8 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
>                 int ret;
>                 int i;
>                 for (i = 1; i < part_drv->max_entries; i++) {
> +                       if (part_type >= 0 && part_type != part_drv->part_type)
> +                               break;
>                         ret = part_drv->get_info(dev_desc, i, info);
>                         if (ret != 0) {
>                                 /* no more entries in table */
> @@ -652,6 +657,12 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
>         return -1;
>  }
>
> +int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
> +                         disk_partition_t *info)
> +{
> +       return part_get_info_by_name_type(dev_desc, name, info, PART_TYPE_ALL);
> +}
> +
>  void part_set_generic_name(const struct blk_desc *dev_desc,
>         int part_num, char *name)
>  {
> diff --git a/include/part.h b/include/part.h
> index 86117a7ce5..1a61518722 100644
> --- a/include/part.h
> +++ b/include/part.h
> @@ -173,6 +173,21 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
>                             struct blk_desc **dev_desc,
>                             disk_partition_t *info, int allow_whole_dev);
>
> +/**
> + * part_get_info_by_name_type() - Search for a partition by name
> + *                                for only specified partition type
> + *
> + * @param dev_desc - block device descriptor
> + * @param gpt_name - the specified table entry name
> + * @param info - returns the disk partition info
> + * @param part_type - only search in partitions of this type

Can you reference the PART_TYPE_ #define here (since we don't have an enum).

> + *
> + * @return - the partition number on match (starting on 1), -1 on no match,
> + * otherwise error
> + */
> +int part_get_info_by_name_type(struct blk_desc *dev_desc, const char *name,
> +                              disk_partition_t *info, int part_type);
> +
>  /**
>   * part_get_info_by_name() - Search for a partition by name
>   *                           among all available registered partitions
> --
> 2.14.1
>

Regards,
Simon

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

* [U-Boot] [PATCH 2/2] omap: Fix warning when looking for userdata part
  2017-09-21 22:51 ` [U-Boot] [PATCH 2/2] omap: Fix warning when looking for userdata part Sam Protsenko
@ 2017-09-25  2:14   ` Simon Glass
  2017-10-07 13:08   ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Glass @ 2017-09-25  2:14 UTC (permalink / raw)
  To: u-boot

On 21 September 2017 at 16:51, Sam Protsenko <semen.protsenko@linaro.org> wrote:
> When eMMC was formattaed for Linux partition table, "userdata" partition
> is missing. In this case, part_get_info_by_name() iterates over all
> registered drivers (which are PART_TYPE_EFI, PART_TYPE_DOS and
> PART_TYPE_ISO). And when it comes to PART_TYPE_ISO (which has empty
> partition table), we can see next warning in U-Boot output:
>
>     ** First descriptor is NOT a primary desc on 1:1 **
>
> This patch switches to part_get_info_by_name_type() API in order to
> check only EFI partitions for "userdata" partitions. This eliminates
> mentioned warning.
>
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> ---
>  arch/arm/mach-omap2/utils.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

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

* [U-Boot] [PATCH 1/2] disk: Provide API to get partition by name for specific type
  2017-09-25  2:14 ` [U-Boot] [PATCH 1/2] disk: Provide API to get partition by name for specific type Simon Glass
@ 2017-09-25 18:11   ` Sam Protsenko
  0 siblings, 0 replies; 7+ messages in thread
From: Sam Protsenko @ 2017-09-25 18:11 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On 24 September 2017 at 19:14, Simon Glass <sjg@chromium.org> wrote:
> Hi Sam,
>
> On 21 September 2017 at 16:51, Sam Protsenko <semen.protsenko@linaro.org> wrote:
>> There is already existing function part_get_info_by_name().
>> But sometimes user is particularly interested in looking for only
>> specific partition type. This patch implements such an API that
>> provides partition searching by name for specified partition type.
>>
>> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
>> ---
>>  disk/part.c    | 15 +++++++++++++--
>>  include/part.h | 15 +++++++++++++++
>>  2 files changed, 28 insertions(+), 2 deletions(-)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> nit below
>
>>
>> diff --git a/disk/part.c b/disk/part.c
>> index aa9183d696..66b8101f98 100644
>> --- a/disk/part.c
>> +++ b/disk/part.c
>> @@ -21,6 +21,9 @@
>>  #define PRINTF(fmt,args...)
>>  #endif
>>
>> +/* Check all partition types */
>> +#define PART_TYPE_ALL          -1
>> +
>>  DECLARE_GLOBAL_DATA_PTR;
>>
>>  #ifdef HAVE_BLOCK_DEVICE
>> @@ -626,8 +629,8 @@ cleanup:
>>         return ret;
>>  }
>>
>> -int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
>> -       disk_partition_t *info)
>> +int part_get_info_by_name_type(struct blk_desc *dev_desc, const char *name,
>> +                              disk_partition_t *info, int part_type)
>>  {
>>         struct part_driver *first_drv =
>>                 ll_entry_start(struct part_driver, part_driver);
>> @@ -638,6 +641,8 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
>>                 int ret;
>>                 int i;
>>                 for (i = 1; i < part_drv->max_entries; i++) {
>> +                       if (part_type >= 0 && part_type != part_drv->part_type)
>> +                               break;
>>                         ret = part_drv->get_info(dev_desc, i, info);
>>                         if (ret != 0) {
>>                                 /* no more entries in table */
>> @@ -652,6 +657,12 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
>>         return -1;
>>  }
>>
>> +int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
>> +                         disk_partition_t *info)
>> +{
>> +       return part_get_info_by_name_type(dev_desc, name, info, PART_TYPE_ALL);
>> +}
>> +
>>  void part_set_generic_name(const struct blk_desc *dev_desc,
>>         int part_num, char *name)
>>  {
>> diff --git a/include/part.h b/include/part.h
>> index 86117a7ce5..1a61518722 100644
>> --- a/include/part.h
>> +++ b/include/part.h
>> @@ -173,6 +173,21 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
>>                             struct blk_desc **dev_desc,
>>                             disk_partition_t *info, int allow_whole_dev);
>>
>> +/**
>> + * part_get_info_by_name_type() - Search for a partition by name
>> + *                                for only specified partition type
>> + *
>> + * @param dev_desc - block device descriptor
>> + * @param gpt_name - the specified table entry name
>> + * @param info - returns the disk partition info
>> + * @param part_type - only search in partitions of this type
>
> Can you reference the PART_TYPE_ #define here (since we don't have an enum).
>

If you mean PART_TYPE_ALL, I'd prefer not to, because for all driver
types you need to use part_get_info_by_name() API instead of new
part_get_info_by_name_type(). Basically I just copied that doxygen
block from part_get_info_by_name(), so if we should fix the
description, we should probably do that for both functions, in
separate patch. We can create corresponding enum in that patch as
well. You agree?

Also, the format of those doxygen comments is a bit wrong, we should
either fix them, or switch to kernel-doc format. Actually, it bring
the question: which format (doxygen or kernel-doc) we should use in
U-Boot? Because right now it's a mix of both. So if you have an idea
how it should look like, please share, so that I can rework this in
one patch.

As for this patch -- I'd really like it to be applied as is, so we can
keep things atomic. Hope it's fine with you?

Thanks.

>> + *
>> + * @return - the partition number on match (starting on 1), -1 on no match,
>> + * otherwise error
>> + */
>> +int part_get_info_by_name_type(struct blk_desc *dev_desc, const char *name,
>> +                              disk_partition_t *info, int part_type);
>> +
>>  /**
>>   * part_get_info_by_name() - Search for a partition by name
>>   *                           among all available registered partitions
>> --
>> 2.14.1
>>
>
> Regards,
> Simon

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

* [U-Boot] [U-Boot, 1/2] disk: Provide API to get partition by name for specific type
  2017-09-21 22:51 [U-Boot] [PATCH 1/2] disk: Provide API to get partition by name for specific type Sam Protsenko
  2017-09-21 22:51 ` [U-Boot] [PATCH 2/2] omap: Fix warning when looking for userdata part Sam Protsenko
  2017-09-25  2:14 ` [U-Boot] [PATCH 1/2] disk: Provide API to get partition by name for specific type Simon Glass
@ 2017-10-07 13:08 ` Tom Rini
  2 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2017-10-07 13:08 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 22, 2017 at 01:51:58AM +0300, Sam Protsenko wrote:

> There is already existing function part_get_info_by_name().
> But sometimes user is particularly interested in looking for only
> specific partition type. This patch implements such an API that
> provides partition searching by name for specified partition type.
> 
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171007/16f8300f/attachment.sig>

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

* [U-Boot] [U-Boot, 2/2] omap: Fix warning when looking for userdata part
  2017-09-21 22:51 ` [U-Boot] [PATCH 2/2] omap: Fix warning when looking for userdata part Sam Protsenko
  2017-09-25  2:14   ` Simon Glass
@ 2017-10-07 13:08   ` Tom Rini
  1 sibling, 0 replies; 7+ messages in thread
From: Tom Rini @ 2017-10-07 13:08 UTC (permalink / raw)
  To: u-boot

On Fri, Sep 22, 2017 at 01:51:59AM +0300, Sam Protsenko wrote:

> When eMMC was formattaed for Linux partition table, "userdata" partition
> is missing. In this case, part_get_info_by_name() iterates over all
> registered drivers (which are PART_TYPE_EFI, PART_TYPE_DOS and
> PART_TYPE_ISO). And when it comes to PART_TYPE_ISO (which has empty
> partition table), we can see next warning in U-Boot output:
> 
>     ** First descriptor is NOT a primary desc on 1:1 **
> 
> This patch switches to part_get_info_by_name_type() API in order to
> check only EFI partitions for "userdata" partitions. This eliminates
> mentioned warning.
> 
> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171007/d2988706/attachment.sig>

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

end of thread, other threads:[~2017-10-07 13:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-21 22:51 [U-Boot] [PATCH 1/2] disk: Provide API to get partition by name for specific type Sam Protsenko
2017-09-21 22:51 ` [U-Boot] [PATCH 2/2] omap: Fix warning when looking for userdata part Sam Protsenko
2017-09-25  2:14   ` Simon Glass
2017-10-07 13:08   ` [U-Boot] [U-Boot, " Tom Rini
2017-09-25  2:14 ` [U-Boot] [PATCH 1/2] disk: Provide API to get partition by name for specific type Simon Glass
2017-09-25 18:11   ` Sam Protsenko
2017-10-07 13:08 ` [U-Boot] [U-Boot, " Tom Rini

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.