linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* drivers/char/synclink_gt.c: chars don't have more than 8 bits
@ 2006-08-26  2:01 Adrian Bunk
  2006-08-26  2:49 ` Paul Fulghum
  2006-08-28 19:07 ` [PATCH] synclink_gt fix receive tty error handling Paul Fulghum
  0 siblings, 2 replies; 3+ messages in thread
From: Adrian Bunk @ 2006-08-26  2:01 UTC (permalink / raw)
  To: Paul Fulghum; +Cc: linux-kernel

The GNU C compiler (SVN version) spotted the following buggy code in 
drivers/char/synclink_gt.c:

<--  snip  -->

...
static void rx_async(struct slgt_info *info)
{
...
        unsigned char *p;
        unsigned char status;
...
                        if ((status = *(p+1) & (BIT9 + BIT8))) {
                                if (status & BIT9)
                                        icount->parity++;
                                else if (status & BIT8)
                                        icount->frame++;
                                /* discard char if tty control flags say so */
                                if (status & info->ignore_status_mask)
                                        continue;
                                if (status & BIT9)
                                        stat = TTY_PARITY;
                                else if (status & BIT8)
                                        stat = TTY_FRAME;
                        }
...

<--  snip  -->

Since there are no bits 8 or 9 in a char this code is currently
dead code.

cu
Adrian

-- 

    Gentoo kernels are 42 times more popular than SUSE kernels among
    KLive users  (a service by SUSE contractor Andrea Arcangeli that
    gathers data about kernels from many users worldwide).

       There are three kinds of lies: Lies, Damn Lies, and Statistics.
                                                    Benjamin Disraeli


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: drivers/char/synclink_gt.c: chars don't have more than 8 bits
  2006-08-26  2:01 drivers/char/synclink_gt.c: chars don't have more than 8 bits Adrian Bunk
@ 2006-08-26  2:49 ` Paul Fulghum
  2006-08-28 19:07 ` [PATCH] synclink_gt fix receive tty error handling Paul Fulghum
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Fulghum @ 2006-08-26  2:49 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: linux-kernel

Adrian Bunk wrote:
> The GNU C compiler (SVN version) spotted the following buggy code in 
> drivers/char/synclink_gt.c:
> ...
  > Since there are no bits 8 or 9 in a char this code is currently
> dead code.

Yes, that is a bug.

Status and data come in byte pairs, bits 9 and 8 are
referenced from the 16 bit combination.

The code is operating on individual bytes in the buffer,
so it should be bits 1 and 0 that are tested.

I will make a patch and post it.

Thanks,
Paul



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] synclink_gt fix receive tty error handling
  2006-08-26  2:01 drivers/char/synclink_gt.c: chars don't have more than 8 bits Adrian Bunk
  2006-08-26  2:49 ` Paul Fulghum
@ 2006-08-28 19:07 ` Paul Fulghum
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Fulghum @ 2006-08-28 19:07 UTC (permalink / raw)
  To: Andrew Morton, Adrian Bunk; +Cc: linux-kernel

Fix receive tty error handling in synclink_gt driver.
Adrian reported compiler warning for incorrect bit test
against char variable. I determined these and other
device specific error bits were incorrectly defined.
 
Signed-off-by: Paul Fulghum <paulkf@microgate.com>

--- linux-2.6.18-rc5/drivers/char/synclink_gt.c	2006-08-28 08:39:18.000000000 -0500
+++ b/drivers/char/synclink_gt.c	2006-08-28 10:38:49.000000000 -0500
@@ -391,8 +391,8 @@ static MGSL_PARAMS default_params = {
 #define DESC_LIST_SIZE 4096
 
 #define MASK_PARITY  BIT1
-#define MASK_FRAMING BIT2
-#define MASK_BREAK   BIT3
+#define MASK_FRAMING BIT0
+#define MASK_BREAK   BIT14
 #define MASK_OVERRUN BIT4
 
 #define GSR   0x00 /* global status */
@@ -1800,17 +1800,17 @@ static void rx_async(struct slgt_info *i
 
 			stat = 0;
 
-			if ((status = *(p+1) & (BIT9 + BIT8))) {
-				if (status & BIT9)
+			if ((status = *(p+1) & (BIT1 + BIT0))) {
+				if (status & BIT1)
 					icount->parity++;
-				else if (status & BIT8)
+				else if (status & BIT0)
 					icount->frame++;
 				/* discard char if tty control flags say so */
 				if (status & info->ignore_status_mask)
 					continue;
-				if (status & BIT9)
+				if (status & BIT1)
 					stat = TTY_PARITY;
-				else if (status & BIT8)
+				else if (status & BIT0)
 					stat = TTY_FRAME;
 			}
 			if (tty) {





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-08-28 19:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-26  2:01 drivers/char/synclink_gt.c: chars don't have more than 8 bits Adrian Bunk
2006-08-26  2:49 ` Paul Fulghum
2006-08-28 19:07 ` [PATCH] synclink_gt fix receive tty error handling Paul Fulghum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).