Changeset 299


Ignore:
Timestamp:
Feb 21, 2008, 7:31:22 AM (17 years ago)
Author:
Brendan Oakley
Message:

Separate misc_driver.c functions from misc.c

Location:
GPL/branches/alsa-resync1/alsa-kernel
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • GPL/branches/alsa-resync1/alsa-kernel/core/makefile.os2

    r246 r299  
    3333#===================================================================
    3434FILE1    = sound.obj init.obj memory.obj memalloc.obj sgbuf.obj
    35 FILE2    = control.obj device.obj misc.obj wrappers.obj
     35FILE2    = control.obj device.obj misc.obj wrappers.obj misc_driver.obj
    3636#FILE3    = sound_oss.obj info_oss.obj isadma.obj
    3737FILE4    = pcm.obj pcm_native.obj pcm_lib.obj pcm_misc.obj pcm_timer.obj pcm_memory.obj
  • GPL/branches/alsa-resync1/alsa-kernel/core/misc.c

    r210 r299  
    2626#include <sound/core.h>
    2727
    28 #ifdef TARGET_OS2
    29 #include <linux/firmware.h>
    30 #endif /* TARGET_OS2 */
    31 
    3228int snd_task_name(struct task_struct *task, char *name, size_t size)
    3329{
     
    4137}
    4238
    43 void destroy_workqueue(struct workqueue_struct *wq)
    44 {
    45 #if 0
    46     flush_workqueue(wq);
    47         kill_proc(wq->task_pid, SIGKILL, 1);
    48         if (wq->task_pid >= 0)
    49             wait_for_completion(&wq->thread_exited);
    50 #endif
    51         kfree(wq);
    52 }
    53 
    54 struct workqueue_struct *create_workqueue(const char *name)
    55 {
    56         struct workqueue_struct *wq;
    57        
    58         //BUG_ON(strlen(name) > 10);
    59        
    60         wq = kmalloc(sizeof(*wq), GFP_KERNEL);
    61         if (!wq)
    62                 return NULL;
    63         memset(wq, 0, sizeof(*wq));
    64        
    65         spin_lock_init(&wq->lock);
    66         INIT_LIST_HEAD(&wq->worklist);
    67         init_waitqueue_head(&wq->more_work);
    68         init_waitqueue_head(&wq->work_done);
    69         wq->name = name;
    70 #if 0
    71         init_completion(&wq->thread_exited);
    72         wq->task_pid = kernel_thread(xworker_thread, wq, 0);
    73         if (wq->task_pid < 0) {
    74                 printk(KERN_ERR "snd: failed to start thread %s\n", name);
    75                 destroy_workqueue(wq);
    76                 wq = NULL;
    77         }
    78 #endif
    79         return wq;
    80 }
    81 
    82 static void __x_queue_work(struct workqueue_struct *wq, struct work_struct *work)
    83 {
    84         unsigned long flags;
    85 
    86         spin_lock_irqsave(&wq->lock, flags);
    87         work->wq_data = wq;
    88         list_add_tail(&work->entry, &wq->worklist);
    89         wake_up(&wq->more_work);
    90         spin_unlock_irqrestore(&wq->lock, flags);
    91 }
    92 
    93 int queue_work(struct workqueue_struct *wq, struct work_struct *work)
    94 {
    95         if (!test_and_set_bit(0, &work->pending)) {
    96                 __x_queue_work(wq, work);
    97                 return 1;
    98         }
    99         return 0;
    100 }
    101 
    102 static void delayed_work_timer_fn(unsigned long __data)
    103 {
    104         struct work_struct *work = (struct work_struct *)__data;
    105         struct workqueue_struct *wq = work->wq_data;
    106        
    107         __x_queue_work(wq, work);
    108 }
    109 
    110 int queue_delayed_work(struct workqueue_struct *wq, struct work_struct *work, unsigned long delay)
    111 {
    112         struct timer_list *timer = &work->timer;
    113 
    114         if (!test_and_set_bit(0, &work->pending)) {
    115                 work->wq_data = work;
    116                 timer->expires = jiffies + delay;
    117                 timer->data = (unsigned long)work;
    118                 timer->function = delayed_work_timer_fn;
    119                 add_timer(timer);
    120                 return 1;
    121         }
    122         return 0;
    123 }
    12439
    12540void release_and_free_resource(struct resource *res)
     
    12944                kfree(res);
    13045        }
    131 }
    132 
    133 int mod_firmware_load(const char *fn, char **fp)
    134 {
    135     return 0;
    136 }
    137 
    138 static int snd_try_load_firmware(const char *path, const char *name,
    139                                  struct firmware *firmware)
    140 {
    141         char filename[30 + FIRMWARE_NAME_MAX];
    142 
    143         sprintf(filename, "%s/%s", path, name);
    144         firmware->size = mod_firmware_load(filename, (char **)&firmware->data);
    145         if (firmware->size)
    146                 printk(KERN_INFO "Loaded '%s'.", filename);
    147         return firmware->size;
    148 }
    149 
    150 int request_firmware(const struct firmware **fw, const char *name,
    151                      struct device *device)
    152 {
    153         struct firmware *firmware;
    154 
    155         *fw = NULL;
    156         firmware = kmalloc(sizeof *firmware, GFP_KERNEL);
    157         if (!firmware)
    158                 return -ENOMEM;
    159         if (!snd_try_load_firmware("/lib/firmware", name, firmware) &&
    160             !snd_try_load_firmware("/lib/hotplug/firmware", name, firmware) &&
    161             !snd_try_load_firmware("/usr/lib/hotplug/firmware", name, firmware)) {
    162                 kfree(firmware);
    163                 return -EIO;
    164         }
    165         *fw = firmware;
    166         return 0;
    167 }
    168 
    169 void release_firmware(const struct firmware *fw)
    170 {
    171         if (fw) {
    172                 vfree(fw->data);
    173                 kfree(fw);
    174         }
    17546}
    17647
  • GPL/branches/alsa-resync1/alsa-kernel/core/misc_driver.c

    r298 r299  
    1 /*
    2  *  Misc and compatibility things
    3  *  Copyright (c) by Jaroslav Kysela <perex@suse.cz>
    4  *
    5  *
    6  *   This program is free software; you can redistribute it and/or modify
    7  *   it under the terms of the GNU General Public License as published by
    8  *   the Free Software Foundation; either version 2 of the License, or
    9  *   (at your option) any later version.
    10  *
    11  *   This program is distributed in the hope that it will be useful,
    12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  *   GNU General Public License for more details.
    15  *
    16  *   You should have received a copy of the GNU General Public License
    17  *   along with this program; if not, write to the Free Software
    18  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
    19  *
    20  */
    21 
     1#define __NO_VERSION__
    222#include <sound/driver.h>
    23 #include <linux/init.h>
    24 #include <linux/sched.h>
    25 #include <linux/time.h>
    263#include <sound/core.h>
    274
     
    307#endif /* TARGET_OS2 */
    318
    32 int snd_task_name(struct task_struct *task, char *name, size_t size)
    33 {
    34         unsigned int idx;
    35 
    36         snd_assert(task != NULL && name != NULL && size >= 2, return -EINVAL);
    37         for (idx = 0; idx < sizeof(task->comm) && idx + 1 < size; idx++)
    38                 name[idx] = task->comm[idx];
    39         name[idx] = '\0';
    40         return 0;
    41 }
    42 
    43 void destroy_workqueue(struct workqueue_struct *wq)
     9void snd_compat_destroy_workqueue(struct workqueue_struct *wq)
    4410{
    4511#if 0
    46     flush_workqueue(wq);
     12    snd_compat_flush_workqueue(wq);
    4713        kill_proc(wq->task_pid, SIGKILL, 1);
    4814        if (wq->task_pid >= 0)
     
    5218}
    5319
    54 struct workqueue_struct *create_workqueue(const char *name)
     20struct workqueue_struct *snd_compat_create_workqueue(const char *name)
    5521{
    5622        struct workqueue_struct *wq;
     
    9157}
    9258
    93 int queue_work(struct workqueue_struct *wq, struct work_struct *work)
     59int snd_compat_queue_work(struct workqueue_struct *wq, struct work_struct *work)
    9460{
    9561        if (!test_and_set_bit(0, &work->pending)) {
     
    10874}
    10975
    110 int queue_delayed_work(struct workqueue_struct *wq, struct work_struct *work, unsigned long delay)
     76int snd_compat_queue_delayed_work(struct workqueue_struct *wq, struct work_struct *work, unsigned long delay)
    11177{
    11278        struct timer_list *timer = &work->timer;
    11379
    11480        if (!test_and_set_bit(0, &work->pending)) {
    115                 work->wq_data = work;
     81                work->wq_data = wq;
    11682                timer->expires = jiffies + delay;
    11783                timer->data = (unsigned long)work;
     
    12187        }
    12288        return 0;
    123 }
    124 
    125 void release_and_free_resource(struct resource *res)
    126 {
    127         if (res) {
    128                 release_resource(res);
    129                 kfree(res);
    130         }
    13189}
    13290
     
    175133}
    176134
    177 /**
    178  * snd_pci_quirk_lookup - look up a PCI SSID quirk list
    179  * @pci: pci_dev handle
    180  * @list: quirk list, terminated by a null entry
    181  *
    182  * Look through the given quirk list and finds a matching entry
    183  * with the same PCI SSID.  When subdevice is 0, all subdevice
    184  * values may match.
    185  *
    186  * Returns the matched entry pointer, or NULL if nothing matched.
    187  */
    188 const struct snd_pci_quirk *
    189 snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list)
    190 {
    191         const struct snd_pci_quirk *q;
    192 
    193         for (q = list; q->subvendor; q++)
    194                 if (q->subvendor == pci->subsystem_vendor &&
    195                     (!q->subdevice || q->subdevice == pci->subsystem_device))
    196                         return q;
    197         return NULL;
    198 }
    199 
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/adriver.h

    r290 r299  
    213213typedef int irqreturn_t;
    214214
     215
     216/* workqueue-alike; 2.5.45 */
     217#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
     218#include <linux/workqueue.h>
     219#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 45) && !defined(__WORK_INITIALIZER)
     220#define SND_WORKQUEUE_COMPAT
     221struct workqueue_struct;
    215222struct work_struct {
    216223        unsigned long pending;
     
    235242int snd_compat_schedule_work(struct work_struct *work);
    236243#define schedule_work(w) snd_compat_schedule_work(w)
     244struct workqueue_struct *snd_compat_create_workqueue(const char *name);
     245#define create_workqueue(name) snd_compat_create_workqueue((name))
     246void snd_compat_flush_workqueue(struct workqueue_struct *wq);
     247#define flush_workqueue(wq) snd_compat_flush_workqueue((wq));
     248void snd_compat_destroy_workqueue(struct workqueue_struct *wq);
     249#define destroy_workqueue(wq) snd_compat_destroy_workqueue((wq));
     250int snd_compat_queue_work(struct workqueue_struct *wq, struct work_struct *work);
     251#define queue_work(wq, work) snd_compat_queue_work((wq), (work))
     252int snd_compat_queue_delayed_work(struct workqueue_struct *wq, struct work_struct *work, unsigned long delay);
     253#define queue_delayed_work(wq, work, delay) snd_compat_queue_delayed_work((wq), (work), (delay))
     254#endif /* < 2.5.45 */
     255#endif /* < 2.6.0 */
    237256
    238257/* 2.5 new modules */
  • GPL/branches/alsa-resync1/alsa-kernel/include/sound/core.h

    r290 r299  
    2525#include <linux/sched.h>                /* wake_up() */
    2626#include <asm/semaphore.h>
    27 #ifndef TARGET_OS2 //TODO: implement linux/rwsem.h, workqueue.h
    2827#include <linux/rwsem.h>                /* struct rw_semaphore */
    2928#include <linux/workqueue.h>            /* struct workqueue_struct */
    30 #endif /* !TARGET_OS2 */
    3129#include <sound/typedefs.h>
    3230
Note: See TracChangeset for help on using the changeset viewer.