From patchwork Sun May 18 12:24:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars-Peter Clausen X-Patchwork-Id: 4197811 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6BBCE9F1CD for ; Sun, 18 May 2014 12:27:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 975B4201F7 for ; Sun, 18 May 2014 12:27:04 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 281FE201EC for ; Sun, 18 May 2014 12:27:02 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 25B8526519F; Sun, 18 May 2014 14:27:01 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 93AD5264FE7; Sun, 18 May 2014 14:24:39 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 62D74264F0D; Sun, 18 May 2014 14:24:33 +0200 (CEST) Received: from smtp-out-145.synserver.de (smtp-out-151.synserver.de [212.40.185.151]) by alsa0.perex.cz (Postfix) with ESMTP id A8D85264F03 for ; Sun, 18 May 2014 14:24:28 +0200 (CEST) Received: (qmail 19831 invoked by uid 0); 18 May 2014 12:24:26 -0000 X-SynServer-TrustedSrc: 1 X-SynServer-AuthUser: lars@metafoo.de X-SynServer-PPID: 19571 Received: from ppp-212-114-237-253.dynamic.mnet-online.de (HELO lars-adi-laptop.fritz.box) [212.114.237.253] by 217.119.54.77 with SMTP; 18 May 2014 12:24:26 -0000 From: Lars-Peter Clausen To: Mark Brown , Liam Girdwood Date: Sun, 18 May 2014 14:24:12 +0200 Message-Id: <1400415858-11025-6-git-send-email-lars@metafoo.de> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1400415858-11025-1-git-send-email-lars@metafoo.de> References: <1400415858-11025-1-git-send-email-lars@metafoo.de> Cc: alsa-devel@alsa-project.org, Lars-Peter Clausen Subject: [alsa-devel] [PATCH 05/11] ASoC: Add helper functions to cast from DAPM context to CODEC/platform X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- include/sound/soc.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) 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,