From patchwork Tue Dec 22 14:09:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 346640 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp5358615jai; Tue, 22 Dec 2020 06:10:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQai4ngdfu20ysCA+xzX9UBjVzQ1KOQU/waOmTwyz40H0dyeixrpNhL/ClNrMTQJsiRR3j X-Received: by 2002:a17:906:a115:: with SMTP id t21mr19745074ejy.549.1608646252535; Tue, 22 Dec 2020 06:10:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608646252; cv=none; d=google.com; s=arc-20160816; b=iyHrIOFYfcThgwFFeGA6oElg0Yg5Uf/cLkceflTpHIEHzUhQoP0/cDk/vRAfKVH7i9 kQEK9WFHolcGEfN8Lt4ZNBTXFlatb51SmkYB/cLYfBxIKakDLxuYN1bGAI2sd0Y4fOD3 /grlkM3HSY6qZkstA4ul2vEjzAx+Pgpb8COn+uIs4bSNr3/2ABbnakr8fHXqAwQdh6gL O6wVIqyPXXOKs0qPXiqChXAgN91YdVoVpjhtdohbaigrKtbFyLg6b0JYd+KTuSLPUPQY OaKPlblw8+qaoEHDHK0xrx+wLjo49sUTsNNpVk4jkc0GNvjgQHOPIp4fKrc+O/RuA7pO zttQ== 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=xzHBcDYJ891E+4IKdcxvRnQFEgNb3FjG6Y3OFUyh2nteYt4R26bFwIlB9w3B+CYb01 +KUHu1Ynz+eCsc5GvwLaQ9ydLlsx0JmsNie5CEefXDje5Nfyjl19MLWfmksHaqZyvTSn 3/jN+yRmPv542FvhWA6BPlf54cIfDIqUCECvU/Rs9zcvjlZdkVMdSYAhVnqX2OXBVAT4 dOFrMwhhRATBnpgrzryYCsbwXuCZJvsDp005/uXfD45FfgsAjWHTrDqUDEgayXWdZJUY KrEjlYejf66AHLhWFW10wmeAnlh06eNuVm4hd1TypXUJSgloynxqeZAW31QXK6Xj1cDH +WtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=aniFWqdP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id k9si10171324ejz.703.2020.12.22.06.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Dec 2020 06:10:52 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=aniFWqdP; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 7609082ACA; Tue, 22 Dec 2020 15:10:30 +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="aniFWqdP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BE9EF82AD6; Tue, 22 Dec 2020 15:10:00 +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 mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2A99982AC6 for ; Tue, 22 Dec 2020 15:09:50 +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 eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20201222140949euoutp01075a6e79b4ffe9d78b316e9979a4b098~TDy-BHLIa2159821598euoutp01f for ; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20201222140949euoutp01075a6e79b4ffe9d78b316e9979a4b098~TDy-BHLIa2159821598euoutp01f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608646189; bh=F6V+qSwemnBQzCEmGI+kufqwnsfQVkuy9Ib33MTjCQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aniFWqdPO6TkJdqsFKEV/DaljjlhUkUh6Om72rnpSigLlJXxVDMXfMgMZ2OLeRgEy p2XzZa6RkM8hSGgP9XMaDWCmcCw5qUPKrBHDq11ZwmEU9DvhzKTkXGq6t45/ezP6oJ MjHch/MRsdck6OAcPsZ/iAOw6+A/dPoT5nzg3zOk= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20201222140949eucas1p274f2a1051cf62c5f1dd7f42407a941ba~TDy_pV73g1624516245eucas1p2-; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id DB.8D.45488.D2EF1EF5; Tue, 22 Dec 2020 14:09:49 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20201222140948eucas1p1e3e38a2c34b4779297dbba74d6a1b781~TDy_PJ-fw2338623386eucas1p1K; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201222140948eusmtrp110d6c253938f7c249e2e83500e71b379~TDy_OmPZO0827608276eusmtrp1h; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) X-AuditID: cbfec7f5-c5fff7000000b1b0-f3-5fe1fe2de26a Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 55.37.16282.C2EF1EF5; Tue, 22 Dec 2020 14:09:48 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20201222140948eusmtip16323816e965b3fc310ced4e7d9083b73~TDy9xkIKT0861208612eusmtip1D; Tue, 22 Dec 2020 14:09:48 +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 v2 3/6] disk: dos: use generic macro for unaligned le32 access Date: Tue, 22 Dec 2020 15:09:11 +0100 Message-Id: <20201222140914.9933-4-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201222140914.9933-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSe0hTcRTH++3ebdfZ6jpFf9lDkizssZw9uOYqA8P7l0kFvdA58qKWm7Lr q6JcaWZD1rQk2cBKrcx3OqcMtJw2LZv5qoSU0lEza+VQK0dJzkv23+d7zvd7DhwOhgimUF8s UZ5KKeTSJH8ODzWY53q3bZsfkwQ1tLkRj4vr2MSwM5dN2L4NsoiazlEu8UNvAIS99TqX6Cia AmFcUqfsR8kSbTdKTjliSMtICyDV+koQxT7JE8dRSYnplGL7vlheglmlYqeYVme+qupGlKDa WwUwDOI7oW48XQV4mACvANBiaQaMmAGwU29iMWIawAFN84JwW0xk5xg5TOMhgE7DI+5SpLQ6 l+tycXARVNlVHBd74RA6b7xenIvg8wC2Ox1sV8MTj4LdL+2LARQPgC9GraiL+bgYzhqH2Mw6 P1hV/xRxsRu+F5onRhDXIIgXYVBbMM5hTOFw5l0byrAnnOzScxleA3tu5qNMIBvAsd4aLiPy ARy8UgwYVygc6XVyXPdA8EBYZ9zOlA9Ay+AwhznTCjhs93CVkQUsNNxGmDIf5uUKGPdGqO2q XVrb3jeAMEzCj7O3EOZCGgBL2gY4GuCn/b/sLgCVwIdKo2XxFL1DTmUIaamMTpPHC08nyxrA wlP0zHfNtoCKSYfQBFgYMAGIIf5e/N2+7yUCfpz03HlKkSxRpCVRtAmsxlB/H76xqVoiwOOl qdRZikqhFP+6LMzNV8mif00pA9pfzCoD4i/k1VSmG7KPBh5WnvmzIeGziPxClERw5zqOZH7Z EiNrLHu8NiYyK+64YZeCN8Fu9LaVa+H+6BPF1kN1ibz88elrl+sn5VEzvb9XnBL9DL1Wr3FU iA+ul+mzq7SZBS2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fZ/KfXFn/p0sNvF6UZf5vF/VdOYdrSgsfy J8w46pbcD2+5l3yZr820z81H1vzbSfcrX9becdui3FbftuuO1/pCq4fT6pw/6nFuWjvr2LY7 bVb/Z+eeK1Eoye4OsPFTYinOSDTUYi4qTgQAt8xJw+ICAAA= X-CMS-MailID: 20201222140948eucas1p1e3e38a2c34b4779297dbba74d6a1b781 X-Msg-Generator: CA X-RootMTR: 20201222140948eucas1p1e3e38a2c34b4779297dbba74d6a1b781 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201222140948eucas1p1e3e38a2c34b4779297dbba74d6a1b781 References: <20201222140914.9933-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,