Skip to content

Commit

Permalink
Staging: aten2011: fix up sparse warnings
Browse files Browse the repository at this point in the history
This resolves all of the sparse warnings.


Cc: Russell Lang <gsview@ghostgum.com.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Greg Kroah-Hartman committed Apr 3, 2009
1 parent a7fefd1 commit 907aff4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 29 deletions.
1 change: 0 additions & 1 deletion drivers/staging/uc2322/TODO
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
TODO:
- checkpatch.pl cleanups
- sparse cleanups
- remove dead and useless code (auditing the tty ioctls to
verify that they really are correct and needed.)

Expand Down
46 changes: 18 additions & 28 deletions drivers/staging/uc2322/aten2011.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ static int debug = 0;
#define ATEN_CTRL_TIMEOUT 500
#define VENDOR_READ_LENGTH (0x01)

int RS485mode = 0; //set to 1 for RS485 mode and 0 for RS232 mode
/* set to 1 for RS485 mode and 0 for RS232 mode */
/* FIXME make this somehow dynamic and not build time specific */
static int RS485mode = 0;

static struct usb_serial *ATEN2011_get_usb_serial(struct usb_serial_port *port, const
char *function);
Expand Down Expand Up @@ -1519,7 +1521,6 @@ static int ATEN2011_write(struct tty_struct *tty, struct usb_serial_port *port,
int i;
int bytes_sent = 0;
int transfer_size;
int from_user = 0;
int minor;

struct ATENINTL_port *ATEN2011_port;
Expand Down Expand Up @@ -1581,15 +1582,7 @@ static int ATEN2011_write(struct tty_struct *tty, struct usb_serial_port *port,
}
transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE);

if (from_user) {
if (copy_from_user
(urb->transfer_buffer, current_position, transfer_size)) {
bytes_sent = -EFAULT;
goto exit;
}
} else {
memcpy(urb->transfer_buffer, current_position, transfer_size);
}
memcpy(urb->transfer_buffer, current_position, transfer_size);
//usb_serial_debug_data (__FILE__, __FUNCTION__, transfer_size, urb->transfer_buffer);

/* fill urb with data and submit */
Expand Down Expand Up @@ -1906,7 +1899,7 @@ static void ATEN2011_set_termios(struct tty_struct *tty,

static int get_lsr_info(struct tty_struct *tty,
struct ATENINTL_port *ATEN2011_port,
unsigned int *value)
unsigned int __user *value)
{
int count;
unsigned int result = 0;
Expand All @@ -1924,7 +1917,7 @@ static int get_lsr_info(struct tty_struct *tty,

static int get_number_bytes_avail(struct tty_struct *tty,
struct ATENINTL_port *ATEN2011_port,
unsigned int *value)
unsigned int __user *value)
{
unsigned int result = 0;

Expand All @@ -1941,7 +1934,7 @@ static int get_number_bytes_avail(struct tty_struct *tty,
}

static int set_modem_info(struct ATENINTL_port *ATEN2011_port, unsigned int cmd,
unsigned int *value)
unsigned int __user *value)
{
unsigned int mcr;
unsigned int arg;
Expand Down Expand Up @@ -2006,7 +1999,7 @@ static int set_modem_info(struct ATENINTL_port *ATEN2011_port, unsigned int cmd,
}

static int get_modem_info(struct ATENINTL_port *ATEN2011_port,
unsigned int *value)
unsigned int __user *value)
{
unsigned int result = 0;
__u16 msr;
Expand All @@ -2030,7 +2023,7 @@ static int get_modem_info(struct ATENINTL_port *ATEN2011_port,
}

static int get_serial_info(struct ATENINTL_port *ATEN2011_port,
struct serial_struct *retinfo)
struct serial_struct __user *retinfo)
{
struct serial_struct tmp;

Expand Down Expand Up @@ -2068,8 +2061,7 @@ static int ATEN2011_ioctl(struct tty_struct *tty, struct file *file,
struct async_icount cprev;
struct serial_icounter_struct icount;
int ATENret = 0;
//int retval;
//struct tty_ldisc *ld;
unsigned int __user *user_arg = (unsigned int __user *)arg;

//printk("%s - port %d, cmd = 0x%x\n", __FUNCTION__, port->number, cmd);
if (ATEN2011_port_paranoia_check(port, __FUNCTION__)) {
Expand All @@ -2089,19 +2081,17 @@ static int ATEN2011_ioctl(struct tty_struct *tty, struct file *file,

case TIOCINQ:
dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number);
return get_number_bytes_avail(tty, ATEN2011_port,
(unsigned int *)arg);
return get_number_bytes_avail(tty, ATEN2011_port, user_arg);
break;

case TIOCOUTQ:
dbg("%s (%d) TIOCOUTQ", __FUNCTION__, port->number);
return put_user(ATEN2011_chars_in_buffer(tty),
(int __user *)arg);
return put_user(ATEN2011_chars_in_buffer(tty), user_arg);
break;

case TIOCSERGETLSR:
dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number);
return get_lsr_info(tty, ATEN2011_port, (unsigned int *)arg);
return get_lsr_info(tty, ATEN2011_port, user_arg);
return 0;

case TIOCMBIS:
Expand All @@ -2111,18 +2101,18 @@ static int ATEN2011_ioctl(struct tty_struct *tty, struct file *file,
port->number);
// printk("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__, port->number);
ATENret =
set_modem_info(ATEN2011_port, cmd, (unsigned int *)arg);
set_modem_info(ATEN2011_port, cmd, user_arg);
// printk(" %s: ret:%d\n",__FUNCTION__,ATENret);
return ATENret;

case TIOCMGET:
dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number);
return get_modem_info(ATEN2011_port, (unsigned int *)arg);
return get_modem_info(ATEN2011_port, user_arg);

case TIOCGSERIAL:
dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number);
return get_serial_info(ATEN2011_port,
(struct serial_struct *)arg);
(struct serial_struct __user *)arg);

case TIOCSSERIAL:
dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number);
Expand Down Expand Up @@ -2170,7 +2160,7 @@ static int ATEN2011_ioctl(struct tty_struct *tty, struct file *file,

dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__,
port->number, icount.rx, icount.tx);
if (copy_to_user((void *)arg, &icount, sizeof(icount)))
if (copy_to_user((void __user *)arg, &icount, sizeof(icount)))
return -EFAULT;
return 0;

Expand Down Expand Up @@ -2829,7 +2819,7 @@ static int ATEN2011_startup(struct usb_serial *serial)

/* setting configuration feature to one */
usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
(__u8) 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 5 * HZ);
(__u8) 0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5 * HZ);
return 0;
}

Expand Down

0 comments on commit 907aff4

Please sign in to comment.