From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751462AbdKKQCM (ORCPT ); Sat, 11 Nov 2017 11:02:12 -0500 Received: from smtprelay0047.hostedemail.com ([216.40.44.47]:60812 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750929AbdKKQCL (ORCPT ); Sat, 11 Nov 2017 11:02:11 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:355:379:421:541:599:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1381:1437:1515:1516:1518:1534:1543:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2559:2562:2828:2911:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3873:3874:4321:4425:5007:6119:7903:9040:10004:10400:10848:11026:11232:11473:11658:11914:12043:12048:12050:12296:12438:12663:12679:12740:12760:12895:13160:13161:13229:13439:13972:14180:14659:14721:21060:21080:21433:21451:21611:21627:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: jail14_12bf4b604021e X-Filterd-Recvd-Size: 3882 Message-ID: <1510416127.10883.30.camel@perches.com> Subject: Re: staging: pi433: Possible bug in rf69.c From: Joe Perches To: Marcus Wolf , Greg Kroah-Hartman , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, dan.carpenter@oracle.com Date: Sat, 11 Nov 2017 08:02:07 -0800 In-Reply-To: <709d3e3f-be3b-aa98-1cf6-6a048ef14d7b@smarthome-wolf.de> References: <709d3e3f-be3b-aa98-1cf6-6a048ef14d7b@smarthome-wolf.de> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2017-11-10 at 18:23 +0100, Marcus Wolf wrote: > Hi everybody! > > Just comparing the master of Gregs statging of pi433 with my local SVN > to review all changes, that were done the last monthes. > > I am not sure, but maybe we imported a bug in rf69.c lines 378 and > following: > > Gregs repo: > case automatic: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & > ~MASK_LNA_GAIN) & LNA_GAIN_AUTO) ); > case max: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & > ~MASK_LNA_GAIN) & LNA_GAIN_MAX) ); > case maxMinus6: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & > ~MASK_LNA_GAIN) & LNA_GAIN_MAX_MINUS_6) ); > case maxMinus12: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & > ~MASK_LNA_GAIN) & LNA_GAIN_MAX_MINUS_12) ); > case maxMinus24: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & > ~MASK_LNA_GAIN) & LNA_GAIN_MAX_MINUS_24) ); > case maxMinus36: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & > ~MASK_LNA_GAIN) & LNA_GAIN_MAX_MINUS_36) ); > case maxMinus48: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & > ~MASK_LNA_GAIN) & LNA_GAIN_MAX_MINUS_48) ); > > my repo: > case automatic: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & > ~MASK_LNA_GAIN) | LNA_GAIN_AUTO) ); > case max: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & > ~MASK_LNA_GAIN) | LNA_GAIN_MAX) ); > case maxMinus6: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & > ~MASK_LNA_GAIN) | LNA_GAIN_MAX_MINUS_6) ); > case maxMinus12: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & > ~MASK_LNA_GAIN) | LNA_GAIN_MAX_MINUS_12) ); > case maxMinus24: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & > ~MASK_LNA_GAIN) | LNA_GAIN_MAX_MINUS_24) ); > case maxMinus36: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & > ~MASK_LNA_GAIN) | LNA_GAIN_MAX_MINUS_36) ); > case maxMinus48: return WRITE_REG(REG_LNA, ( (READ_REG(REG_LNA) & > ~MASK_LNA_GAIN) | LNA_GAIN_MAX_MINUS_48) ); > > Up to my opinion, my (old) version is better then Gregs (new) version. > If you agree, I'll prepare a patch, to revert the modification. There seems to be a lot of enum/#define duplication in this driver. For instance: drivers/staging/pi433/rf69_registers.h #define LNA_GAIN_AUTO 0x00 /* default */ #define LNA_GAIN_MAX 0x01 #define LNA_GA IN_MAX_MINUS_6 0x02 #define LNA_GAIN_MAX_MINUS_12 0x03 #define LNA_GAIN_MAX_MINUS_24 0x04 #define LNA_GAIN_MAX_MINUS_36 0x05 #d efine LNA_GAIN_MAX_MINUS_48 0x06 vs drivers/staging/pi433/rf69_enum.h enum lnaGain { automatic, max, maxMinus6, maxMinus12, maxM inus24, maxMinus36, maxMinus48, undefined }; My suggestion would be to remove drivers/staging/pi433/rf69_enum.h where possible and convert all these switch/case entries into macros like #define GAIN_CASE(type) \ case type: return WRITE_REG(REG_LNA, \ (READ_REG(REG_LNA) & ~MASK_LNA_GAIN) | (type)); so for example this switch becomes switch (lnaGain) { GAIN_CASE(LNA_GAIN_AUTO); ... }