Hi Pete, > First, please use existing spacing. I'm not kidding. Here is what I changed:
1) I added spaces after my if statements and before the ( 2) changed the whitespace before "int type" from spaces to a tab, inside the usb_serial_post_job struct 3) removed a space after the struct usb_serial_post_job declaration I am not sure what to do with the spacing between function names and the ( for function declarations, some existing functions seem to use a space and others do not. I do not think there are any other spacing issues with the patch. If there are, please let me know where my mistake is and I will fix it. I read the SubmittingPatches and CodingStyle documents again, so hopefully this covers it all. > Second, make sure that usb_serial_post_job stays below 128 > bytes in size. Move the type down a line, where it uses less > space on 64-bitters. Done. I also took 8 bytes off of the POST_BSIZE to account for the extra int (assuming int's are 8 bytes on 64 bit CPUs). --Sam Signed-off-by: Sam King <[EMAIL PROTECTED]> --- drivers/usb/serial/usbserial.orig 2004-09-28 10:21:54.000000000 -0400 +++ drivers/usb/serial/usbserial.c 2004-09-28 16:40:31.000000000 -0400 @@ -350,10 +350,13 @@ /* * The post kludge structures and variables. */ -#define POST_BSIZE 100 /* little below 128 in total */ +#define POST_JOB_WRITE 0 +#define POST_JOB_THROTTLE 1 +#define POST_BSIZE 92 /* little below 128 in total */ struct usb_serial_post_job { struct list_head link; struct usb_serial_port *port; + int type; int len; char buff[POST_BSIZE]; }; @@ -367,11 +370,12 @@ static int __serial_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count); static int serial_write (struct tty_struct * tty, int from_user, const unsigned char *buf, int count); static int serial_post_job(struct usb_serial_port *port, int from_user, - int gfp, const unsigned char *buf, int count); + int gfp, const unsigned char *buf, int count, int type); static int serial_post_one(struct usb_serial_port *port, int from_user, - int gfp, const unsigned char *buf, int count); + int gfp, const unsigned char *buf, int count, int type); static int serial_write_room (struct tty_struct *tty); static int serial_chars_in_buffer (struct tty_struct *tty); +static void __serial_throttle (struct tty_struct * tty); static void serial_throttle (struct tty_struct * tty); static void serial_unthrottle (struct tty_struct * tty); static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned int cmd, unsigned long arg); @@ -497,21 +501,30 @@ port = job->port; /* get_usb_serial checks port->tty, so cannot be used */ serial = port->serial; - if (port->write_busy) { - dbg("%s - port %d busy", __FUNCTION__, port->number); - pos = pos->next; - continue; + if (job->type == POST_JOB_WRITE) { + if (port->write_busy) { + dbg("%s - port %d busy", __FUNCTION__, port->number); + pos = pos->next; + continue; + } } list_del(&job->link); spin_unlock_irqrestore(&post_lock, flags); down(&port->sem); - dbg("%s - port %d len %d backlog %d", __FUNCTION__, - port->number, job->len, port->write_backlog); - if (port->tty != NULL) - __serial_write(port, 0, job->buff, job->len); + if (job->type == POST_JOB_WRITE) { + dbg("%s - port %d len %d backlog %d", __FUNCTION__, + port->number, job->len, port->write_backlog); + if (port->tty != NULL) + __serial_write(port, 0, job->buff, job->len); + } else if (job->type == POST_JOB_THROTTLE) { + if (port->tty != NULL) + __serial_throttle(port->tty); + } else { + BUG(); + } up(&port->sem); - + spin_lock_irqsave(&post_lock, flags); port->write_backlog -= job->len; kfree(job); @@ -722,7 +735,7 @@ if (port->write_busy) { up(&port->sem); return serial_post_job(port, from_user, GFP_KERNEL, - buf, count); + buf, count, POST_JOB_WRITE); } rc = __serial_write(port, from_user, buf, count); @@ -740,11 +753,12 @@ return -EINVAL; } - return serial_post_job(port, 0, GFP_ATOMIC, buf, count); + return serial_post_job(port, 0, GFP_ATOMIC, buf, count, + POST_JOB_WRITE); } static int serial_post_job(struct usb_serial_port *port, int from_user, - int gfp, const unsigned char *buf, int count) + int gfp, const unsigned char *buf, int count, int type) { int done = 0, length; int rc; @@ -767,27 +781,34 @@ count = 512; } - while (done < count) { - length = count - done; - if (length > POST_BSIZE) - length = POST_BSIZE; - if (length > port->bulk_out_size) - length = port->bulk_out_size; - - rc = serial_post_one(port, from_user, gfp, buf + done, length); - if (rc <= 0) { - if (done != 0) - return done; - return rc; + if (type == POST_JOB_WRITE) { + while (done < count) { + length = count - done; + if (length > POST_BSIZE) + length = POST_BSIZE; + if (length > port->bulk_out_size) + length = port->bulk_out_size; + + rc = serial_post_one(port, from_user, gfp, buf + done, + length, type); + if (rc <= 0) { + if (done != 0) + return done; + return rc; + } + done += rc; } - done += rc; + } else if (type == POST_JOB_THROTTLE) { + serial_post_one(port, from_user, gfp, buf, count, type); + } else { + BUG(); } - + return done; } static int serial_post_one(struct usb_serial_port *port, int from_user, - int gfp, const unsigned char *buf, int count) + int gfp, const unsigned char *buf, int count, int type) { struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); struct usb_serial_post_job *job; @@ -803,14 +824,17 @@ if (count >= POST_BSIZE) count = POST_BSIZE; job->len = count; + job->type = type; - if (from_user) { - if (copy_from_user(job->buff, buf, count)) { - kfree(job); - return -EFAULT; + if (type == POST_JOB_WRITE) { + if (from_user) { + if (copy_from_user(job->buff, buf, count)) { + kfree(job); + return -EFAULT; + } + } else { + memcpy(job->buff, buf, count); } - } else { - memcpy(job->buff, buf, count); } spin_lock_irqsave(&post_lock, flags); @@ -895,21 +919,36 @@ if (!serial) return; - down (&port->sem); + if (!in_interrupt()) { + post_helper(NULL); + + down(&port->sem); + __serial_throttle(tty); + up (&port->sem); + return; + } + + serial_post_job(port, 0, GFP_ATOMIC, NULL, 0, POST_JOB_THROTTLE); +} + +static void __serial_throttle (struct tty_struct * tty) +{ + struct usb_serial_port *port = (struct usb_serial_port *) tty->driver_data; + struct usb_serial *serial = get_usb_serial (port, __FUNCTION__); + + if (!serial) + return; dbg("%s - port %d", __FUNCTION__, port->number); if (!port->open_count) { dbg ("%s - port not open", __FUNCTION__); - goto exit; + return; } /* pass on to the driver specific version of this function */ if (serial->type->throttle) serial->type->throttle(port); - -exit: - up (&port->sem); } static void serial_unthrottle (struct tty_struct * tty) ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel