* [PATCH] ASoC: Reintroduce do_spi_write()
@ 2011-05-11 17:25 Mark Brown
2011-05-11 19:05 ` [PATCH] ASoC: snd_soc_hw_bulk_write_raw: Use the codec's hw_write callback Lars-Peter Clausen
2011-05-12 8:42 ` [PATCH] ASoC: Reintroduce do_spi_write() Liam Girdwood
0 siblings, 2 replies; 4+ messages in thread
From: Mark Brown @ 2011-05-11 17:25 UTC (permalink / raw)
To: Lars-Peter Clausen, Liam Girdwood; +Cc: alsa-devel, patches, Mark Brown
There is an unfortunate difference in return values between spi_write()
and i2c_master_send() so we need an adaptor function to translate.
Reported-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
sound/soc/soc-cache.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c
index 04861c4..dee86fc 100644
--- a/sound/soc/soc-cache.c
+++ b/sound/soc/soc-cache.c
@@ -20,6 +20,20 @@
#include <trace/events/asoc.h>
+#ifdef CONFIG_SPI_MASTER
+static int do_spi_write(void *control, const char *data, int len)
+{
+ struct spi_device *spi = control;
+ int ret;
+
+ ret = spi_write(spi, data, len);
+ if (ret < 0)
+ return ret;
+
+ return len;
+}
+#endif
+
static int do_hw_write(struct snd_soc_codec *codec, unsigned int reg,
unsigned int value, const void *data, int len)
{
@@ -409,7 +423,7 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
case SND_SOC_SPI:
#ifdef CONFIG_SPI_MASTER
- codec->hw_write = (hw_write_t)spi_write;
+ codec->hw_write = do_spi_write;
#endif
codec->control_data = container_of(codec->dev,
--
1.7.5.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH] ASoC: snd_soc_hw_bulk_write_raw: Use the codec's hw_write callback
2011-05-11 17:25 [PATCH] ASoC: Reintroduce do_spi_write() Mark Brown
@ 2011-05-11 19:05 ` Lars-Peter Clausen
2011-05-11 20:00 ` Mark Brown
2011-05-12 8:42 ` [PATCH] ASoC: Reintroduce do_spi_write() Liam Girdwood
1 sibling, 1 reply; 4+ messages in thread
From: Lars-Peter Clausen @ 2011-05-11 19:05 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood; +Cc: alsa-devel, Lars-Peter Clausen
Currently there are two places in the snd_soc_cache code where the function to
write to the hardware is determined by looking at the control_type.
One lookup is done when the cache is initialized the other is done in
snd_soc_hw_bulk_write_raw. This requires, that when the spi or i2c write function
is changed, that both places are updated.
To avoid missing one of them use the codec's hw_write callback in
snd_soc_hw_bulk_write_raw instead of looking at the control_type.
Also this allows to use other bus types to do raw writes instead of limiting it
to spi and i2c.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
sound/soc/soc-cache.c | 16 +---------------
1 files changed, 1 insertions(+), 15 deletions(-)
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c
index 06b7b81..fb34d65 100644
--- a/sound/soc/soc-cache.c
+++ b/sound/soc/soc-cache.c
@@ -308,21 +308,7 @@ static int snd_soc_hw_bulk_write_raw(struct snd_soc_codec *codec, unsigned int r
&& reg < codec->driver->reg_cache_size)
return -EINVAL;
- switch (codec->control_type) {
-#if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE))
- case SND_SOC_I2C:
- ret = i2c_master_send(codec->control_data, data, len);
- break;
-#endif
-#if defined(CONFIG_SPI_MASTER)
- case SND_SOC_SPI:
- ret = spi_write(codec->control_data, data, len);
- break;
-#endif
- default:
- BUG();
- }
-
+ ret = codec->hw_write(codec, data, len);
if (ret == len)
return 0;
if (ret < 0)
--
1.7.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] ASoC: snd_soc_hw_bulk_write_raw: Use the codec's hw_write callback
2011-05-11 19:05 ` [PATCH] ASoC: snd_soc_hw_bulk_write_raw: Use the codec's hw_write callback Lars-Peter Clausen
@ 2011-05-11 20:00 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2011-05-11 20:00 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: alsa-devel, Liam Girdwood
On Wed, May 11, 2011 at 12:05:14PM -0700, Lars-Peter Clausen wrote:
> Currently there are two places in the snd_soc_cache code where the function to
> write to the hardware is determined by looking at the control_type.
> One lookup is done when the cache is initialized the other is done in
> snd_soc_hw_bulk_write_raw. This requires, that when the spi or i2c write function
> is changed, that both places are updated.
> To avoid missing one of them use the codec's hw_write callback in
> snd_soc_hw_bulk_write_raw instead of looking at the control_type.
>
> Also this allows to use other bus types to do raw writes instead of limiting it
> to spi and i2c.
You're missing the bigger picture here where the raw bulk write doesn't
work at all at the minute as it doesn't include the register. Dimitris
said he was going to fix this, I suspect this will collide with that
more important fix.
Please do also bear in mind my previous feedback about fixing the line
lengths and general formatting in your commit logs. It's rather hard to
read the above.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: Reintroduce do_spi_write()
2011-05-11 17:25 [PATCH] ASoC: Reintroduce do_spi_write() Mark Brown
2011-05-11 19:05 ` [PATCH] ASoC: snd_soc_hw_bulk_write_raw: Use the codec's hw_write callback Lars-Peter Clausen
@ 2011-05-12 8:42 ` Liam Girdwood
1 sibling, 0 replies; 4+ messages in thread
From: Liam Girdwood @ 2011-05-12 8:42 UTC (permalink / raw)
To: Mark Brown; +Cc: alsa-devel, Lars-Peter Clausen, patches
On Wed, 2011-05-11 at 19:25 +0200, Mark Brown wrote:
> There is an unfortunate difference in return values between spi_write()
> and i2c_master_send() so we need an adaptor function to translate.
>
> Reported-by: Lars-Peter Clausen <lars@metafoo.de>
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
> sound/soc/soc-cache.c | 16 +++++++++++++++-
> 1 files changed, 15 insertions(+), 1 deletions(-)
>
> diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c
> index 04861c4..dee86fc 100644
> --- a/sound/soc/soc-cache.c
> +++ b/sound/soc/soc-cache.c
> @@ -20,6 +20,20 @@
>
> #include <trace/events/asoc.h>
>
> +#ifdef CONFIG_SPI_MASTER
> +static int do_spi_write(void *control, const char *data, int len)
> +{
> + struct spi_device *spi = control;
> + int ret;
> +
> + ret = spi_write(spi, data, len);
> + if (ret < 0)
> + return ret;
> +
> + return len;
> +}
> +#endif
> +
> static int do_hw_write(struct snd_soc_codec *codec, unsigned int reg,
> unsigned int value, const void *data, int len)
> {
> @@ -409,7 +423,7 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
>
> case SND_SOC_SPI:
> #ifdef CONFIG_SPI_MASTER
> - codec->hw_write = (hw_write_t)spi_write;
> + codec->hw_write = do_spi_write;
> #endif
>
> codec->control_data = container_of(codec->dev,
Acked-by: Liam Girdwood <lrg@ti.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-05-12 8:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-11 17:25 [PATCH] ASoC: Reintroduce do_spi_write() Mark Brown
2011-05-11 19:05 ` [PATCH] ASoC: snd_soc_hw_bulk_write_raw: Use the codec's hw_write callback Lars-Peter Clausen
2011-05-11 20:00 ` Mark Brown
2011-05-12 8:42 ` [PATCH] ASoC: Reintroduce do_spi_write() Liam Girdwood
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.