diff options
Diffstat (limited to 'drivers/staging/dgnc/dgnc_tty.c')
-rw-r--r-- | drivers/staging/dgnc/dgnc_tty.c | 80 |
1 files changed, 29 insertions, 51 deletions
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c index f81a375..ce4187f 100644 --- a/drivers/staging/dgnc/dgnc_tty.c +++ b/drivers/staging/dgnc/dgnc_tty.c @@ -11,21 +11,6 @@ * but WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - * NOTE TO LINUX KERNEL HACKERS: DO NOT REFORMAT THIS CODE! - * - * This is shared code between Digi's CVS archive and the - * Linux Kernel sources. - * Changing the source just for reformatting needlessly breaks - * our CVS diff history. - * - * Send any bug fixes/changes to: Eng.Linux at digi dot com. - * Thank you. */ /************************************************************************ @@ -44,6 +29,7 @@ #include <linux/ctype.h> #include <linux/tty.h> #include <linux/tty_flip.h> +#include <linux/types.h> #include <linux/serial_reg.h> #include <linux/slab.h> #include <linux/delay.h> /* For udelay */ @@ -51,10 +37,8 @@ #include <linux/pci.h> #include "dgnc_driver.h" #include "dgnc_tty.h" -#include "dgnc_types.h" #include "dgnc_neo.h" #include "dgnc_cls.h" -#include "dpacompat.h" #include "dgnc_sysfs.h" #include "dgnc_utils.h" @@ -236,7 +220,7 @@ int dgnc_tty_register(struct dgnc_board *brd) "Can't register tty device (%d)\n", rc); return rc; } - brd->dgnc_Major_Serial_Registered = TRUE; + brd->dgnc_Major_Serial_Registered = true; } /* @@ -286,7 +270,7 @@ int dgnc_tty_register(struct dgnc_board *brd) rc); return rc; } - brd->dgnc_Major_TransparentPrint_Registered = TRUE; + brd->dgnc_Major_TransparentPrint_Registered = true; } dgnc_BoardsByMajor[brd->SerialDriver.major] = brd; @@ -424,7 +408,7 @@ void dgnc_tty_uninit(struct dgnc_board *brd) tty_unregister_device(&brd->SerialDriver, i); } tty_unregister_driver(&brd->SerialDriver); - brd->dgnc_Major_Serial_Registered = FALSE; + brd->dgnc_Major_Serial_Registered = false; } if (brd->dgnc_Major_TransparentPrint_Registered) { @@ -435,7 +419,7 @@ void dgnc_tty_uninit(struct dgnc_board *brd) tty_unregister_device(&brd->PrintDriver, i); } tty_unregister_driver(&brd->PrintDriver); - brd->dgnc_Major_TransparentPrint_Registered = FALSE; + brd->dgnc_Major_TransparentPrint_Registered = false; } kfree(brd->SerialDriver.ttys); @@ -507,7 +491,7 @@ void dgnc_input(struct channel_t *ch) { struct dgnc_board *bd; struct tty_struct *tp; - struct tty_ldisc *ld; + struct tty_ldisc *ld = NULL; uint rmask; ushort head; ushort tail; @@ -539,10 +523,8 @@ void dgnc_input(struct channel_t *ch) tail = ch->ch_r_tail & rmask; data_len = (head - tail) & rmask; - if (data_len == 0) { - spin_unlock_irqrestore(&ch->ch_lock, flags); - return; - } + if (data_len == 0) + goto exit_unlock; /* * If the device is not open, or CREAD is off, @@ -556,17 +538,14 @@ void dgnc_input(struct channel_t *ch) /* Force queue flow control to be released, if needed */ dgnc_check_queue_flow_control(ch); - spin_unlock_irqrestore(&ch->ch_lock, flags); - return; + goto exit_unlock; } /* * If we are throttled, simply don't read any data. */ - if (ch->ch_flags & CH_FORCED_STOPI) { - spin_unlock_irqrestore(&ch->ch_lock, flags); - return; - } + if (ch->ch_flags & CH_FORCED_STOPI) + goto exit_unlock; flip_len = TTY_FLIPBUF_SIZE; @@ -604,12 +583,8 @@ void dgnc_input(struct channel_t *ch) } } - if (len <= 0) { - spin_unlock_irqrestore(&ch->ch_lock, flags); - if (ld) - tty_ldisc_deref(ld); - return; - } + if (len <= 0) + goto exit_unlock; /* * The tty layer in the kernel has changed in 2.6.16+. @@ -677,6 +652,12 @@ void dgnc_input(struct channel_t *ch) if (ld) tty_ldisc_deref(ld); + return; + +exit_unlock: + spin_unlock_irqrestore(&ch->ch_lock, flags); + if (ld) + tty_ldisc_deref(ld); } @@ -886,10 +867,6 @@ void dgnc_check_queue_flow_control(struct channel_t *ch) ch->ch_stops_sent++; } } - /* No FLOW */ - else { - /* Empty... Can't do anything about the impending overflow... */ - } } /* @@ -1064,7 +1041,7 @@ static int dgnc_tty_open(struct tty_struct *tty, struct file *file) spin_lock_irqsave(&brd->bd_lock, flags); /* If opened device is greater than our number of ports, bail. */ - if (PORT_NUM(minor) > brd->nasync) { + if (PORT_NUM(minor) >= brd->nasync) { spin_unlock_irqrestore(&brd->bd_lock, flags); return -ENXIO; } @@ -1777,10 +1754,8 @@ static int dgnc_tty_write(struct tty_struct *tty, /* * Bail if no space left. */ - if (count <= 0) { - spin_unlock_irqrestore(&ch->ch_lock, flags); - return 0; - } + if (count <= 0) + goto exit_retry; /* * Output the printer ON string, if we are in terminal mode, but @@ -1807,10 +1782,8 @@ static int dgnc_tty_write(struct tty_struct *tty, /* * If there is nothing left to copy, or I can't handle any more data, leave. */ - if (count <= 0) { - spin_unlock_irqrestore(&ch->ch_lock, flags); - return 0; - } + if (count <= 0) + goto exit_retry; if (from_user) { @@ -1896,6 +1869,11 @@ static int dgnc_tty_write(struct tty_struct *tty, } return count; + +exit_retry: + + spin_unlock_irqrestore(&ch->ch_lock, flags); + return 0; } |