From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752837AbcIJTV6 (ORCPT ); Sat, 10 Sep 2016 15:21:58 -0400 Received: from smtprelay0215.hostedemail.com ([216.40.44.215]:50315 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751219AbcIJTV4 (ORCPT ); Sat, 10 Sep 2016 15:21:56 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:355:379:541:599:960:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1381:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3866:3867:3868:3871:3872:3873:4250:4321:5007:7904:9108:10004:10400:10848:11232:11473:11658:11914:12043:12048:12438:12679:12740:13069:13071:13311:13357:13439:13894:14180:14659:21080:21451:30012:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: game01_2d55c3643c136 X-Filterd-Recvd-Size: 2200 Message-ID: <1473535309.19464.5.camel@perches.com> Subject: Re: [PATCH] Drivers: i2c: busses: Use max macro instead of ternary operator From: Joe Perches To: Bhumika Goyal , wsa@the-dreams.de, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sat, 10 Sep 2016 12:21:49 -0700 In-Reply-To: <1473534490-16592-1-git-send-email-bhumirks@gmail.com> References: <1473534490-16592-1-git-send-email-bhumirks@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.21.91-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2016-09-11 at 00:38 +0530, Bhumika Goyal wrote: > Replace ternary operators with macro 'max' as it is shorter > and thus increases code readability. Macro max returns > the maximum of the two compared values. > Done using coccinelle: > > @@ > type T; > T x; > T y; > @@ > ( > - x < y ? x : y > + min(x,y) > - x > y ? x : y > + max(x,y) > ) Hello. Please make sure to inspect and if appropriate modify the coccinelle output for the 'best' coding style, for whatever definition of 'best' you might use, before submitting automatically produced patches. > diff --git a/drivers/i2c/busses/i2c-jz4780.c b/drivers/i2c/busses/i2c-jz4780.c [] > @@ -133,10 +133,10 @@ static const char * const jz4780_i2c_abrt_src[] = { >   > #define JZ4780_I2C_ENB_I2C BIT(0) >   > -#define JZ4780_I2CSHCNT_ADJUST(n) (((n) - 8) < 6 ? 6 : ((n) - 8)) > -#define JZ4780_I2CSLCNT_ADJUST(n) (((n) - 1) < 8 ? 8 : ((n) - 1)) > -#define JZ4780_I2CFHCNT_ADJUST(n) (((n) - 8) < 6 ? 6 : ((n) - 8)) > -#define JZ4780_I2CFLCNT_ADJUST(n) (((n) - 1) < 8 ? 8 : ((n) - 1)) > +#define JZ4780_I2CSHCNT_ADJUST(n) (max(6, (n) - 8)) > +#define JZ4780_I2CSLCNT_ADJUST(n) (max(8, (n) - 1)) > +#define JZ4780_I2CFHCNT_ADJUST(n) (max(6, (n) - 8)) > +#define JZ4780_I2CFLCNT_ADJUST(n) (max(8, (n) - 1)) For instance: the parentheses are unnecessary and could be removed like the BIT macro above. >