diff options
author | Takashi Iwai <tiwai@suse.de> | 2015-02-17 07:56:29 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-02-17 08:23:57 -0500 |
commit | ef7449780ebb596b47d5019eb7ba7878c30a3404 (patch) | |
tree | 1eb413a617ebca8e9e81cc2080208cdba3e5a32b /sound/pci | |
parent | 9fd37810daa56b8c0a8d51565216c95220889e62 (diff) |
ALSA: hda - Drop hda_bus_template for snd_hda_bus_new()
Instead of copying from the given template, let the caller fills the
fields after creation. This simplifies the code after all.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 15 | ||||
-rw-r--r-- | sound/pci/hda/hda_codec.h | 13 | ||||
-rw-r--r-- | sound/pci/hda/hda_controller.c | 54 |
3 files changed, 32 insertions, 50 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 2fe86d2e1b09..215bf048c668 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -861,14 +861,12 @@ static int snd_hda_bus_dev_disconnect(struct snd_device *device) | |||
861 | /** | 861 | /** |
862 | * snd_hda_bus_new - create a HDA bus | 862 | * snd_hda_bus_new - create a HDA bus |
863 | * @card: the card entry | 863 | * @card: the card entry |
864 | * @temp: the template for hda_bus information | ||
865 | * @busp: the pointer to store the created bus instance | 864 | * @busp: the pointer to store the created bus instance |
866 | * | 865 | * |
867 | * Returns 0 if successful, or a negative error code. | 866 | * Returns 0 if successful, or a negative error code. |
868 | */ | 867 | */ |
869 | int snd_hda_bus_new(struct snd_card *card, | 868 | int snd_hda_bus_new(struct snd_card *card, |
870 | const struct hda_bus_template *temp, | 869 | struct hda_bus **busp) |
871 | struct hda_bus **busp) | ||
872 | { | 870 | { |
873 | struct hda_bus *bus; | 871 | struct hda_bus *bus; |
874 | int err; | 872 | int err; |
@@ -877,11 +875,6 @@ int snd_hda_bus_new(struct snd_card *card, | |||
877 | .dev_free = snd_hda_bus_dev_free, | 875 | .dev_free = snd_hda_bus_dev_free, |
878 | }; | 876 | }; |
879 | 877 | ||
880 | if (snd_BUG_ON(!temp)) | ||
881 | return -EINVAL; | ||
882 | if (snd_BUG_ON(!temp->ops.command || !temp->ops.get_response)) | ||
883 | return -EINVAL; | ||
884 | |||
885 | if (busp) | 878 | if (busp) |
886 | *busp = NULL; | 879 | *busp = NULL; |
887 | 880 | ||
@@ -892,12 +885,6 @@ int snd_hda_bus_new(struct snd_card *card, | |||
892 | } | 885 | } |
893 | 886 | ||
894 | bus->card = card; | 887 | bus->card = card; |
895 | bus->private_data = temp->private_data; | ||
896 | bus->pci = temp->pci; | ||
897 | bus->modelname = temp->modelname; | ||
898 | bus->power_save = temp->power_save; | ||
899 | bus->ops = temp->ops; | ||
900 | |||
901 | mutex_init(&bus->cmd_mutex); | 888 | mutex_init(&bus->cmd_mutex); |
902 | mutex_init(&bus->prepare_mutex); | 889 | mutex_init(&bus->prepare_mutex); |
903 | INIT_LIST_HEAD(&bus->codec_list); | 890 | INIT_LIST_HEAD(&bus->codec_list); |
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index 9c8820f21f94..5a6594884069 100644 --- a/sound/pci/hda/hda_codec.h +++ b/sound/pci/hda/hda_codec.h | |||
@@ -101,15 +101,6 @@ struct hda_bus_ops { | |||
101 | #endif | 101 | #endif |
102 | }; | 102 | }; |
103 | 103 | ||
104 | /* template to pass to the bus constructor */ | ||
105 | struct hda_bus_template { | ||
106 | void *private_data; | ||
107 | struct pci_dev *pci; | ||
108 | const char *modelname; | ||
109 | int *power_save; | ||
110 | struct hda_bus_ops ops; | ||
111 | }; | ||
112 | |||
113 | /* | 104 | /* |
114 | * codec bus | 105 | * codec bus |
115 | * | 106 | * |
@@ -119,7 +110,6 @@ struct hda_bus_template { | |||
119 | struct hda_bus { | 110 | struct hda_bus { |
120 | struct snd_card *card; | 111 | struct snd_card *card; |
121 | 112 | ||
122 | /* copied from template */ | ||
123 | void *private_data; | 113 | void *private_data; |
124 | struct pci_dev *pci; | 114 | struct pci_dev *pci; |
125 | const char *modelname; | 115 | const char *modelname; |
@@ -420,8 +410,7 @@ enum { | |||
420 | /* | 410 | /* |
421 | * constructors | 411 | * constructors |
422 | */ | 412 | */ |
423 | int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp, | 413 | int snd_hda_bus_new(struct snd_card *card, struct hda_bus **busp); |
424 | struct hda_bus **busp); | ||
425 | int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, | 414 | int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, |
426 | struct hda_codec **codecp); | 415 | struct hda_codec **codecp); |
427 | int snd_hda_codec_configure(struct hda_codec *codec); | 416 | int snd_hda_codec_configure(struct hda_codec *codec); |
diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c index dfcb5e929f9f..31ff8b55f386 100644 --- a/sound/pci/hda/hda_controller.c +++ b/sound/pci/hda/hda_controller.c | |||
@@ -1815,39 +1815,45 @@ static int get_jackpoll_interval(struct azx *chip) | |||
1815 | return j; | 1815 | return j; |
1816 | } | 1816 | } |
1817 | 1817 | ||
1818 | static struct hda_bus_ops bus_ops = { | ||
1819 | .command = azx_send_cmd, | ||
1820 | .get_response = azx_get_response, | ||
1821 | .attach_pcm = azx_attach_pcm_stream, | ||
1822 | .bus_reset = azx_bus_reset, | ||
1823 | #ifdef CONFIG_PM | ||
1824 | .pm_notify = azx_power_notify, | ||
1825 | #endif | ||
1826 | #ifdef CONFIG_SND_HDA_DSP_LOADER | ||
1827 | .load_dsp_prepare = azx_load_dsp_prepare, | ||
1828 | .load_dsp_trigger = azx_load_dsp_trigger, | ||
1829 | .load_dsp_cleanup = azx_load_dsp_cleanup, | ||
1830 | #endif | ||
1831 | }; | ||
1832 | |||
1818 | /* Codec initialization */ | 1833 | /* Codec initialization */ |
1819 | int azx_codec_create(struct azx *chip, const char *model, | 1834 | int azx_codec_create(struct azx *chip, const char *model, |
1820 | unsigned int max_slots, | 1835 | unsigned int max_slots, |
1821 | int *power_save_to) | 1836 | int *power_save_to) |
1822 | { | 1837 | { |
1823 | struct hda_bus_template bus_temp; | 1838 | struct hda_bus *bus; |
1824 | int c, codecs, err; | 1839 | int c, codecs, err; |
1825 | 1840 | ||
1826 | memset(&bus_temp, 0, sizeof(bus_temp)); | 1841 | err = snd_hda_bus_new(chip->card, &bus); |
1827 | bus_temp.private_data = chip; | ||
1828 | bus_temp.modelname = model; | ||
1829 | bus_temp.pci = chip->pci; | ||
1830 | bus_temp.ops.command = azx_send_cmd; | ||
1831 | bus_temp.ops.get_response = azx_get_response; | ||
1832 | bus_temp.ops.attach_pcm = azx_attach_pcm_stream; | ||
1833 | bus_temp.ops.bus_reset = azx_bus_reset; | ||
1834 | #ifdef CONFIG_PM | ||
1835 | bus_temp.power_save = power_save_to; | ||
1836 | bus_temp.ops.pm_notify = azx_power_notify; | ||
1837 | #endif | ||
1838 | #ifdef CONFIG_SND_HDA_DSP_LOADER | ||
1839 | bus_temp.ops.load_dsp_prepare = azx_load_dsp_prepare; | ||
1840 | bus_temp.ops.load_dsp_trigger = azx_load_dsp_trigger; | ||
1841 | bus_temp.ops.load_dsp_cleanup = azx_load_dsp_cleanup; | ||
1842 | #endif | ||
1843 | |||
1844 | err = snd_hda_bus_new(chip->card, &bus_temp, &chip->bus); | ||
1845 | if (err < 0) | 1842 | if (err < 0) |
1846 | return err; | 1843 | return err; |
1847 | 1844 | ||
1845 | chip->bus = bus; | ||
1846 | bus->private_data = chip; | ||
1847 | bus->pci = chip->pci; | ||
1848 | bus->modelname = model; | ||
1849 | bus->ops = bus_ops; | ||
1850 | #ifdef CONFIG_PM | ||
1851 | bus->power_save = power_save_to; | ||
1852 | #endif | ||
1853 | |||
1848 | if (chip->driver_caps & AZX_DCAPS_RIRB_DELAY) { | 1854 | if (chip->driver_caps & AZX_DCAPS_RIRB_DELAY) { |
1849 | dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n"); | 1855 | dev_dbg(chip->card->dev, "Enable delay in RIRB handling\n"); |
1850 | chip->bus->needs_damn_long_delay = 1; | 1856 | bus->needs_damn_long_delay = 1; |
1851 | } | 1857 | } |
1852 | 1858 | ||
1853 | codecs = 0; | 1859 | codecs = 0; |
@@ -1883,15 +1889,15 @@ int azx_codec_create(struct azx *chip, const char *model, | |||
1883 | */ | 1889 | */ |
1884 | if (chip->driver_caps & AZX_DCAPS_SYNC_WRITE) { | 1890 | if (chip->driver_caps & AZX_DCAPS_SYNC_WRITE) { |
1885 | dev_dbg(chip->card->dev, "Enable sync_write for stable communication\n"); | 1891 | dev_dbg(chip->card->dev, "Enable sync_write for stable communication\n"); |
1886 | chip->bus->sync_write = 1; | 1892 | bus->sync_write = 1; |
1887 | chip->bus->allow_bus_reset = 1; | 1893 | bus->allow_bus_reset = 1; |
1888 | } | 1894 | } |
1889 | 1895 | ||
1890 | /* Then create codec instances */ | 1896 | /* Then create codec instances */ |
1891 | for (c = 0; c < max_slots; c++) { | 1897 | for (c = 0; c < max_slots; c++) { |
1892 | if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) { | 1898 | if ((chip->codec_mask & (1 << c)) & chip->codec_probe_mask) { |
1893 | struct hda_codec *codec; | 1899 | struct hda_codec *codec; |
1894 | err = snd_hda_codec_new(chip->bus, c, &codec); | 1900 | err = snd_hda_codec_new(bus, c, &codec); |
1895 | if (err < 0) | 1901 | if (err < 0) |
1896 | continue; | 1902 | continue; |
1897 | codec->jackpoll_interval = get_jackpoll_interval(chip); | 1903 | codec->jackpoll_interval = get_jackpoll_interval(chip); |