Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753959AbbHXJBT (ORCPT ); Mon, 24 Aug 2015 05:01:19 -0400 Received: from smtp-out6.electric.net ([192.162.217.181]:51170 "EHLO smtp-out6.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751475AbbHXJBR (ORCPT ); Mon, 24 Aug 2015 05:01:17 -0400 From: David Laight To: "'Vaishali Thakkar'" CC: Felipe Balbi , Greg Kroah-Hartman , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] usb: gadget: f_uac1: Convert use of __constant_cpu_to_le16 to cpu_to_le16 Thread-Topic: [PATCH] usb: gadget: f_uac1: Convert use of __constant_cpu_to_le16 to cpu_to_le16 Thread-Index: AQHQ2j/yD7Ok64YU90KPzAXeYWFpdp4Ut1+wgAJ/KICAA6hP0A== Date: Mon, 24 Aug 2015 08:59:08 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1CB822B8@AcuExch.aculab.com> References: <20150819053122.GA11573@localhost> <063D6719AE5E284EB5DD2968C1650D6D1CB804E2@AcuExch.aculab.com> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id t7O91fAO009298 Content-Length: 1628 Lines: 36 From: Vaishali Thakkar [mailto:vthakkar1994@gmail.com] > Sent: 22 August 2015 02:57 ... > >> - .bcdADC = __constant_cpu_to_le16(0x0100), > >> - .wTotalLength = __constant_cpu_to_le16(UAC_DT_TOTAL_LENGTH), > >> + .bcdADC = cpu_to_le16(0x0100), > >> + .wTotalLength = cpu_to_le16(UAC_DT_TOTAL_LENGTH), > > > > Have you test compiled this on a big-endian system? > > My gut feeling is that is fails. > > No. I have tested it on little-endian system only. But I'll > be really surprised if this will fail. Can you please tell me > if I am missing something in this particular case or same > applies for other cases because most of the cases like > __constant_ are already converted to ? > > As far as I know, if the argument is a constant the > conversion happens at compile time. And unfolding both > definitions returns to same expression. Still I am trying if > someone can test it for me on big endian system. Flip one to cpu_to_be16() and see if it still compiles. Static initialisers and case labels can be expressions, but the expression itself must only contain constants. So it needs to be constant regardless of the value of any constants. If it contains 'a ? t : f' then both 't' and 'f' must be constant. In code, if 'a' is constant the optimiser discards one of 't' or 'f'. I'm not sure what happens for non-static initialisers (they generate odd code at the best of times). David ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?