From patchwork Thu Aug 28 07:00:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 4795271 Return-Path: X-Original-To: patchwork-ltsi-dev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4965BC0338 for ; Thu, 28 Aug 2014 07:40:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 57EE520122 for ; Thu, 28 Aug 2014 07:40:57 +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 616892011E for ; Thu, 28 Aug 2014 07:40:56 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 73590C62; Thu, 28 Aug 2014 07:27:16 +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 8041EF16 for ; Thu, 28 Aug 2014 07:27:11 +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 BE7DC1F88A for ; Thu, 28 Aug 2014 07:27:10 +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 ABFF7267353; Thu, 28 Aug 2014 17:08:38 +1000 (EST) Received: by ayumi.isobedori.kobe.vergenet.net (Postfix, from userid 7100) id 3B8A6EDE008; 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:49 +0900 Message-Id: <1409209620-24487-524-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 523/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 In the non-DT sequence, the platform data is copied as a whole to the dynamic card info and the same pointer 'cinfo' is used to copy the platform information to the card. Use 'priv' as the pointer to the dynamic card info and copy only the useful information from the platform data. Signed-off-by: Jean-Francois Moine Signed-off-by: Mark Brown (cherry picked from commit ca65b492c7a265b220f763fd68bf87391213248f) Signed-off-by: Simon Horman --- sound/soc/generic/simple-card.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 9068ab4..90c6fd5 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -195,40 +195,42 @@ static int asoc_simple_card_parse_of(struct device_node *node, static int asoc_simple_card_probe(struct platform_device *pdev) { - struct asoc_simple_card_info *cinfo; + struct asoc_simple_card_info *priv; struct snd_soc_dai_link *dai_link; struct device_node *np = pdev->dev.of_node; struct device *dev = &pdev->dev; int ret; - cinfo = devm_kzalloc(dev, sizeof(*cinfo), GFP_KERNEL); - if (!cinfo) + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) return -ENOMEM; /* * init snd_soc_card */ - cinfo->snd_card.owner = THIS_MODULE; - cinfo->snd_card.dev = dev; - dai_link = &cinfo->snd_link; - cinfo->snd_card.dai_link = dai_link; - cinfo->snd_card.num_links = 1; + priv->snd_card.owner = THIS_MODULE; + priv->snd_card.dev = dev; + dai_link = &priv->snd_link; + priv->snd_card.dai_link = dai_link; + priv->snd_card.num_links = 1; if (np && of_device_is_available(np)) { - ret = asoc_simple_card_parse_of(np, cinfo, dev); + ret = asoc_simple_card_parse_of(np, priv, dev); if (ret < 0) { if (ret != -EPROBE_DEFER) dev_err(dev, "parse error %d\n", ret); return ret; } } else { - if (!dev->platform_data) { + struct asoc_simple_card_info *cinfo; + + cinfo = dev->platform_data; + if (!cinfo) { dev_err(dev, "no info for asoc-simple-card\n"); return -EINVAL; } - memcpy(cinfo, dev->platform_data, sizeof(*cinfo)); if (!cinfo->name || !cinfo->card || !cinfo->codec_dai.name || @@ -239,13 +241,17 @@ static int asoc_simple_card_probe(struct platform_device *pdev) return -EINVAL; } - cinfo->snd_card.name = cinfo->card; + priv->snd_card.name = cinfo->card; dai_link->name = cinfo->name; dai_link->stream_name = cinfo->name; dai_link->platform_name = cinfo->platform; dai_link->codec_name = cinfo->codec; dai_link->cpu_dai_name = cinfo->cpu_dai.name; dai_link->codec_dai_name = cinfo->codec_dai.name; + memcpy(&priv->cpu_dai, &cinfo->cpu_dai, + sizeof(priv->cpu_dai)); + memcpy(&priv->codec_dai, &cinfo->codec_dai, + sizeof(priv->codec_dai)); } /* @@ -253,9 +259,9 @@ static int asoc_simple_card_probe(struct platform_device *pdev) */ dai_link->init = asoc_simple_card_dai_init; - snd_soc_card_set_drvdata(&cinfo->snd_card, cinfo); + snd_soc_card_set_drvdata(&priv->snd_card, priv); - return devm_snd_soc_register_card(&pdev->dev, &cinfo->snd_card); + return devm_snd_soc_register_card(&pdev->dev, &priv->snd_card); } static const struct of_device_id asoc_simple_of_match[] = {