From patchwork Wed Dec 23 12:55:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 351445 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp6172166jai; Wed, 23 Dec 2020 04:55:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDDHWnJtiJeYLhorRT6YGeTrUX6OvZI1Y4LH7e3tiLiLiBN67y4rdT6YWxVGC3aw3Ipg6V X-Received: by 2002:a05:6402:1c04:: with SMTP id ck4mr24263593edb.320.1608728145180; Wed, 23 Dec 2020 04:55:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608728145; cv=none; d=google.com; s=arc-20160816; b=Wr91v8IGGsMfoG7oAXBaw3uSfxTWPs7ZlTG2OK8rYiELPmH3zDp9GZoNNORbcux9Tu QqVOsEAZpEehBjdeDhj8KV3ni0Bdtecz1OJWQlcaXv1jFODy0TtxnkEiCglkh365ahN5 OvtbYHRLf8MZ6z5rtCOPGqNOXjEvHi9WRCBCXpOBT9CkoZjBdCr3y09xW/MnMMEFaov/ RAlIaZJTxaJ078aQgAPY1+1OzSDtTcwnX1nLkDdavB8eigNeLUWCyTM8eM8tL/2YVR1S LJPCyonis2fTNuL2XoTcA+73ufzzXkiojVmn71AnYUM0nMXPU8FvRbAelU3tsmz9fVrT 2Hng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:cms-type:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=F6V+qSwemnBQzCEmGI+kufqwnsfQVkuy9Ib33MTjCQw=; b=k3k/6Sv05Uy+nKmPULNJn+cYbbdIM4w3gK3MLrUFxhWw0zU7WOr29EN0D51Nc4UeCG sITWSrNHUwC7XcNFAnT6e32+5DrVGeiilG6KD+O4fBzotaSErlWyDoYVgwsWriKo6MRI kRgZwZkO/bsdLTRZXi8t7tNyOprFldSv3t2GAHUIYc0yTlXEPI5LXZ+sEvWIZTyX4U7n blFXnpos1fIcTBE9NkV9pEWd9/0jGTso+OZBClBODPo0IzmKN1EfMvj7Ojnisx4BAPN/ T2IJDqytVg30ORq4M8L6yqMaHbtZDguyyAVfe3gwzygC0kBkFfDQwET7Um6HIohLqppw 83MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=i0thcqNG; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id o59si13397055edd.460.2020.12.23.04.55.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 04:55:45 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=i0thcqNG; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 116C48272A; Wed, 23 Dec 2020 13:55:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com 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=samsung.com header.i=@samsung.com header.b="i0thcqNG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6C13C82736; Wed, 23 Dec 2020 13:55:39 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 92A198272A for ; Wed, 23 Dec 2020 13:55:35 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=m.szyprowski@samsung.com Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20201223125535euoutp020508591773f7ed221b50decba9cf5306~TWbcoqXxb3096730967euoutp02P for ; Wed, 23 Dec 2020 12:55:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201223125535euoutp020508591773f7ed221b50decba9cf5306~TWbcoqXxb3096730967euoutp02P DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608728135; bh=F6V+qSwemnBQzCEmGI+kufqwnsfQVkuy9Ib33MTjCQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i0thcqNGQ02qwAWeC0NZ/F7BJ6DxZN6N92xeSuSpk3RAqlTO5w0lkRPJLXYMF2kXp u/j1IgnTIIGy4xSZRiwKepllaq6KapW38B9ASRQG2IvSZ4pXdeQFUgr+lO7jzdisBE /ouaYQ4Wgu48qPSIxvz10Rv4bXKJ8Npl2e4kCO/8= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201223125534eucas1p245258553da0084e10192b953d19dba2b~TWbca9H2W3011430114eucas1p2J; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 3D.41.45488.64E33EF5; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201223125534eucas1p12cb4b6a480be29f0101e5cd953d1ce02~TWbcHNwYJ1010410104eucas1p1D; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201223125534eusmtrp1568c0fba116fde5182a8ce6b6e99b64e~TWbcGkXZs2414424144eusmtrp1j; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) X-AuditID: cbfec7f5-c77ff7000000b1b0-5f-5fe33e46080f Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 91.E8.16282.64E33EF5; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201223125534eusmtip217956245bce3710eeca27510994398f8~TWbbrBTAH2411424114eusmtip2k; Wed, 23 Dec 2020 12:55:34 +0000 (GMT) From: Marek Szyprowski To: u-boot@lists.denx.de Cc: Marek Szyprowski , Lukasz Majewski , Simon Glass , Heinrich Schuchardt , Jaehoon Chung , Bartlomiej Zolnierkiewicz Subject: [PATCH v3 3/6] disk: dos: use generic macro for unaligned le32 access Date: Wed, 23 Dec 2020 13:55:12 +0100 Message-Id: <20201223125515.28865-4-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201223125515.28865-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSe0hTYRjG+XbOtqOxPM2ylyVJK8OKprGI0UU0QmZISCCkVnPmQVdO105m SdFSFJ3SbTMvs7L+cXm3zLzQxamboWlWw0U3bZQkbcy00kWS8yz77/c+3/PyPLx8BMZ34QJC kXGKUmfI04UcX7zNPDe0NSrcLgu77xBJWsqb2BKbu4AtmXC+Ykkaet9zJT9b25DE8aiIK+kp daEIrtSgGcGlNyv7calr6qj0+bt2JL3UWoti2Qm+u1OodMVpSh0anuSbZtZq2SrTmjPDdf2Y BtUHaJEPAeR2+D5jY2uRL8EnjQg0xW85zDCDoKPxKcYM0wichlH2v5UqjcG7UoPg8/ATtLTy orFi0cUht4HWoeV4eCUJ4L5sXTRh5DyCbvfUosmfjIWJb1aWh3EyGHoL5rge5pF7wFY/4I0L grpmTw8fwocMh5/VhV69ggB71xGG98HlzlKMYX+YtLRyGQ6EAV0J7gkGMg/B+FADlxlKELzK LUeMaxe8G3IvVCUW6m2Cps5QRo6Eiw3PcI8M5HKwOVZ4ZGwBr7WVYYzMg8ICPuPeCJWWxqXY 7hcvvXWkoNP0eG96FUH+XDl+BQVV/g+rRqgWraayaGUqRYszqGwRLVfSWRmpomOZynto4VMM zFt+tCPj5JTIhFgEMiEgMOFK3ks/u4zPS5GfzaHUmTJ1VjpFm9AaAheu5nU+qJfxyVT5KeoE Rako9b9XFuEj0LAyWb9PBiVFbakPmY6xR0Z/s4guCuOLmu580cVFdczO3f7UqoK2dTnFYQ8V yhlDeOhMvihxtjTYpRpTDbppv4MjtcmC/ctjXE9DrcPOXJHb2Ge25tK/qsXxt97c75j3dwSf XrU7xzGmT3hcdLcjJXFybFcg6+t4S51KMK77YFymsDw81LxMfyPp0vGQ7X/2Vg3JjOYLyeIN d+L0+kFF8fHp4utlVcodtlvPzY7kmqox4Ydj9vMR0RN+XT0KevLMugOH9AF9TkNNDPTlpjUZ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oqEWc1FxIgAv1Khh4wIAAA== X-CMS-MailID: 20201223125534eucas1p12cb4b6a480be29f0101e5cd953d1ce02 X-Msg-Generator: CA X-RootMTR: 20201223125534eucas1p12cb4b6a480be29f0101e5cd953d1ce02 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201223125534eucas1p12cb4b6a480be29f0101e5cd953d1ce02 References: <20201223125515.28865-1-m.szyprowski@samsung.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean Use a generic helper for reading LE32 integers. Signed-off-by: Marek Szyprowski --- disk/part_dos.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) -- 2.17.1 diff --git a/disk/part_dos.c b/disk/part_dos.c index 20d35dc9cd..3b79b9b1b8 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "part_dos.h" #include @@ -29,17 +30,6 @@ * to use large numbers of partitions */ #define MAX_EXT_PARTS 256 -/* Convert char[4] in little endian format to the host format integer - */ -static inline unsigned int le32_to_int(unsigned char *le32) -{ - return ((le32[3] << 24) + - (le32[2] << 16) + - (le32[1] << 8) + - le32[0] - ); -} - static inline int is_extended(int part_type) { return (part_type == DOS_PART_TYPE_EXTENDED || @@ -61,8 +51,8 @@ static int get_bootable(dos_partition_t *p) static void print_one_part(dos_partition_t *p, lbaint_t ext_part_sector, int part_num, unsigned int disksig) { - lbaint_t lba_start = ext_part_sector + le32_to_int (p->start4); - lbaint_t lba_size = le32_to_int (p->size4); + lbaint_t lba_start = ext_part_sector + get_unaligned_le32(p->start4); + lbaint_t lba_size = get_unaligned_le32(p->size4); printf("%3d\t%-10" LBAFlength "u\t%-10" LBAFlength "u\t%08x-%02x\t%02x%s%s\n", @@ -171,7 +161,7 @@ static void print_partition_extended(struct blk_desc *dev_desc, } if (!ext_part_sector) - disksig = le32_to_int(&buffer[DOS_PART_DISKSIG_OFFSET]); + disksig = get_unaligned_le32(&buffer[DOS_PART_DISKSIG_OFFSET]); /* Print all primary/logical partitions */ pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET); @@ -198,7 +188,7 @@ static void print_partition_extended(struct blk_desc *dev_desc, for (i = 0; i < 4; i++, pt++) { if (is_extended (pt->sys_ind)) { lbaint_t lba_start - = le32_to_int (pt->start4) + relative; + = get_unaligned_le32 (pt->start4) + relative; print_partition_extended(dev_desc, lba_start, ext_part_sector == 0 ? lba_start : relative, @@ -244,7 +234,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc, #if CONFIG_IS_ENABLED(PARTITION_UUIDS) if (!ext_part_sector) - disksig = le32_to_int(&buffer[DOS_PART_DISKSIG_OFFSET]); + disksig = get_unaligned_le32(&buffer[DOS_PART_DISKSIG_OFFSET]); #endif /* Print all primary/logical partitions */ @@ -260,8 +250,8 @@ static int part_get_info_extended(struct blk_desc *dev_desc, (ext_part_sector == 0 || is_extended(pt->sys_ind) == 0)) { info->blksz = DOS_PART_DEFAULT_SECTOR; info->start = (lbaint_t)(ext_part_sector + - le32_to_int(pt->start4)); - info->size = (lbaint_t)le32_to_int(pt->size4); + get_unaligned_le32(pt->start4)); + info->size = (lbaint_t)get_unaligned_le32(pt->size4); part_set_generic_name(dev_desc, part_num, (char *)info->name); /* sprintf(info->type, "%d, pt->sys_ind); */ @@ -286,7 +276,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc, for (i = 0; i < 4; i++, pt++) { if (is_extended (pt->sys_ind)) { lbaint_t lba_start - = le32_to_int (pt->start4) + relative; + = get_unaligned_le32 (pt->start4) + relative; return part_get_info_extended(dev_desc, lba_start, ext_part_sector == 0 ? lba_start : relative,