/[openvortex]/alsa/alsa-kernel/core/init.c
ViewVC logotype

Diff of /alsa/alsa-kernel/core/init.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by vizard, Sun Jun 15 21:01:30 2003 UTC revision 1.4 by vizard, Mon Aug 11 00:06:37 2003 UTC
# Line 26  Line 26 
26  #include <linux/slab.h>  #include <linux/slab.h>
27  #include <linux/time.h>  #include <linux/time.h>
28  #include <linux/ctype.h>  #include <linux/ctype.h>
 #include <linux/workqueue.h>  
29  #include <sound/core.h>  #include <sound/core.h>
30  #include <sound/control.h>  #include <sound/control.h>
31  #include <sound/info.h>  #include <sound/info.h>
# Line 50  static void snd_card_id_read(snd_info_en Line 49  static void snd_card_id_read(snd_info_en
49          snd_iprintf(buffer, "%s\n", entry->card->id);          snd_iprintf(buffer, "%s\n", entry->card->id);
50  }  }
51    
52    static void snd_card_free_thread(void * __card);
53    
54  /**  /**
55   *  snd_card_new - create and initialize a soundcard structure   *  snd_card_new - create and initialize a soundcard structure
56   *  @idx: card index (address) [0 ... (SNDRV_CARDS-1)]   *  @idx: card index (address) [0 ... (SNDRV_CARDS-1)]
# Line 115  snd_card_t *snd_card_new(int idx, const Line 116  snd_card_t *snd_card_new(int idx, const
116          INIT_LIST_HEAD(&card->ctl_files);          INIT_LIST_HEAD(&card->ctl_files);
117          spin_lock_init(&card->files_lock);          spin_lock_init(&card->files_lock);
118          init_waitqueue_head(&card->shutdown_sleep);          init_waitqueue_head(&card->shutdown_sleep);
119            INIT_WORK(&card->free_workq, snd_card_free_thread, card);
120  #ifdef CONFIG_PM  #ifdef CONFIG_PM
121          init_MUTEX(&card->power_lock);          init_MUTEX(&card->power_lock);
122          init_waitqueue_head(&card->power_sleep);          init_waitqueue_head(&card->power_sleep);
# Line 327  static void snd_card_free_thread(void * Line 329  static void snd_card_free_thread(void *
329   */   */
330  int snd_card_free_in_thread(snd_card_t * card)  int snd_card_free_in_thread(snd_card_t * card)
331  {  {
         DECLARE_WORK(works, snd_card_free_thread, card);  
   
332          if (card->files == NULL) {          if (card->files == NULL) {
333                  snd_card_free(card);                  snd_card_free(card);
334                  return 0;                  return 0;
335          }          }
336          if (schedule_work(&works))  
337            if (schedule_work(&card->free_workq))
338                  return 0;                  return 0;
339    
340          snd_printk(KERN_ERR "kernel_thread failed in snd_card_free_in_thread for card %i\n", card->number);          snd_printk(KERN_ERR "schedule_work() failed in snd_card_free_in_thread for card %i\n", card->number);
341          /* try to free the structure immediately */          /* try to free the structure immediately */
342          snd_card_free(card);          snd_card_free(card);
343          return -EFAULT;          return -EFAULT;
# Line 354  static void choose_default_id(snd_card_t Line 355  static void choose_default_id(snd_card_t
355                  id++;                  id++;
356          }          }
357          id = card->id;          id = card->id;
358            while (*spos != '\0' && !isalnum(*spos))
359                    spos++;
360            if (isdigit(*spos))
361                    *id++ = isalpha(card->shortname[0]) ? card->shortname[0] : 'D';
362          while (*spos != '\0' && (size_t)(id - card->id) < sizeof(card->id) - 1) {          while (*spos != '\0' && (size_t)(id - card->id) < sizeof(card->id) - 1) {
363                  if (isalnum(*spos))                  if (isalnum(*spos))
364                          *id++ = *spos;                          *id++ = *spos;
# Line 362  static void choose_default_id(snd_card_t Line 367  static void choose_default_id(snd_card_t
367          *id = '\0';          *id = '\0';
368    
369          id = card->id;          id = card->id;
370            
371            if (*id == '\0')
372                    strcpy(id, "default");
373    
374          while (1) {          while (1) {
375                  if (loops-- == 0) {                  if (loops-- == 0) {
# Line 421  int snd_card_register(snd_card_t * card) Line 429  int snd_card_register(snd_card_t * card)
429                  write_unlock(&snd_card_rwlock);                  write_unlock(&snd_card_rwlock);
430                  return 0;                  return 0;
431          }          }
432          if (!card->id[0])          if (card->id[0] == '\0')
433                  choose_default_id(card);                  choose_default_id(card);
434          snd_cards[card->number] = card;          snd_cards[card->number] = card;
435          snd_cards_count++;          snd_cards_count++;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26