All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dr. Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] disk: part: use common api to lookup part driver
Date: Fri, 15 Dec 2017 10:08:50 +0100	[thread overview]
Message-ID: <CCAB292D-9E6E-495B-A307-4091D029113A@theobroma-systems.com> (raw)
In-Reply-To: <3e90b652-62ac-c56d-f566-96626029d0fc@rock-chips.com>


> On 15 Dec 2017, at 03:34, Kever Yang <kever.yang@rock-chips.com> wrote:
> 
> Hi Philipp,
> 
> 
> On 12/14/2017 05:53 PM, Dr. Philipp Tomsich wrote:
>> Kever,
>> 
>>> On 14 Dec 2017, at 07:39, Kever Yang <kever.yang@rock-chips.com> wrote:
>>> 
>>> Do not need to scan disk every time when we get part info
>>> by name.
>> How does this interact with USB devices?
>> I.e.: what happens, when you get the partition-info for a usb drive, then change
>> the attached usb drive (with only a single one attached, but a different one) and
>> do a ‘usb rescan’?
> 
> I don't understand your question here, the part driver is using block api,
> no matter its from usb or emmc, it's the same for part driver.
> USB msc driver should always call part_init() for a new device.

Thanks, this answers it: part_init() will always be called for new devices.

> This patch does not change the functionality of the origin implement, but with
> a better api, and do not need to scan the disk if the disk already have a known type.
> 
> Thanks,
> - Kever
>> 
>> Regards,
>> Philipp.
>> 
>>> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
>>> ---
>>> 
>>> disk/part.c | 29 +++++++++++++----------------
>>> 1 file changed, 13 insertions(+), 16 deletions(-)
>>> 
>>> diff --git a/disk/part.c b/disk/part.c
>>> index b007138..96c2858 100644
>>> --- a/disk/part.c
>>> +++ b/disk/part.c
>>> @@ -638,26 +638,23 @@ cleanup:
>>> int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
>>> 	disk_partition_t *info)
>>> {
>>> -	struct part_driver *first_drv =
>>> -		ll_entry_start(struct part_driver, part_driver);
>>> -	const int n_drvs = ll_entry_count(struct part_driver, part_driver);
>>> 	struct part_driver *part_drv;
>>> +	int ret;
>>> +	int i;
>>> 
>>> -	for (part_drv = first_drv; part_drv != first_drv + n_drvs; part_drv++) {
>>> -		int ret;
>>> -		int i;
>>> -		for (i = 1; i < part_drv->max_entries; i++) {
>>> -			ret = part_drv->get_info(dev_desc, i, info);
>>> -			if (ret != 0) {
>>> -				/* no more entries in table */
>>> -				break;
>>> -			}
>>> -			if (strcmp(name, (const char *)info->name) == 0) {
>>> -				/* matched */
>>> -				return i;
>>> -			}
>>> +	part_drv = part_driver_lookup_type(dev_desc);
>>> +	for (i = 1; i < part_drv->max_entries; i++) {
>>> +		ret = part_drv->get_info(dev_desc, i, info);
>>> +		if (ret != 0) {
>>> +			/* no more entries in table */
>>> +			break;
>>> +		}
>>> +		if (strcmp(name, (const char *)info->name) == 0) {
>>> +			/* matched */
>>> +			return i;
>>> 		}
>>> 	}
>>> +
>>> 	return -1;
>>> }
>>> 
>>> -- 
>>> 1.9.1
>>> 
>> 
> 
> 

  reply	other threads:[~2017-12-15  9:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-14  6:39 [U-Boot] [PATCH 1/2] disk: part: scan the disk if the part_type is unknow Kever Yang
2017-12-14  6:39 ` [U-Boot] [PATCH 2/2] disk: part: use common api to lookup part driver Kever Yang
2017-12-14  9:53   ` Dr. Philipp Tomsich
2017-12-15  2:34     ` Kever Yang
2017-12-15  9:08       ` Dr. Philipp Tomsich [this message]
2017-12-19 15:41 ` [U-Boot] [PATCH 1/2] disk: part: scan the disk if the part_type is unknow Simon Glass
2017-12-22  3:33   ` Kever Yang

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=CCAB292D-9E6E-495B-A307-4091D029113A@theobroma-systems.com \
    --to=philipp.tomsich@theobroma-systems.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 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.