Rename pci_init() to pci_apply_final_quirks(), move it to quirks.c
[safe/jmp/linux-2.6] / drivers / telephony / ixj.c
index d5863b8..40de151 100644 (file)
@@ -42,8 +42,6 @@
  ***************************************************************************/
 
 /*
- * $Log: ixj.c,v $
- *
  * Revision 4.8  2003/07/09 19:39:00  Daniele Bellucci
  * Audit some copy_*_user and minor cleanup.
  *
 #include <linux/fs.h>          /* everything... */
 #include <linux/errno.h>       /* error codes */
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/mm.h>
 #include <linux/ioport.h>
 #include <linux/interrupt.h>
@@ -284,6 +283,14 @@ static int samplerate = 100;
 
 module_param(ixjdebug, int, 0);
 
+static struct pci_device_id ixj_pci_tbl[] __devinitdata = {
+       { PCI_VENDOR_ID_QUICKNET, PCI_DEVICE_ID_QUICKNET_XJ,
+         PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
+       { }
+};
+
+MODULE_DEVICE_TABLE(pci, ixj_pci_tbl);
+
 /************************************************************************
 *
 * ixjdebug meanings are now bit mapped instead of level based
@@ -329,10 +336,8 @@ static IXJ *ixj_alloc()
 
 static void ixj_fsk_free(IXJ *j)
 {
-       if(j->fskdata != NULL) {
-               kfree(j->fskdata);
-               j->fskdata = NULL;
-       }
+       kfree(j->fskdata);
+       j->fskdata = NULL;
 }
 
 static void ixj_fsk_alloc(IXJ *j)
@@ -642,9 +647,9 @@ static inline BYTE SLIC_GetState(IXJ *j)
        return j->pld_slicr.bits.state;
 }
 
-static BOOL SLIC_SetState(BYTE byState, IXJ *j)
+static bool SLIC_SetState(BYTE byState, IXJ *j)
 {
-       BOOL fRetVal = FALSE;
+       bool fRetVal = false;
 
        if (j->cardtype == QTI_PHONECARD) {
                if (j->flags.pcmciasct) {
@@ -653,14 +658,14 @@ static BOOL SLIC_SetState(BYTE byState, IXJ *j)
                        case PLD_SLIC_STATE_OC:
                                j->pslic.bits.powerdown = 1;
                                j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0;
-                               fRetVal = TRUE;
+                               fRetVal = true;
                                break;
                        case PLD_SLIC_STATE_RINGING:
                                if (j->readers || j->writers) {
                                        j->pslic.bits.powerdown = 0;
                                        j->pslic.bits.ring0 = 1;
                                        j->pslic.bits.ring1 = 0;
-                                       fRetVal = TRUE;
+                                       fRetVal = true;
                                }
                                break;
                        case PLD_SLIC_STATE_OHT:        /* On-hook transmit */
@@ -673,14 +678,14 @@ static BOOL SLIC_SetState(BYTE byState, IXJ *j)
                                        j->pslic.bits.powerdown = 1;
                                }
                                j->pslic.bits.ring0 = j->pslic.bits.ring1 = 0;
-                               fRetVal = TRUE;
+                               fRetVal = true;
                                break;
                        case PLD_SLIC_STATE_APR:        /* Active polarity reversal */
 
                        case PLD_SLIC_STATE_OHTPR:      /* OHT polarity reversal */
 
                        default:
-                               fRetVal = FALSE;
+                               fRetVal = false;
                                break;
                        }
                        j->psccr.bits.dev = 3;
@@ -697,7 +702,7 @@ static BOOL SLIC_SetState(BYTE byState, IXJ *j)
                        j->pld_slicw.bits.c3 = 0;
                        j->pld_slicw.bits.b2en = 0;
                        outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
-                       fRetVal = TRUE;
+                       fRetVal = true;
                        break;
                case PLD_SLIC_STATE_RINGING:
                        j->pld_slicw.bits.c1 = 1;
@@ -705,7 +710,7 @@ static BOOL SLIC_SetState(BYTE byState, IXJ *j)
                        j->pld_slicw.bits.c3 = 0;
                        j->pld_slicw.bits.b2en = 1;
                        outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
-                       fRetVal = TRUE;
+                       fRetVal = true;
                        break;
                case PLD_SLIC_STATE_ACTIVE:
                        j->pld_slicw.bits.c1 = 0;
@@ -713,7 +718,7 @@ static BOOL SLIC_SetState(BYTE byState, IXJ *j)
                        j->pld_slicw.bits.c3 = 0;
                        j->pld_slicw.bits.b2en = 0;
                        outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
-                       fRetVal = TRUE;
+                       fRetVal = true;
                        break;
                case PLD_SLIC_STATE_OHT:        /* On-hook transmit */
 
@@ -722,7 +727,7 @@ static BOOL SLIC_SetState(BYTE byState, IXJ *j)
                        j->pld_slicw.bits.c3 = 0;
                        j->pld_slicw.bits.b2en = 0;
                        outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
-                       fRetVal = TRUE;
+                       fRetVal = true;
                        break;
                case PLD_SLIC_STATE_TIPOPEN:
                        j->pld_slicw.bits.c1 = 0;
@@ -730,7 +735,7 @@ static BOOL SLIC_SetState(BYTE byState, IXJ *j)
                        j->pld_slicw.bits.c3 = 1;
                        j->pld_slicw.bits.b2en = 0;
                        outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
-                       fRetVal = TRUE;
+                       fRetVal = true;
                        break;
                case PLD_SLIC_STATE_STANDBY:
                        j->pld_slicw.bits.c1 = 1;
@@ -738,7 +743,7 @@ static BOOL SLIC_SetState(BYTE byState, IXJ *j)
                        j->pld_slicw.bits.c3 = 1;
                        j->pld_slicw.bits.b2en = 1;
                        outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
-                       fRetVal = TRUE;
+                       fRetVal = true;
                        break;
                case PLD_SLIC_STATE_APR:        /* Active polarity reversal */
 
@@ -747,7 +752,7 @@ static BOOL SLIC_SetState(BYTE byState, IXJ *j)
                        j->pld_slicw.bits.c3 = 1;
                        j->pld_slicw.bits.b2en = 0;
                        outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
-                       fRetVal = TRUE;
+                       fRetVal = true;
                        break;
                case PLD_SLIC_STATE_OHTPR:      /* OHT polarity reversal */
 
@@ -756,10 +761,10 @@ static BOOL SLIC_SetState(BYTE byState, IXJ *j)
                        j->pld_slicw.bits.c3 = 1;
                        j->pld_slicw.bits.b2en = 0;
                        outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
-                       fRetVal = TRUE;
+                       fRetVal = true;
                        break;
                default:
-                       fRetVal = FALSE;
+                       fRetVal = false;
                        break;
                }
        }
@@ -776,10 +781,7 @@ static int ixj_wink(IXJ *j)
        j->pots_winkstart = jiffies;
        SLIC_SetState(PLD_SLIC_STATE_OC, j);
 
-       while (time_before(jiffies, j->pots_winkstart + j->winktime)) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(1);
-       }
+       msleep(jiffies_to_msecs(j->winktime));
 
        SLIC_SetState(slicnow, j);
        return 0;
@@ -1914,7 +1916,6 @@ static int ixj_pcmcia_cable_check(IXJ *j)
 
 static int ixj_hookstate(IXJ *j)
 {
-       unsigned long det;
        int fOffHook = 0;
 
        switch (j->cardtype) {
@@ -1945,11 +1946,7 @@ static int ixj_hookstate(IXJ *j)
                            j->pld_slicr.bits.state == PLD_SLIC_STATE_STANDBY) {
                                if (j->flags.ringing || j->flags.cringing) {
                                        if (!in_interrupt()) {
-                                               det = jiffies + (hertz / 50);
-                                               while (time_before(jiffies, det)) {
-                                                       set_current_state(TASK_INTERRUPTIBLE);
-                                                       schedule_timeout(1);
-                                               }
+                                               msleep(20);
                                        }
                                        SLIC_GetState(j);
                                        if (j->pld_slicr.bits.state == PLD_SLIC_STATE_RINGING) {
@@ -2064,7 +2061,7 @@ static void ixj_ring_start(IXJ *j)
 static int ixj_ring(IXJ *j)
 {
        char cntr;
-       unsigned long jif, det;
+       unsigned long jif;
 
        j->flags.ringing = 1;
        if (ixj_hookstate(j) & 1) {
@@ -2072,7 +2069,6 @@ static int ixj_ring(IXJ *j)
                j->flags.ringing = 0;
                return 1;
        }
-       det = 0;
        for (cntr = 0; cntr < j->maxrings; cntr++) {
                jif = jiffies + (1 * hertz);
                ixj_ring_on(j);
@@ -2082,8 +2078,7 @@ static int ixj_ring(IXJ *j)
                                j->flags.ringing = 0;
                                return 1;
                        }
-                       set_current_state(TASK_INTERRUPTIBLE);
-                       schedule_timeout(1);
+                       schedule_timeout_interruptible(1);
                        if (signal_pending(current))
                                break;
                }
@@ -2091,20 +2086,13 @@ static int ixj_ring(IXJ *j)
                ixj_ring_off(j);
                while (time_before(jiffies, jif)) {
                        if (ixj_hookstate(j) & 1) {
-                               det = jiffies + (hertz / 100);
-                               while (time_before(jiffies, det)) {
-                                       set_current_state(TASK_INTERRUPTIBLE);
-                                       schedule_timeout(1);
-                                       if (signal_pending(current))
-                                               break;
-                               }
+                               msleep(10);
                                if (ixj_hookstate(j) & 1) {
                                        j->flags.ringing = 0;
                                        return 1;
                                }
                        }
-                       set_current_state(TASK_INTERRUPTIBLE);
-                       schedule_timeout(1);
+                       schedule_timeout_interruptible(1);
                        if (signal_pending(current))
                                break;
                }
@@ -2170,10 +2158,8 @@ static int ixj_release(struct inode *inode, struct file *file_p)
         *    Set up locks to ensure that only one process is talking to the DSP at a time.
         *    This is necessary to keep the DSP from locking up.
         */
-       while(test_and_set_bit(board, (void *)&j->busyflags) != 0) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(1);
-       }
+       while(test_and_set_bit(board, (void *)&j->busyflags) != 0)
+               schedule_timeout_interruptible(1);
        if (ixjdebug & 0x0002)
                printk(KERN_INFO "Closing board %d\n", NUM(inode));
 
@@ -2343,7 +2329,6 @@ static int ixj_release(struct inode *inode, struct file *file_p)
        j->rec_codec = j->play_codec = 0;
        j->rec_frame_size = j->play_frame_size = 0;
        j->flags.cidsent = j->flags.cidring = 0;
-       ixj_fasync(-1, file_p, 0);      /* remove from list of async notification */
 
        if(j->cardtype == QTI_LINEJACK && !j->readers && !j->writers) {
                ixj_set_port(j, PORT_PSTN);
@@ -2760,7 +2745,7 @@ static void alaw2ulaw(unsigned char *buff, unsigned long len)
 static ssize_t ixj_read(struct file * file_p, char __user *buf, size_t length, loff_t * ppos)
 {
        unsigned long i = *ppos;
-       IXJ * j = get_ixj(NUM(file_p->f_dentry->d_inode));
+       IXJ * j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
 
        DECLARE_WAITQUEUE(wait, current);
 
@@ -2817,7 +2802,7 @@ static ssize_t ixj_enhanced_read(struct file * file_p, char __user *buf, size_t
 {
        int pre_retval;
        ssize_t read_retval = 0;
-       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
+       IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
 
        pre_retval = ixj_PreRead(j, 0L);
        switch (pre_retval) {
@@ -2896,7 +2881,7 @@ static ssize_t ixj_enhanced_write(struct file * file_p, const char __user *buf,
        int pre_retval;
        ssize_t write_retval = 0;
 
-       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
+       IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
 
        pre_retval = ixj_PreWrite(j, 0L);
        switch (pre_retval) {
@@ -3303,14 +3288,10 @@ static void ixj_write_cidcw(IXJ *j)
        ixj_play_tone(j, 23);
 
        clear_bit(j->board, &j->busyflags);
-       while(j->tone_state) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(1);
-       }
-       while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(1);
-       }
+       while(j->tone_state)
+               schedule_timeout_interruptible(1);
+       while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0)
+               schedule_timeout_interruptible(1);
        if(ixjdebug & 0x0200) {
                printk("IXJ cidcw phone%d first tone end at %ld\n", j->board, jiffies);
        }
@@ -3330,14 +3311,10 @@ static void ixj_write_cidcw(IXJ *j)
        ixj_play_tone(j, 24);
 
        clear_bit(j->board, &j->busyflags);
-       while(j->tone_state) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(1);
-       }
-       while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(1);
-       }
+       while(j->tone_state)
+               schedule_timeout_interruptible(1);
+       while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0)
+               schedule_timeout_interruptible(1);
        if(ixjdebug & 0x0200) {
                printk("IXJ cidcw phone%d sent second tone at %ld\n", j->board, jiffies);
        }
@@ -3345,14 +3322,10 @@ static void ixj_write_cidcw(IXJ *j)
        j->cidcw_wait = jiffies + ((50 * hertz) / 100);
 
        clear_bit(j->board, &j->busyflags);
-       while(!j->flags.cidcw_ack && time_before(jiffies, j->cidcw_wait)) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(1);
-       }
-       while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(1);
-       }
+       while(!j->flags.cidcw_ack && time_before(jiffies, j->cidcw_wait))
+               schedule_timeout_interruptible(1);
+       while(test_and_set_bit(j->board, (void *)&j->busyflags) != 0)
+               schedule_timeout_interruptible(1);
        j->cidcw_wait = 0;
        if(!j->flags.cidcw_ack) {
                if(ixjdebug & 0x0200) {
@@ -3478,7 +3451,6 @@ static void ixj_write_frame(IXJ *j)
 {
        int cnt, frame_count, dly;
        IXJ_WORD dat;
-       BYTES blankword;
 
        frame_count = 0;
        if(j->flags.cidplay) {
@@ -3526,6 +3498,8 @@ static void ixj_write_frame(IXJ *j)
                }
                if (frame_count >= 1) {
                        if (j->ver.low == 0x12 && j->play_mode && j->flags.play_first_frame) {
+                               BYTES blankword;
+
                                switch (j->play_mode) {
                                case PLAYBACK_MODE_ULAW:
                                case PLAYBACK_MODE_ALAW:
@@ -3533,6 +3507,7 @@ static void ixj_write_frame(IXJ *j)
                                        break;
                                case PLAYBACK_MODE_8LINEAR:
                                case PLAYBACK_MODE_16LINEAR:
+                               default:
                                        blankword.low = blankword.high = 0x00;
                                        break;
                                case PLAYBACK_MODE_8LINEAR_WSS:
@@ -3556,6 +3531,8 @@ static void ixj_write_frame(IXJ *j)
                                j->flags.play_first_frame = 0;
                        } else  if (j->play_codec == G723_63 && j->flags.play_first_frame) {
                                for (cnt = 0; cnt < 24; cnt++) {
+                                       BYTES blankword;
+
                                        if(cnt == 12) {
                                                blankword.low = 0x02;
                                                blankword.high = 0x00;
@@ -3591,10 +3568,16 @@ static void ixj_write_frame(IXJ *j)
                                }
                        /* Add word 0 to G.729 frames for the 8021.  Right now we don't do VAD/CNG  */
                                if (j->play_codec == G729 && (cnt == 0 || cnt == 10 || cnt == 20)) {
-                                       if(j->write_buffer_rp + cnt == 0 && j->write_buffer_rp + cnt + 1 == 0 && j->write_buffer_rp + cnt + 2 == 0 &&
-                                          j->write_buffer_rp + cnt + 3 == 0 && j->write_buffer_rp + cnt + 4 == 0 && j->write_buffer_rp + cnt + 5 == 0 &&
-                                          j->write_buffer_rp + cnt + 6 == 0 && j->write_buffer_rp + cnt + 7 == 0 && j->write_buffer_rp + cnt + 8 == 0 &&
-                                          j->write_buffer_rp + cnt + 9 == 0) {
+                                       if (j->write_buffer_rp[cnt] == 0 &&
+                                           j->write_buffer_rp[cnt + 1] == 0 &&
+                                           j->write_buffer_rp[cnt + 2] == 0 &&
+                                           j->write_buffer_rp[cnt + 3] == 0 &&
+                                           j->write_buffer_rp[cnt + 4] == 0 &&
+                                           j->write_buffer_rp[cnt + 5] == 0 &&
+                                           j->write_buffer_rp[cnt + 6] == 0 &&
+                                           j->write_buffer_rp[cnt + 7] == 0 &&
+                                           j->write_buffer_rp[cnt + 8] == 0 &&
+                                           j->write_buffer_rp[cnt + 9] == 0) {
                                        /* someone is trying to write silence lets make this a type 0 frame. */
                                                outb_p(0x00, j->DSPbase + 0x0C);
                                                outb_p(0x00, j->DSPbase + 0x0D);
@@ -3867,13 +3850,11 @@ static int set_rec_codec(IXJ *j, int rate)
                j->rec_mode = 7;
                break;
        default:
+               kfree(j->read_buffer);
                j->rec_frame_size = 0;
                j->rec_mode = -1;
-               if (j->read_buffer) {
-                       kfree(j->read_buffer);
-                       j->read_buffer = NULL;
-                       j->read_buffer_size = 0;
-               }
+               j->read_buffer = NULL;
+               j->read_buffer_size = 0;
                retval = 1;
                break;
        }
@@ -3991,14 +3972,12 @@ static int ixj_record_start(IXJ *j)
 
 static void ixj_record_stop(IXJ *j)
 {
-       if(ixjdebug & 0x0002)
+       if (ixjdebug & 0x0002)
                printk("IXJ %d Stopping Record Codec %d at %ld\n", j->board, j->rec_codec, jiffies);
 
-       if (j->read_buffer) {
-               kfree(j->read_buffer);
-               j->read_buffer = NULL;
-               j->read_buffer_size = 0;
-       }
+       kfree(j->read_buffer);
+       j->read_buffer = NULL;
+       j->read_buffer_size = 0;
        if (j->rec_mode > -1) {
                ixj_WriteDSPCommand(0x5120, j);
                j->rec_mode = -1;
@@ -4449,13 +4428,11 @@ static int set_play_codec(IXJ *j, int rate)
                j->play_mode = 5;
                break;
        default:
+               kfree(j->write_buffer);
                j->play_frame_size = 0;
                j->play_mode = -1;
-               if (j->write_buffer) {
-                       kfree(j->write_buffer);
-                       j->write_buffer = NULL;
-                       j->write_buffer_size = 0;
-               }
+               j->write_buffer = NULL;
+               j->write_buffer_size = 0;
                retval = 1;
                break;
        }
@@ -4578,14 +4555,12 @@ static int ixj_play_start(IXJ *j)
 
 static void ixj_play_stop(IXJ *j)
 {
-       if(ixjdebug & 0x0002)
+       if (ixjdebug & 0x0002)
                printk("IXJ %d Stopping Play Codec %d at %ld\n", j->board, j->play_codec, jiffies);
 
-       if (j->write_buffer) {
-               kfree(j->write_buffer);
-               j->write_buffer = NULL;
-               j->write_buffer_size = 0;
-       }
+       kfree(j->write_buffer);
+       j->write_buffer = NULL;
+       j->write_buffer_size = 0;
        if (j->play_mode > -1) {
                ixj_WriteDSPCommand(0x5221, j); /* Stop playback and flush buffers.  8022 reference page 9-40 */
 
@@ -4609,7 +4584,7 @@ static unsigned int ixj_poll(struct file *file_p, poll_table * wait)
 {
        unsigned int mask = 0;
 
-       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
+       IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
 
        poll_wait(file_p, &(j->poll_q), wait);
        if (j->read_buffer_ready > 0)
@@ -4895,6 +4870,7 @@ static char daa_CR_read(IXJ *j, int cr)
                bytes.high = 0xB0 + cr;
                break;
        case SOP_PU_PULSEDIALING:
+       default:
                bytes.high = 0xF0 + cr;
                break;
        }
@@ -4996,7 +4972,8 @@ static int ixj_daa_cid_read(IXJ *j)
 {
        int i;
        BYTES bytes;
-       char CID[ALISDAA_CALLERID_SIZE], mContinue;
+       char CID[ALISDAA_CALLERID_SIZE];
+       bool mContinue;
        char *pIn, *pOut;
 
        if (!SCI_Prepare(j))
@@ -5040,7 +5017,7 @@ static int ixj_daa_cid_read(IXJ *j)
 
        pIn = CID;
        pOut = j->m_DAAShadowRegs.CAO_REGS.CAO.CallerID;
-       mContinue = 1;
+       mContinue = true;
        while (mContinue) {
                if ((pIn[1] & 0x03) == 0x01) {
                        pOut[0] = pIn[0];
@@ -5054,7 +5031,7 @@ static int ixj_daa_cid_read(IXJ *j)
                if ((pIn[4] & 0xc0) == 0x40) {
                        pOut[3] = ((pIn[4] & 0x3f) << 2) | ((pIn[3] & 0xc0) >> 6);
                } else {
-                       mContinue = FALSE;
+                       mContinue = false;
                }
                pIn += 5, pOut += 4;
        }
@@ -5747,7 +5724,7 @@ static int ixj_daa_write(IXJ *j)
        return 1;
 }
 
-int ixj_set_tone_off(unsigned short arg, IXJ *j)
+static int ixj_set_tone_off(unsigned short arg, IXJ *j)
 {
        j->tone_off_time = arg;
        if (ixj_WriteDSPCommand(0x6E05, j))             /* Set Tone Off Period */
@@ -5810,9 +5787,7 @@ static void ixj_cpt_stop(IXJ *j)
                ixj_play_tone(j, 0);
                j->tone_state = j->tone_cadence_state = 0;
                if (j->cadence_t) {
-                       if (j->cadence_t->ce) {
-                               kfree(j->cadence_t->ce);
-                       }
+                       kfree(j->cadence_t->ce);
                        kfree(j->cadence_t);
                        j->cadence_t = NULL;
                }
@@ -6118,15 +6093,15 @@ static int capabilities_check(IXJ *j, struct phone_capability *pcreq)
        return retval;
 }
 
-static int ixj_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd, unsigned long arg)
+static long do_ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long arg)
 {
        IXJ_TONE ti;
        IXJ_FILTER jf;
        IXJ_FILTER_RAW jfr;
        void __user *argp = (void __user *)arg;
-
-       unsigned int raise, mant;
+       struct inode *inode = file_p->f_path.dentry->d_inode;
        unsigned int minor = iminor(inode);
+       unsigned int raise, mant;
        int board = NUM(inode);
 
        IXJ *j = get_ixj(NUM(inode));
@@ -6137,10 +6112,8 @@ static int ixj_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd,
         *    Set up locks to ensure that only one process is talking to the DSP at a time.
         *    This is necessary to keep the DSP from locking up.
         */
-       while(test_and_set_bit(board, (void *)&j->busyflags) != 0) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(1);
-       }
+       while(test_and_set_bit(board, (void *)&j->busyflags) != 0)
+               schedule_timeout_interruptible(1);
        if (ixjdebug & 0x0040)
                printk("phone%d ioctl, cmd: 0x%x, arg: 0x%lx\n", minor, cmd, arg);
        if (minor >= IXJMAX) {
@@ -6686,28 +6659,35 @@ static int ixj_ioctl(struct inode *inode, struct file *file_p, unsigned int cmd,
        return retval;
 }
 
+static long ixj_ioctl(struct file *file_p, unsigned int cmd, unsigned long arg)
+{
+       long ret;
+       lock_kernel();
+       ret = do_ixj_ioctl(file_p, cmd, arg);
+       unlock_kernel();
+       return ret;
+}
+
 static int ixj_fasync(int fd, struct file *file_p, int mode)
 {
-       IXJ *j = get_ixj(NUM(file_p->f_dentry->d_inode));
+       IXJ *j = get_ixj(NUM(file_p->f_path.dentry->d_inode));
 
        return fasync_helper(fd, file_p, mode, &j->async_queue);
 }
 
-static struct file_operations ixj_fops =
+static const struct file_operations ixj_fops =
 {
         .owner          = THIS_MODULE,
         .read           = ixj_enhanced_read,
         .write          = ixj_enhanced_write,
         .poll           = ixj_poll,
-        .ioctl          = ixj_ioctl,
+        .unlocked_ioctl = ixj_ioctl,
         .release        = ixj_release,
         .fasync         = ixj_fasync
 };
 
 static int ixj_linetest(IXJ *j)
 {
-       unsigned long jifwait;
-
        j->flags.pstncheck = 1; /* Testing */
        j->flags.pstn_present = 0; /* Assume the line is not there */
 
@@ -6738,11 +6718,7 @@ static int ixj_linetest(IXJ *j)
 
                outb_p(j->pld_scrw.byte, j->XILINXbase);
                daa_set_mode(j, SOP_PU_CONVERSATION);
-               jifwait = jiffies + hertz;
-               while (time_before(jiffies, jifwait)) {
-                       set_current_state(TASK_INTERRUPTIBLE);
-                       schedule_timeout(1);
-               }
+               msleep(1000);
                daa_int_read(j);
                daa_set_mode(j, SOP_PU_RESET);
                if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) {
@@ -6762,11 +6738,7 @@ static int ixj_linetest(IXJ *j)
        j->pld_slicw.bits.rly3 = 0;
        outb_p(j->pld_slicw.byte, j->XILINXbase + 0x01);
        daa_set_mode(j, SOP_PU_CONVERSATION);
-       jifwait = jiffies + hertz;
-       while (time_before(jiffies, jifwait)) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(1);
-       }
+       msleep(1000);
        daa_int_read(j);
        daa_set_mode(j, SOP_PU_RESET);
        if (j->m_DAAShadowRegs.XOP_REGS.XOP.xr0.bitreg.VDD_OK) {
@@ -6795,7 +6767,6 @@ static int ixj_linetest(IXJ *j)
 static int ixj_selfprobe(IXJ *j)
 {
        unsigned short cmd;
-       unsigned long jif;
        int cnt;
        BYTES bytes;
 
@@ -6945,29 +6916,13 @@ static int ixj_selfprobe(IXJ *j)
        } else {
                if (j->cardtype == QTI_LINEJACK) {
                        LED_SetState(0x1, j);
-                       jif = jiffies + (hertz / 10);
-                       while (time_before(jiffies, jif)) {
-                               set_current_state(TASK_INTERRUPTIBLE);
-                               schedule_timeout(1);
-                       }
+                       msleep(100);
                        LED_SetState(0x2, j);
-                       jif = jiffies + (hertz / 10);
-                       while (time_before(jiffies, jif)) {
-                               set_current_state(TASK_INTERRUPTIBLE);
-                               schedule_timeout(1);
-                       }
+                       msleep(100);
                        LED_SetState(0x4, j);
-                       jif = jiffies + (hertz / 10);
-                       while (time_before(jiffies, jif)) {
-                               set_current_state(TASK_INTERRUPTIBLE);
-                               schedule_timeout(1);
-                       }
+                       msleep(100);
                        LED_SetState(0x8, j);
-                       jif = jiffies + (hertz / 10);
-                       while (time_before(jiffies, jif)) {
-                               set_current_state(TASK_INTERRUPTIBLE);
-                               schedule_timeout(1);
-                       }
+                       msleep(100);
                        LED_SetState(0x0, j);
                        daa_get_version(j);
                        if (ixjdebug & 0x0002)
@@ -7497,10 +7452,8 @@ static void cleanup(void)
                                        printk(KERN_INFO "IXJ: Releasing XILINX address for /dev/phone%d\n", cnt);
                                release_region(j->XILINXbase, 4);
                        }
-                       if (j->read_buffer)
-                               kfree(j->read_buffer);
-                       if (j->write_buffer)
-                               kfree(j->write_buffer);
+                       kfree(j->read_buffer);
+                       kfree(j->write_buffer);
                        if (j->dev)
                                pnp_device_detach(j->dev);
                        if (ixjdebug & 0x0002)
@@ -7558,7 +7511,7 @@ static BYTE PCIEE_ReadBit(WORD wEEPROMAddress, BYTE lastLCC)
        return ((inb(wEEPROMAddress) >> 3) & 1);
 }
 
-static BOOL PCIEE_ReadWord(WORD wAddress, WORD wLoc, WORD * pwResult)
+static bool PCIEE_ReadWord(WORD wAddress, WORD wLoc, WORD * pwResult)
 {
        BYTE lastLCC;
        WORD wEEPROMAddress = wAddress + 3;
@@ -7751,7 +7704,8 @@ static int __init ixj_probe_pci(int *cnt)
        IXJ *j = NULL;
 
        for (i = 0; i < IXJMAX - *cnt; i++) {
-               pci = pci_find_device(0x15E2, 0x0500, pci);
+               pci = pci_get_device(PCI_VENDOR_ID_QUICKNET,
+                                     PCI_DEVICE_ID_QUICKNET_XJ, pci);
                if (!pci)
                        break;
 
@@ -7770,6 +7724,7 @@ static int __init ixj_probe_pci(int *cnt)
                        printk(KERN_INFO "ixj: found Internet PhoneJACK PCI at 0x%x\n", j->DSPbase);
                ++*cnt;
        }
+       pci_dev_put(pci);
        return probe;
 }