From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755521AbbFVGjE (ORCPT ); Mon, 22 Jun 2015 02:39:04 -0400 Received: from ni.piap.pl ([195.187.100.4]:35147 "EHLO ni.piap.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933036AbbFVGiz (ORCPT ); Mon, 22 Jun 2015 02:38:55 -0400 From: khalasa@piap.pl (Krzysztof =?utf-8?Q?Ha=C5=82asa?=) To: Joe Perches Cc: Frans Klaver , Andy Whitcroft , lkml Subject: Re: Coding style details (checkpatch) References: <1434725667.2689.121.camel@perches.com> <1434953551.9808.19.camel@perches.com> Date: Mon, 22 Jun 2015 08:38:53 +0200 In-Reply-To: <1434953551.9808.19.camel@perches.com> (Joe Perches's message of "Sun, 21 Jun 2015 23:12:31 -0700") Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Lua-Profiles: 79655 [Jun 22 2015] X-KLMS-AntiSpam-Version: 5.5.6 X-KLMS-AntiSpam-Envelope-From: khalasa@piap.pl X-KLMS-AntiSpam-Rate: 0 X-KLMS-AntiSpam-Status: not_detected X-KLMS-AntiSpam-Method: none X-KLMS-AntiSpam-Moebius-Timestamps: 3611692, 3611731, 3611558 X-KLMS-AntiSpam-Info: LuaCore: 230 2015-06-18_15-19-46 a57002d05d325a1ca642728c4b1d1e7603231830, Auth:dkim=none X-KLMS-AntiSpam-Interceptor-Info: scan successful X-KLMS-AntiPhishing: Clean, 2015/06/18 15:23:24 X-KLMS-AntiVirus: Kaspersky Security 8.0 for Linux Mail Server, version 8.0.1.721, bases: 2015/06/22 01:06:00 #8271670 X-KLMS-AntiVirus-Status: Clean, skipped Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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}) also #define VDREG8(a0) ((const u16[8]){ \ a0 + 0x000, a0 + 0x010, a0 +0x020, a0 + 0x030, \ a0 + 0x100, a0 + 0x110, a0 +0x120, a0 + 0x130}) #define VIDSTAT VDREG8(0x100) #define BRIGHT VDREG8(0x101) #define CONTRAST VDREG8(0x102) etc. One would have to remember (writing .c code) which scheme applies to which access. The tables, while probably less than optimal WRT CPU cycles used, are consistent, and the addressing details are grouped in one place - the *regs.h file. -- Krzysztof Halasa Industrial Research Institute for Automation and Measurements PIAP Al. Jerozolimskie 202, 02-486 Warsaw, Poland -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Please read the FAQ at http://www.tux.org/lkml/