Changeset 381 for GPL/branches


Ignore:
Timestamp:
Sep 27, 2008, 11:09:10 AM (17 years ago)
Author:
Paul Smedley
Message:

Add missing functions to load firmware + cleanups

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  
    55#include <linux/slab.h>
    66#include <linux/platform_device.h>
     7#include <linux/firmware.h>
    78#include <sound/core.h>
    89
    9 #define NEEDS_COMPAT_FW_LOADER
    1010/*
    1111 * platform_device wrapper
     
    390390
    391391/* we know this is used below exactly once for at most one waiter */
    392 #if 0
    393 struct completion {
    394         int done;
    395         wait_queue_head_t wait;
    396 };
    397 #endif
    398 
    399392static inline void init_completion(struct completion *comp)
    400393{
     
    449442}
    450443
    451 #if 0
    452 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 #endif
    458444struct workqueue_struct {
    459445        spinlock_t lock;
     
    488474}
    489475
    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 0
    517         kill_proc(wq->task_pid, SIGKILL, 1);
    518         if (wq->task_pid >= 0)
    519                 wait_for_completion(&wq->thread_exited);
    520 #endif
    521         kfree(wq);
    522 }
    523 EXPORT_SYMBOL(snd_compat_destroy_workqueue);
    524 
    525476static int xworker_thread(void *data)
    526477{
     
    542493#endif
    543494}
    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);
    572495
    573496static void __x_queue_work(struct workqueue_struct *wq, struct work_struct *work)
     
    581504        spin_unlock_irqrestore(&wq->lock, flags);
    582505}
    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);
    593506
    594507static void delayed_work_timer_fn(unsigned long __data)
     
    603516}
    604517
    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
    634519EXPORT_SYMBOL(snd_compat_cancel_delayed_work);
    635520
    636521#endif
    637522
    638 #if 0
    639 #ifndef CONFIG_HAVE_KZALLOC
    640 #ifndef CONFIG_SND_DEBUG_MEMORY
    641 /* 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 #endif
    652 #endif
    653 
    654 #ifndef CONFIG_HAVE_KCALLOC
    655 #ifndef CONFIG_SND_DEBUG_MEMORY
    656 /* 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 #endif
    665 #endif
    666 
    667 #ifndef CONFIG_HAVE_KSTRDUP
    668 #ifndef CONFIG_SND_DEBUG_MEMORY
    669 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 #endif
    684 #endif
    685 #endif
    686523#ifdef CONFIG_CREATE_WORKQUEUE_FLAGS
    687524
     
    874711#endif /* PNP && PM */
    875712
    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);
     713int mod_firmware_load(const char *fn, char **fp)
     714{
     715    return 0;
     716}
    882717
    883718static int snd_try_load_firmware(const char *path, const char *name,
     
    893728}
    894729
    895 int snd_compat_request_firmware(const struct firmware **fw, const char *name)
     730int request_firmware(const struct firmware **fw, const char *name,
     731                     struct device *device)
    896732{
    897733        struct firmware *firmware;
     
    910746        return 0;
    911747}
    912 EXPORT_SYMBOL(snd_compat_request_firmware);
    913 
    914 void snd_compat_release_firmware(const struct firmware *fw)
     748
     749void release_firmware(const struct firmware *fw)
    915750{
    916751        if (fw) {
     
    919754        }
    920755}
    921 EXPORT_SYMBOL(snd_compat_release_firmware);
    922 
    923 #endif /* NEEDS_COMPAT_FW_LOADER */
    924 #endif /* !2.6 */
    925 #endif
    926756
    927757/* ISA drivers */
  • GPL/branches/uniaud32-2.0/include/linux/firmware.h

    r305 r381  
    11#ifndef _LINUX_FIRMWARE_H
    22#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
     6struct firmware {
     7        size_t size;
     8        u8 *data;
     9};
     10struct device;
     11int request_firmware(const struct firmware **fw, const char *name,
     12                     struct device *device);
     13int 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));
    417
    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 
     18void release_firmware(const struct firmware *fw);
     19void register_firmware(const char *name, const u8 *data, size_t size);
    1820#endif
Note: See TracChangeset for help on using the changeset viewer.