public inbox for linux-sh@vger.kernel.org
 help / color / mirror / Atom feed
* i2c old to new style conversion
@ 2008-07-31 14:26 Luca Santini
  2008-07-31 14:27 ` Luca Santini
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luca Santini @ 2008-07-31 14:26 UTC (permalink / raw)
  To: linux-sh

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?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* i2c old to new style conversion
  2008-07-31 14:26 i2c old to new style conversion Luca Santini
@ 2008-07-31 14:27 ` Luca Santini
  2008-07-31 14:43 ` Paul Mundt
  2008-07-31 15:52 ` Luca Santini
  2 siblings, 0 replies; 4+ messages in thread
From: Luca Santini @ 2008-07-31 14:27 UTC (permalink / raw)
  To: linux-sh

[-- 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);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: i2c old to new style conversion
  2008-07-31 14:26 i2c old to new style conversion Luca Santini
  2008-07-31 14:27 ` Luca Santini
@ 2008-07-31 14:43 ` Paul Mundt
  2008-07-31 15:52 ` Luca Santini
  2 siblings, 0 replies; 4+ messages in thread
From: Paul Mundt @ 2008-07-31 14:43 UTC (permalink / raw)
  To: linux-sh

On Thu, Jul 31, 2008 at 04:27:56PM +0200, Luca Santini wrote:
> (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?
> 
> 

You should be sending this inquiry to the i2c list, where someone might
be able to help you with i2c related problems.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: i2c old to new style conversion
  2008-07-31 14:26 i2c old to new style conversion Luca Santini
  2008-07-31 14:27 ` Luca Santini
  2008-07-31 14:43 ` Paul Mundt
@ 2008-07-31 15:52 ` Luca Santini
  2 siblings, 0 replies; 4+ messages in thread
From: Luca Santini @ 2008-07-31 15:52 UTC (permalink / raw)
  To: linux-sh

thanks for redirection Paul.

in the i2c list i found the solution:


in board setup init code you need to register the i2c device:

-----------------
	i2c_register_board_info(0, edosk7760_i2c_devices0,
				ARRAY_SIZE(edosk7760_i2c_devices0));
-----------------


where edosk7760_i2c_devices0 is:

-----------------
static struct i2c_board_info __initdata edosk7760_i2c_devices0[] = {
	{
		I2C_BOARD_INFO("wm8731", 0x1a), //channel 0
		.irq = 62,
	},
};
-----------------



and in the driver you need:

-----------------
static const struct i2c_device_id wm8731_id[] = {
	{ "wm8731", 0 },
	{ }
};
MODULE_DEVICE_TABLE(i2c, wm8731_id);


static struct i2c_driver wm8731_i2c_driver = {
	.driver = {
		.name = "wm8731",
		.owner = THIS_MODULE,
	},

	.probe	= wm8731_i2c_probe,
	.remove	= wm8731_i2c_remove,
	.id_table	= wm8731_id,  // <-- this field is important!
};
-----------------


it's important that i2c_device_id  and I2C_BOARD_INFO name field  (in my 
case "wm8731") are matching.



Paul Mundt wrote:
> On Thu, Jul 31, 2008 at 04:27:56PM +0200, Luca Santini wrote:
>> (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?
>>
>>
> 
> You should be sending this inquiry to the i2c list, where someone might
> be able to help you with i2c related problems.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-07-31 15:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-31 14:26 i2c old to new style conversion Luca Santini
2008-07-31 14:27 ` Luca Santini
2008-07-31 14:43 ` Paul Mundt
2008-07-31 15:52 ` Luca Santini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox