From patchwork Tue Nov 19 11:07:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 21623 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f70.google.com (mail-qa0-f70.google.com [209.85.216.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 78F6A23FB4 for ; Tue, 19 Nov 2013 11:08:24 +0000 (UTC) Received: by mail-qa0-f70.google.com with SMTP id j5sf2902669qaq.5 for ; Tue, 19 Nov 2013 03:08:24 -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=EUtEzqMpIFznhsMJVuBy6SV/OltfLNApxSlUFTrVNMg=; b=iiM3ND+rf6aR4I0yc8UkqdZE3qkNcHpti5sW80Rc0HWBcoxpylwl9rvD4QmAmxQhjN LYOkbpYCqX/rZjI/iIUzApev2C84l81UYI1OnftfbM+SGkv1exWD4URdQIkZQeETsxKK 8MgoWI1ZL4srvwN5dqweMY9gYviMFKHtcpuezHfh8sEV+1UizLJjRO/QlpltS7wC73qT YW73Ts8grCuNIAk/05EUo7sJ4hep92NAJkibuNiQps0CcO1Lkz2cTg6HK8Kk0FQWBg3I IJ8A4NxG33H+qjp9HsrQGP20oXabHpYeYp+fVtFAmO2bZRFeZB96g1kItXEUInCSdbV0 Maqg== X-Gm-Message-State: ALoCoQmmVEXcCDCyzXz694awQOcGpPG9/dq2SDtgavHBurTNrj/ChlWuywe/M4D+mibjWOltACUk X-Received: by 10.224.5.5 with SMTP id 5mr13477263qat.4.1384859304357; Tue, 19 Nov 2013 03:08:24 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.99.10 with SMTP id em10ls3070485qeb.82.gmail; Tue, 19 Nov 2013 03:08:24 -0800 (PST) X-Received: by 10.220.199.5 with SMTP id eq5mr20585484vcb.16.1384859304251; Tue, 19 Nov 2013 03:08:24 -0800 (PST) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id a15si8014637vew.45.2013.11.19.03.08.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Nov 2013 03:08:24 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id hz11so4560010vcb.38 for ; Tue, 19 Nov 2013 03:08:24 -0800 (PST) X-Received: by 10.52.177.166 with SMTP id cr6mr949554vdc.26.1384859304156; Tue, 19 Nov 2013 03:08:24 -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 u4csp269515vcz; Tue, 19 Nov 2013 03:08:23 -0800 (PST) X-Received: by 10.60.144.230 with SMTP id sp6mr24688560oeb.29.1384859303537; Tue, 19 Nov 2013 03:08:23 -0800 (PST) Received: from mail-ob0-f177.google.com (mail-ob0-f177.google.com [209.85.214.177]) by mx.google.com with ESMTPS id sy1si15118873obc.90.2013.11.19.03.08.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Nov 2013 03:08:23 -0800 (PST) Received-SPF: neutral (google.com: 209.85.214.177 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.214.177; Received: by mail-ob0-f177.google.com with SMTP id wp4so8347531obc.22 for ; Tue, 19 Nov 2013 03:08:23 -0800 (PST) X-Received: by 10.60.70.134 with SMTP id m6mr24511272oeu.14.1384859303292; Tue, 19 Nov 2013 03:08:23 -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 d8sm34904086oeu.6.2013.11.19.03.08.21 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Nov 2013 03:08:22 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: linus.walleij@linaro.org, Lee Jones Subject: [PATCH 10/10] ASoC: ux500: Dynamically fill DAI driver data on probe Date: Tue, 19 Nov 2013 11:07:49 +0000 Message-Id: <1384859269-19801-11-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1384859269-19801-1-git-send-email-lee.jones@linaro.org> References: <1384859269-19801-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.220.179 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. 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);