diff mbox

[05/11] ASoC: Add helper functions to cast from DAPM context to CODEC/platform

Message ID 1400415858-11025-6-git-send-email-lars@metafoo.de (mailing list archive)
State Accepted
Commit 24089e04cb1b4975bafd6368ab8b92082ebf6ad7
Delegated to: Takashi Iwai
Headers show

Commit Message

Lars-Peter Clausen May 18, 2014, 12:24 p.m. UTC
This is useful if we have a pointer to a DAPM context and know that it is a
CODEC or platform DAPM context and want to get a pointer to the CODEC or
platform.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 include/sound/soc.h | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Lars-Peter Clausen May 26, 2014, 7:36 p.m. UTC | #1
On 05/18/2014 02:24 PM, Lars-Peter Clausen wrote:
> This is useful if we have a pointer to a DAPM context and know that it is a
> CODEC or platform DAPM context and want to get a pointer to the CODEC or
> platform.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---

It would be nice if this one could make it into 3.16. It doesn't depend on any 
of the patches earlier in this series and I think it is pretty trivial. Having 
it in 3.16 makes it possible to use it after the merge window in some driver 
cleanup patches without having to do cross topic branch merges.

Thanks,
- Lars
Mark Brown June 1, 2014, 6:18 p.m. UTC | #2
On Mon, May 26, 2014 at 09:36:54PM +0200, Lars-Peter Clausen wrote:

> It would be nice if this one could make it into 3.16. It doesn't depend on
> any of the patches earlier in this series and I think it is pretty trivial.
> Having it in 3.16 makes it possible to use it after the merge window in some
> driver cleanup patches without having to do cross topic branch merges.

I've applied it - as a general suggestion if I've said something is
being punted for a while then replying to the series probably isn't a
good way to get attention for it, I very nearly just punted on this
until after the merge window.  Resending individually or pinging me on
IRC will probably work better.
Vinod Koul June 6, 2014, 5:47 a.m. UTC | #3
On Mon, May 26, 2014 at 09:36:54PM +0200, Lars-Peter Clausen wrote:
> On 05/18/2014 02:24 PM, Lars-Peter Clausen wrote:
> >This is useful if we have a pointer to a DAPM context and know that it is a
> >CODEC or platform DAPM context and want to get a pointer to the CODEC or
> >platform.
> >
> >Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> >---
> 
> It would be nice if this one could make it into 3.16. It doesn't
> depend on any of the patches earlier in this series and I think it
> is pretty trivial. Having it in 3.16 makes it possible to use it
> after the merge window in some driver cleanup patches without having
> to do cross topic branch merges.

I think that would be a good idea. At least my driver updates are dependent on
this series and this series looks good to me. But merge window opened earlier
this week, so chances are bit slim :(

Anyway its Mark's call...
Lars-Peter Clausen June 6, 2014, 6:20 a.m. UTC | #4
On 06/06/2014 07:47 AM, Vinod Koul wrote:
> On Mon, May 26, 2014 at 09:36:54PM +0200, Lars-Peter Clausen wrote:
>> On 05/18/2014 02:24 PM, Lars-Peter Clausen wrote:
>>> This is useful if we have a pointer to a DAPM context and know that it is a
>>> CODEC or platform DAPM context and want to get a pointer to the CODEC or
>>> platform.
>>>
>>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>>> ---
>>
>> It would be nice if this one could make it into 3.16. It doesn't
>> depend on any of the patches earlier in this series and I think it
>> is pretty trivial. Having it in 3.16 makes it possible to use it
>> after the merge window in some driver cleanup patches without having
>> to do cross topic branch merges.
>
> I think that would be a good idea. At least my driver updates are dependent on
> this series and this series looks good to me. But merge window opened earlier
> this week, so chances are bit slim :(
>
> Anyway its Mark's call...
>

This particular patch is queued for 3.16. The rest of the series will 
hopefully, if no issues turn up during review, be merged into the ASoC tree 
after the merged window.

- Lars
diff mbox

Patch

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 9b335d8..aa9acaf 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -1142,6 +1142,33 @@  static inline struct snd_soc_platform *snd_soc_component_to_platform(
 	return container_of(component, struct snd_soc_platform, component);
 }
 
+/**
+ * snd_soc_dapm_to_codec() - Casts a DAPM context to the CODEC it is embedded in
+ * @dapm: The DAPM context to cast to the CODEC
+ *
+ * This function must only be used on DAPM contexts that are known to be part of
+ * a CODEC (e.g. in a CODEC driver). Otherwise the behavior is undefined.
+ */
+static inline struct snd_soc_codec *snd_soc_dapm_to_codec(
+	struct snd_soc_dapm_context *dapm)
+{
+	return container_of(dapm, struct snd_soc_codec, dapm);
+}
+
+/**
+ * snd_soc_dapm_to_platform() - Casts a DAPM context to the platform it is
+ *  embedded in
+ * @dapm: The DAPM context to cast to the platform.
+ *
+ * This function must only be used on DAPM contexts that are known to be part of
+ * a platform (e.g. in a platform driver). Otherwise the behavior is undefined.
+ */
+static inline struct snd_soc_platform *snd_soc_dapm_to_platform(
+	struct snd_soc_dapm_context *dapm)
+{
+	return container_of(dapm, struct snd_soc_platform, dapm);
+}
+
 /* codec IO */
 unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
 int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg,