From patchwork Mon Dec 2 18:00:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 21940 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3237520299 for ; Mon, 2 Dec 2013 18:00:35 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hu19sf29218395vcb.7 for ; Mon, 02 Dec 2013 10:00:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=Qc/GFu3wQZzuqrtWkWI5G18WEHLK4vgrH+ndRbU4+fk=; b=axSaYRTytss4pZ6NMl1Esqf1j24b/WG5LXovZD5wjzr4gGfOzQFKGGmAj6pacUe4zI GcY9hXOIYjcN6Et0z6TxWUZPqQNU0EknbBajcQOR+VXyJWAfwVkTnWOiNxgOoPq4SQUH gmM5Ve9pqNSj3wX452JaPr/O2Qw8JHCOMPPRkg/Q0daq4zMqw1zNUnXOhTqobKk8T8Pk gcnWkfWZe4Drn8716OYHL5UoKb3/yFA2UqigPWIbj1L0f8XeP5/+fP86FazTyydlR9Kb ZVnLF1tBk+Mov/7LorAKNVYa0hb1dFL0eTWuGFwbYn0MkSCPxxmRClkXSoEmaiAUjmut l4bA== X-Gm-Message-State: ALoCoQmYiorWVhAmLj4uvligIxwwXYSR+jo05gmo7+2FybvA3M3Wn+lV93vLadypYPqaStQ9FbKX X-Received: by 10.58.201.36 with SMTP id jx4mr1257431vec.35.1386007234693; Mon, 02 Dec 2013 10:00:34 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.119.196 with SMTP id kw4ls4741891qeb.90.gmail; Mon, 02 Dec 2013 10:00:34 -0800 (PST) X-Received: by 10.52.227.233 with SMTP id sd9mr442847vdc.53.1386007234581; Mon, 02 Dec 2013 10:00:34 -0800 (PST) Received: from mail-vb0-f41.google.com (mail-vb0-f41.google.com [209.85.212.41]) by mx.google.com with ESMTPS id on2si29970780vcb.90.2013.12.02.10.00.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Dec 2013 10:00:34 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.41; Received: by mail-vb0-f41.google.com with SMTP id w5so9013331vbf.0 for ; Mon, 02 Dec 2013 10:00:34 -0800 (PST) X-Received: by 10.58.241.135 with SMTP id wi7mr316585vec.70.1386007234483; Mon, 02 Dec 2013 10:00:34 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp143012vcz; Mon, 2 Dec 2013 10:00:34 -0800 (PST) X-Received: by 10.43.138.148 with SMTP id is20mr42048552icc.23.1386007233617; Mon, 02 Dec 2013 10:00:33 -0800 (PST) Received: from mail-ie0-f171.google.com (mail-ie0-f171.google.com [209.85.223.171]) by mx.google.com with ESMTPS id i1si50085867igi.36.2013.12.02.10.00.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Dec 2013 10:00:33 -0800 (PST) Received-SPF: neutral (google.com: 209.85.223.171 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.223.171; Received: by mail-ie0-f171.google.com with SMTP id ar20so22000246iec.30 for ; Mon, 02 Dec 2013 10:00:33 -0800 (PST) X-Received: by 10.43.60.139 with SMTP id ws11mr42277650icb.12.1386007233198; Mon, 02 Dec 2013 10:00:33 -0800 (PST) Received: from localhost.localdomain (cpc15-aztw25-2-0-cust493.aztw.cable.virginm.net. [92.233.57.238]) by mx.google.com with ESMTPSA id p5sm67718324igj.10.2013.12.02.10.00.31 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Dec 2013 10:00:32 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: linus.walleij@linaro.org, broonie@kernel.org, Lee Jones , alsa-devel@alsa-project.org Subject: [PATCH 3/3] ASoC: ux500: Dynamically fill DAI driver data on probe Date: Mon, 2 Dec 2013 18:00:22 +0000 Message-Id: <1386007222-10081-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1386007222-10081-1-git-send-email-lee.jones@linaro.org> References: <1386007222-10081-1-git-send-email-lee.jones@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.41 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , We no longer have a means to differentiate MSP devices at probe time, mainline because we don't really have to. So rather than have an over- sized static data structure in place, where the only difference between devices is the ID and name (which are unused), we'll create them only when required and omit the unnecessary information. Cc: alsa-devel@alsa-project.org Signed-off-by: Lee Jones --- sound/soc/ux500/ux500_msp_dai.c | 108 ++++++++++------------------------------ 1 file changed, 26 insertions(+), 82 deletions(-) diff --git a/sound/soc/ux500/ux500_msp_dai.c b/sound/soc/ux500/ux500_msp_dai.c index 8d1b01f..153fb3f 100644 --- a/sound/soc/ux500/ux500_msp_dai.c +++ b/sound/soc/ux500/ux500_msp_dai.c @@ -718,87 +718,20 @@ static struct snd_soc_dai_ops ux500_msp_dai_ops[] = { } }; -static struct snd_soc_dai_driver ux500_msp_dai_drv[UX500_NBR_OF_DAI] = { - { - .name = "ux500-msp-i2s.0", - .probe = ux500_msp_dai_probe, - .id = 0, - .suspend = NULL, - .resume = NULL, - .playback = { - .channels_min = UX500_MSP_MIN_CHANNELS, - .channels_max = UX500_MSP_MAX_CHANNELS, - .rates = UX500_I2S_RATES, - .formats = UX500_I2S_FORMATS, - }, - .capture = { - .channels_min = UX500_MSP_MIN_CHANNELS, - .channels_max = UX500_MSP_MAX_CHANNELS, - .rates = UX500_I2S_RATES, - .formats = UX500_I2S_FORMATS, - }, - .ops = ux500_msp_dai_ops, - }, - { - .name = "ux500-msp-i2s.1", - .probe = ux500_msp_dai_probe, - .id = 1, - .suspend = NULL, - .resume = NULL, - .playback = { - .channels_min = UX500_MSP_MIN_CHANNELS, - .channels_max = UX500_MSP_MAX_CHANNELS, - .rates = UX500_I2S_RATES, - .formats = UX500_I2S_FORMATS, - }, - .capture = { - .channels_min = UX500_MSP_MIN_CHANNELS, - .channels_max = UX500_MSP_MAX_CHANNELS, - .rates = UX500_I2S_RATES, - .formats = UX500_I2S_FORMATS, - }, - .ops = ux500_msp_dai_ops, - }, - { - .name = "ux500-msp-i2s.2", - .id = 2, - .probe = ux500_msp_dai_probe, - .suspend = NULL, - .resume = NULL, - .playback = { - .channels_min = UX500_MSP_MIN_CHANNELS, - .channels_max = UX500_MSP_MAX_CHANNELS, - .rates = UX500_I2S_RATES, - .formats = UX500_I2S_FORMATS, - }, - .capture = { - .channels_min = UX500_MSP_MIN_CHANNELS, - .channels_max = UX500_MSP_MAX_CHANNELS, - .rates = UX500_I2S_RATES, - .formats = UX500_I2S_FORMATS, - }, - .ops = ux500_msp_dai_ops, - }, - { - .name = "ux500-msp-i2s.3", - .probe = ux500_msp_dai_probe, - .id = 3, - .suspend = NULL, - .resume = NULL, - .playback = { - .channels_min = UX500_MSP_MIN_CHANNELS, - .channels_max = UX500_MSP_MAX_CHANNELS, - .rates = UX500_I2S_RATES, - .formats = UX500_I2S_FORMATS, - }, - .capture = { - .channels_min = UX500_MSP_MIN_CHANNELS, - .channels_max = UX500_MSP_MAX_CHANNELS, - .rates = UX500_I2S_RATES, - .formats = UX500_I2S_FORMATS, - }, - .ops = ux500_msp_dai_ops, - }, +void ux500_msp_populate_dai_drv(struct snd_soc_dai_driver *ux500_msp_dai_drv) +{ + ux500_msp_dai_drv->probe = ux500_msp_dai_probe; + ux500_msp_dai_drv->suspend = NULL; + ux500_msp_dai_drv->resume = NULL; + ux500_msp_dai_drv->playback.channels_min = UX500_MSP_MIN_CHANNELS; + ux500_msp_dai_drv->playback.channels_max = UX500_MSP_MAX_CHANNELS; + ux500_msp_dai_drv->playback.rates = UX500_I2S_RATES; + ux500_msp_dai_drv->playback.formats = UX500_I2S_FORMATS; + ux500_msp_dai_drv->capture.channels_min = UX500_MSP_MIN_CHANNELS; + ux500_msp_dai_drv->capture.channels_max = UX500_MSP_MAX_CHANNELS; + ux500_msp_dai_drv->capture.rates = UX500_I2S_RATES; + ux500_msp_dai_drv->capture.formats = UX500_I2S_FORMATS; + ux500_msp_dai_drv->ops = ux500_msp_dai_ops; }; static const struct snd_soc_component_driver ux500_msp_component = { @@ -809,6 +742,7 @@ static const struct snd_soc_component_driver ux500_msp_component = { static int ux500_msp_drv_probe(struct platform_device *pdev) { struct ux500_msp_i2s_drvdata *drvdata; + struct snd_soc_dai_driver *ux500_msp_dai_drv; int ret = 0; dev_dbg(&pdev->dev, "%s: Enter (pdev->name = %s).\n", __func__, @@ -863,8 +797,18 @@ static int ux500_msp_drv_probe(struct platform_device *pdev) } dev_set_drvdata(&pdev->dev, drvdata); + ux500_msp_dai_drv = devm_kzalloc(&pdev->dev, + sizeof(*ux500_msp_dai_drv), + GFP_KERNEL); + if (!ux500_msp_dai_drv) { + ret = -ENOMEM; + goto err_init_msp; + } + + ux500_msp_populate_dai_drv(ux500_msp_dai_drv); + ret = snd_soc_register_component(&pdev->dev, &ux500_msp_component, - &ux500_msp_dai_drv[drvdata->msp->id], 1); + ux500_msp_dai_drv, 1); if (ret < 0) { dev_err(&pdev->dev, "Error: %s: Failed to register MSP%d!\n", __func__, drvdata->msp->id);