From patchwork Thu Sep 21 22:51:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 113934 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp2567136qgf; Thu, 21 Sep 2017 15:52:14 -0700 (PDT) X-Received: by 10.80.193.26 with SMTP id l26mr2662343edf.97.1506034334064; Thu, 21 Sep 2017 15:52:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506034334; cv=none; d=google.com; s=arc-20160816; b=YJJ8m6pdf2Pb6vlnlxwu7uFMHe45JP24lQkBRci8wege1q4RYYkWAXODY4K6l+2EGQ snmQzFSbB+pdh4i3oKmjgMXT9PfCDVlVKKAuMMeunS0bpAuio+Cf332lbNoOCbXiy3mK qc4iEpA6/1LAA1tBC4sUySEaZX02xwh1wODwk6oCFzmMBCCaitcZp3UKqOCI5kQyrLq1 TxT3NYlWACLLAoCdW481UfV6ITIegYPWoDe5jCzquRRvq62Hfpap14vIlp7xokRk0nIE MPHwGUpPqbZBG5EVGpC0ydM5ATEfPkIHlhOn+O50xgI4UY8KEoX7dPPaHLKvHZzc20RS UvvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=JvtG4G7rD/H4Yt3dNNrTztGBObA2ZesLyRbn1NfaLIo=; b=YJM56GV/ev+GG6hv+Sbk31XvS+sQ8bP6wVKXQMvcbmAVAbq+ChLQAefHHGDLRgSeux 6H5fCxLzJmm/uEw2M5XQffs9kJtyx3BQ4/pY3UUnKW7KvkEKwteVsnXGRkYU/SnK1Csy i2rxU2dkR/hs/KzkXD+TrElJwLMV31/nGZVl0bulPyfNT0miJdzbSS8pYggBlRaPFtn7 oynsT4KbtZNaKYCi8vhUCctHqVfuH+NrMi6SdoHaBEPHvbJet9C1d/sJcHKdw9Jnccgh a29Au9rfoOK7HbNhFiayTfxXHuAXg0uIuat+ZXSryHGb45cgEpSffgxdHujYAdaeE6Py 3sFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Us8bqfBb; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id q7si2153781edk.133.2017.09.21.15.52.13; Thu, 21 Sep 2017 15:52:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Us8bqfBb; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 39249C21E44; Thu, 21 Sep 2017 22:52:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id ED9E6C21C29; Thu, 21 Sep 2017 22:52:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 75426C21C29; Thu, 21 Sep 2017 22:52:03 +0000 (UTC) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by lists.denx.de (Postfix) with ESMTPS id 98D88C21C26 for ; Thu, 21 Sep 2017 22:52:02 +0000 (UTC) Received: by mail-lf0-f51.google.com with SMTP id q132so7139427lfe.5 for ; Thu, 21 Sep 2017 15:52:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Bed68ixEI4wnY+sDy3Zlvd8AeH/xjgVEr3oefmLHjF0=; b=Us8bqfBbzhsG0GVxdOdjwpbB9ECEGf0SBgWiPBZGlldfJr38TY8pzjTif1SWZOEnjK OxeF8pqLa8XZq3gO+N/8FKvSN5LwGJb/Q24dDZUamazwGEhMfSa/rkgd4sIoxh0hYe4E mhU/NWPkQLqCW2zwnDh//UBfMpLw2d2CHv/ew= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Bed68ixEI4wnY+sDy3Zlvd8AeH/xjgVEr3oefmLHjF0=; b=t+R7Qqy8Y/aOoRlelpfLBG4hKsL3MsLOo0hyKV1RVE72HvWEnS7EnzBRb4ftZlz4Ra J3JpZ0MiiF7xaAf13SbZJzIvxjl3GXLlrpWT4kkaV5PDV8HOwqBoZaCtFbKy8zV+uTa5 YKfPxOWsKaWDOKZL6qKOh0N1hpTO8kxlx9bCP6qTLrzpCZTRzVVqCrFf0derzO8QoWep z2JrGeyDPe7e5ggvDNodL0tSyzMz4NLjO2UikAJjkmRcuO6Zyvx2q3sf1o+wJCsVJlI7 GP4PLRkjJqSpPgbbveZIdsXbR/kbhxMrPktm3M9rLtrpZ6KaaKkiuBJwTT3kQel2+0yZ h/jg== X-Gm-Message-State: AHPjjUjkKYJBjgHb5gPuf6iU2xBsnh7mMER5LPfnvotJN80/3KW1+VP2 8Aox4qc3kNRfqIUpuUfQ84cLH4shilQ= X-Google-Smtp-Source: AOwi7QDsPvEmOylINgRCKWCuvchO7lFhqVM7tqHN40pQhGzilYbuO45JzGo8RD9Es3rrBfeqQbSlIw== X-Received: by 10.25.219.18 with SMTP id s18mr1158238lfg.232.1506034321627; Thu, 21 Sep 2017 15:52:01 -0700 (PDT) Received: from localhost ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id t63sm513991lje.81.2017.09.21.15.51.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Sep 2017 15:52:00 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Fri, 22 Sep 2017 01:51:58 +0300 Message-Id: <20170921225159.2546-1-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.14.1 Cc: Praneeth Bajjuri , Tom Rini Subject: [U-Boot] [PATCH 1/2] disk: Provide API to get partition by name for specific type X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "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 Reviewed-by: Simon Glass --- 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