Commit 107b40ad authored by Daeseok Youn's avatar Daeseok Youn Committed by Greg Kroah-Hartman

staging: dgnc: check the type of print before calling

The dgnc_maxcps_room() function must be called only for print device.
The if-statement for checking print device checks before calling
dgnc_maxcps_room() and also this function doesn't need to have any
data except channel_t.
Signed-off-by: default avatarDaeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5d2b7c4a
...@@ -1492,18 +1492,8 @@ static int dgnc_tty_chars_in_buffer(struct tty_struct *tty) ...@@ -1492,18 +1492,8 @@ static int dgnc_tty_chars_in_buffer(struct tty_struct *tty)
* returns the new bytes_available. This only affects printer * returns the new bytes_available. This only affects printer
* output. * output.
*/ */
static int dgnc_maxcps_room(struct tty_struct *tty, int bytes_available) static int dgnc_maxcps_room(struct channel_t *ch, int bytes_available)
{ {
struct un_t *un = tty->driver_data;
struct channel_t *ch = un->un_ch;
/*
* If its not the Transparent print device, return
* the full data amount.
*/
if (un->un_type != DGNC_PRINT)
return bytes_available;
if (ch->ch_digi.digi_maxcps > 0 && ch->ch_digi.digi_bufsize > 0) { if (ch->ch_digi.digi_maxcps > 0 && ch->ch_digi.digi_bufsize > 0) {
int cps_limit = 0; int cps_limit = 0;
unsigned long current_time = jiffies; unsigned long current_time = jiffies;
...@@ -1567,7 +1557,8 @@ static int dgnc_tty_write_room(struct tty_struct *tty) ...@@ -1567,7 +1557,8 @@ static int dgnc_tty_write_room(struct tty_struct *tty)
ret += WQUEUESIZE; ret += WQUEUESIZE;
/* Limit printer to maxcps */ /* Limit printer to maxcps */
ret = dgnc_maxcps_room(tty, ret); if (un->un_type != DGNC_PRINT)
ret = dgnc_maxcps_room(ch, ret);
/* /*
* If we are printer device, leave space for * If we are printer device, leave space for
...@@ -1659,7 +1650,8 @@ static int dgnc_tty_write(struct tty_struct *tty, ...@@ -1659,7 +1650,8 @@ static int dgnc_tty_write(struct tty_struct *tty,
* Limit printer output to maxcps overall, with bursts allowed * Limit printer output to maxcps overall, with bursts allowed
* up to bufsize characters. * up to bufsize characters.
*/ */
bufcount = dgnc_maxcps_room(tty, bufcount); if (un->un_type != DGNC_PRINT)
bufcount = dgnc_maxcps_room(ch, bufcount);
/* /*
* Take minimum of what the user wants to send, and the * Take minimum of what the user wants to send, and the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment