From patchwork Mon May 26 18:52:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 30935 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 30BA820A25 for ; Mon, 26 May 2014 18:53:05 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id y20sf44051310ier.7 for ; Mon, 26 May 2014 11:53:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=QOsEt3xfGNrWpS2tZdnF1/cXctgyFf6qTqpLzuUI9+Y=; b=cjg8UWkgqtZdg0MBAWBuqr2AGWbHKUjGNcjjhr5Nj/Y0j8QB4ZKw5eRnuqMvU8fS8H 40bbubJ1AKdaTPv+F5d47QUJOjBcrWf4P0LQ97XP25ip+ym6kb64Rrpz3Zyk/TSlKehx ReBwFcTzMkpEqWDeG2aqp9uEjDIqD5waNz0vmOr3yzWOdJCCUpm4DLZWO2JODMksheA3 JwvQT7tNK/lAyqhQQw3vte6qIrkxT6qWVs66VU5nD7HEPfThs521ZcL+GhInfLdPd84y 2Vi4L5qWJv/0gLBiaNZ/FoqoTwFVtDWFCkSM+4tJE2epp3qerlG4CpK4KTm2y3K9Blhv KKog== X-Gm-Message-State: ALoCoQlA/jh9g++q9SkLPvwFnFKk46PM44jIsFo64FJ2F62HzWoPIJKLcd7WGB0phe90FDWN21dC X-Received: by 10.50.6.45 with SMTP id x13mr484338igx.4.1401130385529; Mon, 26 May 2014 11:53:05 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.247 with SMTP id h110ls2894421qgf.44.gmail; Mon, 26 May 2014 11:53:05 -0700 (PDT) X-Received: by 10.220.167.2 with SMTP id o2mr22933692vcy.8.1401130385432; Mon, 26 May 2014 11:53:05 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id fx3si6716207vdc.84.2014.05.26.11.53.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 May 2014 11:53:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hq11so3739250vcb.36 for ; Mon, 26 May 2014 11:53:05 -0700 (PDT) X-Received: by 10.220.166.211 with SMTP id n19mr1671vcy.69.1401130385274; Mon, 26 May 2014 11:53:05 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp63563vcb; Mon, 26 May 2014 11:53:04 -0700 (PDT) X-Received: by 10.181.8.67 with SMTP id di3mr30256673wid.8.1401130384443; Mon, 26 May 2014 11:53:04 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id wz7si19914456wjc.87.2014.05.26.11.53.03 for ; Mon, 26 May 2014 11:53:04 -0700 (PDT) Received-SPF: none (google.com: u-boot-bounces@lists.denx.de does not designate permitted sender hosts) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3AB9C4B671; Mon, 26 May 2014 20:52:57 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fvFrAC75o1b2; Mon, 26 May 2014 20:52:56 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9753E4B659; Mon, 26 May 2014 20:52:49 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9E17E4B632 for ; Mon, 26 May 2014 20:52:45 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id load-zlDn5lc for ; Mon, 26 May 2014 20:52:45 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-gw1-out.broadcom.com (mail-gw1-out.broadcom.com [216.31.210.62]) by theia.denx.de (Postfix) with ESMTP id 18B0A4B635 for ; Mon, 26 May 2014 20:52:35 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.98,914,1392192000"; d="scan'208";a="31630885" Received: from irvexchcas07.broadcom.com (HELO IRVEXCHCAS07.corp.ad.broadcom.com) ([10.9.208.55]) by mail-gw1-out.broadcom.com with ESMTP; 26 May 2014 11:57:55 -0700 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS07.corp.ad.broadcom.com (10.9.208.55) with Microsoft SMTP Server (TLS) id 14.3.174.1; Mon, 26 May 2014 11:52:35 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) with Microsoft SMTP Server id 14.3.174.1; Mon, 26 May 2014 11:52:35 -0700 Received: from mail.broadcom.com (lbrmn-vmlnx03.ric.broadcom.com [10.136.4.105]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 8249A9F9F7; Mon, 26 May 2014 11:52:34 -0700 (PDT) From: Steve Rae To: Date: Mon, 26 May 2014 11:52:24 -0700 Message-ID: <1401130344-15450-4-git-send-email-srae@broadcom.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: <1401130344-15450-1-git-send-email-srae@broadcom.com> References: <1401130344-15450-1-git-send-email-srae@broadcom.com> MIME-Version: 1.0 Cc: Tom Rini , Steve Rae , Przemyslaw Marczak , Rob Herring Subject: [U-Boot] [PATCH 3/3] disk: part_efi: add get_partition_info_efi_by_name() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: srae@broadcom.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Add function to find a GPT table entry by name. Tested on little endian ARMv7 and ARMv8 configurations Signed-off-by: Steve Rae --- disk/part_efi.c | 21 ++++++++++++++++++++- include/part.h | 11 +++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/disk/part_efi.c b/disk/part_efi.c index 78a3782..612f092 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -181,7 +181,7 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, UUID_STR_FORMAT_GUID); #endif - debug("%s: start 0x" LBAF ", size 0x" LBAF ", name %s", __func__, + debug("%s: start 0x" LBAF ", size 0x" LBAF ", name %s\n", __func__, info->start, info->size, info->name); /* Remember to free pte */ @@ -189,6 +189,25 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, return 0; } +int get_partition_info_efi_by_name(block_dev_desc_t *dev_desc, + const char *name, disk_partition_t *info) +{ + int ret; + int i; + for (i = 1; i < GPT_ENTRY_NUMBERS; i++) { + ret = get_partition_info_efi(dev_desc, i, info); + if (ret != 0) { + /* no more entries in table */ + return -1; + } + if (strcmp(name, (const char *)info->name) == 0) { + /* matched */ + return 0; + } + } + return -2; +} + int test_part_efi(block_dev_desc_t * dev_desc) { ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, legacymbr, 1, dev_desc->blksz); diff --git a/include/part.h b/include/part.h index f2c8c64..a496a4a 100644 --- a/include/part.h +++ b/include/part.h @@ -180,6 +180,17 @@ int test_part_amiga (block_dev_desc_t *dev_desc); #include /* disk/part_efi.c */ int get_partition_info_efi (block_dev_desc_t * dev_desc, int part, disk_partition_t *info); +/** + * get_partition_info_efi_by_name() - Find the specified GPT partition table entry + * + * @param dev_desc - block device descriptor + * @param gpt_name - the specified table entry name + * @param info - returns the disk partition info + * + * @return - '0' on match, '-1' on no match, otherwise error + */ +int get_partition_info_efi_by_name(block_dev_desc_t *dev_desc, + const char *name, disk_partition_t *info); void print_part_efi (block_dev_desc_t *dev_desc); int test_part_efi (block_dev_desc_t *dev_desc);