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 25944C001DE for ; Tue, 25 Jul 2023 21:37:35 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DE0E78678A; Tue, 25 Jul 2023 23:37:32 +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="K7UsmRGL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 556878680B; Tue, 25 Jul 2023 23:36:57 +0200 (CEST) Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) (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 4710D8678A for ; Tue, 25 Jul 2023 23:36:50 +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-x132.google.com with SMTP id e9e14a558f8ab-3461053677eso997875ab.0 for ; Tue, 25 Jul 2023 14:36:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690321009; x=1690925809; 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=Ku74WpLTYmp1sYUtPou8pgQzQWR++hXCHAdzLTQJZAM=; b=K7UsmRGLxULsHwB6SkCNwmKyxo+hM5c5aTVz4VVEqbaU1Olqj0zY61fWd8IRjWNNmi WCwSJfv+AuOi4R7HcotqUZuH3R1NTq5XETF9MRjQj5D28he8ggJNcQ6omZEEa64nCC0u OBwnkB+o+Af0cOejJwraivVhtqQvjVGJ4tiZ8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690321009; x=1690925809; 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=Ku74WpLTYmp1sYUtPou8pgQzQWR++hXCHAdzLTQJZAM=; b=D03/P55T89rzWCoUe6sYPxXULvkGouLSck+nWBDFoeOyfVQFAGhNMhHmOqWMsFArCu 9rhSP7Vq1UUwbyxi2WtDjANMoUxaP4AF3tnsmAKJ1I8HHo70Y1ld71f7vu9fJxXOKSXC uugNnLvb9G/+aBdapANUOVbNOEX0YPPFODSX/hkhBQy18/KMEHchu0xC6AOSh0vYHcfX 7FWQQfY7LZ91KOj1pkFU1NgaBez4qVMKI628SV6HGV0FvIPuNDOgs40x2dRSw5542Ha3 U9YYasXM488fcfg4udgj35FzS0MMQHwiOYekpUO2dSt0T7V+nFdYoIgTZaFhD/t0kqfU 3Zkg== X-Gm-Message-State: ABy/qLY0PGvnPgFUyI+JxVGhsBLbCVFtmjbjeqwv3psNdcW7gkGAiuH5 2spDHo31AjnxX0+H/TMk4wgQDCmrGMhLTrMgiSw= X-Google-Smtp-Source: APBJJlEYGVNyBbBV2JXxlydLdZCydgSyMorsgxRjLiAKeHaU4+vKRdJJSCU1HmxE8CiV2YP/xc1YIg== X-Received: by 2002:a05:6e02:1807:b0:348:ca87:3f19 with SMTP id a7-20020a056e02180700b00348ca873f19mr2514276ilv.3.1690321008853; Tue, 25 Jul 2023 14:36:48 -0700 (PDT) Received: from kea.bld.corp.google.com ([2620:15c:183:200:ce78:3dad:1309:8d43]) by smtp.gmail.com with ESMTPSA id ep18-20020a0566384e1200b0042b2d43ee3fsm3891987jab.82.2023.07.25.14.36.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 14:36:48 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Tom Rini , Julius Werner , Dan Handley , Jose Marinho , Simon Glass , Bin Meng , Nikhil M Jain Subject: [PATCH 05/14] bloblist: Access record hdr_size and tag via a function Date: Tue, 25 Jul 2023 15:36:17 -0600 Message-ID: <20230725213634.255345-6-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230725213634.255345-1-sjg@chromium.org> References: <20230725213634.255345-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 These values currently use a simple field. With spec v0.9 they have moved to a packed format. Convert most accesses to use functions, so this change can be accomodated. Signed-off-by: Simon Glass --- common/bloblist.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index b9332c03ca7..0def7fc9b2f 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -73,13 +73,23 @@ static struct bloblist_rec *bloblist_first_blob(struct bloblist_hdr *hdr) return (struct bloblist_rec *)((void *)hdr + hdr->hdr_size); } +static inline uint rec_hdr_size(struct bloblist_rec *rec) +{ + return rec->hdr_size; +} + +static inline uint rec_tag(struct bloblist_rec *rec) +{ + return rec->tag; +} + static ulong bloblist_blob_end_ofs(struct bloblist_hdr *hdr, struct bloblist_rec *rec) { ulong offset; offset = (void *)rec - (void *)hdr; - offset += rec->hdr_size + ALIGN(rec->size, BLOBLIST_ALIGN); + offset += rec_hdr_size(rec) + ALIGN(rec->size, BLOBLIST_ALIGN); return offset; } @@ -108,7 +118,7 @@ static struct bloblist_rec *bloblist_findrec(uint tag) return NULL; foreach_rec(rec, hdr) { - if (rec->tag == tag) + if (rec_tag(rec) == tag) return rec; } @@ -147,7 +157,7 @@ static int bloblist_addrec(uint tag, int size, int align_log2, rec->spare = 0; /* Zero the record data */ - memset((void *)rec + rec->hdr_size, '\0', rec->size); + memset((void *)rec + rec_hdr_size(rec), '\0', rec->size); hdr->alloced = new_alloced; *recp = rec; @@ -188,7 +198,7 @@ void *bloblist_find(uint tag, int size) if (size && size != rec->size) return NULL; - return (void *)rec + rec->hdr_size; + return (void *)rec + rec_hdr_size(rec); } void *bloblist_add(uint tag, int size, int align_log2) @@ -198,7 +208,7 @@ void *bloblist_add(uint tag, int size, int align_log2) if (bloblist_addrec(tag, size, align_log2, &rec)) return NULL; - return (void *)rec + rec->hdr_size; + return (void *)rec + rec_hdr_size(rec); } int bloblist_ensure_size(uint tag, int size, int align_log2, void **blobp) @@ -209,7 +219,7 @@ int bloblist_ensure_size(uint tag, int size, int align_log2, void **blobp) ret = bloblist_ensurerec(tag, &rec, size, align_log2); if (ret) return ret; - *blobp = (void *)rec + rec->hdr_size; + *blobp = (void *)rec + rec_hdr_size(rec); return 0; } @@ -221,7 +231,7 @@ void *bloblist_ensure(uint tag, int size) if (bloblist_ensurerec(tag, &rec, size, 0)) return NULL; - return (void *)rec + rec->hdr_size; + return (void *)rec + rec_hdr_size(rec); } int bloblist_ensure_size_ret(uint tag, int *sizep, void **blobp) @@ -234,7 +244,7 @@ int bloblist_ensure_size_ret(uint tag, int *sizep, void **blobp) *sizep = rec->size; else if (ret) return ret; - *blobp = (void *)rec + rec->hdr_size; + *blobp = (void *)rec + rec_hdr_size(rec); return 0; } @@ -270,7 +280,7 @@ static int bloblist_resize_rec(struct bloblist_hdr *hdr, /* Zero the new part of the blob */ if (expand_by > 0) { - memset((void *)rec + rec->hdr_size + rec->size, '\0', + memset((void *)rec + rec_hdr_size(rec) + rec->size, '\0', new_size - rec->size); } @@ -304,8 +314,9 @@ static u32 bloblist_calc_chksum(struct bloblist_hdr *hdr) chksum = crc32(0, (unsigned char *)hdr, offsetof(struct bloblist_hdr, chksum)); foreach_rec(rec, hdr) { - chksum = crc32(chksum, (void *)rec, rec->hdr_size); - chksum = crc32(chksum, (void *)rec + rec->hdr_size, rec->size); + chksum = crc32(chksum, (void *)rec, rec_hdr_size(rec)); + chksum = crc32(chksum, (void *)rec + rec_hdr_size(rec), + rec->size); } return chksum; @@ -413,8 +424,9 @@ void bloblist_show_list(void) for (rec = bloblist_first_blob(hdr); rec; rec = bloblist_next_blob(hdr, rec)) { printf("%08lx %8x %4x %s\n", - (ulong)map_to_sysmem((void *)rec + rec->hdr_size), - rec->size, rec->tag, bloblist_tag_name(rec->tag)); + (ulong)map_to_sysmem((void *)rec + rec_hdr_size(rec)), + rec->size, rec_tag(rec), + bloblist_tag_name(rec_tag(rec))); } } -- 2.41.0.487.g6d72f3e995-goog