The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sound/sound_firmware.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #include <linux/vmalloc.h>
    2 #include <linux/module.h>
    3 #include <linux/fs.h>
    4 #include <linux/mm.h>
    5 #include <linux/sched.h>
    6 #include <asm/uaccess.h>
    7 #include "oss/sound_firmware.h"
    8 
    9 static int do_mod_firmware_load(const char *fn, char **fp)
   10 {
   11         struct file* filp;
   12         long l;
   13         char *dp;
   14         loff_t pos;
   15 
   16         filp = filp_open(fn, 0, 0);
   17         if (IS_ERR(filp))
   18         {
   19                 printk(KERN_INFO "Unable to load '%s'.\n", fn);
   20                 return 0;
   21         }
   22         l = i_size_read(filp->f_path.dentry->d_inode);
   23         if (l <= 0 || l > 131072)
   24         {
   25                 printk(KERN_INFO "Invalid firmware '%s'\n", fn);
   26                 filp_close(filp, NULL);
   27                 return 0;
   28         }
   29         dp = vmalloc(l);
   30         if (dp == NULL)
   31         {
   32                 printk(KERN_INFO "Out of memory loading '%s'.\n", fn);
   33                 filp_close(filp, NULL);
   34                 return 0;
   35         }
   36         pos = 0;
   37         if (vfs_read(filp, dp, l, &pos) != l)
   38         {
   39                 printk(KERN_INFO "Failed to read '%s'.\n", fn);
   40                 vfree(dp);
   41                 filp_close(filp, NULL);
   42                 return 0;
   43         }
   44         filp_close(filp, NULL);
   45         *fp = dp;
   46         return (int) l;
   47 }
   48 
   49 /**
   50  *      mod_firmware_load - load sound driver firmware
   51  *      @fn: filename
   52  *      @fp: return for the buffer.
   53  *
   54  *      Load the firmware for a sound module (up to 128K) into a buffer.
   55  *      The buffer is returned in *fp. It is allocated with vmalloc so is
   56  *      virtually linear and not DMAable. The caller should free it with
   57  *      vfree when finished.
   58  *
   59  *      The length of the buffer is returned on a successful load, the
   60  *      value zero on a failure.
   61  *
   62  *      Caution: This API is not recommended. Firmware should be loaded via
   63  *      request_firmware.
   64  */
   65  
   66 int mod_firmware_load(const char *fn, char **fp)
   67 {
   68         int r;
   69         mm_segment_t fs = get_fs();
   70 
   71         set_fs(get_ds());
   72         r = do_mod_firmware_load(fn, fp);
   73         set_fs(fs);
   74         return r;
   75 }
   76 EXPORT_SYMBOL(mod_firmware_load);
   77 
   78 MODULE_LICENSE("GPL");

Cache object: 35f536495f3c22e530c9616e5313d119


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.