Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754575AbcC1JWb (ORCPT ); Mon, 28 Mar 2016 05:22:31 -0400 Received: from smtp-out-072.synserver.de ([212.40.185.72]:1363 "EHLO smtp-out-069.synserver.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751288AbcC1JW3 (ORCPT ); Mon, 28 Mar 2016 05:22:29 -0400 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 1645 Subject: Re: [PATCH 28/31] iio: gyro: use parity32 in adxrs450.c To: Jonathan Cameron , "zhaoxiu.zeng" , Michael Hennerich , Hartmut Knaack , Peter Meerwald References: <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com> <56F78ED3.8080603@gmail.com> <56F8ECDE.3010701@kernel.org> Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org From: Lars-Peter Clausen Message-ID: <56F8F045.7060409@metafoo.de> Date: Mon, 28 Mar 2016 10:50:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.6.0 MIME-Version: 1.0 In-Reply-To: <56F8ECDE.3010701@kernel.org> Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 818 Lines: 24 On 03/28/2016 10:35 AM, Jonathan Cameron wrote: > On 27/03/16 08:42, zhaoxiu.zeng wrote: >> From: Zeng Zhaoxiu >> >> Signed-off-by: Zeng Zhaoxiu > Interesting. Whilst obviously correct I wonder if this obscures the > intent of the code a little. Lars, what do you think? The parity function is newly introduced in this series and can be more efficient that just hw_weight() & 1 on certain architectures. Since the result is the same using it is certainly an improvement. But ... [...] >> - if (!(hweight32(tx) & 1)) >> - tx |= ADXRS450_P; >> + tx |= !parity32(tx) * ADXRS450_P; ... this should still be if (!parity32(tx)) tx |= ADXRS450_P; Otherwise it's a bit too much obfuscated for my taste. Just leave it to the compiler to optimize it as it sees it fit.