* [PATCH] Staging: quatech_usb2: fix coding style issues
@ 2010-03-30 20:11 Soeren Moeller
2010-03-30 20:58 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Soeren Moeller @ 2010-03-30 20:11 UTC (permalink / raw)
To: gregkh, richard, andre.goddard, soerenmoeller2001, nm127
Cc: devel, linux-kernel
This is a patch to the file quatech_usb2.c that fixes two space before tabular and one line of more than 80 characters warnings found by checkpatch.pl
Signed-off-by: Soeren Moeller <soerenmoeller2001@gmail.com>
---
drivers/staging/quatech_usb2/quatech_usb2.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/quatech_usb2/quatech_usb2.c b/drivers/staging/quatech_usb2/quatech_usb2.c
index 1561f74..ecd7313 100644
--- a/drivers/staging/quatech_usb2/quatech_usb2.c
+++ b/drivers/staging/quatech_usb2/quatech_usb2.c
@@ -57,7 +57,7 @@ static int debug;
#define QT2_HW_FLOW_CONTROL_MASK 0xc5
#define QT2_SW_FLOW_CONTROL_MASK 0xc6
#define QT2_SW_FLOW_CONTROL_DISABLE 0xc7
-#define QT2_BREAK_CONTROL 0xc8
+#define QT2_BREAK_CONTROL 0xc8
#define QT2_STOP_RECEIVE 0xe0
#define QT2_FLUSH_DEVICE 0xc4
#define QT2_GET_SET_QMCR 0xe1
@@ -207,7 +207,7 @@ struct quatech2_dev {
bool ReadBulkStopped;
char open_ports;
struct usb_serial_port *current_port;
- int buffer_size;
+ int buffer_size;
};
/* structure which holds line and modem status flags */
@@ -1648,10 +1648,10 @@ __func__);
} /*endif*/
if (tty_st && urb->actual_length) {
tty_buffer_request_room(tty_st, 1);
- tty_insert_flip_string(tty_st,
- &((unsigned char *)(urb->transfer_buffer)
- )[i],
- 1);
+ tty_insert_flip_string(tty_st, &(
+ (unsigned char *)
+ (urb->transfer_buffer)
+ )[i], 1);
}
} /*endfor*/
tty_flip_buffer_push(tty_st);
--
1.6.3.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Staging: quatech_usb2: fix coding style issues
2010-03-30 20:11 [PATCH] Staging: quatech_usb2: fix coding style issues Soeren Moeller
@ 2010-03-30 20:58 ` Joe Perches
2010-03-31 8:34 ` Søren Møller
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2010-03-30 20:58 UTC (permalink / raw)
To: Soeren Moeller; +Cc: gregkh, richard, andre.goddard, nm127, devel, linux-kernel
On Tue, 2010-03-30 at 20:11 +0000, Soeren Moeller wrote:
> This is a patch to the file quatech_usb2.c that fixes two space before tabular and one line of more than 80 characters warnings found by checkpatch.pl
> - tty_insert_flip_string(tty_st,
> - &((unsigned char *)(urb->transfer_buffer)
> - )[i],
> - 1);
> + tty_insert_flip_string(tty_st, &(
> + (unsigned char *)
> + (urb->transfer_buffer)
> + )[i], 1);
I think this is unsightly.
Perhaps a macro instead?
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/staging/quatech_usb2/quatech_usb2.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/quatech_usb2/quatech_usb2.c b/drivers/staging/quatech_usb2/quatech_usb2.c
index 1561f74..d14792a 100644
--- a/drivers/staging/quatech_usb2/quatech_usb2.c
+++ b/drivers/staging/quatech_usb2/quatech_usb2.c
@@ -109,12 +109,15 @@ static int debug;
#define QT2_LINE_STATUS_REGISTER 0x05
#define QT2_MODEM_STATUS_REGISTER 0x06
+/* handy macro for extracting a byte from a data read transfer buffer */
+#define URB_TBUF(urb, pos) (((unsigned char *)(urb->transfer_buffer))[pos])
+
/* handy macros for doing escape sequence parsing on data reads */
-#define THISCHAR ((unsigned char *)(urb->transfer_buffer))[i]
-#define NEXTCHAR ((unsigned char *)(urb->transfer_buffer))[i + 1]
-#define THIRDCHAR ((unsigned char *)(urb->transfer_buffer))[i + 2]
-#define FOURTHCHAR ((unsigned char *)(urb->transfer_buffer))[i + 3]
-#define FIFTHCHAR ((unsigned char *)(urb->transfer_buffer))[i + 4]
+#define THISCHAR URB_TBUF(urb, i + 0)
+#define NEXTCHAR URB_TBUF(urb, i + 1)
+#define THIRDCHAR URB_TBUF(urb, i + 2)
+#define FOURTHCHAR URB_TBUF(urb, i + 3)
+#define FIFTHCHAR URB_TBUF(urb, i + 4)
static const struct usb_device_id quausb2_id_table[] = {
{USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_SSU2_100)},
@@ -1649,9 +1652,7 @@ __func__);
if (tty_st && urb->actual_length) {
tty_buffer_request_room(tty_st, 1);
tty_insert_flip_string(tty_st,
- &((unsigned char *)(urb->transfer_buffer)
- )[i],
- 1);
+ &URB_TBUF(urb, i), 1);
}
} /*endfor*/
tty_flip_buffer_push(tty_st);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Staging: quatech_usb2: fix coding style issues
2010-03-30 20:58 ` Joe Perches
@ 2010-03-31 8:34 ` Søren Møller
0 siblings, 0 replies; 3+ messages in thread
From: Søren Møller @ 2010-03-31 8:34 UTC (permalink / raw)
To: Joe Perches; +Cc: gregkh, richard, andre.goddard, nm127, devel, linux-kernel
2010/3/30 Joe Perches <joe@perches.com>
>
> On Tue, 2010-03-30 at 20:11 +0000, Soeren Moeller wrote:
> > This is a patch to the file quatech_usb2.c that fixes two space before tabular and one line of more than 80 characters warnings found by checkpatch.pl
> > - tty_insert_flip_string(tty_st,
> > - &((unsigned char *)(urb->transfer_buffer)
> > - )[i],
> > - 1);
> > + tty_insert_flip_string(tty_st, &(
> > + (unsigned char *)
> > + (urb->transfer_buffer)
> > + )[i], 1);
>
> I think this is unsightly.
> Perhaps a macro instead?
>
The macro seems like a good idea, it makes the code a lot more readable.
Thanks for your response
Regards
Sören Möller
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> drivers/staging/quatech_usb2/quatech_usb2.c | 17 +++++++++--------
> 1 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/staging/quatech_usb2/quatech_usb2.c b/drivers/staging/quatech_usb2/quatech_usb2.c
> index 1561f74..d14792a 100644
> --- a/drivers/staging/quatech_usb2/quatech_usb2.c
> +++ b/drivers/staging/quatech_usb2/quatech_usb2.c
> @@ -109,12 +109,15 @@ static int debug;
> #define QT2_LINE_STATUS_REGISTER 0x05
> #define QT2_MODEM_STATUS_REGISTER 0x06
>
> +/* handy macro for extracting a byte from a data read transfer buffer */
> +#define URB_TBUF(urb, pos) (((unsigned char *)(urb->transfer_buffer))[pos])
> +
> /* handy macros for doing escape sequence parsing on data reads */
> -#define THISCHAR ((unsigned char *)(urb->transfer_buffer))[i]
> -#define NEXTCHAR ((unsigned char *)(urb->transfer_buffer))[i + 1]
> -#define THIRDCHAR ((unsigned char *)(urb->transfer_buffer))[i + 2]
> -#define FOURTHCHAR ((unsigned char *)(urb->transfer_buffer))[i + 3]
> -#define FIFTHCHAR ((unsigned char *)(urb->transfer_buffer))[i + 4]
> +#define THISCHAR URB_TBUF(urb, i + 0)
> +#define NEXTCHAR URB_TBUF(urb, i + 1)
> +#define THIRDCHAR URB_TBUF(urb, i + 2)
> +#define FOURTHCHAR URB_TBUF(urb, i + 3)
> +#define FIFTHCHAR URB_TBUF(urb, i + 4)
>
> static const struct usb_device_id quausb2_id_table[] = {
> {USB_DEVICE(USB_VENDOR_ID_QUATECH, QUATECH_SSU2_100)},
> @@ -1649,9 +1652,7 @@ __func__);
> if (tty_st && urb->actual_length) {
> tty_buffer_request_room(tty_st, 1);
> tty_insert_flip_string(tty_st,
> - &((unsigned char *)(urb->transfer_buffer)
> - )[i],
> - 1);
> + &URB_TBUF(urb, i), 1);
> }
> } /*endfor*/
> tty_flip_buffer_push(tty_st);
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-31 8:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-30 20:11 [PATCH] Staging: quatech_usb2: fix coding style issues Soeren Moeller
2010-03-30 20:58 ` Joe Perches
2010-03-31 8:34 ` Søren Møller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®