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 B0BEDC001B0 for ; Sun, 13 Aug 2023 14:29:03 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B583986994; Sun, 13 Aug 2023 16:27:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="hj1p5CuC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6050F86967; Sun, 13 Aug 2023 16:27:36 +0200 (CEST) Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (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 511FC8619C for ; Sun, 13 Aug 2023 16:27:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-349a7cb1a5cso8385495ab.0 for ; Sun, 13 Aug 2023 07:27:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1691936853; x=1692541653; 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=S4w+Z5SxeLI2EBuWmWxtFIJqa0cmcVCd0KY1CWuhV30=; b=hj1p5CuCQqjU1Ml5i9fmc0U/5ZH+qodIZqeuxQ6sC/FtdK9jmi8b2SZnRwJf9RUR6z My/BZLAAVUtRgOa6d6rhbdxkoNOYI0T4oN7sehTQuaS/j13/VRQ+Jw2aV5u1HNbnij5O 3geOg1W5NiCvTgYqBk3uyf4bdhJCl3Omn0ikE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691936853; x=1692541653; 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=S4w+Z5SxeLI2EBuWmWxtFIJqa0cmcVCd0KY1CWuhV30=; b=JbmQq5Q+GJa0Au2u1QbqsSvdVzg6xA1YPUODXYIGYtzTkiAhMQBNG7djzFvfjFspHn WXm6UNm8c7/DS6HsaeLMSdiALtAP10sz4lFtXeX3xyjAxA4eXYBmGFh2sXFm9q/riZ0A FYD1k+VUlmfS3uXCMNsdODU4tckg/3z+JiUEOlWUdeZBAf9DwcEQPciNE2rC+HLXDmg2 QO3MnKK7Zf4450iwNRj0GgxKrRRVNiDZjfjgqFLwRSA+SRsbN5gQBQEMt8wZaAnMvGir KtdCXuYZu2tOaC9N71i8ZcoQd3fV3WYj2MsCDbKJBKqZ+7qOSKjApagaTq5OR0318ClE MYCg== X-Gm-Message-State: AOJu0YxaMd2Jxl6d/ZZSLfXuxDZsqUuzB06NzjrNIEcCvC/MUDH/dNhk pZIH+u1hzV3uTXGYNQb1wl2wrmKcvccr+82eUgY= X-Google-Smtp-Source: AGHT+IEkM1AbRdYNOVU/OX7IvBhdwqHfWk0tVP1fhcQXlcHfQK+LQafbrPP3+74vvlQTzb5+zgCIIQ== X-Received: by 2002:a05:6e02:160d:b0:345:d583:5c64 with SMTP id t13-20020a056e02160d00b00345d5835c64mr13535356ilu.24.1691936853028; Sun, 13 Aug 2023 07:27:33 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id w7-20020a02cf87000000b00430cf006d9bsm2280952jar.30.2023.08.13.07.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Aug 2023 07:27:32 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Bin Meng , Heinrich Schuchardt , Joshua Watt , Stefan Herbrechtsmeier , Tobias Waldekranz Subject: [PATCH 09/24] part: Add accessors for struct disk_partition type_uuid Date: Sun, 13 Aug 2023 08:26:37 -0600 Message-ID: <20230813142708.361456-10-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.640.ga95def55d0-goog In-Reply-To: <20230813142708.361456-1-sjg@chromium.org> References: <20230813142708.361456-1-sjg@chromium.org> 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 This field is only present when a CONFIG is set. To avoid annoying #ifdefs in the source code, add accessors. Update all code to use it. Note that the accessor is optional. It can be omitted if it is known that the option is enabled. Signed-off-by: Simon Glass --- disk/part.c | 8 ++------ disk/part_efi.c | 9 +++++---- include/part.h | 28 ++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/disk/part.c b/disk/part.c index 91c6ac42cc83..72241b7b232c 100644 --- a/disk/part.c +++ b/disk/part.c @@ -370,9 +370,7 @@ int part_get_info_by_type(struct blk_desc *desc, int part, int part_type, if (blk_enabled()) { /* The common case is no UUID support */ disk_partition_clr_uuid(info); -#ifdef CONFIG_PARTITION_TYPE_GUID - info->type_guid[0] = 0; -#endif + disk_partition_clr_type_guid(info); if (part_type == PART_TYPE_UNKNOWN) { drv = part_driver_lookup_type(desc); @@ -415,9 +413,7 @@ int part_get_info_whole_disk(struct blk_desc *desc, strcpy((char *)info->type, BOOT_PART_TYPE); strcpy((char *)info->name, "Whole Disk"); disk_partition_clr_uuid(info); -#ifdef CONFIG_PARTITION_TYPE_GUID - info->type_guid[0] = 0; -#endif + disk_partition_clr_type_guid(info); return 0; } diff --git a/disk/part_efi.c b/disk/part_efi.c index a6f7375cd38a..208675213822 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -294,10 +294,11 @@ int part_get_info_efi(struct blk_desc *desc, int part, (char *)disk_partition_uuid(info), UUID_STR_FORMAT_GUID); } -#ifdef CONFIG_PARTITION_TYPE_GUID - uuid_bin_to_str(gpt_pte[part - 1].partition_type_guid.b, - info->type_guid, UUID_STR_FORMAT_GUID); -#endif + if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) { + uuid_bin_to_str(gpt_pte[part - 1].partition_type_guid.b, + (char *)disk_partition_type_uuid(info), + UUID_STR_FORMAT_GUID); + } log_debug("start 0x" LBAF ", size 0x" LBAF ", name %s\n", info->start, info->size, info->name); diff --git a/include/part.h b/include/part.h index 303ccd036754..aa96516ba353 100644 --- a/include/part.h +++ b/include/part.h @@ -107,6 +107,34 @@ static inline void disk_partition_clr_uuid(struct disk_partition *info) #endif } +/* Accessors for struct disk_partition field ->type_guid */ +extern char *__invalid_use_of_disk_partition_type_uuid; + +static inline const +char *disk_partition_type_uuid(const struct disk_partition *info) +{ +#ifdef CONFIG_PARTITION_TYPE_GUID + return info->type_guid; +#else + return __invalid_use_of_disk_partition_type_uuid; +#endif +} + +static inline void disk_partition_set_type_guid(struct disk_partition *info, + const char *val) +{ +#ifdef CONFIG_PARTITION_TYPE_GUID + strlcpy(info->type_guid, val, UUID_STR_LEN + 1); +#endif +} + +static inline void disk_partition_clr_type_guid(struct disk_partition *info) +{ +#ifdef CONFIG_PARTITION_TYPE_GUID + *info->type_guid = '\0'; +#endif +} + struct disk_part { int partnum; struct disk_partition gpt_part_info; -- 2.41.0.640.ga95def55d0-goog