pata_sis: Implement MWDMA for the UDMA 133 capable chips
[safe/jmp/linux-2.6] / sound / pci / mixart / mixart_hwdep.c
index 170781a..4cf4cd8 100644 (file)
@@ -20,7 +20,6 @@
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  */
 
-#include <sound/driver.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/firmware.h>
@@ -289,7 +288,9 @@ static int mixart_enum_physio(struct mixart_mgr *mgr)
                return -EINVAL;
        }
 
-       snd_assert(phys_io.nb_uid >= (MIXART_MAX_CARDS * 2),  return -EINVAL); /* min 2 phys io per card (analog in + analog out) */
+       /* min 2 phys io per card (analog in + analog out) */
+       if (phys_io.nb_uid < MIXART_MAX_CARDS * 2)
+               return -EINVAL;
 
        for(k=0; k<mgr->num_cards; k++) {
                mgr->chip[k]->uid_in_analog_physio = phys_io.uid[k];
@@ -344,8 +345,8 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
        status_daught = readl_be( MIXART_MEM( mgr,MIXART_PSEUDOREG_DXLX_STATUS_OFFSET ));
 
        /* motherboard xilinx status 5 will say that the board is performing a reset */
-       if( status_xilinx == 5 ) {
-               snd_printk( KERN_ERR "miXart is resetting !\n");
+       if (status_xilinx == 5) {
+               snd_printk(KERN_ERR "miXart is resetting !\n");
                return -EAGAIN; /* try again later */
        }
 
@@ -353,19 +354,22 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
        case MIXART_MOTHERBOARD_XLX_INDEX:
 
                /* xilinx already loaded ? */ 
-               if( status_xilinx == 4 ) {
-                       snd_printk( KERN_DEBUG "xilinx is already loaded !\n");
+               if (status_xilinx == 4) {
+                       snd_printk(KERN_DEBUG "xilinx is already loaded !\n");
                        return 0;
                }
                /* the status should be 0 == "idle" */
-               if( status_xilinx != 0 ) {
-                       snd_printk( KERN_ERR "xilinx load error ! status = %d\n", status_xilinx);
+               if (status_xilinx != 0) {
+                       snd_printk(KERN_ERR "xilinx load error ! status = %d\n",
+                                  status_xilinx);
                        return -EIO; /* modprob -r may help ? */
                }
 
                /* check xilinx validity */
-               snd_assert(((u32*)(dsp->data))[0]==0xFFFFFFFF, return -EINVAL);
-               snd_assert(dsp->size % 4 == 0, return -EINVAL);
+               if (((u32*)(dsp->data))[0] == 0xffffffff)
+                       return -EINVAL;
+               if (dsp->size % 4)
+                       return -EINVAL;
 
                /* set xilinx status to copying */
                writel_be( 1, MIXART_MEM( mgr, MIXART_PSEUDOREG_MXLX_STATUS_OFFSET ));
@@ -386,21 +390,23 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
 
        case MIXART_MOTHERBOARD_ELF_INDEX:
 
-               if( status_elf == 4 ) {
-                       snd_printk( KERN_DEBUG "elf file already loaded !\n");
+               if (status_elf == 4) {
+                       snd_printk(KERN_DEBUG "elf file already loaded !\n");
                        return 0;
                }
 
                /* the status should be 0 == "idle" */
-               if( status_elf != 0 ) {
-                       snd_printk( KERN_ERR "elf load error ! status = %d\n", status_elf);
+               if (status_elf != 0) {
+                       snd_printk(KERN_ERR "elf load error ! status = %d\n",
+                                  status_elf);
                        return -EIO; /* modprob -r may help ? */
                }
 
                /* wait for xilinx status == 4 */
                err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_MXLX_STATUS_OFFSET, 1, 4, 500); /* 5sec */
                if (err < 0) {
-                       snd_printk( KERN_ERR "xilinx was not loaded or could not be started\n");
+                       snd_printk(KERN_ERR "xilinx was not loaded or "
+                                  "could not be started\n");
                        return err;
                }
 
@@ -421,7 +427,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
                /* wait for elf status == 4 */
                err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_ELF_STATUS_OFFSET, 1, 4, 300); /* 3sec */
                if (err < 0) {
-                       snd_printk( KERN_ERR "elf could not be started\n");
+                       snd_printk(KERN_ERR "elf could not be started\n");
                        return err;
                }
 
@@ -434,15 +440,16 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
        default:
 
                /* elf and xilinx should be loaded */
-               if( (status_elf != 4) || (status_xilinx != 4) ) {
-                       printk( KERN_ERR "xilinx or elf not successfully loaded\n");
+               if (status_elf != 4 || status_xilinx != 4) {
+                       printk(KERN_ERR "xilinx or elf not "
+                              "successfully loaded\n");
                        return -EIO; /* modprob -r may help ? */
                }
 
                /* wait for daughter detection != 0 */
                err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DBRD_PRESENCE_OFFSET, 0, 0, 30); /* 300msec */
                if (err < 0) {
-                       snd_printk( KERN_ERR "error starting elf file\n");
+                       snd_printk(KERN_ERR "error starting elf file\n");
                        return err;
                }
 
@@ -457,14 +464,17 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
                        return -EINVAL;
 
                /* daughter should be idle */
-               if( status_daught != 0 ) {
-                       printk( KERN_ERR "daughter load error ! status = %d\n", status_daught);
+               if (status_daught != 0) {
+                       printk(KERN_ERR "daughter load error ! status = %d\n",
+                              status_daught);
                        return -EIO; /* modprob -r may help ? */
                }
  
                /* check daughterboard xilinx validity */
-               snd_assert(((u32*)(dsp->data))[0]==0xFFFFFFFF, return -EINVAL);
-               snd_assert(dsp->size % 4 == 0, return -EINVAL);
+               if (((u32*)(dsp->data))[0] == 0xffffffff)
+                       return -EINVAL;
+               if (dsp->size % 4)
+                       return -EINVAL;
 
                /* inform mixart about the size of the file */
                writel_be( dsp->size, MIXART_MEM( mgr, MIXART_PSEUDOREG_DXLX_SIZE_OFFSET ));
@@ -475,13 +485,14 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
                /* wait for status == 2 */
                err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET, 1, 2, 30); /* 300msec */
                if (err < 0) {
-                       snd_printk( KERN_ERR "daughter board load error\n");
+                       snd_printk(KERN_ERR "daughter board load error\n");
                        return err;
                }
 
                /* get the address where to write the file */
                val = readl_be( MIXART_MEM( mgr, MIXART_PSEUDOREG_DXLX_BASE_ADDR_OFFSET ));
-               snd_assert(val != 0, return -EINVAL);
+               if (!val)
+                       return -EINVAL;
 
                /* copy daughterboard xilinx code */
                memcpy_toio(  MIXART_MEM( mgr, val),  dsp->data,  dsp->size);
@@ -496,7 +507,8 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
         /* wait for daughter status == 3 */
         err = mixart_wait_nice_for_register_value( mgr, MIXART_PSEUDOREG_DXLX_STATUS_OFFSET, 1, 3, 300); /* 3sec */
         if (err < 0) {
-               snd_printk( KERN_ERR "daughter board could not be initialised\n");
+               snd_printk(KERN_ERR
+                          "daughter board could not be initialised\n");
                return err;
        }
 
@@ -506,7 +518,7 @@ static int mixart_dsp_load(struct mixart_mgr* mgr, int index, const struct firmw
        /* first communication with embedded */
        err = mixart_first_init(mgr);
         if (err < 0) {
-               snd_printk( KERN_ERR "miXart could not be set up\n");
+               snd_printk(KERN_ERR "miXart could not be set up\n");
                return err;
        }
 
@@ -575,16 +587,6 @@ MODULE_FIRMWARE("mixart/miXart8AES.xlx");
 /* miXart hwdep interface id string */
 #define SND_MIXART_HWDEP_ID       "miXart Loader"
 
-static int mixart_hwdep_open(struct snd_hwdep *hw, struct file *file)
-{
-       return 0;
-}
-
-static int mixart_hwdep_release(struct snd_hwdep *hw, struct file *file)
-{
-       return 0;
-}
-
 static int mixart_hwdep_dsp_status(struct snd_hwdep *hw,
                                   struct snd_hwdep_dsp_status *info)
 {
@@ -614,7 +616,7 @@ static int mixart_hwdep_dsp_load(struct snd_hwdep *hw,
                           (int)dsp->length);
                return -ENOMEM;
        }
-       if (copy_from_user(fw.data, dsp->image, dsp->length)) {
+       if (copy_from_user((void *) fw.data, dsp->image, dsp->length)) {
                vfree(fw.data);
                return -EFAULT;
        }
@@ -637,8 +639,6 @@ int snd_mixart_setup_firmware(struct mixart_mgr *mgr)
 
        hw->iface = SNDRV_HWDEP_IFACE_MIXART;
        hw->private_data = mgr;
-       hw->ops.open = mixart_hwdep_open;
-       hw->ops.release = mixart_hwdep_release;
        hw->ops.dsp_status = mixart_hwdep_dsp_status;
        hw->ops.dsp_load = mixart_hwdep_dsp_load;
        hw->exclusive = 1;