All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Santini <luca.santini@spesonline.com>
To: linux-sh@vger.kernel.org
Subject: i2c old to new style conversion
Date: Thu, 31 Jul 2008 14:27:56 +0000	[thread overview]
Message-ID: <4891CBEC.9090803@spesonline.com> (raw)
In-Reply-To: <4891CB91.6040308@spesonline.com>

[-- Attachment #1: Type: text/plain, Size: 458 bytes --]

(diff attached)


Hi Manuel,
i'm trying the conversion of wm8731 driver and a attach my patch.

The problem is: the method wm8731_i2c_probe() - connected to
i2c_add_driver.probe field - isn't called and alsa says "No Soundcard
found".


in the old style driver the method wm8731_codec_probe()  - connected to
i2c_add_driver.attach_adapter field -  is called during initialization
by i2c_add_driver() .

How to call wm8731_i2c_probe()? Do i miss something?



[-- Attachment #2: wm8731.patch --]
[-- Type: text/x-diff, Size: 2840 bytes --]


605,609c607,617
< static struct i2c_driver wm8731_i2c_driver;
< static struct i2c_client client_template;
< 
< /* If the i2c layer weren't so broken, we could pass this kind of data
<    around */
---
> static void wm8731_deinit(struct snd_soc_device *socdev)
> {
> 	if (socdev) {
> 		wm8731_dapm_event(socdev->codec, SNDRV_CTL_POWER_D3cold);
> 		snd_soc_free_pcms(socdev);
> 		snd_soc_dapm_free(socdev);
> 		kfree(socdev->codec->private_data);
> 		kfree(socdev->codec->reg_cache);
> 		kfree(socdev->codec);
> 	}
> }
611c619
< static int wm8731_codec_probe(struct i2c_adapter *adap, int addr, int kind)
---
> static int wm8731_i2c_probe(struct i2c_client *client, const struct i2c_device_id * id /*SPES*/)
614d621
< 	struct wm8731_setup_data *setup = socdev->codec_data;
616d622
< 	struct i2c_client *i2c;
619,620c625
< 	if (addr != setup->i2c_address)
< 		return -ENODEV;
---
622,637d626
< 	client_template.adapter = adap;
< 	client_template.addr = addr;
< 
< 	i2c = kmemdup(&client_template, sizeof(client_template), GFP_KERNEL);
< 	if (i2c == NULL) {
< 		kfree(codec);
< 		return -ENOMEM;
< 	}
< 	i2c_set_clientdata(i2c, codec);
< 	codec->control_data = i2c;
< 
< 	ret = i2c_attach_client(i2c);
< 	if (ret < 0) {
< 		err("failed to attach codec at addr %x\n", addr);
< 		goto err;
< 	}
638a628,630
> 	i2c_set_clientdata(client,socdev);
> 	codec->control_data = client;	
> 	
640,641c632,633
< 	if (ret < 0) {
< 		err("failed to initialise WM8731\n");
---
> 	if (unlikely(ret < 0)) {
> 		err("failed to initialise WM8731 codec\n");
648d639
< 	kfree(i2c);
652c643
< static int wm8731_i2c_detach(struct i2c_client *client)
---
> static int wm8731_i2c_remove(struct i2c_client *client)
654,659c645
< 	struct snd_soc_codec *codec = i2c_get_clientdata(client);
< 	i2c_detach_client(client);
< 	kfree(codec->reg_cache);
< 	kfree(client);
< 	return 0;
< }
---
> 	struct snd_soc_device *socdev = i2c_get_clientdata(client);
661,663c647,649
< static int wm8731_i2c_attach(struct i2c_adapter *adap)
< {
< 	return i2c_probe(adap, &addr_data, wm8731_codec_probe);
---
> 	wm8731_deinit(socdev);
> 
> 	return 0;
666d651
< /* corgi i2c codec control layer */
672,676d656
< 	.id =             I2C_DRIVERID_WM8731,
< 	.attach_adapter = wm8731_i2c_attach,
< 	.detach_client =  wm8731_i2c_detach,
< 	.command =        NULL,
< };
678,680c658,660
< static struct i2c_client client_template = {
< 	.name =   "WM8731",
< 	.driver = &wm8731_i2c_driver,
---
> 	.probe	= wm8731_i2c_probe,
> 	.remove	= wm8731_i2c_remove,
> 
729,733d716
< 	struct snd_soc_device *socdev = platform_get_drvdata(pdev);
< 	struct snd_soc_codec *codec = socdev->codec;
< 
< 	if (codec->control_data)
< 		wm8731_dapm_event(codec, SNDRV_CTL_POWER_D3cold);
735,736d717
< 	snd_soc_free_pcms(socdev);
< 	snd_soc_dapm_free(socdev);
740,741d720
< 	kfree(codec->private_data);
< 	kfree(codec);

  reply	other threads:[~2008-07-31 14:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-31 14:26 i2c old to new style conversion Luca Santini
2008-07-31 14:27 ` Luca Santini [this message]
2008-07-31 14:43 ` Paul Mundt
2008-07-31 15:52 ` Luca Santini

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=4891CBEC.9090803@spesonline.com \
    --to=luca.santini@spesonline.com \
    --cc=linux-sh@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.