Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6:
ALSA: ASoC: Fix another cs4270 error path
ALSA: make the CS4270 driver a new-style I2C driver

+16 -62
+16 -62
sound/soc/codecs/cs4270.c
··· 490 490 491 491 #endif 492 492 493 - static int cs4270_i2c_probe(struct i2c_adapter *adap, int addr, int kind); 494 - 495 - /* 496 - * Notify the driver that a new I2C bus has been found. 497 - * 498 - * This function is called for each I2C bus in the system. The function 499 - * then asks the I2C subsystem to probe that bus at the addresses on which 500 - * our device (the CS4270) could exist. If a device is found at one of 501 - * those addresses, then our probe function (cs4270_i2c_probe) is called. 502 - */ 503 - static int cs4270_i2c_attach(struct i2c_adapter *adapter) 504 - { 505 - return i2c_probe(adapter, &addr_data, cs4270_i2c_probe); 506 - } 507 - 508 - static int cs4270_i2c_detach(struct i2c_client *client) 509 - { 510 - struct snd_soc_codec *codec = i2c_get_clientdata(client); 511 - 512 - i2c_detach_client(client); 513 - codec->control_data = NULL; 514 - 515 - kfree(codec->reg_cache); 516 - codec->reg_cache = NULL; 517 - 518 - kfree(client); 519 - return 0; 520 - } 493 + static int cs4270_i2c_probe(struct i2c_client *, const struct i2c_device_id *); 521 494 522 495 /* A list of non-DAPM controls that the CS4270 supports */ 523 496 static const struct snd_kcontrol_new cs4270_snd_controls[] = { ··· 498 525 CS4270_VOLA, CS4270_VOLB, 0, 0xFF, 1) 499 526 }; 500 527 528 + static const struct i2c_device_id cs4270_id[] = { 529 + {"cs4270", 0}, 530 + {} 531 + }; 532 + MODULE_DEVICE_TABLE(i2c, cs4270_id); 533 + 501 534 static struct i2c_driver cs4270_i2c_driver = { 502 535 .driver = { 503 536 .name = "CS4270 I2C", 504 537 .owner = THIS_MODULE, 505 538 }, 506 - .id = I2C_DRIVERID_CS4270, 507 - .attach_adapter = cs4270_i2c_attach, 508 - .detach_client = cs4270_i2c_detach, 539 + .id_table = cs4270_id, 540 + .probe = cs4270_i2c_probe, 509 541 }; 510 542 511 543 /* ··· 539 561 * Note: snd_soc_new_pcms() must be called before this function can be called, 540 562 * because of snd_ctl_add(). 541 563 */ 542 - static int cs4270_i2c_probe(struct i2c_adapter *adapter, int addr, int kind) 564 + static int cs4270_i2c_probe(struct i2c_client *i2c_client, 565 + const struct i2c_device_id *id) 543 566 { 544 567 struct snd_soc_device *socdev = cs4270_socdev; 545 568 struct snd_soc_codec *codec = socdev->codec; 546 - struct i2c_client *i2c_client = NULL; 547 569 int i; 548 570 int ret = 0; 549 571 ··· 556 578 557 579 /* Note: codec_dai->codec is NULL here */ 558 580 559 - i2c_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); 560 - if (!i2c_client) { 561 - printk(KERN_ERR "cs4270: could not allocate I2C client\n"); 562 - return -ENOMEM; 563 - } 564 - 565 581 codec->reg_cache = kzalloc(CS4270_NUMREGS, GFP_KERNEL); 566 582 if (!codec->reg_cache) { 567 583 printk(KERN_ERR "cs4270: could not allocate register cache\n"); 568 584 ret = -ENOMEM; 569 585 goto error; 570 586 } 571 - 572 - i2c_set_clientdata(i2c_client, codec); 573 - strcpy(i2c_client->name, "CS4270"); 574 - 575 - i2c_client->driver = &cs4270_i2c_driver; 576 - i2c_client->adapter = adapter; 577 - i2c_client->addr = addr; 578 587 579 588 /* Verify that we have a CS4270 */ 580 589 ··· 577 612 goto error; 578 613 } 579 614 580 - printk(KERN_INFO "cs4270: found device at I2C address %X\n", addr); 615 + printk(KERN_INFO "cs4270: found device at I2C address %X\n", 616 + i2c_client->addr); 581 617 printk(KERN_INFO "cs4270: hardware revision %X\n", ret & 0xF); 582 - 583 - /* Tell the I2C layer a new client has arrived */ 584 - 585 - ret = i2c_attach_client(i2c_client); 586 - if (ret) { 587 - printk(KERN_ERR "cs4270: could not attach codec, " 588 - "I2C address %x, error code %i\n", addr, ret); 589 - goto error; 590 - } 591 618 592 619 codec->control_data = i2c_client; 593 620 codec->read = cs4270_read_reg_cache; ··· 605 648 goto error; 606 649 } 607 650 651 + i2c_set_clientdata(i2c_client, codec); 652 + 608 653 return 0; 609 654 610 655 error: 611 - if (codec->control_data) { 612 - i2c_detach_client(i2c_client); 613 - codec->control_data = NULL; 614 - } 656 + codec->control_data = NULL; 615 657 616 658 kfree(codec->reg_cache); 617 659 codec->reg_cache = NULL; 618 660 codec->reg_cache_size = 0; 619 - 620 - kfree(i2c_client); 621 661 622 662 return ret; 623 663 }