aboutsummaryrefslogtreecommitdiffstats
path: root/sound/usb/usx2y/usx2yhwdeppcm.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-11-17 04:48:52 -0500
committerJaroslav Kysela <perex@suse.cz>2006-01-03 06:17:09 -0500
commitcb432379eff40d5656ca9f24afc435b4df353d13 (patch)
treef00428351803fc5ad0b5b2c74c239402d47a7293 /sound/usb/usx2y/usx2yhwdeppcm.c
parent9fd9156c6b0dfb8630f68d11dc48a3e824aa64e6 (diff)
[ALSA] usx2y - Code clean up
Modules: USB USX2Y Clean up snd-usb-usx2y driver code: - Avoid unnecessary cast - Fix spaces/indents - Use kzalloc() - Remove weird debug prints Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/usx2y/usx2yhwdeppcm.c')
-rw-r--r--sound/usb/usx2y/usx2yhwdeppcm.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/sound/usb/usx2y/usx2yhwdeppcm.c b/sound/usb/usx2y/usx2yhwdeppcm.c
index 4bbf52bd6025..c5379280fab7 100644
--- a/sound/usb/usx2y/usx2yhwdeppcm.c
+++ b/sound/usb/usx2y/usx2yhwdeppcm.c
@@ -177,10 +177,8 @@ static inline int usX2Y_usbpcm_usbframe_complete(snd_usX2Y_substream_t *capsubs,
177 if (NULL != urb) { 177 if (NULL != urb) {
178 if (state == state_RUNNING) 178 if (state == state_RUNNING)
179 usX2Y_urb_play_retire(playbacksubs, urb); 179 usX2Y_urb_play_retire(playbacksubs, urb);
180 else 180 else if (state >= state_PRERUNNING)
181 if (state >= state_PRERUNNING) { 181 atomic_inc(&playbacksubs->state);
182 atomic_inc(&playbacksubs->state);
183 }
184 } else { 182 } else {
185 switch (state) { 183 switch (state) {
186 case state_STARTING1: 184 case state_STARTING1:
@@ -207,10 +205,8 @@ static inline int usX2Y_usbpcm_usbframe_complete(snd_usX2Y_substream_t *capsubs,
207 if (state == state_RUNNING) { 205 if (state == state_RUNNING) {
208 if ((err = usX2Y_usbpcm_urb_capt_retire(capsubs))) 206 if ((err = usX2Y_usbpcm_urb_capt_retire(capsubs)))
209 return err; 207 return err;
210 } else { 208 } else if (state >= state_PRERUNNING)
211 if (state >= state_PRERUNNING) 209 atomic_inc(&capsubs->state);
212 atomic_inc(&capsubs->state);
213 }
214 usX2Y_usbpcm_urb_capt_iso_advance(capsubs, capsubs->completed_urb); 210 usX2Y_usbpcm_urb_capt_iso_advance(capsubs, capsubs->completed_urb);
215 if (NULL != capsubs2) 211 if (NULL != capsubs2)
216 usX2Y_usbpcm_urb_capt_iso_advance(NULL, capsubs2->completed_urb); 212 usX2Y_usbpcm_urb_capt_iso_advance(NULL, capsubs2->completed_urb);
@@ -330,7 +326,7 @@ static int usX2Y_usbpcm_urbs_allocate(snd_usX2Y_substream_t *subs)
330 326
331 /* allocate and initialize data urbs */ 327 /* allocate and initialize data urbs */
332 for (i = 0; i < NRURBS; i++) { 328 for (i = 0; i < NRURBS; i++) {
333 struct urb** purb = subs->urb + i; 329 struct urb **purb = subs->urb + i;
334 if (*purb) { 330 if (*purb) {
335 usb_kill_urb(*purb); 331 usb_kill_urb(*purb);
336 continue; 332 continue;
@@ -582,10 +578,9 @@ static int snd_usX2Y_usbpcm_close(snd_pcm_substream_t *substream)
582{ 578{
583 snd_pcm_runtime_t *runtime = substream->runtime; 579 snd_pcm_runtime_t *runtime = substream->runtime;
584 snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data; 580 snd_usX2Y_substream_t *subs = (snd_usX2Y_substream_t *)runtime->private_data;
585 int err = 0; 581
586 snd_printd("\n");
587 subs->pcm_substream = NULL; 582 subs->pcm_substream = NULL;
588 return err; 583 return 0;
589} 584}
590 585
591 586
@@ -710,9 +705,9 @@ static struct vm_operations_struct snd_usX2Y_hwdep_pcm_vm_ops = {
710static int snd_usX2Y_hwdep_pcm_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_area_struct *area) 705static int snd_usX2Y_hwdep_pcm_mmap(snd_hwdep_t * hw, struct file *filp, struct vm_area_struct *area)
711{ 706{
712 unsigned long size = (unsigned long)(area->vm_end - area->vm_start); 707 unsigned long size = (unsigned long)(area->vm_end - area->vm_start);
713 usX2Ydev_t *usX2Y = (usX2Ydev_t*)hw->private_data; 708 usX2Ydev_t *usX2Y = hw->private_data;
714 709
715 if (!(((usX2Ydev_t*)hw->private_data)->chip_status & USX2Y_STAT_CHIP_INIT)) 710 if (!(usX2Y->chip_status & USX2Y_STAT_CHIP_INIT))
716 return -EBUSY; 711 return -EBUSY;
717 712
718 /* if userspace tries to mmap beyond end of our buffer, fail */ 713 /* if userspace tries to mmap beyond end of our buffer, fail */
@@ -726,7 +721,6 @@ static int snd_usX2Y_hwdep_pcm_mmap(snd_hwdep_t * hw, struct file *filp, struct
726 } 721 }
727 area->vm_ops = &snd_usX2Y_hwdep_pcm_vm_ops; 722 area->vm_ops = &snd_usX2Y_hwdep_pcm_vm_ops;
728 area->vm_flags |= VM_RESERVED; 723 area->vm_flags |= VM_RESERVED;
729 snd_printd("vm_flags=0x%lX\n", area->vm_flags);
730 area->vm_private_data = hw->private_data; 724 area->vm_private_data = hw->private_data;
731 return 0; 725 return 0;
732} 726}
@@ -734,7 +728,7 @@ static int snd_usX2Y_hwdep_pcm_mmap(snd_hwdep_t * hw, struct file *filp, struct
734 728
735static void snd_usX2Y_hwdep_pcm_private_free(snd_hwdep_t *hwdep) 729static void snd_usX2Y_hwdep_pcm_private_free(snd_hwdep_t *hwdep)
736{ 730{
737 usX2Ydev_t *usX2Y = (usX2Ydev_t *)hwdep->private_data; 731 usX2Ydev_t *usX2Y = hwdep->private_data;
738 if (NULL != usX2Y->hwdep_pcm_shm) 732 if (NULL != usX2Y->hwdep_pcm_shm)
739 snd_free_pages(usX2Y->hwdep_pcm_shm, sizeof(snd_usX2Y_hwdep_pcm_shm_t)); 733 snd_free_pages(usX2Y->hwdep_pcm_shm, sizeof(snd_usX2Y_hwdep_pcm_shm_t));
740} 734}
@@ -749,10 +743,9 @@ int usX2Y_hwdep_pcm_new(snd_card_t* card)
749 if (1 != nr_of_packs()) 743 if (1 != nr_of_packs())
750 return 0; 744 return 0;
751 745
752 if ((err = snd_hwdep_new(card, SND_USX2Y_USBPCM_ID, 1, &hw)) < 0) { 746 if ((err = snd_hwdep_new(card, SND_USX2Y_USBPCM_ID, 1, &hw)) < 0)
753 snd_printd("\n");
754 return err; 747 return err;
755 } 748
756 hw->iface = SNDRV_HWDEP_IFACE_USX2Y_PCM; 749 hw->iface = SNDRV_HWDEP_IFACE_USX2Y_PCM;
757 hw->private_data = usX2Y(card); 750 hw->private_data = usX2Y(card);
758 hw->private_free = snd_usX2Y_hwdep_pcm_private_free; 751 hw->private_free = snd_usX2Y_hwdep_pcm_private_free;