fix integer overflow with mite_bytes_transferred()
authorFrank Mori Hess <fmhess@speakeasy.net>
Sun, 7 Jul 2002 05:54:07 +0000 (05:54 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Sun, 7 Jul 2002 05:54:07 +0000 (05:54 +0000)
comedi/drivers/mite.c
comedi/drivers/mite.h
comedi/drivers/ni_mio_common.c

index a3447dcff19104337c31ee844cec5501285276f3..0d48eaf920552eccc5e515bcbc41d5eb7257909a 100644 (file)
@@ -481,10 +481,10 @@ void mite_prep_dma(struct mite_struct *mite)
 }
 
 
-int mite_bytes_transferred(struct mite_struct *mite, int chan)
+unsigned int mite_bytes_transferred(struct mite_struct *mite, int chan)
 {
-       int dar, fcr;
-       
+       unsigned int dar, fcr;
+
        dar = readl(mite->mite_io_addr+MITE_DAR+CHAN_OFFSET(chan));
        fcr = readl(mite->mite_io_addr+MITE_FCR+CHAN_OFFSET(chan)) & 0x000000FF;
        return dar-fcr;
index e3605b6677467f3e5a8362f9ad7f65d747105138..524004fe0c7e1ce8fab2448ec99d98960e4fb92c 100644 (file)
@@ -92,7 +92,7 @@ void mite_list_devices(void);
 int mite_dma_tcr(struct mite_struct *mite);
 void mite_dma_arm(struct mite_struct *mite);
 void mite_dma_disarm(struct mite_struct *mite);
-int mite_bytes_transferred(struct mite_struct *mite, int chan);
+unsigned int mite_bytes_transferred(struct mite_struct *mite, int chan);
 
 #if 0
 unsigned long mite_ll_from_kvmem(struct mite_struct *mite,comedi_async *async,int len);
index 4e101b6f74488ce9625fc015c38c7881cbefa9f8..312f73569c7104ae7c656db82c123c194c141dd2 100644 (file)
@@ -346,7 +346,7 @@ static void ni_E_interrupt(int irq,void *d,struct pt_regs * regs)
 #ifdef PCIDMA
 static void mite_handle_a_linkc(struct mite_struct *mite, comedi_device *dev)
 {
-       int count;
+       unsigned int count;
        comedi_subdevice *s = dev->subdevices + 0;
        comedi_async *async = s->async;
 
@@ -357,6 +357,8 @@ static void mite_handle_a_linkc(struct mite_struct *mite, comedi_device *dev)
                printk("BUG: too many samples in interrupt (%d)\n",count);
                return;
        }
+       // XXX buf_dirty_count should really be incremented earlier...
+       async->buf_dirty_count += count;
        async->buf_write_count += count;
 
        if(async->cmd.flags & CMDF_RAWDATA){