From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756017AbbFVGsB (ORCPT ); Mon, 22 Jun 2015 02:48:01 -0400 Received: from smtprelay0032.hostedemail.com ([216.40.44.32]:53696 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754280AbbFVGrp (ORCPT ); Mon, 22 Jun 2015 02:47:45 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::,RULES_HIT:41:152:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3622:3653:3865:3867:3868:3871:3872:3873:4321:5007:6261:10004:10400:10848:11026:11232:11473:11658:11914:12438:12517:12519:12740:13069:13311:13357:13848:13894:13972:21080,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 X-HE-Tag: drug58_6093e0200e35a X-Filterd-Recvd-Size: 2342 Message-ID: <1434955662.9808.26.camel@perches.com> Subject: Re: Coding style details (checkpatch) From: Joe Perches To: Krzysztof =?UTF-8?Q?Ha=C5=82asa?= Cc: Frans Klaver , Andy Whitcroft , lkml Date: Sun, 21 Jun 2015 23:47:42 -0700 In-Reply-To: References: <1434725667.2689.121.camel@perches.com> <1434953551.9808.19.camel@perches.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.11-0ubuntu3 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 Mon, 2015-06-22 at 08:38 +0200, Krzysztof HaƂasa wrote: > Joe Perches writes: > > > It might be better to use some base + index macro > > as it could be smaller object code. > > > > Something like: > > > > #define REG_NO(base, multiplier, index) (base + (multiplier * index)) > > > > reg_write(vc->dev, REG_NO(0x10, 1, vc->ch), dma_cfg); > > or > > > > #define VDMA_CHANNEL_CONFIG 0x10 > > > > reg_write(vc->dev, REG_NO(VDMA_CHANNEL_CONFIG, 1, vc->ch), dma_cfg); > > Wouldn't work, the register map is a bit messy. > E.g. > > #define DMA_PAGE_TABLE0_ADDR ((const u16[8]){0x08, 0xD0, 0xD2, 0xD4, 0xD6, 0xD8, 0xDA, 0xDC}) > #define DMA_PAGE_TABLE1_ADDR ((const u16[8]){0x09, 0xD1, 0xD3, 0xD5, 0xD7, 0xD9, 0xDB, 0xDD}) Erk, yes, a bit messy. You could elide the 8 and checkpatch wouldn't emit a warning. #define VDREG8(a0) ((const u16[]){ \ a0 + 0x000, a0 + 0x010, a0 +0x020, a0 + 0x030, \ a0 + 0x100, a0 + 0x110, a0 +0x120, a0 + 0x130}) as "const u16[]" is a $Type but "const u16[]" is not. Still, as written, the code seems fragile as MACRO[index] allows index to be any value, maybe larger than the array. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Please read the FAQ at http://www.tux.org/lkml/