From patchwork Sun Mar 13 08:53:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Nazzareno Trimarchi X-Patchwork-Id: 8573251 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 32C5CC0553 for ; Sun, 13 Mar 2016 08:54:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F13B120263 for ; Sun, 13 Mar 2016 08:54:11 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 8B9BF20260 for ; Sun, 13 Mar 2016 08:54:10 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 21158261A64; Sun, 13 Mar 2016 09:54:09 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id CF1912605B6; Sun, 13 Mar 2016 09:54:00 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 40D0E2608F0; Sun, 13 Mar 2016 09:53:59 +0100 (CET) Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) by alsa0.perex.cz (Postfix) with ESMTP id 3964D2605B2 for ; Sun, 13 Mar 2016 09:53:54 +0100 (CET) Received: by mail-wm0-f44.google.com with SMTP id l68so69650601wml.0 for ; Sun, 13 Mar 2016 00:53:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=dipHQi+SpG0DQxiJQ1nrYJtRb0M59Dpfj4uCvCTICGI=; b=cnxX6apshFZX3YxBXk04rRWr7YznAkR5DQJatQs7SQ+U++ShPhEHs3qIHc9GjpafLW gpY88yWM48M43sqfPWof/f+9pkWJMwzvBQ79pglKpFwfY6xIems0jU8e9JDwNxmckJqx nLUCI0uivRBMOA1X1gvDXqT0m47jso8nHE1sB6aQ3VZjmlM11xKq7XWfySf34rwZGNU4 R/qYDO4hspImgA3/wF0T246DYGh33ddoBg1gXprVVIWG3TDX5aEVdsQvcgMLE88pJurB p9pm++qxMc9aPNpO8748lalhdHgg+u6MmjXExZpkhHsPKOp92oyZk9NgPWx9JHXM8luV oZ4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=dipHQi+SpG0DQxiJQ1nrYJtRb0M59Dpfj4uCvCTICGI=; b=AN7SsF2E3u4ENosezPmJ8nQWKV8uwl2Xei+/ugwWuENpBd672kUbG/HeSQKO131AQ4 tsLot97MLUGks47NBGpG12fJl/wqUNmt/ucjD9LsoIzFPlhn9hVGHHr0YLsWoSetljgx qaKFMc00lYNKXH/eCpJrq8bIkfhvQM7J/oKv311mRASmuOIKVmjbQXbftW0DwWBDK2YQ M96jfBnIAv4QhfSpTVZFOkgSZohRvCaLULOor2UPZt9UmQSoVZXlUqn3/bFV+vYjn/Lt VKmEUDQpxL1F203qFkZoL9PdewmLj//anh/Qor9axz5i+mODZ/DX1GZOPGbmj74H6WYr Jonw== X-Gm-Message-State: AD7BkJLuWL/uBk+mEtcSsLaNNmKoVIoaZ5LK2eSnyIppuxUnJ0tEqUbsQitMrhTji+mH+dbK X-Received: by 10.28.230.157 with SMTP id e29mr12102589wmi.24.1457859233837; Sun, 13 Mar 2016 00:53:53 -0800 (PST) Received: from panicking (93-34-51-230.ip48.fastwebnet.it. [93.34.51.230]) by smtp.gmail.com with ESMTPSA id 192sm10619630wmw.0.2016.03.13.00.53.52 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sun, 13 Mar 2016 00:53:53 -0800 (PST) Date: Sun, 13 Mar 2016 09:53:50 +0100 From: Michael Trimarchi To: Mark Brown Message-ID: <20160313085346.GA8896@panicking> References: <1452382685-18009-1-git-send-email-michael@amarulasolutions.com> <1452382685-18009-4-git-send-email-michael@amarulasolutions.com> <20160110120045.GW6588@sirena.org.uk> <20160110173812.GA16304@panicking> <20160205172451.GA30542@panicking> <20160222031944.GT18327@sirena.org.uk> <20160311225937.GA27257@panicking> <20160311230930.GB27257@panicking> <20160311232856.GC27257@panicking> <20160312055317.GT3898@sirena.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160312055317.GT3898@sirena.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org, adamo.a60@gmail.com, lgirdwood@gmail.com, Johan Hovold , Jacob Siverskog Subject: Re: [alsa-devel] [PATCH V6] ASoC: pcm179x: Add support for pcm1795 and pcm1796 X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP On Sat, Mar 12, 2016 at 12:53:17PM +0700, Mark Brown wrote: > On Sat, Mar 12, 2016 at 12:29:00AM +0100, Michael Trimarchi wrote: > > > diff --git a/sound/soc/codecs/pcm179x-i2c.c b/sound/soc/codecs/pcm179x-i2c.c > > index 4118106..609f07f 100644 > > --- a/sound/soc/codecs/pcm179x-i2c.c > > +++ b/sound/soc/codecs/pcm179x-i2c.c > > @@ -44,12 +44,6 @@ static int pcm179x_i2c_remove(struct i2c_client *client) > > return pcm179x_common_exit(&client->dev); > > } > > > > -static const struct of_device_id pcm179x_of_match[] = { > > - { .compatible = "ti,pcm1792a", }, > > - { } > > -}; > > -MODULE_DEVICE_TABLE(of, pcm179x_of_match); > > - > > One effect of moving this out of the I2C driver is to break module > autoloading: currently modutils does not pay attention to the reference > from the driver structure to the ID table but instead just looks at the > MODULE_DEVICE_TABLE. This is a problem with some existing devices but > we shouldn't introduce new instances. > > I don't actually know if MODULE_DEVICE_TABLE can reference an object in > a different file off the top of my head, though a brief test suggests it > has issues. > Does this approch can work? > > +static int pcm179x_startup(struct snd_pcm_substream *substream, > > + struct snd_soc_dai *dai) > > +{ > > + struct snd_soc_codec *codec = dai->codec; > > + struct pcm179x_private *priv = snd_soc_codec_get_drvdata(codec); > > + u64 formats = PCM1792A_FORMATS; > > + > > + switch (priv->codec_model) { > > + case PCM1795: > > + formats = PCM1795_FORMATS; > > + break; > > It would be more data driven to just register a different DAI structure > for the 1795. Both approaches work, it's just a little nicer to avoid > code where possible. Yes I know but my idea was exactly to not create special DAI because technically they are the same code with diffferent constraints. This even give an other example of the usage of the API. Michael diff --git a/sound/soc/codecs/pcm179x-i2c.c b/sound/soc/codecs/pcm179x-i2c.c index 609f07f..6bed54f 100644 --- a/sound/soc/codecs/pcm179x-i2c.c +++ b/sound/soc/codecs/pcm179x-i2c.c @@ -49,6 +49,7 @@ static const struct i2c_device_id pcm179x_i2c_ids[] = { { } }; MODULE_DEVICE_TABLE(i2c, pcm179x_i2c_ids); +MODULE_DEVICE_TABLE(of, pcm179x_of_match); static struct i2c_driver pcm179x_i2c_driver = { .driver = { diff --git a/sound/soc/codecs/pcm179x-spi.c b/sound/soc/codecs/pcm179x-spi.c index 6ae0e4d..556c875 100644 --- a/sound/soc/codecs/pcm179x-spi.c +++ b/sound/soc/codecs/pcm179x-spi.c @@ -48,6 +48,7 @@ static const struct spi_device_id pcm179x_spi_ids[] = { { }, }; MODULE_DEVICE_TABLE(spi, pcm179x_spi_ids); +MODULE_DEVICE_TABLE(of, pcm179x_of_match); static struct spi_driver pcm179x_spi_driver = { .driver = { diff --git a/sound/soc/codecs/pcm179x.c b/sound/soc/codecs/pcm179x.c index fb01822..a34af5b 100644 --- a/sound/soc/codecs/pcm179x.c +++ b/sound/soc/codecs/pcm179x.c @@ -255,7 +255,6 @@ const struct of_device_id pcm179x_of_match[] = { { .compatible = "ti,pcm1796", }, { } }; -MODULE_DEVICE_TABLE(of, pcm179x_of_match); EXPORT_SYMBOL_GPL(pcm179x_of_match); int pcm179x_common_init(struct device *dev, struct regmap *regmap)