From patchwork Thu Aug 28 07:00:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 4796171 Return-Path: X-Original-To: patchwork-ltsi-dev@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 BE4579F375 for ; Thu, 28 Aug 2014 07:53:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DAC382016C for ; Thu, 28 Aug 2014 07:53:10 +0000 (UTC) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E168A2013A for ; Thu, 28 Aug 2014 07:53:09 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id BD141105A; Thu, 28 Aug 2014 07:28:56 +0000 (UTC) X-Original-To: ltsi-dev@lists.linuxfoundation.org Delivered-To: ltsi-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 0577C1058 for ; Thu, 28 Aug 2014 07:28:56 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from kirsty.vergenet.net (kirsty.vergenet.net [202.4.237.240]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 31BB320225 for ; Thu, 28 Aug 2014 07:28:55 +0000 (UTC) Received: from ayumi.isobedori.kobe.vergenet.net (p4222-ipbfp1605kobeminato.hyogo.ocn.ne.jp [114.154.95.222]) by kirsty.vergenet.net (Postfix) with ESMTP id 37A5B26734F; Thu, 28 Aug 2014 17:08:38 +1000 (EST) Received: by ayumi.isobedori.kobe.vergenet.net (Postfix, from userid 7100) id AF309EDE5F7; Thu, 28 Aug 2014 16:08:36 +0900 (JST) From: Simon Horman To: ltsi-dev@lists.linuxfoundation.org Date: Thu, 28 Aug 2014 16:00:46 +0900 Message-Id: <1409209620-24487-521-git-send-email-horms+renesas@verge.net.au> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1409209620-24487-1-git-send-email-horms+renesas@verge.net.au> References: <1409209620-24487-1-git-send-email-horms+renesas@verge.net.au> X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org Cc: Magnus Damm Subject: [LTSI-dev] [PATCH LTSI-3.14 520/894] ASoC: simple-card: simplify code X-BeenThere: ltsi-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "A list to discuss patches, development, and other things related to the LTSI project" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ltsi-dev-bounces@lists.linuxfoundation.org Errors-To: ltsi-dev-bounces@lists.linuxfoundation.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jean-Francois Moine The OF pointers are put in the stack and then copied to the card descriptor. Put them directly at their right place. Signed-off-by: Jean-Francois Moine Signed-off-by: Mark Brown (cherry picked from commit 201a0eac7fe5e7a8fa33f0742304f885bc344d0d) Signed-off-by: Simon Horman --- sound/soc/generic/simple-card.c | 55 +++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 35 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 7c5dc73..89f83b3 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -60,8 +60,9 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) static int asoc_simple_card_sub_parse_of(struct device_node *np, struct asoc_simple_dai *dai, - struct device_node **node) + const struct device_node **p_node) { + struct device_node *node; struct clk *clk; int ret; @@ -69,9 +70,10 @@ asoc_simple_card_sub_parse_of(struct device_node *np, * get node via "sound-dai = <&phandle port>" * it will be used as xxx_of_node on soc_bind_dai_link() */ - *node = of_parse_phandle(np, "sound-dai", 0); - if (!*node) + node = of_parse_phandle(np, "sound-dai", 0); + if (!node) return -ENODEV; + *p_node = node; /* get dai->name */ ret = snd_soc_of_get_dai_name(np, &dai->name); @@ -104,7 +106,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np, "system-clock-frequency", &dai->sysclk); } else { - clk = of_clk_get(*node, 0); + clk = of_clk_get(node, 0); if (!IS_ERR(clk)) dai->sysclk = clk_get_rate(clk); } @@ -112,17 +114,14 @@ asoc_simple_card_sub_parse_of(struct device_node *np, ret = 0; parse_error: - of_node_put(*node); + of_node_put(node); return ret; } static int asoc_simple_card_parse_of(struct device_node *node, struct asoc_simple_card_info *info, - struct device *dev, - struct device_node **of_cpu, - struct device_node **of_codec, - struct device_node **of_platform) + struct device *dev) { struct device_node *np; char *name; @@ -146,7 +145,7 @@ static int asoc_simple_card_parse_of(struct device_node *node, if (np) ret = asoc_simple_card_sub_parse_of(np, &info->cpu_dai, - of_cpu); + &info->snd_link.cpu_of_node); if (ret < 0) return ret; @@ -156,7 +155,7 @@ static int asoc_simple_card_parse_of(struct device_node *node, if (np) ret = asoc_simple_card_sub_parse_of(np, &info->codec_dai, - of_codec); + &info->snd_link.codec_of_node); if (ret < 0) return ret; @@ -173,7 +172,7 @@ static int asoc_simple_card_parse_of(struct device_node *node, info->snd_link.name = info->snd_link.stream_name = name; /* simple-card assumes platform == cpu */ - *of_platform = *of_cpu; + info->snd_link.platform_of_node = info->snd_link.cpu_of_node; dev_dbg(dev, "card-name : %s\n", name); dev_dbg(dev, "platform : %04x\n", info->daifmt); @@ -193,34 +192,29 @@ static int asoc_simple_card_probe(struct platform_device *pdev) { struct asoc_simple_card_info *cinfo; struct device_node *np = pdev->dev.of_node; - struct device_node *of_cpu, *of_codec, *of_platform; struct device *dev = &pdev->dev; int ret; - cinfo = NULL; - of_cpu = NULL; - of_codec = NULL; - of_platform = NULL; - cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL); if (!cinfo) return -ENOMEM; + /* + * init snd_soc_card + */ + cinfo->snd_card.owner = THIS_MODULE; + cinfo->snd_card.dev = dev; + cinfo->snd_card.dai_link = &cinfo->snd_link; + cinfo->snd_card.num_links = 1; + if (np && of_device_is_available(np)) { - cinfo->snd_card.dev = dev; - ret = asoc_simple_card_parse_of(np, cinfo, dev, - &of_cpu, - &of_codec, - &of_platform); + ret = asoc_simple_card_parse_of(np, cinfo, dev); if (ret < 0) { if (ret != -EPROBE_DEFER) dev_err(dev, "parse error %d\n", ret); return ret; } - cinfo->snd_link.cpu_of_node = of_cpu; - cinfo->snd_link.codec_of_node = of_codec; - cinfo->snd_link.platform_of_node = of_platform; } else { if (!dev->platform_data) { dev_err(dev, "no info for asoc-simple-card\n"); @@ -228,8 +222,6 @@ static int asoc_simple_card_probe(struct platform_device *pdev) } memcpy(cinfo, dev->platform_data, sizeof(*cinfo)); - cinfo->snd_card.dev = dev; - if (!cinfo->name || !cinfo->card || !cinfo->codec_dai.name || @@ -254,13 +246,6 @@ static int asoc_simple_card_probe(struct platform_device *pdev) cinfo->snd_link.codec_dai_name = cinfo->codec_dai.name; cinfo->snd_link.init = asoc_simple_card_dai_init; - /* - * init snd_soc_card - */ - cinfo->snd_card.owner = THIS_MODULE; - cinfo->snd_card.dai_link = &cinfo->snd_link; - cinfo->snd_card.num_links = 1; - snd_soc_card_set_drvdata(&cinfo->snd_card, cinfo); return devm_snd_soc_register_card(&pdev->dev, &cinfo->snd_card);