From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 15650EB64DA for ; Sat, 24 Jun 2023 22:27:11 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4328085DFA; Sun, 25 Jun 2023 00:27:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QXDxjGKX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6695B85E73; Sun, 25 Jun 2023 00:27:06 +0200 (CEST) Received: from mail-vs1-xe29.google.com (mail-vs1-xe29.google.com [IPv6:2607:f8b0:4864:20::e29]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DD57785DB6 for ; Sun, 25 Jun 2023 00:27:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jpewhacker@gmail.com Received: by mail-vs1-xe29.google.com with SMTP id ada2fe7eead31-440cdef2c27so2263851137.0 for ; Sat, 24 Jun 2023 15:27:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687645620; x=1690237620; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qblCE2GeAlcaIFwGiIMa1L+5PvvcU0jzi34l6CG5ybk=; b=QXDxjGKXZex1r6mPrqjTyCgLLfCsIr6tCsj3Db5HcBXQ5sw8fPYbFZfe2c/nNL3HB9 rFJArF85iPVs/m4oL3fxdKl1Whcie2w82X6/T1zrRilJMninP411IXaTKHjZZgsweJwC L5dQqDI2TkidXoGtOBV4Yy1uABGj9NfdqA/e0MJlnIEGcvx4e6/tnAv+KU8vS/emb+AK C8KCqmELJirbcUCl+6jRT0LxpbN/YVKAFAwxLcvdID7IpYO5BdNPKlcklly21cxjOvKD Ue5/fpRgTiIyQ6IugaJqKq5WJI+FI9zLmNAttwA0yIPbakONab+e4uLugFuat2+/cnmO LvLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687645620; x=1690237620; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qblCE2GeAlcaIFwGiIMa1L+5PvvcU0jzi34l6CG5ybk=; b=d3+vJtocuLdq97dnqKbzcV/QszchVdAAGiSTuBu+lLfi6/vgmDb3/XOuHCCX+kDUy9 T4QfMwCdbH5Uzrq5vdm/rR0aqH52RHSTHO42hefHMn7g+Z/GwEBBepltr6emhRWRSl2c daMrs8uUWiebpQaH+tN1IKIGDn2oHZGbGfmpMm0v7SSR0Kl9cZ/JQ+/zASe2c2BNQMGT gAAZy8VB0xQgJHysHBwOBKGjKqmkDbyaN3+ij2rD3gzPMztMx/gz4aySH08OOgQn/Ht2 7bZkhIsQntJSW1YiZ/Ua/ZCBitkLTQy0iqahi0nXWj8Adrq4MCx05FNkzXaPsVYIMsC1 d3BA== X-Gm-Message-State: AC+VfDwm5y77SzwAR4nf4JXB1Kqd8ln9ZNStHXlIY/znfUxr1bFwa7xG DE7EgxlfQMtbt5Whnffd/AUxgTLBClM= X-Google-Smtp-Source: ACHHUZ6gTQG16FoyBZFKBZDyrZ2eWRPuEkQtE6jMjD9aDSv+uSHvpBPnVs5JPnNuiX9TAjuFcVCjrg== X-Received: by 2002:a05:6830:1388:b0:6b4:65d4:f8a9 with SMTP id d8-20020a056830138800b006b465d4f8a9mr8565602otq.4.1687550458568; Fri, 23 Jun 2023 13:00:58 -0700 (PDT) Received: from localhost.localdomain ([204.77.163.107]) by smtp.gmail.com with ESMTPSA id c13-20020a9d6c8d000000b006b5d7fd66f7sm146132otr.26.2023.06.23.13.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 13:00:57 -0700 (PDT) From: Joshua Watt X-Google-Original-From: Joshua Watt To: u-boot@lists.denx.de Cc: Joshua Watt , Simon Glass , Tobias Waldekranz , Stefan Herbrechtsmeier , Heiko Schocher , Heinrich Schuchardt Subject: [PATCH 1/2] disk: part: Add API to get partitions with specific driver Date: Fri, 23 Jun 2023 14:59:59 -0500 Message-Id: <20230623200031.2689749-2-JPEWhacker@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230623200031.2689749-1-JPEWhacker@gmail.com> References: <20230623200031.2689749-1-JPEWhacker@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Adds part_driver_get_type() API which can be used to force a specific driver to be used when getting partition information instead of relying on auto detection. Signed-off-by: Joshua Watt --- disk/part.c | 38 +++++++++++++++++++++++++++++++------- include/part.h | 2 ++ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/disk/part.c b/disk/part.c index 35300df590..1f8c786ca5 100644 --- a/disk/part.c +++ b/disk/part.c @@ -26,6 +26,22 @@ /* Check all partition types */ #define PART_TYPE_ALL -1 +static struct part_driver *part_driver_get_type(int part_type) +{ + struct part_driver *drv = + ll_entry_start(struct part_driver, part_driver); + const int n_ents = ll_entry_count(struct part_driver, part_driver); + struct part_driver *entry; + + for (entry = drv; entry != drv + n_ents; entry++) { + if (part_type == entry->part_type) + return entry; + } + + /* Not found */ + return NULL; +} + static struct part_driver *part_driver_lookup_type(struct blk_desc *dev_desc) { struct part_driver *drv = @@ -44,10 +60,7 @@ static struct part_driver *part_driver_lookup_type(struct blk_desc *dev_desc) } } } else { - for (entry = drv; entry != drv + n_ents; entry++) { - if (dev_desc->part_type == entry->part_type) - return entry; - } + return part_driver_get_type(dev_desc->part_type); } /* Not found */ @@ -306,8 +319,8 @@ void part_print(struct blk_desc *dev_desc) drv->print(dev_desc); } -int part_get_info(struct blk_desc *dev_desc, int part, - struct disk_partition *info) +int part_get_info_by_type(struct blk_desc *dev_desc, int part, int part_type, + struct disk_partition *info) { struct part_driver *drv; @@ -320,7 +333,12 @@ int part_get_info(struct blk_desc *dev_desc, int part, info->type_guid[0] = 0; #endif - drv = part_driver_lookup_type(dev_desc); + if (part_type == PART_TYPE_UNKNOWN) { + drv = part_driver_lookup_type(dev_desc); + } else { + drv = part_driver_get_type(part_type); + } + if (!drv) { debug("## Unknown partition table type %x\n", dev_desc->part_type); @@ -340,6 +358,12 @@ int part_get_info(struct blk_desc *dev_desc, int part, return -ENOENT; } +int part_get_info(struct blk_desc *dev_desc, int part, + struct disk_partition *info) +{ + return part_get_info_by_type(dev_desc, part, PART_TYPE_UNKNOWN, info); +} + int part_get_info_whole_disk(struct blk_desc *dev_desc, struct disk_partition *info) { diff --git a/include/part.h b/include/part.h index be75c73549..f150c84206 100644 --- a/include/part.h +++ b/include/part.h @@ -106,6 +106,8 @@ struct blk_desc *blk_get_dev(const char *ifname, int dev); struct blk_desc *mg_disk_get_dev(int dev); /* disk/part.c */ +int part_get_info_by_type(struct blk_desc *dev_desc, int part, int part_type, + struct disk_partition *info); int part_get_info(struct blk_desc *dev_desc, int part, struct disk_partition *info); /** -- 2.33.0