Merge branch 'for-2.6.27' of git://git.infradead.org/users/dwmw2/firmware-2.6
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 14 Jul 2008 23:54:07 +0000 (16:54 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 14 Jul 2008 23:54:07 +0000 (16:54 -0700)
* 'for-2.6.27' of git://git.infradead.org/users/dwmw2/firmware-2.6: (64 commits)
  firmware: convert sb16_csp driver to use firmware loader exclusively
  dsp56k: use request_firmware
  edgeport-ti: use request_firmware()
  edgeport: use request_firmware()
  vicam: use request_firmware()
  dabusb: use request_firmware()
  cpia2: use request_firmware()
  ip2: use request_firmware()
  firmware: convert Ambassador ATM driver to request_firmware()
  whiteheat: use request_firmware()
  ti_usb_3410_5052: use request_firmware()
  emi62: use request_firmware()
  emi26: use request_firmware()
  keyspan_pda: use request_firmware()
  keyspan: use request_firmware()
  ttusb-budget: use request_firmware()
  kaweth: use request_firmware()
  smctr: use request_firmware()
  firmware: convert ymfpci driver to use firmware loader exclusively
  firmware: convert maestro3 driver to use firmware loader exclusively
  ...

Fix up trivial conflicts with BKL removal in drivers/char/dsp56k.c and
drivers/char/ip2/ip2main.c manually.

1  2 
Makefile
arch/x86/kernel/microcode.c
drivers/char/dsp56k.c
drivers/char/ip2/ip2main.c
include/asm-generic/vmlinux.lds.h

diff --combined Makefile
+++ b/Makefile
@@@ -450,7 -450,7 +450,7 @@@ scripts: scripts_basic include/config/a
  
  # Objects we will link into vmlinux / subdirs we need to visit
  init-y                := init/
- drivers-y     := drivers/ sound/
+ drivers-y     := drivers/ sound/ firmware/
  net-y         := net/
  libs-y                := lib/
  core-y                := usr/
@@@ -528,10 -528,6 +528,10 @@@ KBUILD_CFLAGS    += -
  KBUILD_AFLAGS += -gdwarf-2
  endif
  
 +ifdef CONFIG_FTRACE
 +KBUILD_CFLAGS += -pg
 +endif
 +
  # We trigger additional mismatches with less inlining
  ifdef CONFIG_DEBUG_SECTION_MISMATCH
  KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once)
@@@ -998,6 -994,16 +998,16 @@@ PHONY += depend de
  depend dep:
        @echo '*** Warning: make $@ is unnecessary now.'
  
+ # ---------------------------------------------------------------------------
+ # Firmware install
+ INSTALL_FW_PATH=$(INSTALL_MOD_PATH)/lib/firmware
+ export INSTALL_FW_PATH
+ PHONY += firmware_install
+ firmware_install: FORCE
+       @mkdir -p $(objtree)/firmware
+       $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_install
  # ---------------------------------------------------------------------------
  # Kernel headers
  INSTALL_HDR_PATH=$(objtree)/usr
@@@ -1084,6 -1090,7 +1094,7 @@@ _modinst_
  # boot script depmod is the master version.
  PHONY += _modinst_post
  _modinst_post: _modinst_
+       $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modinst
        $(call cmd,depmod)
  
  else # CONFIG_MODULES
@@@ -1201,6 -1208,8 +1212,8 @@@ help
        @echo  '* vmlinux         - Build the bare kernel'
        @echo  '* modules         - Build all modules'
        @echo  '  modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
+       @echo  '  firmware_install- Install all firmware to INSTALL_FW_PATH'
+       @echo  '                    (default: $$(INSTALL_MOD_PATH)/lib/firmware)'
        @echo  '  dir/            - Build all files in dir and below'
        @echo  '  dir/file.[ois]  - Build specified target only'
        @echo  '  dir/file.ko     - Build module including final link'
@@@ -76,7 -76,6 +76,7 @@@
  #include <linux/kernel.h>
  #include <linux/init.h>
  #include <linux/sched.h>
 +#include <linux/smp_lock.h>
  #include <linux/cpumask.h>
  #include <linux/module.h>
  #include <linux/slab.h>
@@@ -424,7 -423,6 +424,7 @@@ out
  
  static int microcode_open (struct inode *unused1, struct file *unused2)
  {
 +      cycle_kernel_lock();
        return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
  }
  
@@@ -491,7 -489,7 +491,7 @@@ MODULE_ALIAS_MISCDEV(MICROCODE_MINOR)
  #define microcode_dev_exit() do { } while(0)
  #endif
  
- static long get_next_ucode_from_buffer(void **mc, void *buf,
+ static long get_next_ucode_from_buffer(void **mc, const u8 *buf,
        unsigned long size, long offset)
  {
        microcode_header_t *mc_header;
@@@ -525,7 -523,7 +525,7 @@@ static int cpu_request_microcode(int cp
        char name[30];
        struct cpuinfo_x86 *c = &cpu_data(cpu);
        const struct firmware *firmware;
-       void *buf;
+       const u8 *buf;
        unsigned long size;
        long offset = 0;
        int error;
diff --combined drivers/char/dsp56k.c
@@@ -33,7 -33,8 +33,9 @@@
  #include <linux/mm.h>
  #include <linux/init.h>
  #include <linux/device.h>
 +#include <linux/smp_lock.h>
+ #include <linux/firmware.h>
+ #include <linux/platform_device.h>
  
  #include <asm/atarihw.h>
  #include <asm/traps.h>
        } \
  }
  
- /* DSP56001 bootstrap code */
- static char bootstrap[] = {
-       0x0c, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x60, 0xf4, 0x00, 0x00, 0x00, 0x4f, 0x61, 0xf4,
-       0x00, 0x00, 0x7e, 0xa9, 0x06, 0x2e, 0x80, 0x00, 0x00, 0x47,
-       0x07, 0xd8, 0x84, 0x07, 0x59, 0x84, 0x08, 0xf4, 0xa8, 0x00,
-       0x00, 0x04, 0x08, 0xf4, 0xbf, 0x00, 0x0c, 0x00, 0x00, 0xfe,
-       0xb8, 0x0a, 0xf0, 0x80, 0x00, 0x7e, 0xa9, 0x08, 0xf4, 0xa0,
-       0x00, 0x00, 0x01, 0x08, 0xf4, 0xbe, 0x00, 0x00, 0x00, 0x0a,
-       0xa9, 0x80, 0x00, 0x7e, 0xad, 0x08, 0x4e, 0x2b, 0x44, 0xf4,
-       0x00, 0x00, 0x00, 0x03, 0x44, 0xf4, 0x45, 0x00, 0x00, 0x01,
-       0x0e, 0xa0, 0x00, 0x0a, 0xa9, 0x80, 0x00, 0x7e, 0xb5, 0x08,
-       0x50, 0x2b, 0x0a, 0xa9, 0x80, 0x00, 0x7e, 0xb8, 0x08, 0x46,
-       0x2b, 0x44, 0xf4, 0x45, 0x00, 0x00, 0x02, 0x0a, 0xf0, 0xaa,
-       0x00, 0x7e, 0xc9, 0x20, 0x00, 0x45, 0x0a, 0xf0, 0xaa, 0x00,
-       0x7e, 0xd0, 0x06, 0xc6, 0x00, 0x00, 0x7e, 0xc6, 0x0a, 0xa9,
-       0x80, 0x00, 0x7e, 0xc4, 0x08, 0x58, 0x6b, 0x0a, 0xf0, 0x80,
-       0x00, 0x7e, 0xad, 0x06, 0xc6, 0x00, 0x00, 0x7e, 0xcd, 0x0a,
-       0xa9, 0x80, 0x00, 0x7e, 0xcb, 0x08, 0x58, 0xab, 0x0a, 0xf0,
-       0x80, 0x00, 0x7e, 0xad, 0x06, 0xc6, 0x00, 0x00, 0x7e, 0xd4,
-       0x0a, 0xa9, 0x80, 0x00, 0x7e, 0xd2, 0x08, 0x58, 0xeb, 0x0a,
-       0xf0, 0x80, 0x00, 0x7e, 0xad};
- static int sizeof_bootstrap = 375;
  static struct dsp56k_device {
        unsigned long in_use;
        long maxio, timeout;
@@@ -165,18 -123,40 +124,40 @@@ static int dsp56k_reset(void
  
  static int dsp56k_upload(u_char __user *bin, int len)
  {
+       struct platform_device *pdev;
+       const struct firmware *fw;
+       const char fw_name[] = "dsp56k/bootstrap.bin";
+       int err;
        int i;
-       u_char *p;
-       
        dsp56k_reset();
-   
-       p = bootstrap;
-       for (i = 0; i < sizeof_bootstrap/3; i++) {
+       pdev = platform_device_register_simple("dsp56k", 0, NULL, 0);
+       if (IS_ERR(pdev)) {
+               printk(KERN_ERR "Failed to register device for \"%s\"\n",
+                      fw_name);
+               return -EINVAL;
+       }
+       err = request_firmware(&fw, fw_name, &pdev->dev);
+       platform_device_unregister(pdev);
+       if (err) {
+               printk(KERN_ERR "Failed to load image \"%s\" err %d\n",
+                      fw_name, err);
+               return err;
+       }
+       if (fw->size % 3) {
+               printk(KERN_ERR "Bogus length %d in image \"%s\"\n",
+                      fw->size, fw_name);
+               release_firmware(fw);
+               return -EINVAL;
+       }
+       for (i = 0; i < fw->size; i = i + 3) {
                /* tx_wait(10); */
-               dsp56k_host_interface.data.b[1] = *p++;
-               dsp56k_host_interface.data.b[2] = *p++;
-               dsp56k_host_interface.data.b[3] = *p++;
+               dsp56k_host_interface.data.b[1] = fw->data[i];
+               dsp56k_host_interface.data.b[2] = fw->data[i + 1];
+               dsp56k_host_interface.data.b[3] = fw->data[i + 2];
        }
+       release_firmware(fw);
        for (; i < 512; i++) {
                /* tx_wait(10); */
                dsp56k_host_interface.data.b[1] = 0;
@@@ -437,17 -417,13 +418,17 @@@ static unsigned int dsp56k_poll(struct 
  static int dsp56k_open(struct inode *inode, struct file *file)
  {
        int dev = iminor(inode) & 0x0f;
 +      int ret = 0;
  
 +      lock_kernel();
        switch(dev)
        {
        case DSP56K_DEV_56001:
  
 -              if (test_and_set_bit(0, &dsp56k.in_use))
 -                      return -EBUSY;
 +              if (test_and_set_bit(0, &dsp56k.in_use)) {
 +                      ret = -EBUSY;
 +                      goto out;
 +              }
  
                dsp56k.timeout = TIMEOUT;
                dsp56k.maxio = MAXIO;
                break;
  
        default:
 -              return -ENODEV;
 +              ret = -ENODEV;
        }
 -
 -      return 0;
 +out:
 +      unlock_kernel();
 +      return ret;
  }
  
  static int dsp56k_release(struct inode *inode, struct file *file)
@@@ -540,3 -515,4 +521,4 @@@ static void __exit dsp56k_cleanup_drive
  module_exit(dsp56k_cleanup_driver);
  
  MODULE_LICENSE("GPL");
+ MODULE_FIRMWARE("dsp56k/bootstrap.bin");
@@@ -98,7 -98,8 +98,9 @@@
  #include <linux/major.h>
  #include <linux/wait.h>
  #include <linux/device.h>
 +#include <linux/smp_lock.h>
+ #include <linux/firmware.h>
+ #include <linux/platform_device.h>
  
  #include <linux/tty.h>
  #include <linux/tty_flip.h>
@@@ -156,9 -157,7 +158,7 @@@ static char *pcDriver_name   = "ip2"
  static char *pcIpl                     = "ip2ipl";
  
  // cheezy kludge or genius - you decide?
- int ip2_loadmain(int *, int *, unsigned char *, int);
- static unsigned char *Fip_firmware;
- static int Fip_firmware_size;
+ int ip2_loadmain(int *, int *);
  
  /***********************/
  /* Function Prototypes */
@@@ -209,7 -208,7 +209,7 @@@ static int ip2_ipl_open(struct inode *
  static int DumpTraceBuffer(char __user *, int);
  static int DumpFifoBuffer( char __user *, int);
  
- static void ip2_init_board(int);
+ static void ip2_init_board(int, const struct firmware *);
  static unsigned short find_eisa_board(int);
  
  /***************/
@@@ -475,8 -474,27 +475,27 @@@ static const struct tty_operations ip2_
  /* SA_RANDOM   - can be source for cert. random number generators */
  #define IP2_SA_FLAGS  0
  
+ static const struct firmware *ip2_request_firmware(void)
+ {
+       struct platform_device *pdev;
+       const struct firmware *fw;
+       pdev = platform_device_register_simple("ip2", 0, NULL, 0);
+       if (IS_ERR(pdev)) {
+               printk(KERN_ERR "Failed to register platform device for ip2\n");
+               return NULL;
+       }
+       if (request_firmware(&fw, "intelliport2.bin", &pdev->dev)) {
+               printk(KERN_ERR "Failed to load firmware 'intelliport2.bin'\n");
+               fw = NULL;
+       }
+       platform_device_unregister(pdev);
+       return fw;
+ }
  int
- ip2_loadmain(int *iop, int *irqp, unsigned char *firmware, int firmsize) 
+ ip2_loadmain(int *iop, int *irqp)
  {
        int i, j, box;
        int err = 0;
        i2eBordStrPtr pB = NULL;
        int rc = -1;
        static struct pci_dev *pci_dev_i = NULL;
+       const struct firmware *fw = NULL;
  
        ip2trace (ITRC_NO_PORT, ITRC_INIT, ITRC_ENTER, 0 );
  
        }
        poll_only = !poll_only;
  
-       Fip_firmware = firmware;
-       Fip_firmware_size = firmsize;
        /* Announce our presence */
        printk( KERN_INFO "%s version %s\n", pcName, pcVersion );
  
                }
        }
        for ( i = 0; i < IP2_MAX_BOARDS; ++i ) {
+               /* We don't want to request the firmware unless we have at
+                  least one board */
                if ( i2BoardPtrTable[i] != NULL ) {
-                       ip2_init_board( i );
+                       if (!fw)
+                               fw = ip2_request_firmware();
+                       if (!fw)
+                               break;
+                       ip2_init_board(i, fw);
                }
        }
+       if (fw)
+               release_firmware(fw);
  
        ip2trace (ITRC_NO_PORT, ITRC_INIT, 2, 0 );
  
@@@ -770,7 -794,7 +795,7 @@@ out
  /* are reported on the console.                                               */
  /******************************************************************************/
  static void
- ip2_init_board( int boardnum )
+ ip2_init_board(int boardnum, const struct firmware *fw)
  {
        int i;
        int nports = 0, nboxes = 0;
                goto err_initialize;
        }
  
-       if ( iiDownloadAll ( pB, (loadHdrStrPtr)Fip_firmware, 1, Fip_firmware_size )
+       if ( iiDownloadAll ( pB, (loadHdrStrPtr)fw->data, 1, fw->size )
            != II_DOWN_GOOD ) {
                printk ( KERN_ERR "IP2: failed to download loadware\n" );
                goto err_release_region;
@@@ -2909,11 -2933,42 +2934,11 @@@ ip2_ipl_ioctl ( struct inode *pInode, s
  static int
  ip2_ipl_open( struct inode *pInode, struct file *pFile )
  {
 -      unsigned int iplminor = iminor(pInode);
 -      i2eBordStrPtr pB;
 -      i2ChanStrPtr  pCh;
  
  #ifdef IP2DEBUG_IPL
        printk (KERN_DEBUG "IP2IPL: open\n" );
  #endif
 -
 -      switch(iplminor) {
 -      // These are the IPL devices
 -      case 0:
 -      case 4:
 -      case 8:
 -      case 12:
 -              break;
 -
 -      // These are the status devices
 -      case 1:
 -      case 5:
 -      case 9:
 -      case 13:
 -              break;
 -
 -      // These are the debug devices
 -      case 2:
 -      case 6:
 -      case 10:
 -      case 14:
 -              pB = i2BoardPtrTable[iplminor / 4];
 -              pCh = (i2ChanStrPtr) pB->i2eChannelPtr;
 -              break;
 -
 -      // This is the trace device
 -      case 3:
 -              break;
 -      }
 +      cycle_kernel_lock();
        return 0;
  }
  
@@@ -67,8 -67,6 +67,8 @@@
                *(.rodata1)                                             \
        }                                                               \
                                                                        \
 +      BUG_TABLE                                                       \
 +                                                                      \
        /* PCI quirks */                                                \
        .pci_fixup        : AT(ADDR(.pci_fixup) - LOAD_OFFSET) {        \
                VMLINUX_SYMBOL(__start_pci_fixups_early) = .;           \
                VMLINUX_SYMBOL(__end_pci_fixups_resume) = .;            \
        }                                                               \
                                                                        \
+       /* Built-in firmware blobs */                                   \
+       .builtin_fw        : AT(ADDR(.builtin_fw) - LOAD_OFFSET) {      \
+               VMLINUX_SYMBOL(__start_builtin_fw) = .;                 \
+               *(.builtin_fw)                                          \
+               VMLINUX_SYMBOL(__end_builtin_fw) = .;                   \
+       }                                                               \
+                                                                       \
        /* RapidIO route ops */                                         \
        .rio_route        : AT(ADDR(.rio_route) - LOAD_OFFSET) {        \
                VMLINUX_SYMBOL(__start_rio_route_ops) = .;              \
                .stab.indexstr 0 : { *(.stab.indexstr) }                \
                .comment 0 : { *(.comment) }
  
 +#ifdef CONFIG_GENERIC_BUG
  #define BUG_TABLE                                                     \
        . = ALIGN(8);                                                   \
        __bug_table : AT(ADDR(__bug_table) - LOAD_OFFSET) {             \
                *(__bug_table)                                          \
                __stop___bug_table = .;                                 \
        }
 +#else
 +#define BUG_TABLE
 +#endif
  
  #ifdef CONFIG_PM_TRACE
  #define TRACEDATA                                                     \