All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	alsa-devel@alsa-project.org,
	Eliot Blennerhassett <eliot@blennerhassett.gen.nz>
Subject: [PATCH 00/21] ALSA: Remove always NULL parameters
Date: Fri,  2 Jan 2015 12:24:34 +0100	[thread overview]
Message-ID: <1420197895-17696-1-git-send-email-lars@metafoo.de> (raw)

There is a bit of a anti-pattern in some of the (mostly older) driver. In
these drivers functions which allocate PCMs, timers, etc. take a parameter
which is a pointer to a pointer of the allocated object and if the pointer
is provided it is set to the newly allocate object. The code essentially
looks like this.

	int foobar_allocate(..., struct snd_pcm **rpcm)
	{
		struct snd_pcm *pcm;
		
		if (rpcm)
			*rpcm = NULL;

		... /* Create and initialize object */

		if (rpcm)
			*rpcm = pcm;

		return 0;
	}

But then all callers to these functions always pass NULL for the pointer. So
the code that checks and initializes the pointer becomes dead code. While it
can be argued that such a pattern makes sense for library functions where
there might be new users which want to provide a valid pointer (at least in
the absence of PTR_ERR and friends), it makes less sense for functions that
are only used internally in a driver which hasn't seen any new hardware
support in the last 10 years.

This series goes through these drivers and removes the pointer parameter
from functions which follow this pattern.

There is one exception which is the wss driver, which is kind of a library
driver, where some of the users actually pass a valid pointer. But the same
PCM object that is stored in that pointer can also be accessed through the
wss chip state struct. So that driver is update as well.

- Lars

Lars-Peter Clausen (21):
  ALSA: ml403-ac97cr: Remove always NULL parameter
  ALSA: ad1816a: Remove always NULL parameters
  ALSA: es1688: Remove almost always NULL parameter
  ALSA: es18xx: Remove always NULL parameter
  ALSA: gus: Remove always NULL parameters
  ALSA: msnd: Remove always NULL parameter
  ALSA: sb8: Remove always NULL parameters
  ASoC: sb16: Simplify snd_sb16dsp_pcm()
  ALSA: wss: Remove (almost) always NULL parameters
  ASLA: ad1889: Remove always NULL parameter
  ALSA: asihpi: Remove always NULL parameter
  ALSA: cs4281: Remove always NULL parameters
  ALSA: cs46xx: Remove always NULL parameters
  ALSA: ens1370: Remove always NULL parameters
  ALSA: emu10k1: Remove always NULL parameters
  ALSA: fm801: Remove always NULL parameter
  ALSA: ice1712: Remove always NULL parameters
  ALSA: riptide: Remove always NULL parameter
  ALSA: sonicvibes: Remove always NULL parameter
  ALSA: trident: Remove always NULL parameters
  ALSA: ymfpci: Remove always NULL parameters

 include/sound/ad1816a.h            |  5 ++---
 include/sound/emu10k1.h            | 14 ++++++-------
 include/sound/es1688.h             |  3 +--
 include/sound/gus.h                |  4 ++--
 include/sound/sb.h                 |  6 +++---
 include/sound/wss.h                |  6 +++---
 sound/drivers/ml403-ac97cr.c       |  9 ++-------
 sound/isa/ad1816a/ad1816a.c        |  5 ++---
 sound/isa/ad1816a/ad1816a_lib.c    |  9 ++-------
 sound/isa/ad1848/ad1848.c          |  7 +++----
 sound/isa/als100.c                 |  2 +-
 sound/isa/azt2320.c                |  4 ++--
 sound/isa/cmi8328.c                |  4 ++--
 sound/isa/cs423x/cs4231.c          |  9 ++++-----
 sound/isa/cs423x/cs4236.c          | 13 ++++++-------
 sound/isa/cs423x/cs4236_lib.c      |  9 +++------
 sound/isa/es1688/es1688.c          |  7 +++----
 sound/isa/es1688/es1688_lib.c      |  6 +-----
 sound/isa/es18xx.c                 | 10 ++--------
 sound/isa/galaxy/galaxy.c          |  4 ++--
 sound/isa/gus/gus_pcm.c            |  6 +-----
 sound/isa/gus/gus_uart.c           |  6 +-----
 sound/isa/gus/gusclassic.c         |  4 ++--
 sound/isa/gus/gusextreme.c         |  4 ++--
 sound/isa/gus/gusmax.c             |  8 ++++----
 sound/isa/gus/interwave.c          | 14 ++++++-------
 sound/isa/msnd/msnd.c              |  6 +-----
 sound/isa/msnd/msnd.h              |  2 +-
 sound/isa/msnd/msnd_pinnacle.c     |  2 +-
 sound/isa/opl3sa2.c                |  4 ++--
 sound/isa/opti9xx/miro.c           | 12 +++++-------
 sound/isa/opti9xx/opti92x-ad1848.c | 13 +++++--------
 sound/isa/sb/jazz16.c              |  2 +-
 sound/isa/sb/sb16.c                |  2 +-
 sound/isa/sb/sb16_main.c           |  8 ++------
 sound/isa/sb/sb8.c                 |  4 ++--
 sound/isa/sb/sb8_main.c            |  6 +-----
 sound/isa/sb/sb8_midi.c            |  6 +-----
 sound/isa/sc6000.c                 |  2 +-
 sound/isa/sscape.c                 |  5 ++---
 sound/isa/wavefront/wavefront.c    |  4 ++--
 sound/isa/wss/wss_lib.c            |  8 ++------
 sound/pci/ad1889.c                 | 10 ++--------
 sound/pci/asihpi/asihpi.c          |  9 ++-------
 sound/pci/cs4281.c                 | 18 ++++-------------
 sound/pci/cs46xx/cs46xx.c          | 10 +++++-----
 sound/pci/cs46xx/cs46xx.h          | 10 +++++-----
 sound/pci/cs46xx/cs46xx_lib.c      | 40 +++++---------------------------------
 sound/pci/cs5530.c                 |  2 +-
 sound/pci/emu10k1/emu10k1.c        | 12 ++++++------
 sound/pci/emu10k1/emu10k1x.c       | 19 +++++-------------
 sound/pci/emu10k1/emufx.c          |  7 +------
 sound/pci/emu10k1/emupcm.c         | 33 ++++---------------------------
 sound/pci/emu10k1/p16v.c           |  7 +------
 sound/pci/ens1370.c                | 37 ++++++++---------------------------
 sound/pci/fm801.c                  | 14 +++----------
 sound/pci/ice1712/ice1712.c        | 26 ++++++-------------------
 sound/pci/riptide/riptide.c        |  9 ++-------
 sound/pci/sonicvibes.c             |  7 ++-----
 sound/pci/trident/trident.c        |  6 +++---
 sound/pci/trident/trident.h        |  6 +++---
 sound/pci/trident/trident_main.c   | 21 +++-----------------
 sound/pci/ymfpci/ymfpci.c          |  8 ++++----
 sound/pci/ymfpci/ymfpci.h          |  8 ++++----
 sound/pci/ymfpci/ymfpci_main.c     | 38 ++++++------------------------------
 65 files changed, 185 insertions(+), 436 deletions(-)

-- 
1.8.0

             reply	other threads:[~2015-01-02 11:24 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-02 11:24 Lars-Peter Clausen [this message]
2015-01-02 11:24 ` [PATCH 01/21] ALSA: ml403-ac97cr: Remove always NULL parameter Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 02/21] ALSA: ad1816a: Remove always NULL parameters Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 03/21] ALSA: es1688: Remove almost always NULL parameter Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 04/21] ALSA: es18xx: Remove " Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 05/21] ALSA: gus: Remove always NULL parameters Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 06/21] ALSA: msnd: Remove always NULL parameter Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 07/21] ALSA: sb8: Remove always NULL parameters Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 08/21] ASoC: sb16: Simplify snd_sb16dsp_pcm() Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 09/21] ALSA: wss: Remove (almost) always NULL parameters Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 10/21] ASLA: ad1889: Remove always NULL parameter Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 11/21] ALSA: asihpi: " Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 12/21] ALSA: cs4281: Remove always NULL parameters Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 13/21] ALSA: cs46xx: " Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 14/21] ALSA: ens1370: " Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 15/21] ALSA: emu10k1: " Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 16/21] ALSA: fm801: Remove always NULL parameter Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 17/21] ALSA: ice1712: Remove always NULL parameters Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 18/21] ALSA: riptide: Remove always NULL parameter Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 19/21] ALSA: sonicvibes: " Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 20/21] ALSA: trident: Remove always NULL parameters Lars-Peter Clausen
2015-01-02 11:24 ` [PATCH 21/21] ALSA: ymfpci: " Lars-Peter Clausen
2015-01-02 15:35 ` [PATCH 00/21] ALSA: " Takashi Iwai

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=1420197895-17696-1-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=eliot@blennerhassett.gen.nz \
    --cc=perex@perex.cz \
    --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 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.