From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966657AbbBCTK5 (ORCPT ); Tue, 3 Feb 2015 14:10:57 -0500 Received: from metis.ext.pengutronix.de ([92.198.50.35]:58683 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756091AbbBCTKs (ORCPT ); Tue, 3 Feb 2015 14:10:48 -0500 Date: Tue, 3 Feb 2015 20:10:38 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: David Howells Cc: "'linux-arch@vger.kernel.org'" , "'linux@arm.linux.org.uk'" , "Wang, Yalin" , "'arnd@arndb.de'" , "'linux-kernel@vger.kernel.org'" , "'linux-arm-kernel@lists.infradead.org'" Subject: Re: [RFC] change non-atomic bitops method Message-ID: <20150203191038.GF10842@pengutronix.de> References: <20150202193154.GC10842@pengutronix.de> <35FD53F367049845BC99AC72306C23D1044A02027E0A@CNBJMBX05.corpusers.net> <30242.1422976483@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <30242.1422976483@warthog.procyon.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, [added some more context again] On Tue, Feb 03, 2015 at 03:14:43PM +0000, David Howells wrote: > > > - *p |= mask; > > > + if ((*p & mask) == 0) > > > + *p |= mask; > > Care to fix the double space here while touching the code? > > > > I think the more natural check here is: > > > > if ((~*p & mask) != 0) > > *p |= mask; > > > > Might be a matter of taste, but this check is equivalent to > > > > *p != (*p | mask) > > > > which is what you really want to test for. > I would argue that this is less clear as to what's going on. OK, I admit that this equivalence is not obvious. Then maybe let the compiler find the equivalence and do: - *p |= mask; + if (*p != (*p | mask)) + p |= mask; ? Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |