Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753415AbdLMPYZ (ORCPT ); Wed, 13 Dec 2017 10:24:25 -0500 Received: from dd39320.kasserver.com ([85.13.155.146]:38104 "EHLO dd39320.kasserver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753141AbdLMPYW (ORCPT ); Wed, 13 Dec 2017 10:24:22 -0500 Subject: Re: [PATCH 4/8] staging: pi433: add parentheses to mask and shift To: Valentin Vidic , Greg Kroah-Hartman Cc: =?UTF-8?Q?Simon_Sandstr=c3=b6m?= , Marcin Ciupak , Marcus Wolf , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org References: <20171213142156.3201-1-Valentin.Vidic@CARNet.hr> <20171213142156.3201-4-Valentin.Vidic@CARNet.hr> From: Marcus Wolf Message-ID: <916bb681-b0f8-f072-539b-7a18555d65ea@smarthome-wolf.de> Date: Wed, 13 Dec 2017 17:24:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171213142156.3201-4-Valentin.Vidic@CARNet.hr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2021 Lines: 56 Am 13.12.2017 um 16:21 schrieb Valentin Vidic: > Fixes checkpatch warning: > > WARNING: Possible precedence defect with mask then right shift - may need parentheses > > Signed-off-by: Valentin Vidic > --- > drivers/staging/pi433/rf69.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c > index f77ecd60f43a..b1e243e5bcac 100644 > --- a/drivers/staging/pi433/rf69.c > +++ b/drivers/staging/pi433/rf69.c > @@ -102,7 +102,7 @@ enum modulation rf69_get_modulation(struct spi_device *spi) > > currentValue = rf69_read_reg(spi, REG_DATAMODUL); > > - switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE >> 3) { // TODO improvement: change 3 to define > + switch ((currentValue & MASK_DATAMODUL_MODULATION_TYPE) >> 3) { // TODO improvement: change 3 to define As mentioned by Dan, this change isn't needed any more, since ther was a bug, that's already fixed. > case DATAMODUL_MODULATION_TYPE_OOK: return OOK; > case DATAMODUL_MODULATION_TYPE_FSK: return FSK; > default: return UNDEF; > @@ -340,7 +340,7 @@ enum lnaGain rf69_get_lna_gain(struct spi_device *spi) > > currentValue = rf69_read_reg(spi, REG_LNA); > > - switch (currentValue & MASK_LNA_CURRENT_GAIN >> 3) { // improvement: change 3 to define > + switch ((currentValue & MASK_LNA_CURRENT_GAIN) >> 3) { // improvement: change 3 to define To my knowledge,'>>' is stronger than '&'. So this change will modify the behaviour. If I am wrong, the code was wrong from the beginning. What should happen here, is: read the value from reg and do a bitwise and with the shifted value from MASK_... > case LNA_GAIN_AUTO: return automatic; > case LNA_GAIN_MAX: return max; > case LNA_GAIN_MAX_MINUS_6: return maxMinus6; > -- Smarthome-Wolf UG (haftungsbeschränkt) Helene-Lange-Weg 23 80637 München Amtsgericht München, HRB 223529 Umastzsteuer-ID: DE304719911 Geschäftsführer: Marcus Wolf