alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Michael Trimarchi <michael@amarulasolutions.com>
To: Mark Brown <broonie@kernel.org>
Cc: devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	adamo.a60@gmail.com, lgirdwood@gmail.com,
	Johan Hovold <johan@kernel.org>,
	Jacob Siverskog <jacob@teenage.engineering>
Subject: Re: [PATCH V6] ASoC: pcm179x: Add support for pcm1795 and pcm1796
Date: Sun, 13 Mar 2016 10:10:44 +0100	[thread overview]
Message-ID: <20160313091040.GB8896@panicking> (raw)
In-Reply-To: <20160313085346.GA8896@panicking>

On Sun, Mar 13, 2016 at 09:53:46AM +0100, Michael Trimarchi wrote:
> 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?
> 

I need to test, as you said I don't have feeling. I found only this commit

commit 5e4cb7b60833b0124a9f71dbc5118144ca79c3c4
Author: Axel Lin <axel.lin@ingics.com>
Date:   Thu Jun 25 21:44:13 2015 +0800

    ASoC: cs42xx8: Setup of_match_table
    
    Setup of_match_table and since cs42xx8_of_match is exported and used in
    cs42xx8-i2c.c, it cannot be static.
    
    Signed-off-by: Axel Lin <axel.lin@ingics.com>
    Acked-by: Brian Austin <brian.austin@cirrus.com>
    Signed-off-by: Mark Brown <broonie@kernel.org>

Seems a similar approch

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)
> > > +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
> 
> 
> -- 
> | Michael Nazzareno Trimarchi                     Amarula Solutions BV |
> | COO  -  Founder                                      Cruquiuskade 47 |
> | +31(0)851119172                                 Amsterdam 1018 AM NL |
> |                  [`as] http://www.amarulasolutions.com               |

-- 
| Michael Nazzareno Trimarchi                     Amarula Solutions BV |
| COO  -  Founder                                      Cruquiuskade 47 |
| +31(0)851119172                                 Amsterdam 1018 AM NL |
|                  [`as] http://www.amarulasolutions.com               |

  reply	other threads:[~2016-03-13  9:10 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-09 23:38 [RFC PATCH 0/3] ASoC: pcm1792a: Add support for pcm1795 and pcm1796 Michael Trimarchi
     [not found] ` <1452382685-18009-1-git-send-email-michael-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org>
2016-01-09 23:38   ` [RFC PATCH 1/3] ASoC: pcm1792a: Rename internal data and function to pcm179x Michael Trimarchi
2016-01-10 12:07     ` Applied "ASoC: pcm1792a: Rename internal data and function to pcm179x" to the asoc tree Mark Brown
2016-01-09 23:38   ` [RFC PATCH 2/3] ASoC: pcm1792a: Rename pcm1792a to pcm179x Michael Trimarchi
     [not found]     ` <1452382685-18009-3-git-send-email-michael-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org>
2016-01-11  3:06       ` Rob Herring
2016-01-09 23:38   ` [RFC PATCH 3/3] ASoC: pcm179x: Add support for pcm1795 and pcm1796 Michael Trimarchi
     [not found]     ` <1452382685-18009-4-git-send-email-michael-dyjBcgdgk7Pe9wHmmfpqLFaTQe2KTcn/@public.gmane.org>
2016-01-10 12:00       ` Mark Brown
     [not found]         ` <20160110120045.GW6588-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-01-10 17:38           ` [PATCH V2] " Michael Trimarchi
2016-02-05 17:24             ` [PATCH V3] " Michael Trimarchi
2016-02-20  9:27               ` Michael Trimarchi
     [not found]                 ` <CAOf5uwnpY8J=NC82rtZ_q50mWmHqEf2gteJxZe+cXVs_3FNmrw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-22  8:17                   ` Jacob Siverskog
2016-02-22  3:19               ` Mark Brown
     [not found]                 ` <20160222031944.GT18327-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-03-10  9:59                   ` Michael Trimarchi
2016-03-11 22:59                 ` [PATCH V4] " Michael Trimarchi
2016-03-11 23:09                   ` [PATCH V5] " Michael Trimarchi
2016-03-11 23:29                     ` [PATCH V6] " Michael Trimarchi
2016-03-12  5:53                       ` Mark Brown
     [not found]                         ` <20160312055317.GT3898-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2016-03-13  8:53                           ` Michael Trimarchi
2016-03-13  9:10                             ` Michael Trimarchi [this message]
2016-03-14 16:24                             ` Mark Brown
2016-03-18 20:08                       ` Rob Herring
2016-03-12  2:50                   ` [PATCH V4] " Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160313091040.GB8896@panicking \
    --to=michael@amarulasolutions.com \
    --cc=adamo.a60@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jacob@teenage.engineering \
    --cc=johan@kernel.org \
    --cc=lgirdwood@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).