X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fchar%2Fip2main.c;h=d5c18535bbfae4a7a133bc73ab2bc90e97f3667d;hb=7b563c525e46f373a521421e31aa791cc27beb56;hp=ac97e617a10783f5a6b3b8f01474b56d59fc56fa;hpb=a91482bdcc2e0f6035702e46f1b99043a0893346;p=linux-2.6.git diff --git a/drivers/char/ip2main.c b/drivers/char/ip2main.c index ac97e617a..d5c18535b 100644 --- a/drivers/char/ip2main.c +++ b/drivers/char/ip2main.c @@ -203,16 +203,16 @@ static void ip2_wait_until_sent(PTTY,int); static void set_params (i2ChanStrPtr, struct termios *); static int set_modem_info(i2ChanStrPtr, unsigned int, unsigned int *); -static int get_serial_info(i2ChanStrPtr, struct serial_struct __user *); -static int set_serial_info(i2ChanStrPtr, struct serial_struct __user *); +static int get_serial_info(i2ChanStrPtr, struct serial_struct *); +static int set_serial_info(i2ChanStrPtr, struct serial_struct *); -static ssize_t ip2_ipl_read(struct file *, char __user *, size_t, loff_t *); -static ssize_t ip2_ipl_write(struct file *, const char __user *, size_t, loff_t *); +static ssize_t ip2_ipl_read(struct file *, char *, size_t, loff_t *); +static ssize_t ip2_ipl_write(struct file *, const char *, size_t, loff_t *); static int ip2_ipl_ioctl(struct inode *, struct file *, UINT, ULONG); static int ip2_ipl_open(struct inode *, struct file *); -static int DumpTraceBuffer(char __user *, int); -static int DumpFifoBuffer( char __user *, int); +static int DumpTraceBuffer(char *, int); +static int DumpFifoBuffer( char *, int); static void ip2_init_board(int); static unsigned short find_eisa_board(int); @@ -1121,7 +1121,7 @@ set_irq( int boardnum, int boardIrq ) /******************************************************************************/ static inline void -service_all_boards(void) +service_all_boards() { int i; i2eBordStrPtr pB; @@ -2082,10 +2082,9 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) wait_queue_t wait; i2ChanStrPtr pCh = DevTable[tty->index]; struct async_icount cprev, cnow; /* kernel counter temps */ - struct serial_icounter_struct __user *p_cuser; + struct serial_icounter_struct *p_cuser; /* user space */ int rc = 0; unsigned long flags; - void __user *argp = (void __user *)arg; if ( pCh == NULL ) { return -ENODEV; @@ -2102,7 +2101,7 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) ip2trace (CHANN, ITRC_IOCTL, 2, 1, rc ); - rc = get_serial_info(pCh, argp); + rc = get_serial_info(pCh, (struct serial_struct *) arg); if (rc) return rc; break; @@ -2111,7 +2110,7 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) ip2trace (CHANN, ITRC_IOCTL, 3, 1, rc ); - rc = set_serial_info(pCh, argp); + rc = set_serial_info(pCh, (struct serial_struct *) arg); if (rc) return rc; break; @@ -2175,7 +2174,7 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) ip2trace (CHANN, ITRC_IOCTL, 6, 1, rc ); - rc = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long __user *)argp); + rc = put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned long *) arg); if (rc) return rc; break; @@ -2184,7 +2183,7 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) ip2trace (CHANN, ITRC_IOCTL, 7, 1, rc ); - rc = get_user(arg,(unsigned long __user *) argp); + rc = get_user(arg,(unsigned long *) arg); if (rc) return rc; tty->termios->c_cflag = ((tty->termios->c_cflag & ~CLOCAL) @@ -2263,7 +2262,7 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) save_flags(flags);cli(); cnow = pCh->icount; restore_flags(flags); - p_cuser = argp; + p_cuser = (struct serial_icounter_struct *) arg; rc = put_user(cnow.cts, &p_cuser->cts); rc = put_user(cnow.dsr, &p_cuser->dsr); rc = put_user(cnow.rng, &p_cuser->rng); @@ -2312,9 +2311,14 @@ ip2_ioctl ( PTTY tty, struct file *pFile, UINT cmd, ULONG arg ) /* standard Linux serial structure. */ /******************************************************************************/ static int -get_serial_info ( i2ChanStrPtr pCh, struct serial_struct __user *retinfo ) +get_serial_info ( i2ChanStrPtr pCh, struct serial_struct *retinfo ) { struct serial_struct tmp; + int rc; + + if ( !retinfo ) { + return -EFAULT; + } memset ( &tmp, 0, sizeof(tmp) ); tmp.type = pCh->pMyBord->channelBtypes.bid_value[(pCh->port_index & (IP2_PORTS_PER_BOARD-1))/16]; @@ -2331,7 +2335,8 @@ get_serial_info ( i2ChanStrPtr pCh, struct serial_struct __user *retinfo ) tmp.close_delay = pCh->ClosingDelay; tmp.closing_wait = pCh->ClosingWaitTime; tmp.custom_divisor = pCh->BaudDivisor; - return copy_to_user(retinfo,&tmp,sizeof(*retinfo)); + rc = copy_to_user(retinfo,&tmp,sizeof(*retinfo)); + return rc; } /******************************************************************************/ @@ -2346,13 +2351,18 @@ get_serial_info ( i2ChanStrPtr pCh, struct serial_struct __user *retinfo ) /* change the IRQ, address or type of the port the ioctl fails. */ /******************************************************************************/ static int -set_serial_info( i2ChanStrPtr pCh, struct serial_struct __user *new_info ) +set_serial_info( i2ChanStrPtr pCh, struct serial_struct *new_info ) { struct serial_struct ns; int old_flags, old_baud_divisor; - if (copy_from_user(&ns, new_info, sizeof (ns))) + if ( !new_info ) { return -EFAULT; + } + + if (copy_from_user(&ns, new_info, sizeof (ns))) { + return -EFAULT; + } /* * We don't allow setserial to change IRQ, board address, type or baud @@ -2717,7 +2727,7 @@ service_it: static ssize_t -ip2_ipl_read(struct file *pFile, char __user *pData, size_t count, loff_t *off ) +ip2_ipl_read(struct file *pFile, char *pData, size_t count, loff_t *off ) { unsigned int minor = iminor(pFile->f_dentry->d_inode); int rc = 0; @@ -2750,7 +2760,7 @@ ip2_ipl_read(struct file *pFile, char __user *pData, size_t count, loff_t *off ) } static int -DumpFifoBuffer ( char __user *pData, int count ) +DumpFifoBuffer ( char *pData, int count ) { #ifdef DEBUG_FIFO int rc; @@ -2764,13 +2774,13 @@ DumpFifoBuffer ( char __user *pData, int count ) } static int -DumpTraceBuffer ( char __user *pData, int count ) +DumpTraceBuffer ( char *pData, int count ) { #ifdef IP2DEBUG_TRACE int rc; int dumpcount; int chunk; - int *pIndex = (int __user *)pData; + int *pIndex = (int*)pData; if ( count < (sizeof(int) * 6) ) { return -EIO; @@ -2826,7 +2836,7 @@ DumpTraceBuffer ( char __user *pData, int count ) /* */ /******************************************************************************/ static ssize_t -ip2_ipl_write(struct file *pFile, const char __user *pData, size_t count, loff_t *off) +ip2_ipl_write(struct file *pFile, const char *pData, size_t count, loff_t *off) { #ifdef IP2DEBUG_IPL printk (KERN_DEBUG "IP2IPL: write %p, %d bytes\n", pData, count ); @@ -2851,8 +2861,7 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg ) { unsigned int iplminor = iminor(pInode); int rc = 0; - void __user *argp = (void __user *)arg; - ULONG __user *pIndex = argp; + ULONG *pIndex = (ULONG*)arg; i2eBordStrPtr pB = i2BoardPtrTable[iplminor / 4]; i2ChanStrPtr pCh; @@ -2877,9 +2886,9 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg ) case 65: /* Board - ip2stat */ if ( pB ) { - rc = copy_to_user(argp, pB, sizeof(i2eBordStr)); + rc = copy_to_user((char*)arg, (char*)pB, sizeof(i2eBordStr) ); rc = put_user(INB(pB->i2eStatus), - (ULONG __user *)(arg + (ULONG)(&pB->i2eStatus) - (ULONG)pB ) ); + (ULONG*)(arg + (ULONG)(&pB->i2eStatus) - (ULONG)pB ) ); } else { rc = -ENODEV; } @@ -2890,7 +2899,7 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg ) pCh = DevTable[cmd]; if ( pCh ) { - rc = copy_to_user(argp, pCh, sizeof(i2ChanStr)); + rc = copy_to_user((char*)arg, (char*)pCh, sizeof(i2ChanStr) ); } else { rc = -ENODEV; }