All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: "Krzysztof Hałasa" <khalasa@piap.pl>
Cc: Frans Klaver <fransklaver@gmail.com>,
	Andy Whitcroft <apw@canonical.com>,
	lkml <linux-kernel@vger.kernel.org>
Subject: Re: Coding style details (checkpatch)
Date: Sun, 21 Jun 2015 23:47:42 -0700	[thread overview]
Message-ID: <1434955662.9808.26.camel@perches.com> (raw)
In-Reply-To: <m3vbegqmbm.fsf@t19.piap.pl>

On Mon, 2015-06-22 at 08:38 +0200, Krzysztof Hałasa wrote:
> Joe Perches <joe@perches.com> 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[<digits>]" 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/

  reply	other threads:[~2015-06-22  6:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-19  8:35 Coding style details Krzysztof Hałasa
2015-06-19  9:07 ` Frans Klaver
2015-06-19 10:31   ` Coding style details (checkpatch) Krzysztof Hałasa
2015-06-19 10:37     ` Frans Klaver
2015-06-19 10:52       ` Krzysztof Hałasa
2015-06-19 14:54         ` Joe Perches
2015-06-22  5:33           ` Krzysztof Hałasa
2015-06-22  6:12             ` Joe Perches
2015-06-22  6:38               ` Krzysztof Hałasa
2015-06-22  6:47                 ` Joe Perches [this message]
2015-06-22  7:39                   ` Krzysztof Hałasa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1434955662.9808.26.camel@perches.com \
    --to=joe@perches.com \
    --cc=apw@canonical.com \
    --cc=fransklaver@gmail.com \
    --cc=khalasa@piap.pl \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.