Changeset 381 for GPL/branches
- Timestamp:
- Sep 27, 2008, 11:09:10 AM (17 years ago)
- Location:
- GPL/branches/uniaud32-2.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/branches/uniaud32-2.0/alsa-kernel/core/misc_driver.c
r305 r381 5 5 #include <linux/slab.h> 6 6 #include <linux/platform_device.h> 7 #include <linux/firmware.h> 7 8 #include <sound/core.h> 8 9 9 #define NEEDS_COMPAT_FW_LOADER10 10 /* 11 11 * platform_device wrapper … … 390 390 391 391 /* we know this is used below exactly once for at most one waiter */ 392 #if 0393 struct completion {394 int done;395 wait_queue_head_t wait;396 };397 #endif398 399 392 static inline void init_completion(struct completion *comp) 400 393 { … … 449 442 } 450 443 451 #if 0452 int snd_compat_schedule_work(struct work_struct *works)453 {454 return kernel_thread(work_caller, works, 0) >= 0;455 }456 EXPORT_SYMBOL(snd_compat_schedule_work);457 #endif458 444 struct workqueue_struct { 459 445 spinlock_t lock; … … 488 474 } 489 475 490 void snd_compat_flush_workqueue(struct workqueue_struct *wq)491 {492 if (wq->task == current) {493 run_workqueue(wq);494 } else {495 wait_queue_t wait;496 497 init_waitqueue_entry(&wait, current);498 set_current_state(TASK_UNINTERRUPTIBLE);499 spin_lock_irq(&wq->lock);500 add_wait_queue(&wq->work_done, &wait);501 while (!list_empty(&wq->worklist)) {502 spin_unlock_irq(&wq->lock);503 schedule();504 spin_lock_irq(&wq->lock);505 }506 set_current_state(TASK_RUNNING);507 remove_wait_queue(&wq->work_done, &wait);508 spin_unlock_irq(&wq->lock);509 }510 }511 EXPORT_SYMBOL(snd_compat_flush_workqueue);512 513 void snd_compat_destroy_workqueue(struct workqueue_struct *wq)514 {515 snd_compat_flush_workqueue(wq);516 #if 0517 kill_proc(wq->task_pid, SIGKILL, 1);518 if (wq->task_pid >= 0)519 wait_for_completion(&wq->thread_exited);520 #endif521 kfree(wq);522 }523 EXPORT_SYMBOL(snd_compat_destroy_workqueue);524 525 476 static int xworker_thread(void *data) 526 477 { … … 542 493 #endif 543 494 } 544 545 struct workqueue_struct *snd_compat_create_workqueue(const char *name)546 {547 struct workqueue_struct *wq;548 549 BUG_ON(strlen(name) > 10);550 551 wq = kmalloc(sizeof(*wq), GFP_KERNEL);552 if (!wq)553 return NULL;554 memset(wq, 0, sizeof(*wq));555 556 spin_lock_init(&wq->lock);557 INIT_LIST_HEAD(&wq->worklist);558 init_waitqueue_head(&wq->more_work);559 init_waitqueue_head(&wq->work_done);560 init_completion(&wq->thread_exited);561 wq->name = name;562 wq->task_pid = kernel_thread(xworker_thread, wq, 0);563 if (wq->task_pid < 0) {564 printk(KERN_ERR "snd: failed to start thread %s\n", name);565 snd_compat_destroy_workqueue(wq);566 wq = NULL;567 }568 wq->task = find_task_by_pid(wq->task_pid);569 return wq;570 }571 EXPORT_SYMBOL(snd_compat_create_workqueue);572 495 573 496 static void __x_queue_work(struct workqueue_struct *wq, struct work_struct *work) … … 581 504 spin_unlock_irqrestore(&wq->lock, flags); 582 505 } 583 584 int snd_compat_queue_work(struct workqueue_struct *wq, struct work_struct *work)585 {586 if (!test_and_set_bit(0, &work->pending)) {587 __x_queue_work(wq, work);588 return 1;589 }590 return 0;591 }592 EXPORT_SYMBOL(snd_compat_queue_work);593 506 594 507 static void delayed_work_timer_fn(unsigned long __data) … … 603 516 } 604 517 605 int snd_compat_queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay) 606 { 607 struct work_struct *work = &dwork->work; 608 struct timer_list *timer = &work->timer; 609 610 if (!test_and_set_bit(0, &work->pending)) { 611 work->wq_data = wq; 612 timer->expires = jiffies + delay; 613 timer->data = (unsigned long)work; 614 timer->function = delayed_work_timer_fn; 615 add_timer(timer); 616 return 1; 617 } 618 return 0; 619 } 620 EXPORT_SYMBOL(snd_compat_queue_delayed_work); 621 622 #if 0 623 int snd_compat_cancel_delayed_work(struct delayed_work *dwork) 624 { 625 struct work_struct *work = &dwork->work; 626 int ret; 627 628 ret = del_timer_sync(&work->timer); 629 if (ret) 630 clear_bit(0, &work->pending); 631 return ret; 632 } 633 #endif 518 634 519 EXPORT_SYMBOL(snd_compat_cancel_delayed_work); 635 520 636 521 #endif 637 522 638 #if 0639 #ifndef CONFIG_HAVE_KZALLOC640 #ifndef CONFIG_SND_DEBUG_MEMORY641 /* Don't put this to wrappers.c. We need to call the kmalloc wrapper here. */642 void *snd_compat_kzalloc(size_t size, unsigned int __nocast flags)643 {644 void *ret;645 ret = kmalloc(size, flags);646 if (ret)647 memset(ret, 0, size);648 return ret;649 }650 EXPORT_SYMBOL(snd_compat_kzalloc);651 #endif652 #endif653 654 #ifndef CONFIG_HAVE_KCALLOC655 #ifndef CONFIG_SND_DEBUG_MEMORY656 /* Don't put this to wrappers.c. We need to call the kmalloc wrapper here. */657 void *snd_compat_kcalloc(size_t n, size_t size, unsigned int __nocast flags)658 {659 if (n != 0 && size > INT_MAX / n)660 return NULL;661 return snd_compat_kzalloc(n * size, flags);662 }663 EXPORT_SYMBOL(snd_compat_kcalloc);664 #endif665 #endif666 667 #ifndef CONFIG_HAVE_KSTRDUP668 #ifndef CONFIG_SND_DEBUG_MEMORY669 char *snd_compat_kstrdup(const char *s, unsigned int __nocast gfp_flags)670 {671 int len;672 char *buf;673 674 if (!s) return NULL;675 676 len = strlen(s) + 1;677 buf = kmalloc(len, gfp_flags);678 if (buf)679 memcpy(buf, s, len);680 return buf;681 }682 EXPORT_SYMBOL(snd_compat_kstrdup);683 #endif684 #endif685 #endif686 523 #ifdef CONFIG_CREATE_WORKQUEUE_FLAGS 687 524 … … 874 711 #endif /* PNP && PM */ 875 712 876 #if 0 877 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0) 878 #include <linux/firmware.h> 879 #ifdef NEEDS_COMPAT_FW_LOADER 880 881 extern int mod_firmware_load(const char *fn, char **fp); 713 int mod_firmware_load(const char *fn, char **fp) 714 { 715 return 0; 716 } 882 717 883 718 static int snd_try_load_firmware(const char *path, const char *name, … … 893 728 } 894 729 895 int snd_compat_request_firmware(const struct firmware **fw, const char *name) 730 int request_firmware(const struct firmware **fw, const char *name, 731 struct device *device) 896 732 { 897 733 struct firmware *firmware; … … 910 746 return 0; 911 747 } 912 EXPORT_SYMBOL(snd_compat_request_firmware); 913 914 void snd_compat_release_firmware(const struct firmware *fw) 748 749 void release_firmware(const struct firmware *fw) 915 750 { 916 751 if (fw) { … … 919 754 } 920 755 } 921 EXPORT_SYMBOL(snd_compat_release_firmware);922 923 #endif /* NEEDS_COMPAT_FW_LOADER */924 #endif /* !2.6 */925 #endif926 756 927 757 /* ISA drivers */ -
GPL/branches/uniaud32-2.0/include/linux/firmware.h
r305 r381 1 1 #ifndef _LINUX_FIRMWARE_H 2 2 #define _LINUX_FIRMWARE_H 3 #define FIRMWARE_NAME_MAX 30 3 #include <linux/module.h> 4 #include <linux/types.h> 5 #define FIRMWARE_NAME_MAX 30 6 struct firmware { 7 size_t size; 8 u8 *data; 9 }; 10 struct device; 11 int request_firmware(const struct firmware **fw, const char *name, 12 struct device *device); 13 int request_firmware_nowait( 14 struct module *module, 15 const char *name, struct device *device, void *context, 16 void (*cont)(const struct firmware *fw, void *context)); 4 17 5 struct firmware { 6 unsigned int size; 7 unsigned char *data; 8 }; 9 10 int snd_compat_request_firmware(const struct firmware **fw, const char *name); 11 void snd_compat_release_firmware(const struct firmware *fw); 12 13 #define request_firmware(fw, name, device) snd_compat_request_firmware(fw, name) 14 #define release_firmware(fw) snd_compat_release_firmware(fw) 15 16 #define NEEDS_COMPAT_FW_LOADER 17 18 void release_firmware(const struct firmware *fw); 19 void register_firmware(const char *name, const u8 *data, size_t size); 18 20 #endif
Note:
See TracChangeset
for help on using the changeset viewer.