From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3vfqZv0QKyzDqXx for ; Sat, 11 Mar 2017 01:36:38 +1100 (AEDT) Date: Fri, 10 Mar 2017 08:32:41 -0600 From: Segher Boessenkool To: Christophe LEROY Cc: Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Scott Wood , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] powerpc: sysdev: cpm1: Optimise gpio bit calculation Message-ID: <20170310143241.GJ31469@gate.crashing.org> References: <20170309094206.A832167992@localhost.localdomain> <87a88tle0y.fsf@concordia.ellerman.id.au> <534d8795-ce21-9af6-498d-22597213a3a2@c-s.fr> <20170310130630.GH31469@gate.crashing.org> <906c025b-47d0-f906-2613-291f350bd48d@c-s.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 In-Reply-To: <906c025b-47d0-f906-2613-291f350bd48d@c-s.fr> List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Fri, Mar 10, 2017 at 03:04:48PM +0100, Christophe LEROY wrote: > Le 10/03/2017 à 14:06, Segher Boessenkool a écrit : > >On Fri, Mar 10, 2017 at 11:54:19AM +0100, Christophe LEROY wrote: > >>gpio_get() and gpio_set() are used extensively by some GPIO based > >>drivers like SPI, NAND, so it may be worth it as it doesn't impair > >>readability (if anyone prefers, we could write (1 << 31) >> i instead > >>of 0x80000000 >> i ) > > > >1 << 31 is undefined behaviour, of course. > > > > Shall it be 1U << 31 ? Sure, that works. "1 << (31 - i)" is most readable (but it doesn't yet generate the code you want). Segher