public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Denys Vlasenko <vda.linux@googlemail.com>
To: Joe Perches <joe@perches.com>
Cc: Takashi Iwai <tiwai@suse.de>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] add consts where appropriate in sound/pci/hda/*
Date: Fri, 14 Sep 2007 20:34:59 +0100	[thread overview]
Message-ID: <200709142034.59802.vda.linux@googlemail.com> (raw)
In-Reply-To: <1189793347.19708.156.camel@localhost>

On Friday 14 September 2007 19:09, Joe Perches wrote:
> On Fri, 2007-09-14 at 18:48 +0100, Denys Vlasenko wrote:
> 
> > Patch is attached.
> 
> The SND_HDA_PRESETS define doesn't seem useful.
> It's only used once.

It is defined in .h file and used in .c file.

It is made so because defining static data variables in .h file
is a bad style in general and in this case will result in build-time
warnings in particular.

Therefore definition of hda_preset_tables[] is moved to .c file.

It looks like this:

static const struct hda_codec_preset *const hda_preset_tables[] = {
       snd_hda_preset_realtek,
       snd_hda_preset_cmedia,
       snd_hda_preset_analog,
       snd_hda_preset_sigmatel,
       snd_hda_preset_si3054,
       snd_hda_preset_atihdmi,
       snd_hda_preset_conexant,
       snd_hda_preset_via,
       NULL
};

I want to make it easier for people to add new snd_hda_preset_XXX.

I don't want them to be forced to add it in hda_patch.h first,
and then go to hda_codec.c and add it there too.

Therefore I turned this list into a #define which sits in hda_patch.h:

#define SND_HDA_PRESETS \
       snd_hda_preset_realtek, \
       snd_hda_preset_cmedia, \
       snd_hda_preset_analog, \
       snd_hda_preset_sigmatel, \
       snd_hda_preset_si3054, \
       snd_hda_preset_atihdmi, \
       snd_hda_preset_conexant, \
       snd_hda_preset_via

Now if you want to add yet another snd_hda_preset_XXX, you
don't need to touch hda_codec.c.

Original code was achieving the same by cheating: it has

static const struct hda_codec_preset *hda_preset_tables[] = {...}

in hda_patch.h.
--
vda

  reply	other threads:[~2007-09-14 19:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-14 17:48 [PATCH] add consts where appropriate in sound/pci/hda/* Denys Vlasenko
2007-09-14 18:09 ` Joe Perches
2007-09-14 19:34   ` Denys Vlasenko [this message]
2007-09-14 22:12 ` Denys Vlasenko
2007-09-15  9:43 ` Jan Engelhardt
2007-09-15 10:18   ` Sam Ravnborg
2007-09-15 10:29     ` Jan Engelhardt
2007-09-15 11:42       ` Denys Vlasenko
2007-09-15 12:40         ` Andreas Schwab
2007-09-15 13:47           ` Denys Vlasenko
2007-09-15 17:42             ` Jan Engelhardt
2007-09-17 10:01 ` Takashi Iwai
2007-09-17 21:53   ` Denys Vlasenko

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=200709142034.59802.vda.linux@googlemail.com \
    --to=vda.linux@googlemail.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tiwai@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox