ALSA: ctxfi - Clean up / optimize
[linux-2.6.git] / sound / pci / ctxfi / ctatc.c
index 10b741977dd7b1610d130ea2e5d107ac4515fd67..9b1324544db049d48fc7b79a75359f8cb6e80030 100644 (file)
@@ -1202,7 +1202,7 @@ static int atc_dev_free(struct snd_device *dev)
        return ct_atc_destroy(atc);
 }
 
-static int atc_identify_card(struct ct_atc *atc)
+static int __devinit atc_identify_card(struct ct_atc *atc)
 {
        u16 subsys;
        u8 revision;
@@ -1243,7 +1243,7 @@ static int atc_identify_card(struct ct_atc *atc)
        return 0;
 }
 
-static int ct_create_alsa_devs(struct ct_atc *atc)
+int __devinit ct_atc_create_alsa_devs(struct ct_atc *atc)
 {
        enum CTALSADEVS i;
        struct hw *hw = atc->hw;
@@ -1277,7 +1277,7 @@ static int ct_create_alsa_devs(struct ct_atc *atc)
        return 0;
 }
 
-static int atc_create_hw_devs(struct ct_atc *atc)
+static int __devinit atc_create_hw_devs(struct ct_atc *atc)
 {
        struct hw *hw = NULL;
        struct card_conf info = {0};
@@ -1313,7 +1313,7 @@ static int atc_create_hw_devs(struct ct_atc *atc)
        return 0;
 }
 
-static int atc_get_resources(struct ct_atc *atc)
+static int __devinit atc_get_resources(struct ct_atc *atc)
 {
        struct daio_desc da_desc = {0};
        struct daio_mgr *daio_mgr = NULL;
@@ -1423,7 +1423,7 @@ static int atc_get_resources(struct ct_atc *atc)
        return 0;
 }
 
-static void
+static void __devinit
 atc_connect_dai(struct src_mgr *src_mgr, struct dai *dai,
                struct src **srcs, struct srcimp **srcimps)
 {
@@ -1462,7 +1462,7 @@ atc_connect_dai(struct src_mgr *src_mgr, struct dai *dai,
        src_mgr->commit_write(src_mgr); /* Synchronously enable SRCs */
 }
 
-static void atc_connect_resources(struct ct_atc *atc)
+static void __devinit atc_connect_resources(struct ct_atc *atc)
 {
        struct dai *dai = NULL;
        struct dao *dao = NULL;
@@ -1508,37 +1508,35 @@ static void atc_connect_resources(struct ct_atc *atc)
        }
 }
 
-static void atc_set_ops(struct ct_atc *atc)
-{
-       /* Set operations */
-       atc->map_audio_buffer = ct_map_audio_buffer;
-       atc->unmap_audio_buffer = ct_unmap_audio_buffer;
-       atc->pcm_playback_prepare = atc_pcm_playback_prepare;
-       atc->pcm_release_resources = atc_pcm_release_resources;
-       atc->pcm_playback_start = atc_pcm_playback_start;
-       atc->pcm_playback_stop = atc_pcm_stop;
-       atc->pcm_playback_position = atc_pcm_playback_position;
-       atc->pcm_capture_prepare = atc_pcm_capture_prepare;
-       atc->pcm_capture_start = atc_pcm_capture_start;
-       atc->pcm_capture_stop = atc_pcm_stop;
-       atc->pcm_capture_position = atc_pcm_capture_position;
-       atc->spdif_passthru_playback_prepare = spdif_passthru_playback_prepare;
-       atc->get_ptp_phys = atc_get_ptp_phys;
-       atc->select_line_in = atc_select_line_in;
-       atc->select_mic_in = atc_select_mic_in;
-       atc->select_digit_io = atc_select_digit_io;
-       atc->line_front_unmute = atc_line_front_unmute;
-       atc->line_surround_unmute = atc_line_surround_unmute;
-       atc->line_clfe_unmute = atc_line_clfe_unmute;
-       atc->line_rear_unmute = atc_line_rear_unmute;
-       atc->line_in_unmute = atc_line_in_unmute;
-       atc->spdif_out_unmute = atc_spdif_out_unmute;
-       atc->spdif_in_unmute = atc_spdif_in_unmute;
-       atc->spdif_out_get_status = atc_spdif_out_get_status;
-       atc->spdif_out_set_status = atc_spdif_out_set_status;
-       atc->spdif_out_passthru = atc_spdif_out_passthru;
-       atc->have_digit_io_switch = atc_have_digit_io_switch;
-}
+static struct ct_atc atc_preset __devinitdata = {
+       .map_audio_buffer = ct_map_audio_buffer,
+       .unmap_audio_buffer = ct_unmap_audio_buffer,
+       .pcm_playback_prepare = atc_pcm_playback_prepare,
+       .pcm_release_resources = atc_pcm_release_resources,
+       .pcm_playback_start = atc_pcm_playback_start,
+       .pcm_playback_stop = atc_pcm_stop,
+       .pcm_playback_position = atc_pcm_playback_position,
+       .pcm_capture_prepare = atc_pcm_capture_prepare,
+       .pcm_capture_start = atc_pcm_capture_start,
+       .pcm_capture_stop = atc_pcm_stop,
+       .pcm_capture_position = atc_pcm_capture_position,
+       .spdif_passthru_playback_prepare = spdif_passthru_playback_prepare,
+       .get_ptp_phys = atc_get_ptp_phys,
+       .select_line_in = atc_select_line_in,
+       .select_mic_in = atc_select_mic_in,
+       .select_digit_io = atc_select_digit_io,
+       .line_front_unmute = atc_line_front_unmute,
+       .line_surround_unmute = atc_line_surround_unmute,
+       .line_clfe_unmute = atc_line_clfe_unmute,
+       .line_rear_unmute = atc_line_rear_unmute,
+       .line_in_unmute = atc_line_in_unmute,
+       .spdif_out_unmute = atc_spdif_out_unmute,
+       .spdif_in_unmute = atc_spdif_in_unmute,
+       .spdif_out_get_status = atc_spdif_out_get_status,
+       .spdif_out_set_status = atc_spdif_out_set_status,
+       .spdif_out_passthru = atc_spdif_out_passthru,
+       .have_digit_io_switch = atc_have_digit_io_switch,
+};
 
 /**
  *  ct_atc_create - create and initialize a hardware manager
@@ -1552,7 +1550,7 @@ static void atc_set_ops(struct ct_atc *atc)
  *  Returns 0 if suceeds, or negative error code if fails.
  */
 
-int ct_atc_create(struct snd_card *card, struct pci_dev *pci,
+int __devinit ct_atc_create(struct snd_card *card, struct pci_dev *pci,
                  unsigned int rsr, unsigned int msr, struct ct_atc **ratc)
 {
        struct ct_atc *atc = NULL;
@@ -1567,14 +1565,14 @@ int ct_atc_create(struct snd_card *card, struct pci_dev *pci,
        if (NULL == atc)
                return -ENOMEM;
 
+       /* Set operations */
+       *atc = atc_preset;
+
        atc->card = card;
        atc->pci = pci;
        atc->rsr = rsr;
        atc->msr = msr;
 
-       /* Set operations */
-       atc_set_ops(atc);
-
        spin_lock_init(&atc->atc_lock);
 
        /* Find card model */
@@ -1606,8 +1604,6 @@ int ct_atc_create(struct snd_card *card, struct pci_dev *pci,
        if (!atc->timer)
                goto error1;
 
-       atc->create_alsa_devs = ct_create_alsa_devs;
-
        err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, atc, &ops);
        if (err < 0)
                goto error1;