From patchwork Thu Dec 17 11:27:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 344923 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp1077037jai; Thu, 17 Dec 2020 03:28:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwo6CK+Ykm37FCaw7G7aNP7beAeqVSCls+NKYlvu8gComlOml6wuZXs9XPSXsqw/+c/cOAY X-Received: by 2002:a17:906:417:: with SMTP id d23mr34851521eja.19.1608204519229; Thu, 17 Dec 2020 03:28:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608204519; cv=none; d=google.com; s=arc-20160816; b=ll+8eu3CTEv2MP914AebhsYE1H6ga16Fb/1HxUQIF+CWegnz16c1xhVSNw4gKxM1CD 1jdwv03Rea6xpF7WfnlHfy8R8n30LFGaFHKk3eLx9YRzEQptzjceqP0FsL4DEAngyWN/ fOiFkmJ6i38tl/EfPh5Yk2lYjUlqeTT0L8wADQuebFCgTbp+J/8WvDhYJfXmwZt0H+fw u8wMmfSS3eTeHapm19xBp9rbvVnXtIcRyPUxh6IGK4sQvz5x12DcX6+jpw7KbfT7ZSXJ IjM5FjAPmFDbOWrUjbjaZ0/NYB2y1aeo9jQ9/Q7kuYm10WlPkxdGUmFfEaYP0p5PU55f H03w== 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=cdQS4RSrGduGOGDqnKaZXtKtwAXaYdLJzTCmy5XY16eO4rK9z6I0qXrMfMhpEymE09 sjRR11783hk2l4rm59KT0niBTy/LlYLqIVI6Xi54Nykns/cNXXFE6OtrVCqE9pqEbqoL r1exm3jRLe0veHU57WKVX2ImVHe+vP/mQrRQNlWp81U9mrc+16cG0z/MKFf76S/FUB88 RzSTOheP/WH4cev3Cnz2BbJH2y2OWnlHwBi47FjD7u/efyfW+nUy5qX7N+/gEf3aMsdX i+0sayZr0uO/DohvjGgsOmJchcSD6vFWHGxe3vfJ/2jrGQoA/mpXAAXkegCPNU8EqE2p M4ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=d8gESg0y; 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 ga28si2537851ejc.221.2020.12.17.03.28.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Dec 2020 03:28:39 -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=d8gESg0y; 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 D693182BB3; Thu, 17 Dec 2020 12:28:12 +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="d8gESg0y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ADE2C82BA6; Thu, 17 Dec 2020 12:28:06 +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 93F98826A7 for ; Thu, 17 Dec 2020 12:28:02 +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 20201217112752euoutp0289aa9def6e7d39a59b3781049d82c079~RfXJlj2tS2518325183euoutp02f for ; Thu, 17 Dec 2020 11:27:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20201217112752euoutp0289aa9def6e7d39a59b3781049d82c079~RfXJlj2tS2518325183euoutp02f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1608204472; bh=F6V+qSwemnBQzCEmGI+kufqwnsfQVkuy9Ib33MTjCQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d8gESg0ygmryu2a7sVImLzrjTLFhX+p+MK70s9eFAl0s0dzyFI6RbzZIArfIUM/Jp 9LlMa+2ep+lA0R9lMGdcLs+khK7wFZsite35wlUqlpVbLbMj4++MYTE2SFUex6eCZ9 17zKKnZCFpgYX5xSOk5chdPPMBe3swpyJFhvuYqg= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20201217112746eucas1p142f3266aac9681806833a64a158b36a0~RfXElV1yz1194011940eucas1p10; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 91.41.27958.2B04BDF5; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20201217112746eucas1p28380ab10ea3b33a963dd4f73afecc43c~RfXEJuoH-0440704407eucas1p2l; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20201217112746eusmtrp1e97b0de1c3e38848b146d41e9a7375b2~RfXEJIc6d0498804988eusmtrp1g; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) X-AuditID: cbfec7f2-f15ff70000006d36-e4-5fdb40b29e98 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 1D.73.21957.2B04BDF5; Thu, 17 Dec 2020 11:27:46 +0000 (GMT) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20201217112745eusmtip2af74e0343848c2721626289534c9b316~RfXDwHDAZ3162131621eusmtip2P; Thu, 17 Dec 2020 11:27:45 +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 3/6] disk: dos: use generic macro for unaligned le32 access Date: Thu, 17 Dec 2020 12:27:36 +0100 Message-Id: <20201217112739.5045-4-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201217112739.5045-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHIsWRmVeSWpSXmKPExsWy7djPc7qbHG7HGxzap2WxccZ6Vosbv9pY LZ6/u8xksfbIXXaLb1u2MVq83dvJbnF46gdGB3aP2Q0XWTzmzTrB4vHhY5zH2Ts7GD36tqxi DGCN4rJJSc3JLEst0rdL4Mo41tXFWnBIuuL86hPMDYxrxLoYOTkkBEwkrl29wt7FyMUhJLCC UWL6p8/MEM4XRom7EyawQDifGSUaP3xihGn5+fQCC4gtJLCcUeLIdUYIG6jj0B8hEJtNwFCi 620XG4gtIiAh8av/KiPIIGaBf4wSB399ZAVJCAt4S2z91gTWzCKgKvH/ex8ziM0rYCMx9/Ft dohl8hKrNxwAinNwcArYSixvLwOZIyEwk0Pi9MWTrBA1LhJ7LjxghrCFJV4d3wLVKyNxenIP C0RDM6PEw3Nr2SGcHkaJy00zoN6xlrhz7hcbyAZmAU2J9bv0IcKOEruaroEtlhDgk7jxVhAk zAxkTto2HSrMK9HRJgRRrSYx6/g6uLUHL1yCOsdD4trhx0yQQJzAKPH38R/mCYzysxCWLWBk XMUonlpanJueWmyYl1quV5yYW1yal66XnJ+7iRGYJE7/O/5pB+PcVx/1DjEycTAeYpTgYFYS 4U04cDNeiDclsbIqtSg/vqg0J7X4EKM0B4uSOO+q2WvihQTSE0tSs1NTC1KLYLJMHJxSDUwT Q4u9QqPt3vxYf/6Udt5C9SUc7eJ7D32LeaJSHMRVyjqthNXjW8aXvqcdm8wOaNr+Cpl2my/W 5tOSE07V8xetTO090l18WfMhg0KPStmZ5bNCJ99TXnlsetYFtcxSlr8yJ/T+Lmfkmar2J39e Sd/ia/481ZZbmZY/KH2h4tCkxHtoS/0hrSNu4T96F2zPDlArb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zq13U55rPJ1z3/mBqJuP4dSHfwVe6M0+fMYneYPiDjEZieVXd5oJ2pRWznhj+ePw9ZSW bVs3Hs/g2fkrZPk0c++KhTUySizFGYmGWsxFxYkA5WsIUuICAAA= X-CMS-MailID: 20201217112746eucas1p28380ab10ea3b33a963dd4f73afecc43c X-Msg-Generator: CA X-RootMTR: 20201217112746eucas1p28380ab10ea3b33a963dd4f73afecc43c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20201217112746eucas1p28380ab10ea3b33a963dd4f73afecc43c References: <20201217112739.5045-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,