aboutsummaryrefslogtreecommitdiffstats
path: root/sound/firewire
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2013-06-09 12:15:00 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2013-06-09 12:15:00 -0400
commit94a87157cde95d38b9cdf1116e4f0fd93f6d25df (patch)
tree42cb11cbab50860a66d3e4191c43a85cf42bd77f /sound/firewire
parent317ddd256b9c24b0d78fa8018f80f1e495481a10 (diff)
firewire: introduce fw_driver.probe and .remove methods
FireWire upper layer drivers are converted from generic struct driver.probe() and .remove() to bus-specific struct fw_driver.probe() and .remove(). The new .probe() adds a const struct ieee1394_device_id *id argument, indicating the entry in the driver's device identifiers table which matched the fw_unit to be probed. This new argument is used by the snd-firewire-speakers driver to look up device-specific parameters and methods. There is at least one other FireWire audio driver currently in development in which this will be useful too. The new .remove() drops the unused error return code. Although all in-tree drivers are being converted to the new methods, support for the old methods is left in place in this commit. This allows public developer trees to merge this commit and then move to the new fw_driver methods. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Acked-by: Clemens Ladisch <clemens@ladisch.de> (for sound/firewire/) Cc: Peter Hurley <peter@hurleysoftware.com> (for drivers/staging/fwserial/)
Diffstat (limited to 'sound/firewire')
-rw-r--r--sound/firewire/isight.c44
-rw-r--r--sound/firewire/scs1x.c39
-rw-r--r--sound/firewire/speakers.c106
3 files changed, 82 insertions, 107 deletions
diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
index d428ffede4f3..58a5afefdc69 100644
--- a/sound/firewire/isight.c
+++ b/sound/firewire/isight.c
@@ -626,9 +626,9 @@ static u64 get_unit_base(struct fw_unit *unit)
626 return 0; 626 return 0;
627} 627}
628 628
629static int isight_probe(struct device *unit_dev) 629static int isight_probe(struct fw_unit *unit,
630 const struct ieee1394_device_id *id)
630{ 631{
631 struct fw_unit *unit = fw_unit(unit_dev);
632 struct fw_device *fw_dev = fw_parent_device(unit); 632 struct fw_device *fw_dev = fw_parent_device(unit);
633 struct snd_card *card; 633 struct snd_card *card;
634 struct isight *isight; 634 struct isight *isight;
@@ -637,7 +637,7 @@ static int isight_probe(struct device *unit_dev)
637 err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*isight), &card); 637 err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*isight), &card);
638 if (err < 0) 638 if (err < 0)
639 return err; 639 return err;
640 snd_card_set_dev(card, unit_dev); 640 snd_card_set_dev(card, &unit->device);
641 641
642 isight = card->private_data; 642 isight = card->private_data;
643 isight->card = card; 643 isight->card = card;
@@ -674,7 +674,7 @@ static int isight_probe(struct device *unit_dev)
674 if (err < 0) 674 if (err < 0)
675 goto error; 675 goto error;
676 676
677 dev_set_drvdata(unit_dev, isight); 677 dev_set_drvdata(&unit->device, isight);
678 678
679 return 0; 679 return 0;
680 680
@@ -686,23 +686,6 @@ error:
686 return err; 686 return err;
687} 687}
688 688
689static int isight_remove(struct device *dev)
690{
691 struct isight *isight = dev_get_drvdata(dev);
692
693 isight_pcm_abort(isight);
694
695 snd_card_disconnect(isight->card);
696
697 mutex_lock(&isight->mutex);
698 isight_stop_streaming(isight);
699 mutex_unlock(&isight->mutex);
700
701 snd_card_free_when_closed(isight->card);
702
703 return 0;
704}
705
706static void isight_bus_reset(struct fw_unit *unit) 689static void isight_bus_reset(struct fw_unit *unit)
707{ 690{
708 struct isight *isight = dev_get_drvdata(&unit->device); 691 struct isight *isight = dev_get_drvdata(&unit->device);
@@ -716,6 +699,21 @@ static void isight_bus_reset(struct fw_unit *unit)
716 } 699 }
717} 700}
718 701
702static void isight_remove(struct fw_unit *unit)
703{
704 struct isight *isight = dev_get_drvdata(&unit->device);
705
706 isight_pcm_abort(isight);
707
708 snd_card_disconnect(isight->card);
709
710 mutex_lock(&isight->mutex);
711 isight_stop_streaming(isight);
712 mutex_unlock(&isight->mutex);
713
714 snd_card_free_when_closed(isight->card);
715}
716
719static const struct ieee1394_device_id isight_id_table[] = { 717static const struct ieee1394_device_id isight_id_table[] = {
720 { 718 {
721 .match_flags = IEEE1394_MATCH_SPECIFIER_ID | 719 .match_flags = IEEE1394_MATCH_SPECIFIER_ID |
@@ -732,10 +730,10 @@ static struct fw_driver isight_driver = {
732 .owner = THIS_MODULE, 730 .owner = THIS_MODULE,
733 .name = KBUILD_MODNAME, 731 .name = KBUILD_MODNAME,
734 .bus = &fw_bus_type, 732 .bus = &fw_bus_type,
735 .probe = isight_probe,
736 .remove = isight_remove,
737 }, 733 },
734 .probe = isight_probe,
738 .update = isight_bus_reset, 735 .update = isight_bus_reset,
736 .remove = isight_remove,
739 .id_table = isight_id_table, 737 .id_table = isight_id_table,
740}; 738};
741 739
diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
index 844a555c3b1e..1f5920d6eacc 100644
--- a/sound/firewire/scs1x.c
+++ b/sound/firewire/scs1x.c
@@ -384,9 +384,8 @@ static void scs_card_free(struct snd_card *card)
384 kfree(scs->buffer); 384 kfree(scs->buffer);
385} 385}
386 386
387static int scs_probe(struct device *unit_dev) 387static int scs_probe(struct fw_unit *unit, const struct ieee1394_device_id *id)
388{ 388{
389 struct fw_unit *unit = fw_unit(unit_dev);
390 struct fw_device *fw_dev = fw_parent_device(unit); 389 struct fw_device *fw_dev = fw_parent_device(unit);
391 struct snd_card *card; 390 struct snd_card *card;
392 struct scs *scs; 391 struct scs *scs;
@@ -395,7 +394,7 @@ static int scs_probe(struct device *unit_dev)
395 err = snd_card_create(-16, NULL, THIS_MODULE, sizeof(*scs), &card); 394 err = snd_card_create(-16, NULL, THIS_MODULE, sizeof(*scs), &card);
396 if (err < 0) 395 if (err < 0)
397 return err; 396 return err;
398 snd_card_set_dev(card, unit_dev); 397 snd_card_set_dev(card, &unit->device);
399 398
400 scs = card->private_data; 399 scs = card->private_data;
401 scs->card = card; 400 scs->card = card;
@@ -440,7 +439,7 @@ static int scs_probe(struct device *unit_dev)
440 if (err < 0) 439 if (err < 0)
441 goto err_card; 440 goto err_card;
442 441
443 dev_set_drvdata(unit_dev, scs); 442 dev_set_drvdata(&unit->device, scs);
444 443
445 return 0; 444 return 0;
446 445
@@ -451,9 +450,20 @@ err_card:
451 return err; 450 return err;
452} 451}
453 452
454static int scs_remove(struct device *dev) 453static void scs_update(struct fw_unit *unit)
455{ 454{
456 struct scs *scs = dev_get_drvdata(dev); 455 struct scs *scs = dev_get_drvdata(&unit->device);
456 __be64 data;
457
458 data = cpu_to_be64(((u64)HSS1394_TAG_CHANGE_ADDRESS << 56) |
459 scs->hss_handler.offset);
460 snd_fw_transaction(scs->unit, TCODE_WRITE_BLOCK_REQUEST,
461 HSS1394_ADDRESS, &data, 8);
462}
463
464static void scs_remove(struct fw_unit *unit)
465{
466 struct scs *scs = dev_get_drvdata(&unit->device);
457 467
458 snd_card_disconnect(scs->card); 468 snd_card_disconnect(scs->card);
459 469
@@ -465,19 +475,6 @@ static int scs_remove(struct device *dev)
465 tasklet_kill(&scs->tasklet); 475 tasklet_kill(&scs->tasklet);
466 476
467 snd_card_free_when_closed(scs->card); 477 snd_card_free_when_closed(scs->card);
468
469 return 0;
470}
471
472static void scs_update(struct fw_unit *unit)
473{
474 struct scs *scs = dev_get_drvdata(&unit->device);
475 __be64 data;
476
477 data = cpu_to_be64(((u64)HSS1394_TAG_CHANGE_ADDRESS << 56) |
478 scs->hss_handler.offset);
479 snd_fw_transaction(scs->unit, TCODE_WRITE_BLOCK_REQUEST,
480 HSS1394_ADDRESS, &data, 8);
481} 478}
482 479
483static const struct ieee1394_device_id scs_id_table[] = { 480static const struct ieee1394_device_id scs_id_table[] = {
@@ -506,10 +503,10 @@ static struct fw_driver scs_driver = {
506 .owner = THIS_MODULE, 503 .owner = THIS_MODULE,
507 .name = KBUILD_MODNAME, 504 .name = KBUILD_MODNAME,
508 .bus = &fw_bus_type, 505 .bus = &fw_bus_type,
509 .probe = scs_probe,
510 .remove = scs_remove,
511 }, 506 },
507 .probe = scs_probe,
512 .update = scs_update, 508 .update = scs_update,
509 .remove = scs_remove,
513 .id_table = scs_id_table, 510 .id_table = scs_id_table,
514}; 511};
515 512
diff --git a/sound/firewire/speakers.c b/sound/firewire/speakers.c
index d6846557f270..2c6386503940 100644
--- a/sound/firewire/speakers.c
+++ b/sound/firewire/speakers.c
@@ -663,45 +663,9 @@ static void fwspk_card_free(struct snd_card *card)
663 mutex_destroy(&fwspk->mutex); 663 mutex_destroy(&fwspk->mutex);
664} 664}
665 665
666static const struct device_info *fwspk_detect(struct fw_device *dev) 666static int fwspk_probe(struct fw_unit *unit,
667 const struct ieee1394_device_id *id)
667{ 668{
668 static const struct device_info griffin_firewave = {
669 .driver_name = "FireWave",
670 .short_name = "FireWave",
671 .long_name = "Griffin FireWave Surround",
672 .pcm_constraints = firewave_constraints,
673 .mixer_channels = 6,
674 .mute_fb_id = 0x01,
675 .volume_fb_id = 0x02,
676 };
677 static const struct device_info lacie_speakers = {
678 .driver_name = "FWSpeakers",
679 .short_name = "FireWire Speakers",
680 .long_name = "LaCie FireWire Speakers",
681 .pcm_constraints = lacie_speakers_constraints,
682 .mixer_channels = 1,
683 .mute_fb_id = 0x01,
684 .volume_fb_id = 0x01,
685 };
686 struct fw_csr_iterator i;
687 int key, value;
688
689 fw_csr_iterator_init(&i, dev->config_rom);
690 while (fw_csr_iterator_next(&i, &key, &value))
691 if (key == CSR_VENDOR)
692 switch (value) {
693 case VENDOR_GRIFFIN:
694 return &griffin_firewave;
695 case VENDOR_LACIE:
696 return &lacie_speakers;
697 }
698
699 return NULL;
700}
701
702static int fwspk_probe(struct device *unit_dev)
703{
704 struct fw_unit *unit = fw_unit(unit_dev);
705 struct fw_device *fw_dev = fw_parent_device(unit); 669 struct fw_device *fw_dev = fw_parent_device(unit);
706 struct snd_card *card; 670 struct snd_card *card;
707 struct fwspk *fwspk; 671 struct fwspk *fwspk;
@@ -711,17 +675,13 @@ static int fwspk_probe(struct device *unit_dev)
711 err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*fwspk), &card); 675 err = snd_card_create(-1, NULL, THIS_MODULE, sizeof(*fwspk), &card);
712 if (err < 0) 676 if (err < 0)
713 return err; 677 return err;
714 snd_card_set_dev(card, unit_dev); 678 snd_card_set_dev(card, &unit->device);
715 679
716 fwspk = card->private_data; 680 fwspk = card->private_data;
717 fwspk->card = card; 681 fwspk->card = card;
718 mutex_init(&fwspk->mutex); 682 mutex_init(&fwspk->mutex);
719 fwspk->unit = fw_unit_get(unit); 683 fwspk->unit = fw_unit_get(unit);
720 fwspk->device_info = fwspk_detect(fw_dev); 684 fwspk->device_info = (const struct device_info *)id->driver_data;
721 if (!fwspk->device_info) {
722 err = -ENODEV;
723 goto err_unit;
724 }
725 685
726 err = cmp_connection_init(&fwspk->connection, unit, 0); 686 err = cmp_connection_init(&fwspk->connection, unit, 0);
727 if (err < 0) 687 if (err < 0)
@@ -756,7 +716,7 @@ static int fwspk_probe(struct device *unit_dev)
756 if (err < 0) 716 if (err < 0)
757 goto error; 717 goto error;
758 718
759 dev_set_drvdata(unit_dev, fwspk); 719 dev_set_drvdata(&unit->device, fwspk);
760 720
761 return 0; 721 return 0;
762 722
@@ -770,22 +730,6 @@ error:
770 return err; 730 return err;
771} 731}
772 732
773static int fwspk_remove(struct device *dev)
774{
775 struct fwspk *fwspk = dev_get_drvdata(dev);
776
777 amdtp_out_stream_pcm_abort(&fwspk->stream);
778 snd_card_disconnect(fwspk->card);
779
780 mutex_lock(&fwspk->mutex);
781 fwspk_stop_stream(fwspk);
782 mutex_unlock(&fwspk->mutex);
783
784 snd_card_free_when_closed(fwspk->card);
785
786 return 0;
787}
788
789static void fwspk_bus_reset(struct fw_unit *unit) 733static void fwspk_bus_reset(struct fw_unit *unit)
790{ 734{
791 struct fwspk *fwspk = dev_get_drvdata(&unit->device); 735 struct fwspk *fwspk = dev_get_drvdata(&unit->device);
@@ -803,6 +747,40 @@ static void fwspk_bus_reset(struct fw_unit *unit)
803 amdtp_out_stream_update(&fwspk->stream); 747 amdtp_out_stream_update(&fwspk->stream);
804} 748}
805 749
750static void fwspk_remove(struct fw_unit *unit)
751{
752 struct fwspk *fwspk = dev_get_drvdata(&unit->device);
753
754 amdtp_out_stream_pcm_abort(&fwspk->stream);
755 snd_card_disconnect(fwspk->card);
756
757 mutex_lock(&fwspk->mutex);
758 fwspk_stop_stream(fwspk);
759 mutex_unlock(&fwspk->mutex);
760
761 snd_card_free_when_closed(fwspk->card);
762}
763
764static const struct device_info griffin_firewave = {
765 .driver_name = "FireWave",
766 .short_name = "FireWave",
767 .long_name = "Griffin FireWave Surround",
768 .pcm_constraints = firewave_constraints,
769 .mixer_channels = 6,
770 .mute_fb_id = 0x01,
771 .volume_fb_id = 0x02,
772};
773
774static const struct device_info lacie_speakers = {
775 .driver_name = "FWSpeakers",
776 .short_name = "FireWire Speakers",
777 .long_name = "LaCie FireWire Speakers",
778 .pcm_constraints = lacie_speakers_constraints,
779 .mixer_channels = 1,
780 .mute_fb_id = 0x01,
781 .volume_fb_id = 0x01,
782};
783
806static const struct ieee1394_device_id fwspk_id_table[] = { 784static const struct ieee1394_device_id fwspk_id_table[] = {
807 { 785 {
808 .match_flags = IEEE1394_MATCH_VENDOR_ID | 786 .match_flags = IEEE1394_MATCH_VENDOR_ID |
@@ -813,6 +791,7 @@ static const struct ieee1394_device_id fwspk_id_table[] = {
813 .model_id = 0x00f970, 791 .model_id = 0x00f970,
814 .specifier_id = SPECIFIER_1394TA, 792 .specifier_id = SPECIFIER_1394TA,
815 .version = VERSION_AVC, 793 .version = VERSION_AVC,
794 .driver_data = (kernel_ulong_t)&griffin_firewave,
816 }, 795 },
817 { 796 {
818 .match_flags = IEEE1394_MATCH_VENDOR_ID | 797 .match_flags = IEEE1394_MATCH_VENDOR_ID |
@@ -823,6 +802,7 @@ static const struct ieee1394_device_id fwspk_id_table[] = {
823 .model_id = 0x00f970, 802 .model_id = 0x00f970,
824 .specifier_id = SPECIFIER_1394TA, 803 .specifier_id = SPECIFIER_1394TA,
825 .version = VERSION_AVC, 804 .version = VERSION_AVC,
805 .driver_data = (kernel_ulong_t)&lacie_speakers,
826 }, 806 },
827 { } 807 { }
828}; 808};
@@ -833,10 +813,10 @@ static struct fw_driver fwspk_driver = {
833 .owner = THIS_MODULE, 813 .owner = THIS_MODULE,
834 .name = KBUILD_MODNAME, 814 .name = KBUILD_MODNAME,
835 .bus = &fw_bus_type, 815 .bus = &fw_bus_type,
836 .probe = fwspk_probe,
837 .remove = fwspk_remove,
838 }, 816 },
817 .probe = fwspk_probe,
839 .update = fwspk_bus_reset, 818 .update = fwspk_bus_reset,
819 .remove = fwspk_remove,
840 .id_table = fwspk_id_table, 820 .id_table = fwspk_id_table,
841}; 821};
842 822