From patchwork Sun Aug 6 21:36:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Jarzmik X-Patchwork-Id: 9884145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EACBE602B6 for ; Sun, 6 Aug 2017 21:41:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8AC22018F for ; Sun, 6 Aug 2017 21:41:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBBF328563; Sun, 6 Aug 2017 21:41:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5DF022018F for ; Sun, 6 Aug 2017 21:41:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=E5pFQSFfd6MQxYq+/bsl6UHWT5MXi2r0pve8yGSdTLQ=; b=T9quJYzfvW2xVLvDY2Bgl9PQ9w GF1ug2x9jtYhKqAXS93LAUpZzSEJBS37YnU6OnTTo11gqoCjcHzn4qUvAf4k/lldigdNLXIcpPZeb 6Ilmq1g6WWRz6ql62vrWsqkIUNE8MY2O1/+bpU3fCmgiqiuME+pij3JEkFpaCLorzrrf5M0ZeUjwv 8/Qmk5V2JHWPIfvH2jw+OLcUF3KWUOMvir6GMi+s4A/+0NQsirBrROjK9t2WBhsqvhCmK0QvNTAQl y8Gkt0Ds+VuK7saK9n4Xob7EK225QC6se3EHlC6h57KysbBVMH/NytLvAPbgPdfu9Hj3tco1jnkCb qcBn1hdA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1deTIR-0007dJ-R8; Sun, 06 Aug 2017 21:41:15 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1deTEP-0002w8-1G for linux-arm-kernel@bombadil.infradead.org; Sun, 06 Aug 2017 21:37:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=stJZPkshR368emMtVWuWj1YJGRHSBoPFd/cma6lsoLU=; b=jeh137MiKQfk9cjmBKEjEkgaw O3JRiRALTcCIUgjcyTyYhxfDTzCLxP7HEYQ/hGe258ua+9u8Ef9smrEib4VtDnXvrQ8zQ7IGvVZ0A U+jPYeOrSgDsdR5Aaf5pKsoGLOD9sfcks1+cj2ZIM8p+ps54ZcEzKOh1Ji25SYbf4fK+1Mu9nfIvP 2j+NOB1hkIciYGEBJHS4KZ2bgtKH4tJBpB3M8FA9KzCmcZmnWJtACNM5OMttiOtQxS6QNHMCBgM9g 8F+JHLhOlOrrNSdUzdBn2TvX0bsZ2oQKWCZFqg/GOLFFXBEYy/8F6sZNIyQH65WgBcFqmbOvrj0bg ZwPi0EU7w==; Received: from smtp02.smtpout.orange.fr ([80.12.242.124] helo=smtp.smtpout.orange.fr) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1deTEK-0004hv-Im for linux-arm-kernel@lists.infradead.org; Sun, 06 Aug 2017 21:37:02 +0000 Received: from belgarion.home ([90.55.206.157]) by mwinf5d78 with ME id txcE1v0093QH74y03xcYMx; Sun, 06 Aug 2017 23:36:33 +0200 X-ME-Helo: belgarion.home X-ME-Date: Sun, 06 Aug 2017 23:36:33 +0200 X-ME-IP: 90.55.206.157 From: Robert Jarzmik To: Dmitry Torokhov , Lee Jones , Jaroslav Kysela , Takashi Iwai , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Liam Girdwood , Mark Brown , Lars-Peter Clausen , Charles Keepax Subject: [PATCH v5 10/12] ASoC: wm9705: add private structure Date: Sun, 6 Aug 2017 23:36:11 +0200 Message-Id: <20170806213613.5600-11-robert.jarzmik@free.fr> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170806213613.5600-1-robert.jarzmik@free.fr> References: <20170806213613.5600-1-robert.jarzmik@free.fr> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-input@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add a private data structure. This is a preparation for a codec which would need an another data on top of snd_ac97, which will be the case when an MFD wm97xx device will probe wm9705. Signed-off-by: Robert Jarzmik Acked-by: Charles Keepax --- sound/soc/codecs/wm9705.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c index f6d5c0f2aea5..08477d040028 100644 --- a/sound/soc/codecs/wm9705.c +++ b/sound/soc/codecs/wm9705.c @@ -24,6 +24,10 @@ #define WM9705_VENDOR_ID 0x574d4c05 #define WM9705_VENDOR_ID_MASK 0xffffffff +struct wm9705_priv { + struct snd_ac97 *ac97; +}; + static const struct reg_default wm9705_reg_defaults[] = { { 0x02, 0x8000 }, { 0x04, 0x8000 }, @@ -292,10 +296,10 @@ static int wm9705_soc_suspend(struct snd_soc_codec *codec) static int wm9705_soc_resume(struct snd_soc_codec *codec) { - struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); int ret; - ret = snd_ac97_reset(ac97, true, WM9705_VENDOR_ID, + ret = snd_ac97_reset(wm9705->ac97, true, WM9705_VENDOR_ID, WM9705_VENDOR_ID_MASK); if (ret < 0) return ret; @@ -311,38 +315,38 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec) static int wm9705_soc_probe(struct snd_soc_codec *codec) { - struct snd_ac97 *ac97; + struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); struct regmap *regmap; int ret; - ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID, - WM9705_VENDOR_ID_MASK); - if (IS_ERR(ac97)) { + wm9705->ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID, + WM9705_VENDOR_ID_MASK); + if (IS_ERR(wm9705->ac97)) { dev_err(codec->dev, "Failed to register AC97 codec\n"); - return PTR_ERR(ac97); + return PTR_ERR(wm9705->ac97); } - regmap = regmap_init_ac97(ac97, &wm9705_regmap_config); + regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config); if (IS_ERR(regmap)) { ret = PTR_ERR(regmap); goto err_free_ac97_codec; } - snd_soc_codec_set_drvdata(codec, ac97); + snd_soc_codec_set_drvdata(codec, wm9705->ac97); snd_soc_codec_init_regmap(codec, regmap); return 0; err_free_ac97_codec: - snd_soc_free_ac97_codec(ac97); + snd_soc_free_ac97_codec(wm9705->ac97); return ret; } static int wm9705_soc_remove(struct snd_soc_codec *codec) { - struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); snd_soc_codec_exit_regmap(codec); - snd_soc_free_ac97_codec(ac97); + snd_soc_free_ac97_codec(wm9705->ac97); return 0; } @@ -364,6 +368,14 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm9705 = { static int wm9705_probe(struct platform_device *pdev) { + struct wm9705_priv *wm9705; + + wm9705 = devm_kzalloc(&pdev->dev, sizeof(*wm9705), GFP_KERNEL); + if (wm9705 == NULL) + return -ENOMEM; + + platform_set_drvdata(pdev, wm9705); + return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm9705, wm9705_dai, ARRAY_SIZE(wm9705_dai)); }