All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, Liam Girdwood <lrg@slimlogic.co.uk>
Subject: Re: [PATCH 1/4] ASoC: clean up cache read/write functions
Date: Mon, 20 Dec 2010 17:24:05 +0000	[thread overview]
Message-ID: <20101220172405.GA2531@rakim.wolfsonmicro.main> (raw)
In-Reply-To: <s5h1v5czb5m.wl%tiwai@suse.de>

On Mon, Dec 20, 2010 at 05:01:09PM +0100, Takashi Iwai wrote:

> +static int do_hw_write(struct snd_soc_codec *codec, unsigned int reg,
> +                      unsigned int value, void *data, unsigned int size)
> +{
> +       int ret;
> +
> +       if (!snd_soc_codec_volatile_register(codec, reg) &&
> +           reg < codec->driver->reg_cache_size) {
> +               ret = snd_soc_cache_write(codec, reg, value);
> +               if (ret < 0)
> +                       return -1;
> +       }

This isn't actually doing a hardware write, though - it's the entire
write path which may or may not end up at the hardware.  The whole
passing of both the mangled and unmangled versions also feels a bit odd
here.

I think it'd be clearer to do this by making this a plain function and
adding a mangle operation set by the cache types which gets called out
to at the appropriate moment, that'd probably make the code flow more
naturally.

> +static unsigned int snd_soc_4_12_read(struct snd_soc_codec *codec,
> +				      unsigned int reg)
> +{
> +	return do_hw_read(codec, reg);
> +}
> +

>  static unsigned int snd_soc_7_9_read(struct snd_soc_codec *codec,
>  				     unsigned int reg)
>  {
> -	int ret;
> -	unsigned int val;
> -
> -	if (reg >= codec->driver->reg_cache_size ||
> -		snd_soc_codec_volatile_register(codec, reg)) {
> -			if (codec->cache_only)
> -				return -1;
> -
> -			BUG_ON(!codec->hw_read);
> -			return codec->hw_read(codec, reg);
> -	}
> -
> -	ret = snd_soc_cache_read(codec, reg, &val);
> -	if (ret < 0)
> -		return -1;
> -	return val;
> +	return do_hw_read(codec, reg);

If this is OK to do we should just be making do_hw_read() the operation
directly.

  parent reply	other threads:[~2010-12-20 17:24 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-20 14:50 ASoC cache code (looking toward 2.6.38 merge window) Takashi Iwai
2010-12-20 15:27 ` Mark Brown
2010-12-20 15:56   ` Takashi Iwai
2010-12-20 16:01     ` [PATCH 1/4] ASoC: clean up cache read/write functions Takashi Iwai
2010-12-20 16:01       ` [PATCH 2/4] ASoC: clean up spi " Takashi Iwai
2010-12-20 16:02         ` [PATCH 3/4] ASoC: clean up i2c cache read / write functions Takashi Iwai
2010-12-20 16:05           ` [PATCH 4/4] ASoC: clean up cache accesser Takashi Iwai
2010-12-20 16:27             ` Dimitris Papastamos
2010-12-20 16:47               ` Takashi Iwai
2010-12-20 16:54                 ` Mark Brown
2010-12-20 17:09                   ` Dimitris Papastamos
2010-12-20 17:22                     ` Takashi Iwai
2010-12-20 17:04                 ` Dimitris Papastamos
2010-12-20 16:42             ` Mark Brown
2010-12-20 16:57               ` Takashi Iwai
2010-12-20 17:20                 ` [PATCH 4/4] ASoC: Factor out cache_ops implementations Takashi Iwai
2010-12-20 17:29         ` [PATCH 2/4] ASoC: clean up spi cache read/write functions Mark Brown
2010-12-20 17:23       ` [PATCH 1/4] ASoC: clean up " Dimitris Papastamos
2010-12-20 17:24       ` Mark Brown [this message]
2010-12-20 17:32         ` Takashi Iwai
2010-12-20 16:34     ` ASoC cache code (looking toward 2.6.38 merge window) Mark Brown
2010-12-20 16:51       ` Takashi Iwai
2010-12-20 16:58         ` Mark Brown
2010-12-20 16:59           ` 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=20101220172405.GA2531@rakim.wolfsonmicro.main \
    --to=broonie@opensource.wolfsonmicro.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=lrg@slimlogic.co.uk \
    --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.