vserver 2.0 rc7
[linux-2.6.git] / sound / oss / es1370.c
index 6818985..056091c 100644 (file)
@@ -384,7 +384,7 @@ struct es1370_state {
                unsigned char obuf[MIDIOUTBUF];
        } midi;
 
-       struct gameport gameport;
+       struct gameport *gameport;
        struct semaphore sem;
 };
 
@@ -573,7 +573,7 @@ static int prog_dmabuf(struct es1370_state *s, struct dmabuf *db, unsigned rate,
                if (!db->rawbuf)
                        return -ENOMEM;
                db->buforder = order;
-               /* now mark the pages as reserved; otherwise remap_page_range doesn't do what we want */
+               /* now mark the pages as reserved; otherwise remap_pfn_range doesn't do what we want */
                pend = virt_to_page(db->rawbuf + (PAGE_SIZE << db->buforder) - 1);
                for (page = virt_to_page(db->rawbuf); page <= pend; page++)
                        SetPageReserved(page);
@@ -1037,7 +1037,7 @@ static int es1370_open_mixdev(struct inode *inode, struct file *file)
        }
                VALIDATE_STATE(s);
        file->private_data = s;
-       return 0;
+       return nonseekable_open(inode, file);
 }
 
 static int es1370_release_mixdev(struct inode *inode, struct file *file)
@@ -1147,8 +1147,6 @@ static ssize_t es1370_read(struct file *file, char __user *buffer, size_t count,
        int cnt;
 
        VALIDATE_STATE(s);
-       if (ppos != &file->f_pos)
-               return -ESPIPE;
        if (s->dma_adc.mapped)
                return -ENXIO;
        if (!access_ok(VERIFY_WRITE, buffer, count))
@@ -1225,8 +1223,6 @@ static ssize_t es1370_write(struct file *file, const char __user *buffer, size_t
        int cnt;
 
        VALIDATE_STATE(s);
-       if (ppos != &file->f_pos)
-               return -ESPIPE;
        if (s->dma_dac2.mapped)
                return -ENXIO;
        if (!access_ok(VERIFY_READ, buffer, count))
@@ -1368,7 +1364,9 @@ static int es1370_mmap(struct file *file, struct vm_area_struct *vma)
                ret = -EINVAL;
                goto out;
        }
-       if (remap_page_range(vma, vma->vm_start, virt_to_phys(db->rawbuf), size, vma->vm_page_prot)) {
+       if (remap_pfn_range(vma, vma->vm_start,
+                               virt_to_phys(db->rawbuf) >> PAGE_SHIFT,
+                               size, vma->vm_page_prot)) {
                ret = -EAGAIN;
                goto out;
        }
@@ -1789,7 +1787,7 @@ static int es1370_open(struct inode *inode, struct file *file)
        s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
        up(&s->open_sem);
        init_MUTEX(&s->sem);
-       return 0;
+       return nonseekable_open(inode, file);
 }
 
 static int es1370_release(struct inode *inode, struct file *file)
@@ -1841,8 +1839,6 @@ static ssize_t es1370_write_dac(struct file *file, const char __user *buffer, si
        int cnt;
 
        VALIDATE_STATE(s);
-       if (ppos != &file->f_pos)
-               return -ESPIPE;
        if (s->dma_dac1.mapped)
                return -ENXIO;
        if (!s->dma_dac1.ready && (ret = prog_dmabuf_dac1(s)))
@@ -1946,7 +1942,9 @@ static int es1370_mmap_dac(struct file *file, struct vm_area_struct *vma)
        if (size > (PAGE_SIZE << s->dma_dac1.buforder))
                goto out;
        ret = -EAGAIN;
-       if (remap_page_range(vma, vma->vm_start, virt_to_phys(s->dma_dac1.rawbuf), size, vma->vm_page_prot))
+       if (remap_pfn_range(vma, vma->vm_start,
+                       virt_to_phys(s->dma_dac1.rawbuf) >> PAGE_SHIFT,
+                       size, vma->vm_page_prot))
                goto out;
        s->dma_dac1.mapped = 1;
        ret = 0;
@@ -2222,7 +2220,7 @@ static int es1370_open_dac(struct inode *inode, struct file *file)
        spin_unlock_irqrestore(&s->lock, flags);
        s->open_mode |= FMODE_DAC;
        up(&s->open_sem);
-       return 0;
+       return nonseekable_open(inode, file);
 }
 
 static int es1370_release_dac(struct inode *inode, struct file *file)
@@ -2265,8 +2263,6 @@ static ssize_t es1370_midi_read(struct file *file, char __user *buffer, size_t c
        int cnt;
 
        VALIDATE_STATE(s);
-       if (ppos != &file->f_pos)
-               return -ESPIPE;
        if (!access_ok(VERIFY_WRITE, buffer, count))
                return -EFAULT;
        if (count == 0)
@@ -2328,8 +2324,6 @@ static ssize_t es1370_midi_write(struct file *file, const char __user *buffer, s
        int cnt;
 
        VALIDATE_STATE(s);
-       if (ppos != &file->f_pos)
-               return -ESPIPE;
        if (!access_ok(VERIFY_READ, buffer, count))
                return -EFAULT;
        if (count == 0)
@@ -2464,7 +2458,7 @@ static int es1370_midi_open(struct inode *inode, struct file *file)
        spin_unlock_irqrestore(&s->lock, flags);
        s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
        up(&s->open_sem);
-       return 0;
+       return nonseekable_open(inode, file);
 }
 
 static int es1370_midi_release(struct inode *inode, struct file *file)
@@ -2531,9 +2525,9 @@ static int micbias[NR_DEVICE];
 
 static unsigned int devindex;
 
-MODULE_PARM(lineout, "1-" __MODULE_STRING(NR_DEVICE) "i");
+module_param_array(lineout, bool, NULL, 0);
 MODULE_PARM_DESC(lineout, "if 1 the LINE input is converted to LINE out");
-MODULE_PARM(micbias, "1-" __MODULE_STRING(NR_DEVICE) "i");
+module_param_array(micbias, bool, NULL, 0);
 MODULE_PARM_DESC(micbias, "sets the +5V bias for an electret microphone");
 
 MODULE_AUTHOR("Thomas M. Sailer, sailer@ife.ee.ethz.ch, hb9jnx@hb9w.che.eu");
@@ -2546,7 +2540,7 @@ MODULE_LICENSE("GPL");
 static struct initvol {
        int mixch;
        int vol;
-} initvol[] __initdata = {
+} initvol[] __devinitdata = {
        { SOUND_MIXER_WRITE_VOLUME, 0x4040 },
        { SOUND_MIXER_WRITE_PCM, 0x4040 },
        { SOUND_MIXER_WRITE_SYNTH, 0x4040 },
@@ -2562,6 +2556,7 @@ static struct initvol {
 static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_device_id *pciid)
 {
        struct es1370_state *s;
+       struct gameport *gp = NULL;
        mm_segment_t fs;
        int i, val, ret;
 
@@ -2610,12 +2605,17 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
        /* note: setting CTRL_SERR_DIS is reported to break
         * mic bias setting (by Kim.Berts@fisub.mail.abb.com) */
        s->ctrl = CTRL_CDC_EN | (DAC2_SRTODIV(8000) << CTRL_SH_PCLKDIV) | (1 << CTRL_SH_WTSRSEL);
-       s->gameport.io = 0;
-       if (!request_region(0x200, JOY_EXTENT, "es1370"))
+       if (!request_region(0x200, JOY_EXTENT, "es1370")) {
                printk(KERN_ERR "es1370: joystick io port 0x200 in use\n");
-       else {
+       } else if (!(s->gameport = gp = gameport_allocate_port())) {
+               printk(KERN_ERR "es1370: can not allocate memory for gameport\n");
+               release_region(0x200, JOY_EXTENT);
+       } else {
+               gameport_set_name(gp, "ESS1370");
+               gameport_set_phys(gp, "pci%s/gameport0", pci_name(s->dev));
+               gp->dev.parent = &s->dev->dev;
+               gp->io = 0x200;
                s->ctrl |= CTRL_JYSTK_EN;
-               s->gameport.io = 0x200;
        }
        if (lineout[devindex])
                s->ctrl |= CTRL_XCTL0;
@@ -2671,9 +2671,10 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
                mixer_ioctl(s, initvol[i].mixch, (unsigned long)&val);
        }
        set_fs(fs);
+
        /* register gameport */
-       if (s->gameport.io)
-               gameport_register_port(&s->gameport);
+       if (gp)
+               gameport_register_port(gp);
 
        /* store it in the driver field */
        pci_set_drvdata(pcidev, s);
@@ -2695,8 +2696,10 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
  err_dev1:
        printk(KERN_ERR "es1370: cannot register misc device\n");
        free_irq(s->irq, s);
-       if (s->gameport.io)
-               release_region(s->gameport.io, JOY_EXTENT);
+       if (s->gameport) {
+               release_region(s->gameport->io, JOY_EXTENT);
+               gameport_free_port(s->gameport);
+       }
  err_irq:
        release_region(s->io, ES1370_EXTENT);
  err_region:
@@ -2715,9 +2718,10 @@ static void __devexit es1370_remove(struct pci_dev *dev)
        outl(0, s->io+ES1370_REG_SERIAL_CONTROL); /* clear serial interrupts */
        synchronize_irq(s->irq);
        free_irq(s->irq, s);
-       if (s->gameport.io) {
-               gameport_unregister_port(&s->gameport);
-               release_region(s->gameport.io, JOY_EXTENT);
+       if (s->gameport) {
+               int gpio = s->gameport->io;
+               gameport_unregister_port(s->gameport);
+               release_region(gpio, JOY_EXTENT);
        }
        release_region(s->io, ES1370_EXTENT);
        unregister_sound_dsp(s->dev_audio);