From patchwork Thu May 4 22:50:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9712901 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CAA7560387 for ; Thu, 4 May 2017 22:51:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC30C286A9 for ; Thu, 4 May 2017 22:51:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0921286B3; Thu, 4 May 2017 22:51:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B7F728695 for ; Thu, 4 May 2017 22:51:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751894AbdEDWv4 (ORCPT ); Thu, 4 May 2017 18:51:56 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:18484 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752949AbdEDWvO (ORCPT ); Thu, 4 May 2017 18:51:14 -0400 X-IronPort-AV: E=Sophos;i="5.38,289,1491235200"; d="scan'208";a="111976834" Received: from mail-cys01nam02lp0056.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([207.46.163.56]) by ob1.hgst.iphmx.com with ESMTP; 05 May 2017 06:57:15 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ZsJvWrB2wO9b63zVO3nJokRlW307+/VpGhdD9ASKumA=; b=uPAVcltrgPJ2iNtSeMGt/0+rpwGnul6v2VCzRVQyNleQJg8U4RG6Jk8xkTD7pRH1wNRSl6eJ0dDaW4UqHI6O7l2gTifhjlMhLXudnI75Rhe7sPc0tNhs/4nuRbqFH9DDZBh1/GDmi3qwLC/uBLkIU7E6Xezp/BFDu93IgsiFCjc= Received: from CO2PR04CA0122.namprd04.prod.outlook.com (10.165.95.24) by BN3PR0401MB1543.namprd04.prod.outlook.com (10.163.38.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1061.12; Thu, 4 May 2017 22:51:10 +0000 Received: from CO1NAM04FT003.eop-NAM04.prod.protection.outlook.com (2a01:111:f400:7e4d::202) by CO2PR04CA0122.outlook.office365.com (2603:10b6:104:7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1075.11 via Frontend Transport; Thu, 4 May 2017 22:51:09 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) smtp.mailfrom=sandisk.com; suse.de; dkim=none (message not signed) header.d=none;suse.de; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.21 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.21; helo=milsmgep15.sandisk.com; Received: from milsmgep15.sandisk.com (63.163.107.21) by CO1NAM04FT003.mail.protection.outlook.com (10.152.90.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.1047.9 via Frontend Transport; Thu, 4 May 2017 22:51:08 +0000 Received: from MILHUBIP03.sdcorp.global.sandisk.com (Unknown_Domain [10.201.67.162]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id 1A.D4.29323.B50BB095; Thu, 4 May 2017 15:51:07 -0700 (PDT) Received: from milsmgip11.sandisk.com (10.177.9.6) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Thu, 4 May 2017 15:51:04 -0700 X-AuditID: 0ac94369-548749800000728b-fc-590bb05b1e4f Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id C4.F0.11415.850BB095; Thu, 4 May 2017 15:51:04 -0700 (PDT) From: Bart Van Assche To: Nicholas Bellinger CC: , Bart Van Assche , Christoph Hellwig , Hannes Reinecke , Andy Grover , David Disseldorp Subject: [PATCH 08/19] target: Use get_unaligned_be*() instead of open coding these functions Date: Thu, 4 May 2017 15:50:51 -0700 Message-ID: <20170504225102.8931-9-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170504225102.8931-1-bart.vanassche@sandisk.com> References: <20170504225102.8931-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRmVeSWpSXmKPExsXCddJ5kW70Bu5Igy39Rhb7Zz1jsvj6fzqL xYI3e9ksVq4+ymTRtvoMo0Xr0rdMDmwe97cfYfLYfbOBzeP9vqtsHuu3XGXx2Hy62uPzJrkA tigum5TUnMyy1CJ9uwSujH1rj7AV/DjIWHF4yWamBsa3sxm7GDk5JARMJB4/PcDWxcjFISSw lEni7buNLCAJIYGtjBInZnLDFO39+okVomgzo8T3pmdg3WwCRhLf3s8EaxAR0JGYdfcFO0gR s8BtRonnBz+ygSSEBWIlVq3vAmtgEVCRaJp9gBXE5hWwk+iY2s8GsUFe4uyWncwgNqeAvcTe GfeZIK6wk1jTv5kRZKiEwDJWiQUrJkM1C0qcnPkEbDOzgITEwRcvmCEa1CVOLpnPNIFRaBaS sllIyhYwMq1iFMvNzCnOTU8tMDTVK07MS8ksztZLzs/dxAiJg8wdjHefeB9iFOBgVOLhXeDG HSnEmlhWXJl7iFGCg1lJhDdiBVCINyWxsiq1KD++qDQntfgQozQHi5I47zmZqRFCAumJJanZ qakFqUUwWSYOTqkGRj22H3szxH41bZncyvdKJP27rGXy86auPUxTeWQPrXzuG60y4a5+wwdH j2pz5nYD370nbzzcrHVq35akm0mJvyvv8xR8Piz3+wF30LXi6gVz2Vl2zD9hYu9ROHvicUWj Zt891T8tXyyXsK+LONx5OIU9MDl2hfEvDokpEU//PFw7Y185t/neaUosxRmJhlrMRcWJAEwS L35/AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrDJMWRmVeSWpSXmKPExsXCtZEjRTdiA3ekQdtifYv9s54xWRz82cZo 8fX/dBaLBW/2slmsXH2UyaJt9RlGi9alb5kc2D3ubz/C5LH7ZgObx/t9V9k8pq05z+SxfstV Fo/Np6s9Pm+SC2CP4rJJSc3JLEst0rdL4MrYt/YIW8GPg4wVh5dsZmpgfDubsYuRk0NCwERi 79dPrF2MXBxCAhsZJfZf380EkmATMJL49n4mC4gtIqAjMevuC3aQImaBu4wSF9qfM4MkhAVi JVat7wKbxCKgKrHlzX92EJtXwE5ix9vfLBAb5CXObtkJVs8pYC+xd8Z9sAVCQDVr+jczTmDk XsDIsIpRLDczpzg3PbPA0FCvODEvJbM4Wy85P3cTIzh8OCN3MD6daH6IkYmDU6qB8ULwx1c/ t0/fs6gtIj/2sJc+05Kpv2+1iXK3njzC8TT1bY7OuhDrfwduOlx/VtypyG7f/++WhM77dt71 D9RzT2gGLXoxa7mJO49rtO6avtmsrOun+75Zfq3iRjW3VXfJeaPrkn/OH49KNfRsCYzKsW66 vPvd/k0iiyzznlxYabfdTsz9RMhXXSWW4oxEQy3mouJEAIoOX5vPAQAA MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:63.163.107.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10019020)(39840400002)(39410400002)(39400400002)(39380400002)(39860400002)(39850400002)(39450400003)(2980300002)(438002)(40224003)(199003)(189002)(9170700003)(77096006)(8936002)(1076002)(2906002)(50466002)(478600001)(305945005)(356003)(50226002)(81166006)(8676002)(5003940100001)(50986999)(33646002)(76176999)(48376002)(4326008)(189998001)(54906002)(106466001)(36756003)(86362001)(53936002)(575784001)(2950100002)(5660300001)(47776003)(6666003)(6916009)(38730400002)(110136004); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3PR0401MB1543; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM04FT003; 1:BuJK7oH3uUfc2VX5PjcevrFG1ugcU5BQuYx1UrnL4iO0R4WWyy9Iw/GslPPnI8yUZbV90PO2wsW6lIlA9B3eq/SxfWjsT9chW5nX2kQa0chJyk8LHg5m90wNTDmewee3kGhYP3RcYtmdCG3+hCkvpYSIbyGCUpHiceaRHIDG+8XrCbX0LH/444t920SFfVyvIyXBR3QPUAFRSOQJqSYsih7g5BwNLoGbyEypHTQamFa6ouz98EotiW4/b7qrQyR/5LRZ64jH+ksYVBqDjDgLheYEQ2t7bfEw3O1rfpNNfLVnrwLTbvcggGVXGVS5SntwY1PhcDVl9G2Xja3EynlHZ//Lq736uEozsNqoY82CUa+S6jJ27Pcqge2y5mXB9dlVo3vxqvbFWJBllRif0ks7Bpsyfhj1utLT4ROX7I+nvVMmAT0qc1lGqSbc6w2aF8tovDIj3nyImJqM5GWenKTZhgsfBceqxxPznz5JtpXVQKqH8De+XAEI7HCOCLL54rqUDm2G7uHQ+jZj8ur7H4koc50rt+U7K6rIDGt/Q6D02uk= X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 00f557b2-2605-4883-7501-08d493400e44 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081)(201702281549075); SRVR:BN3PR0401MB1543; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0401MB1543; 3:RX9OhoCkTRisLcBi1nJi+BM5SVOUeaoHZoiocvab63a+d/154PFTVyv23hmq1BOm+NYG1oXZK9jzQxnDCkzTfeOuSm+aGKPZTQuMbEwKC2BWMK5+p7kHUn6eAraMB5s+nDWHnNcJgNP91Y/5q10ghjZigVXE6IO+WFp38FYiA9upxC6fEWAlsX5CFaYauBsr3s0fhFCoWDGW3WZrzCIsPGILscWZ4R6hLiDUfkhOs3478QYWvgzgyACaAAB+KqKMqOQt0z2iaXgp3RRus74r4dMmW1CEJ9u51Xh3miIUl+zLKjzqxszw3WqbdfK/U5ZJURdy2Dt1bL0TX7O1GefmRzgom1ObdoNrQRxAOU+Bhb2Ff5Sic4/BlPauGLDLdi7qr0VL9uNClcNbwSu04AvS8AnyoeuSA7m0R9sE2tRrhHUbT9q0JZVqZCpdR7SANETYif86oBrQRcF9CYVNK5x9q/O2U3qzGPLEZnLl0SXoaERTCEa42v1oRD1XpHU060WphmSDDa32UqVfNCQj3RsxHg== X-Microsoft-Exchange-Diagnostics: 1; BN3PR0401MB1543; 25:yHbbQ9nBtodoDkzGGnxvHd6VuW+qw6L9gURmE0Fgs6Jk8+bf5eXw4yfCnCn2DwPI4ATc86FwZz1yOn/fe9ZCiF9xOrhNNbnAjMiuP/dWYAGlkVENKDyoU/Bk3RW+g4LHLIl31U/9t3rcVfNreXV6rUk4fz4mQ4VFyBhMEXgdgR6hnYTM/hX7atWyqjVXvPih3CuKCqaKg286QJV7KLNF19jtNRDGO7CH7micGbukUXrlIlHa0uTKdzIFE6lIAtk3ykv5wxTKg2gQyryeFJZOTl5T6TRTSK/THj4aXrfvJK8ix75TfoprfwiD9lBeJL+deQME8SyaZLjUEJI7bAGjTUq1IqptIX2iuHlxFgULWTr274WrHCvN7AjtYe1AzbBgN9MQT+liMREI9xN8mqBfwBGdTGUNC1OMZniOlfgySksOkGeeaY1a/ez6oFWx44jhOou5V34JfmkwxktHyOqmCg==; 31:52yMRd6vLHMEvwMjS4YNzteHvwhQTZbblpHN14jZHqs65tL4nV8FzG5xUHXz/37wpsY4sTJI6Smq0IGCIj4fI0MnKUs+L8Z0jlD4KVQQ+mJTb4NlGFji6Igbuwo90hE7A9Vmgz87WHsBAEflrJPTSsSmDvazP+PD/0rcl9tNU5tzbngGZaoNQq7IhLrFkd3hiZY37/a16ZDWOJA/s/wX1ZK9T/9uGPd/StDn2FJX/WEXyv3GQj1EwH1+04yZ5B0kYAWebEdlmGxnL8fvJBmzmQ== WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1; BN3PR0401MB1543; 20:iTaChRVkRy1+kdPNo4fBswt1zsFHHti37OmSILj8Iiekucy5pcD2UegSWRaKG04ZdgS1Vq0O/t67GaJIFVegvQPhAFC4asH/9Cwa6C5/aBRlNSszE6+ZG0JIdCImGJS48ptsaTBOZdXcihZsVToSqxz3nrZREV3yzqdSE8SOYKpWVc7C4oXsA//+Wvnjg5zXW+hqm44W378E95LGaOpI0qjn2wrLgyCpc7GXi2rR13/+F+DuV8SNjVZv0zXNfy+5WgxEAMphIXKhDHMJA2kn0TIbgOeZ4olL9NZh4UQc31MUOZwVWkqce1++2uQb+jVUeggfFVcdctqL3W7ONP+xMkdBUwU+5PT4wiOJSSE9TPmlCxDUOmCcpuBr5XJyWurC8DKJ7Iwp+51YdLfkkyXhaGenTbFR6EEgHwnrjfVvjqc3y4Hgiz9n/WqGA6l1KZkWwoCDppdiSZqGmNmWHKwVzCtwRsSyZVnoBNs6h4jCGRNYdKT5gVXnNAGTSSdSmJxB X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192374486261705)(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(13018025)(13016025)(5005006)(8121501046)(93006095)(93004095)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123555025)(6072148); SRVR:BN3PR0401MB1543; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0401MB1543; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0401MB1543; 4:od/d099GvSwEEEdJp7lq9FgikH45K5rV55EGOJ87ZfW3mquUsb2kiV5B5o8gC0HnJ0CkFE25FuTIhNrEJyPLXYSbjZodj+50HFI/yglYpGY/xysaLq4f49fHYECPO5vk0IebCurc2ixzVggsFdwdglxqb5Id297f+XrGXBYRqeNECfxSe7s1DYn36ygy7lqGYt6KOmRgFpRZw+GhV56N6tPFVsk/UOUiVpIHfMwqmhpnSaiRyhezxSHekaKpiBvXOm5nXnIr/RE2COsF3M6Eqwxr3vvq8c8p/WYmKb/SLkQmo91/zoq2kp3ukuWhcoSZUGZ+2g7whr/XJIksfaL/Z0d+O9LenShceWvfI6di/zuRQU0ksvsrlCaWGxonwMkLnp0xpkGWZI4xqosLcY2rFS+aHIFLKtqeyQVH3rJ3u23rzXAOnsmPPJo7YcT5cwGl4SxX8C5iGU4PezfneIn7yifpq32R9TSXPdRRZp4YEUtiZPYD9SIupEBKAgNt+j0dgaoMgDYUSFcpiykCvd6VVASbuQKlWKJWsWRPnoUQJDF9iP9bSOxoOG1GLuwK/4E2ho98ZCpRWFqP7frKW3eZuiLVvT9h43iwfw6DgnkLI0LoSst63MEqv3CqZ4t1LOuzxKz4SdbJjOrjrK4OrHNVyg4VlfykY6xfsoDRfB4bDB5vWvFVmnAIhnKMPDrl19UnjsACAYBW3SM4LHzi/LkL8hKGfNgVFa6ooSw2TJp4HIPNVExdK3SqxdVKtDfKPXLEnuitlVViyfmZnP8e51HSikiOuZUbG9smr9jTEd6vi1+4brN5Wq1mK/ho/jMSoQ2rLopEgsoDsT4q8Npav5EKZPal1tJpv+b+82OdJNz0xxFiWqy0y8iBC+4MKYH/wW2B0LdsmLhNGrtEd7Sa928osiNR8oD4TdXtg/kNhVyn /Ac= X-Forefront-PRVS: 02973C87BC X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0401MB1543; 23:QcrKPC0FybWgY2ON+RDw6qeuG2e6M9wOgHELHbq?= =?us-ascii?Q?SZQQTsDVK5ONMnD9hPTGa8Xw/RLE8yTGjYX5ERAZcr0yaYorY9gSE58ipGSw?= =?us-ascii?Q?eAr3a/bRotsZFScMvc9WrDGHAi7iJCqK/hNZ/6Twh9JIFLbxn2YRhydPVzoE?= =?us-ascii?Q?JOSMlzOPAF8cVSoGA7sokeC+oufzTJ3+vDLeaNxq/kzNTQo6mMOg6vu7xpAn?= =?us-ascii?Q?WVXpmGPb3qnnZz+hQdqGgZ35na90Ftoos1WS4vACHHZrYH9vADtbpxCWVP8B?= =?us-ascii?Q?jVHnt0CMyhGLSlCEER+3Lx1SGUbQ+PyH68MmzUznaIexNbsfwE/HKUB7rs/Y?= =?us-ascii?Q?juHFlFdSJNUJlYI5ktYacGV93N7ONifQaa2RbsXGRw7pxzdKJIX8T2p2drTM?= =?us-ascii?Q?Ykqfv1PdphhQmyX+86dSPxemSABbbw1uBpho7LGgoT+ar0VeH0692xS5E1Xn?= =?us-ascii?Q?3MvFPJL85b1d+URIuiR8OyMi5SwTbvru5EAWgQ/+8YSFDj+a7vMpwg7jMrOn?= =?us-ascii?Q?if1H8zeOWAtnQ0HuGylOfIjnzz4uLyYnQk9rxgSKz74TLlnIBmGsvHHEE532?= =?us-ascii?Q?NX3oaPg7uxmdiujbvicEwZdpIbDvQZSDI+TGKYrRh+K4jbYJCKj5WsUraK/s?= =?us-ascii?Q?hHPLhhcbUvW1T2c3oCbULjtD+zF0o5XSoarXUqPIQqmUF3F82fCmUu6mdAoe?= =?us-ascii?Q?ubr2SRy07sC603+kQlAK5qNGtmbqBcB++T+DKoJCpss18uzMJdEpGojgjxRO?= =?us-ascii?Q?cQIJFGE8c/XFE8cqmaeQI7wlEeTsEWST1Af21G23PLTDHUqAFNDC3AFah1pH?= =?us-ascii?Q?vMfhF7PB04qZs+nmmU8NCLFCn8WBBJhTLDPfADJ+Qq8HN7ffma/8pb1tMiKW?= =?us-ascii?Q?ku0mC18RU/Qg7AoPEPBj2wPg3Pe65kzok4dMZfqICL44ab5xjletCNVQyGsg?= =?us-ascii?Q?tyqIoyVkbVqZyYv1gV1VHW58xt2fDjpleGuFMowhYzIB+PmRZiyf2j1KTYvO?= =?us-ascii?Q?nlrmvnlN7F+NoaNAHeXjTB/LY7Rqolmjd++aIWoH97AkFVU32WA888FnkD+3?= =?us-ascii?Q?6PZcw6LIqEPrBO05LTm0s34Kg6JiHPsVL4zXyoCZpTBSpk8vQeQADfqqTuh3?= =?us-ascii?Q?xcZDNpcL9Qy0=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0401MB1543; 6:oocYG/ZI0dAGvLoOLh2oZbFTCQJnWhVlilxTo8wBP9hOAl/IVvpUH1+voHWfnrqnUy07Rkxt4BUTXaDsiO+UWpLI/WNrb1q759B8lDcbK1ohzRjbZzvrpCFMSeO39PNKCYmiJvlH2Bmiim1zUBuqKTcjCX9xUuoNJMuAotmVOEGLv1XiLe7GlQWcxi3crymuhyxYUBLclwk5G5wmQ9aBG0f6skxRalsuL4GcRiM9auunWBLazWETpD2v5ln+YFXzpddy7ai+d69roeWzSt0DpphfVApWNxXf4uw0zF9Kgwga3GReOHuaH4TJgDNWeA6Mzm3YnRpaCFQSI9VbUpoz4UNZvFNDDTvEVfYWBFDtZIwmsjku/fuewKOVeajcDHj6MxiLY2GI2h+ixR4DpEmoBD2QRsi58UJ2yLOgJAAGsOAwBbSHJWAMLpLCWqMzfoxq3Y/Nh94X1l2PjU0VOlMvw9JQgK0DpNV4a/SJN9ycD5PZU9IhklgH5poTecAjngI6YsNbHW2gle2h4C/0BWX3xr7IKZ88A8z6ddnfvzOE7IM=; 5:lTKPABIKvg/BPCL7d+o/2mMG30xMdwMQ1vWY2/hgcfi4Usmm2StcxvYAUOnbEvjOJAiuFUxsMEnT0dRyP5VqgMQpMFNJyBJGs8aaO+jg9g57FfhOoFxPC4MXiUjmahyqQ68PWlfLi4dmfpLMOkydZg==; 24:PgvUVRbD3et+C/0FL5el9LK6/GwH0pz0fbkT7Fo9WlG3Za1eFTRAzVuIXADYkViKcoFmAq8zOk5F5/lPjbM5g3DterfW20iUXIQuHxPHGL0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN3PR0401MB1543; 7:hTEDSt4xd5ZpNt+HggzFfU+yEGZyDVSFteaoQIk0FSDJb7Pb4ma23KSvODPiJSgXh7AWWpGxw/+18Ala14xf1HHxZrGp5kiRfYhYXyZ4eJ29o5jTGzGQHsJQIGvm77uO5nWA1Z1SvYe2jPWRBNcZ3GboerEOcXaQz7s1chnEMi7aUfDHtMCWyPXP0Sf7zIyKDGURWtRV2VPRUl3ubsP+kc+Sj0aHuzo9/H1ublL/RalhoHZYkTXt+PIXwyTiXMM7YJ3BsSCYSbvaJeKGQyIdFp1uC31jI+HSsqFtKfn7QCnb92nKCBTx8VrEd3QVqs3lOH+LvgeM2uPd6v5kCWkvlw==; 20:IWPjbgNd6GSBysKidZheJJb7JswwLpX1QM7CXMbhPPieCOlTBz474Wm6C3pj8enAFVM8g2BS7PFjZ1/UIquEGs0UXPrrIhoElMipMlE0M4vg8G+nuQYVno3iKEnBSyR/PLBc423P/5iqPHqv3UU8ukrRhXeRow3Y2118Qi9Yb0I= X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2017 22:51:08.8577 (UTC) X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=b61c8803-16f3-4c35-9b17-6f65f441df86; Ip=[63.163.107.21]; Helo=[milsmgep15.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0401MB1543 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch does not change any functionality. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Andy Grover Cc: David Disseldorp Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig --- drivers/target/target_core_alua.c | 8 +-- drivers/target/target_core_device.c | 8 +-- drivers/target/target_core_fabric_lib.c | 6 +-- drivers/target/target_core_pr.c | 92 +++++++-------------------------- drivers/target/target_core_pscsi.c | 20 +++---- drivers/target/target_core_sbc.c | 59 ++++++--------------- drivers/target/target_core_spc.c | 42 +++++++-------- drivers/target/target_core_xcopy.c | 4 +- include/target/target_core_backend.h | 8 +++ 9 files changed, 82 insertions(+), 165 deletions(-) diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c index fc4a9c303d55..a91b7c25ffd4 100644 --- a/drivers/target/target_core_alua.c +++ b/drivers/target/target_core_alua.c @@ -205,8 +205,8 @@ target_emulate_report_target_port_groups(struct se_cmd *cmd) /* * TARGET PORT GROUP */ - buf[off++] = ((tg_pt_gp->tg_pt_gp_id >> 8) & 0xff); - buf[off++] = (tg_pt_gp->tg_pt_gp_id & 0xff); + put_unaligned_be16(tg_pt_gp->tg_pt_gp_id, &buf[off]); + off += 2; off++; /* Skip over Reserved */ /* @@ -235,8 +235,8 @@ target_emulate_report_target_port_groups(struct se_cmd *cmd) /* * Set RELATIVE TARGET PORT IDENTIFIER */ - buf[off++] = ((lun->lun_rtpi >> 8) & 0xff); - buf[off++] = (lun->lun_rtpi & 0xff); + put_unaligned_be16(lun->lun_rtpi, &buf[off]); + off += 2; rd_len += 4; } spin_unlock(&tg_pt_gp->tg_pt_gp_lock); diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index 5b364634ee7c..bc029ce32108 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -1086,19 +1086,19 @@ passthrough_parse_cdb(struct se_cmd *cmd, TRANSPORT_FLAG_PASSTHROUGH_PGR)) { if (cdb[0] == PERSISTENT_RESERVE_IN) { cmd->execute_cmd = target_scsi3_emulate_pr_in; - size = (cdb[7] << 8) + cdb[8]; + size = get_unaligned_be16(&cdb[7]); return target_cmd_size_check(cmd, size); } if (cdb[0] == PERSISTENT_RESERVE_OUT) { cmd->execute_cmd = target_scsi3_emulate_pr_out; - size = (cdb[7] << 8) + cdb[8]; + size = get_unaligned_be16(&cdb[7]); return target_cmd_size_check(cmd, size); } if (cdb[0] == RELEASE || cdb[0] == RELEASE_10) { cmd->execute_cmd = target_scsi2_reservation_release; if (cdb[0] == RELEASE_10) - size = (cdb[7] << 8) | cdb[8]; + size = get_unaligned_be16(&cdb[7]); else size = cmd->data_length; return target_cmd_size_check(cmd, size); @@ -1106,7 +1106,7 @@ passthrough_parse_cdb(struct se_cmd *cmd, if (cdb[0] == RESERVE || cdb[0] == RESERVE_10) { cmd->execute_cmd = target_scsi2_reservation_reserve; if (cdb[0] == RESERVE_10) - size = (cdb[7] << 8) | cdb[8]; + size = get_unaligned_be16(&cdb[7]); else size = cmd->data_length; return target_cmd_size_check(cmd, size); diff --git a/drivers/target/target_core_fabric_lib.c b/drivers/target/target_core_fabric_lib.c index cb6497ce4b61..508da345b73f 100644 --- a/drivers/target/target_core_fabric_lib.c +++ b/drivers/target/target_core_fabric_lib.c @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -216,8 +217,7 @@ static int iscsi_get_pr_transport_id( if (padding != 0) len += padding; - buf[2] = ((len >> 8) & 0xff); - buf[3] = (len & 0xff); + put_unaligned_be16(len, &buf[2]); /* * Increment value for total payload + header length for * full status descriptor @@ -306,7 +306,7 @@ static char *iscsi_parse_pr_out_transport_id( */ if (out_tid_len) { /* The shift works thanks to integer promotion rules */ - add_len = (buf[2] << 8) | buf[3]; + add_len = get_unaligned_be16(&buf[2]); tid_len = strlen(&buf[4]); tid_len += 4; /* Add four bytes for iSCSI Transport ID header */ diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 129ca572673c..e0c2b5b1e4a3 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c @@ -1562,10 +1562,7 @@ core_scsi3_decode_spec_i_port( * first extract TransportID Parameter Data Length, and make sure * the value matches up to the SCSI expected data transfer length. */ - tpdl = (buf[24] & 0xff) << 24; - tpdl |= (buf[25] & 0xff) << 16; - tpdl |= (buf[26] & 0xff) << 8; - tpdl |= buf[27] & 0xff; + tpdl = get_unaligned_be32(&buf[24]); if ((tpdl + 28) != cmd->data_length) { pr_err("SPC-3 PR: Illegal tpdl: %u + 28 byte header" @@ -3221,12 +3218,8 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key, goto out_put_pr_reg; } - rtpi = (buf[18] & 0xff) << 8; - rtpi |= buf[19] & 0xff; - tid_len = (buf[20] & 0xff) << 24; - tid_len |= (buf[21] & 0xff) << 16; - tid_len |= (buf[22] & 0xff) << 8; - tid_len |= buf[23] & 0xff; + rtpi = get_unaligned_be16(&buf[18]); + tid_len = get_unaligned_be32(&buf[20]); transport_kunmap_data_sg(cmd); buf = NULL; @@ -3554,12 +3547,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key, static unsigned long long core_scsi3_extract_reservation_key(unsigned char *cdb) { - unsigned int __v1, __v2; - - __v1 = (cdb[0] << 24) | (cdb[1] << 16) | (cdb[2] << 8) | cdb[3]; - __v2 = (cdb[4] << 24) | (cdb[5] << 16) | (cdb[6] << 8) | cdb[7]; - - return ((unsigned long long)__v2) | (unsigned long long)__v1 << 32; + return get_unaligned_be64(cdb); } /* @@ -3734,10 +3722,7 @@ core_scsi3_pri_read_keys(struct se_cmd *cmd) if (!buf) return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; - buf[0] = ((dev->t10_pr.pr_generation >> 24) & 0xff); - buf[1] = ((dev->t10_pr.pr_generation >> 16) & 0xff); - buf[2] = ((dev->t10_pr.pr_generation >> 8) & 0xff); - buf[3] = (dev->t10_pr.pr_generation & 0xff); + put_unaligned_be32(dev->t10_pr.pr_generation, buf); spin_lock(&dev->t10_pr.registration_lock); list_for_each_entry(pr_reg, &dev->t10_pr.registration_list, @@ -3749,23 +3734,13 @@ core_scsi3_pri_read_keys(struct se_cmd *cmd) if ((add_len + 8) > (cmd->data_length - 8)) break; - buf[off++] = ((pr_reg->pr_res_key >> 56) & 0xff); - buf[off++] = ((pr_reg->pr_res_key >> 48) & 0xff); - buf[off++] = ((pr_reg->pr_res_key >> 40) & 0xff); - buf[off++] = ((pr_reg->pr_res_key >> 32) & 0xff); - buf[off++] = ((pr_reg->pr_res_key >> 24) & 0xff); - buf[off++] = ((pr_reg->pr_res_key >> 16) & 0xff); - buf[off++] = ((pr_reg->pr_res_key >> 8) & 0xff); - buf[off++] = (pr_reg->pr_res_key & 0xff); - + put_unaligned_be64(pr_reg->pr_res_key >> 56, buf); + off += 8; add_len += 8; } spin_unlock(&dev->t10_pr.registration_lock); - buf[4] = ((add_len >> 24) & 0xff); - buf[5] = ((add_len >> 16) & 0xff); - buf[6] = ((add_len >> 8) & 0xff); - buf[7] = (add_len & 0xff); + put_unaligned_be32(add_len, &buf[4]); transport_kunmap_data_sg(cmd); @@ -3796,10 +3771,7 @@ core_scsi3_pri_read_reservation(struct se_cmd *cmd) if (!buf) return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; - buf[0] = ((dev->t10_pr.pr_generation >> 24) & 0xff); - buf[1] = ((dev->t10_pr.pr_generation >> 16) & 0xff); - buf[2] = ((dev->t10_pr.pr_generation >> 8) & 0xff); - buf[3] = (dev->t10_pr.pr_generation & 0xff); + put_unaligned_be32(dev->t10_pr.pr_generation, buf); spin_lock(&dev->dev_reservation_lock); pr_reg = dev->dev_pr_res_holder; @@ -3807,10 +3779,7 @@ core_scsi3_pri_read_reservation(struct se_cmd *cmd) /* * Set the hardcoded Additional Length */ - buf[4] = ((add_len >> 24) & 0xff); - buf[5] = ((add_len >> 16) & 0xff); - buf[6] = ((add_len >> 8) & 0xff); - buf[7] = (add_len & 0xff); + put_unaligned_be32(add_len, &buf[4]); if (cmd->data_length < 22) goto err; @@ -3837,14 +3806,7 @@ core_scsi3_pri_read_reservation(struct se_cmd *cmd) else pr_res_key = pr_reg->pr_res_key; - buf[8] = ((pr_res_key >> 56) & 0xff); - buf[9] = ((pr_res_key >> 48) & 0xff); - buf[10] = ((pr_res_key >> 40) & 0xff); - buf[11] = ((pr_res_key >> 32) & 0xff); - buf[12] = ((pr_res_key >> 24) & 0xff); - buf[13] = ((pr_res_key >> 16) & 0xff); - buf[14] = ((pr_res_key >> 8) & 0xff); - buf[15] = (pr_res_key & 0xff); + put_unaligned_be64(pr_res_key, &buf[8]); /* * Set the SCOPE and TYPE */ @@ -3882,8 +3844,7 @@ core_scsi3_pri_report_capabilities(struct se_cmd *cmd) if (!buf) return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; - buf[0] = ((add_len >> 8) & 0xff); - buf[1] = (add_len & 0xff); + put_unaligned_be16(add_len, buf); buf[2] |= 0x10; /* CRH: Compatible Reservation Hanlding bit. */ buf[2] |= 0x08; /* SIP_C: Specify Initiator Ports Capable bit */ buf[2] |= 0x04; /* ATP_C: All Target Ports Capable bit */ @@ -3947,10 +3908,7 @@ core_scsi3_pri_read_full_status(struct se_cmd *cmd) if (!buf) return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; - buf[0] = ((dev->t10_pr.pr_generation >> 24) & 0xff); - buf[1] = ((dev->t10_pr.pr_generation >> 16) & 0xff); - buf[2] = ((dev->t10_pr.pr_generation >> 8) & 0xff); - buf[3] = (dev->t10_pr.pr_generation & 0xff); + put_unaligned_be32(dev->t10_pr.pr_generation, &buf[0]); spin_lock(&dev->dev_reservation_lock); if (dev->dev_pr_res_holder) { @@ -3992,14 +3950,8 @@ core_scsi3_pri_read_full_status(struct se_cmd *cmd) /* * Set RESERVATION KEY */ - buf[off++] = ((pr_reg->pr_res_key >> 56) & 0xff); - buf[off++] = ((pr_reg->pr_res_key >> 48) & 0xff); - buf[off++] = ((pr_reg->pr_res_key >> 40) & 0xff); - buf[off++] = ((pr_reg->pr_res_key >> 32) & 0xff); - buf[off++] = ((pr_reg->pr_res_key >> 24) & 0xff); - buf[off++] = ((pr_reg->pr_res_key >> 16) & 0xff); - buf[off++] = ((pr_reg->pr_res_key >> 8) & 0xff); - buf[off++] = (pr_reg->pr_res_key & 0xff); + put_unaligned_be64(pr_reg->pr_res_key, &buf[off]); + off += 8; off += 4; /* Skip Over Reserved area */ /* @@ -4041,8 +3993,8 @@ core_scsi3_pri_read_full_status(struct se_cmd *cmd) if (!pr_reg->pr_reg_all_tg_pt) { u16 sep_rtpi = pr_reg->tg_pt_sep_rtpi; - buf[off++] = ((sep_rtpi >> 8) & 0xff); - buf[off++] = (sep_rtpi & 0xff); + put_unaligned_be16(sep_rtpi, &buf[off]); + off += 2; } else off += 2; /* Skip over RELATIVE TARGET PORT IDENTIFIER */ @@ -4062,10 +4014,7 @@ core_scsi3_pri_read_full_status(struct se_cmd *cmd) /* * Set the ADDITIONAL DESCRIPTOR LENGTH */ - buf[off++] = ((desc_len >> 24) & 0xff); - buf[off++] = ((desc_len >> 16) & 0xff); - buf[off++] = ((desc_len >> 8) & 0xff); - buf[off++] = (desc_len & 0xff); + put_unaligned_be32(desc_len, &buf[off]); /* * Size of full desctipor header minus TransportID * containing $FABRIC_MOD specific) initiator device/port @@ -4082,10 +4031,7 @@ core_scsi3_pri_read_full_status(struct se_cmd *cmd) /* * Set ADDITIONAL_LENGTH */ - buf[4] = ((add_len >> 24) & 0xff); - buf[5] = ((add_len >> 16) & 0xff); - buf[6] = ((add_len >> 8) & 0xff); - buf[7] = (add_len & 0xff); + put_unaligned_be32(add_len, &buf[4]); transport_kunmap_data_sg(cmd); diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c index 8943a62eb203..70de655293dc 100644 --- a/drivers/target/target_core_pscsi.c +++ b/drivers/target/target_core_pscsi.c @@ -168,7 +168,7 @@ static void pscsi_tape_read_blocksize(struct se_device *dev, /* * If MODE_SENSE still returns zero, set the default value to 1024. */ - sdev->sector_size = (buf[9] << 16) | (buf[10] << 8) | (buf[11]); + sdev->sector_size = get_unaligned_be24(&buf[9]); out_free: if (!sdev->sector_size) sdev->sector_size = 1024; @@ -209,8 +209,7 @@ pscsi_get_inquiry_vpd_serial(struct scsi_device *sdev, struct t10_wwn *wwn) cdb[0] = INQUIRY; cdb[1] = 0x01; /* Query VPD */ cdb[2] = 0x80; /* Unit Serial Number */ - cdb[3] = (INQUIRY_VPD_SERIAL_LEN >> 8) & 0xff; - cdb[4] = (INQUIRY_VPD_SERIAL_LEN & 0xff); + put_unaligned_be16(INQUIRY_VPD_SERIAL_LEN, &cdb[3]); ret = scsi_execute_req(sdev, cdb, DMA_FROM_DEVICE, buf, INQUIRY_VPD_SERIAL_LEN, NULL, HZ, 1, NULL); @@ -245,8 +244,7 @@ pscsi_get_inquiry_vpd_device_ident(struct scsi_device *sdev, cdb[0] = INQUIRY; cdb[1] = 0x01; /* Query VPD */ cdb[2] = 0x83; /* Device Identifier */ - cdb[3] = (INQUIRY_VPD_DEVICE_IDENTIFIER_LEN >> 8) & 0xff; - cdb[4] = (INQUIRY_VPD_DEVICE_IDENTIFIER_LEN & 0xff); + put_unaligned_be16(INQUIRY_VPD_DEVICE_IDENTIFIER_LEN, &cdb[3]); ret = scsi_execute_req(sdev, cdb, DMA_FROM_DEVICE, buf, INQUIRY_VPD_DEVICE_IDENTIFIER_LEN, @@ -254,7 +252,7 @@ pscsi_get_inquiry_vpd_device_ident(struct scsi_device *sdev, if (ret) goto out; - page_len = (buf[2] << 8) | buf[3]; + page_len = get_unaligned_be16(&buf[2]); while (page_len > 0) { /* Grab a pointer to the Identification descriptor */ page_83 = &buf[off]; @@ -669,19 +667,17 @@ static void pscsi_transport_complete(struct se_cmd *cmd, struct scatterlist *sg, } if (cdb[0] == MODE_SELECT) - bdl = (buf[3]); + bdl = buf[3]; else - bdl = (buf[6] << 8) | (buf[7]); + bdl = get_unaligned_be16(&buf[6]); if (!bdl) goto after_mode_select; if (cdb[0] == MODE_SELECT) - blocksize = (buf[9] << 16) | (buf[10] << 8) | - (buf[11]); + blocksize = get_unaligned_be24(&buf[9]); else - blocksize = (buf[13] << 16) | (buf[14] << 8) | - (buf[15]); + blocksize = get_unaligned_be24(&buf[13]); sd->sector_size = blocksize; } diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 6517ea2c3859..509be053e8e0 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -71,14 +71,8 @@ sbc_emulate_readcapacity(struct se_cmd *cmd) else blocks = (u32)blocks_long; - buf[0] = (blocks >> 24) & 0xff; - buf[1] = (blocks >> 16) & 0xff; - buf[2] = (blocks >> 8) & 0xff; - buf[3] = blocks & 0xff; - buf[4] = (dev->dev_attrib.block_size >> 24) & 0xff; - buf[5] = (dev->dev_attrib.block_size >> 16) & 0xff; - buf[6] = (dev->dev_attrib.block_size >> 8) & 0xff; - buf[7] = dev->dev_attrib.block_size & 0xff; + put_unaligned_be32(blocks, &buf[0]); + put_unaligned_be32(dev->dev_attrib.block_size, &buf[4]); rbuf = transport_kmap_data_sg(cmd); if (rbuf) { @@ -102,18 +96,8 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd) unsigned long long blocks = dev->transport->get_blocks(dev); memset(buf, 0, sizeof(buf)); - buf[0] = (blocks >> 56) & 0xff; - buf[1] = (blocks >> 48) & 0xff; - buf[2] = (blocks >> 40) & 0xff; - buf[3] = (blocks >> 32) & 0xff; - buf[4] = (blocks >> 24) & 0xff; - buf[5] = (blocks >> 16) & 0xff; - buf[6] = (blocks >> 8) & 0xff; - buf[7] = blocks & 0xff; - buf[8] = (dev->dev_attrib.block_size >> 24) & 0xff; - buf[9] = (dev->dev_attrib.block_size >> 16) & 0xff; - buf[10] = (dev->dev_attrib.block_size >> 8) & 0xff; - buf[11] = dev->dev_attrib.block_size & 0xff; + put_unaligned_be64(blocks, &buf[0]); + put_unaligned_be32(dev->dev_attrib.block_size, &buf[8]); /* * Set P_TYPE and PROT_EN bits for DIF support */ @@ -134,8 +118,8 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd) if (dev->transport->get_alignment_offset_lbas) { u16 lalba = dev->transport->get_alignment_offset_lbas(dev); - buf[14] = (lalba >> 8) & 0x3f; - buf[15] = lalba & 0xff; + + put_unaligned_be16(lalba, &buf[14]); } /* @@ -262,18 +246,17 @@ static inline u32 transport_get_sectors_6(unsigned char *cdb) static inline u32 transport_get_sectors_10(unsigned char *cdb) { - return (u32)(cdb[7] << 8) + cdb[8]; + return get_unaligned_be16(&cdb[7]); } static inline u32 transport_get_sectors_12(unsigned char *cdb) { - return (u32)(cdb[6] << 24) + (cdb[7] << 16) + (cdb[8] << 8) + cdb[9]; + return get_unaligned_be32(&cdb[6]); } static inline u32 transport_get_sectors_16(unsigned char *cdb) { - return (u32)(cdb[10] << 24) + (cdb[11] << 16) + - (cdb[12] << 8) + cdb[13]; + return get_unaligned_be32(&cdb[10]); } /* @@ -281,29 +264,23 @@ static inline u32 transport_get_sectors_16(unsigned char *cdb) */ static inline u32 transport_get_sectors_32(unsigned char *cdb) { - return (u32)(cdb[28] << 24) + (cdb[29] << 16) + - (cdb[30] << 8) + cdb[31]; + return get_unaligned_be32(&cdb[28]); } static inline u32 transport_lba_21(unsigned char *cdb) { - return ((cdb[1] & 0x1f) << 16) | (cdb[2] << 8) | cdb[3]; + return get_unaligned_be24(&cdb[1]) & 0x1fffff; } static inline u32 transport_lba_32(unsigned char *cdb) { - return (cdb[2] << 24) | (cdb[3] << 16) | (cdb[4] << 8) | cdb[5]; + return get_unaligned_be32(&cdb[2]); } static inline unsigned long long transport_lba_64(unsigned char *cdb) { - unsigned int __v1, __v2; - - __v1 = (cdb[2] << 24) | (cdb[3] << 16) | (cdb[4] << 8) | cdb[5]; - __v2 = (cdb[6] << 24) | (cdb[7] << 16) | (cdb[8] << 8) | cdb[9]; - - return ((unsigned long long)__v2) | (unsigned long long)__v1 << 32; + return get_unaligned_be64(&cdb[2]); } /* @@ -311,12 +288,7 @@ static inline unsigned long long transport_lba_64(unsigned char *cdb) */ static inline unsigned long long transport_lba_64_ext(unsigned char *cdb) { - unsigned int __v1, __v2; - - __v1 = (cdb[12] << 24) | (cdb[13] << 16) | (cdb[14] << 8) | cdb[15]; - __v2 = (cdb[16] << 24) | (cdb[17] << 16) | (cdb[18] << 8) | cdb[19]; - - return ((unsigned long long)__v2) | (unsigned long long)__v1 << 32; + return get_unaligned_be64(&cdb[12]); } static sense_reason_t @@ -1111,8 +1083,7 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops) cmd->t_task_cdb[1] & 0x1f); return TCM_INVALID_CDB_FIELD; } - size = (cdb[10] << 24) | (cdb[11] << 16) | - (cdb[12] << 8) | cdb[13]; + size = get_unaligned_be32(&cdb[10]); break; case SYNCHRONIZE_CACHE: case SYNCHRONIZE_CACHE_16: diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c index 2a91ed3ef380..f59ac7671031 100644 --- a/drivers/target/target_core_spc.c +++ b/drivers/target/target_core_spc.c @@ -287,8 +287,8 @@ spc_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) /* Skip over Obsolete field in RTPI payload * in Table 472 */ off += 2; - buf[off++] = ((lun->lun_rtpi >> 8) & 0xff); - buf[off++] = (lun->lun_rtpi & 0xff); + put_unaligned_be16(lun->lun_rtpi, &buf[off]); + off += 2; len += 8; /* Header size + Designation descriptor */ /* * Target port group identifier, see spc4r17 @@ -316,8 +316,8 @@ spc_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) off++; /* Skip over Reserved */ buf[off++] = 4; /* DESIGNATOR LENGTH */ off += 2; /* Skip over Reserved Field */ - buf[off++] = ((tg_pt_gp_id >> 8) & 0xff); - buf[off++] = (tg_pt_gp_id & 0xff); + put_unaligned_be16(tg_pt_gp_id, &buf[off]); + off += 2; len += 8; /* Header size + Designation descriptor */ /* * Logical Unit Group identifier, see spc4r17 @@ -343,8 +343,8 @@ spc_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) off++; /* Skip over Reserved */ buf[off++] = 4; /* DESIGNATOR LENGTH */ off += 2; /* Skip over Reserved Field */ - buf[off++] = ((lu_gp_id >> 8) & 0xff); - buf[off++] = (lu_gp_id & 0xff); + put_unaligned_be16(lu_gp_id, &buf[off]); + off += 2; len += 8; /* Header size + Designation descriptor */ /* * SCSI name string designator, see spc4r17 @@ -431,8 +431,7 @@ spc_emulate_evpd_83(struct se_cmd *cmd, unsigned char *buf) /* Header size + Designation descriptor */ len += (scsi_target_len + 4); } - buf[2] = ((len >> 8) & 0xff); - buf[3] = (len & 0xff); /* Page Length for VPD 0x83 */ + put_unaligned_be16(len, &buf[2]); /* Page Length for VPD 0x83 */ return 0; } EXPORT_SYMBOL(spc_emulate_evpd_83); @@ -1288,7 +1287,7 @@ spc_parse_cdb(struct se_cmd *cmd, unsigned int *size) cmd->execute_cmd = spc_emulate_modeselect; break; case MODE_SELECT_10: - *size = (cdb[7] << 8) + cdb[8]; + *size = get_unaligned_be16(&cdb[7]); cmd->execute_cmd = spc_emulate_modeselect; break; case MODE_SENSE: @@ -1296,25 +1295,25 @@ spc_parse_cdb(struct se_cmd *cmd, unsigned int *size) cmd->execute_cmd = spc_emulate_modesense; break; case MODE_SENSE_10: - *size = (cdb[7] << 8) + cdb[8]; + *size = get_unaligned_be16(&cdb[7]); cmd->execute_cmd = spc_emulate_modesense; break; case LOG_SELECT: case LOG_SENSE: - *size = (cdb[7] << 8) + cdb[8]; + *size = get_unaligned_be16(&cdb[7]); break; case PERSISTENT_RESERVE_IN: - *size = (cdb[7] << 8) + cdb[8]; + *size = get_unaligned_be16(&cdb[7]); cmd->execute_cmd = target_scsi3_emulate_pr_in; break; case PERSISTENT_RESERVE_OUT: - *size = (cdb[7] << 8) + cdb[8]; + *size = get_unaligned_be16(&cdb[7]); cmd->execute_cmd = target_scsi3_emulate_pr_out; break; case RELEASE: case RELEASE_10: if (cdb[0] == RELEASE_10) - *size = (cdb[7] << 8) | cdb[8]; + *size = get_unaligned_be16(&cdb[7]); else *size = cmd->data_length; @@ -1327,7 +1326,7 @@ spc_parse_cdb(struct se_cmd *cmd, unsigned int *size) * Assume the passthrough or $FABRIC_MOD will tell us about it. */ if (cdb[0] == RESERVE_10) - *size = (cdb[7] << 8) | cdb[8]; + *size = get_unaligned_be16(&cdb[7]); else *size = cmd->data_length; @@ -1338,7 +1337,7 @@ spc_parse_cdb(struct se_cmd *cmd, unsigned int *size) cmd->execute_cmd = spc_emulate_request_sense; break; case INQUIRY: - *size = (cdb[3] << 8) + cdb[4]; + *size = get_unaligned_be16(&cdb[3]); /* * Do implicit HEAD_OF_QUEUE processing for INQUIRY. @@ -1349,7 +1348,7 @@ spc_parse_cdb(struct se_cmd *cmd, unsigned int *size) break; case SECURITY_PROTOCOL_IN: case SECURITY_PROTOCOL_OUT: - *size = (cdb[6] << 24) | (cdb[7] << 16) | (cdb[8] << 8) | cdb[9]; + *size = get_unaligned_be32(&cdb[6]); break; case EXTENDED_COPY: *size = get_unaligned_be32(&cdb[10]); @@ -1361,19 +1360,18 @@ spc_parse_cdb(struct se_cmd *cmd, unsigned int *size) break; case READ_ATTRIBUTE: case WRITE_ATTRIBUTE: - *size = (cdb[10] << 24) | (cdb[11] << 16) | - (cdb[12] << 8) | cdb[13]; + *size = get_unaligned_be32(&cdb[10]); break; case RECEIVE_DIAGNOSTIC: case SEND_DIAGNOSTIC: - *size = (cdb[3] << 8) | cdb[4]; + *size = get_unaligned_be16(&cdb[3]); break; case WRITE_BUFFER: - *size = (cdb[6] << 16) + (cdb[7] << 8) + cdb[8]; + *size = get_unaligned_be24(&cdb[6]); break; case REPORT_LUNS: cmd->execute_cmd = spc_emulate_report_luns; - *size = (cdb[6] << 24) | (cdb[7] << 16) | (cdb[8] << 8) | cdb[9]; + *size = get_unaligned_be32(&cdb[6]); /* * Do implicit HEAD_OF_QUEUE processing for REPORT_LUNS * See spc4r17 section 5.3 diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c index cac5a20a4de0..f12cf0c12531 100644 --- a/drivers/target/target_core_xcopy.c +++ b/drivers/target/target_core_xcopy.c @@ -311,9 +311,7 @@ static int target_xcopy_parse_segdesc_02(struct se_cmd *se_cmd, struct xcopy_op (unsigned long long)xop->dst_lba); if (dc != 0) { - xop->dbl = (desc[29] & 0xff) << 16; - xop->dbl |= (desc[30] & 0xff) << 8; - xop->dbl |= desc[31] & 0xff; + xop->dbl = get_unaligned_be24(&desc[29]); pr_debug("XCOPY seg desc 0x02: DC=1 w/ dbl: %u\n", xop->dbl); } diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index e475531565fd..b76071161cdc 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -2,6 +2,7 @@ #define TARGET_CORE_BACKEND_H #include +#include #include #define TRANSPORT_FLAG_PASSTHROUGH 0x1 @@ -109,4 +110,11 @@ sector_t target_to_linux_sector(struct se_device *dev, sector_t lb); bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib, struct request_queue *q); + +/* Only use get_unaligned_be24() if reading p - 1 is allowed. */ +static inline uint32_t get_unaligned_be24(const uint8_t *const p) +{ + return get_unaligned_be32(p - 1) & 0xffffffU; +} + #endif /* TARGET_CORE_BACKEND_H */