mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Søren Møller" <soerenmoeller2001@gmail.com>
To: Joe Perches <joe@perches.com>
Cc: gregkh@suse.de, richard@audacityteam.org,
	andre.goddard@gmail.com, nm127@freemail.hu,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Staging: quatech_usb2: fix coding style issues
Date: Wed, 31 Mar 2010 10:34:20 +0200	[thread overview]
Message-ID: <6797ac6e1003310134y9c333y1fc6811032b2f174@mail.gmail.com> (raw)
In-Reply-To: <1269982719.1507.71.camel@Joe-Laptop.home>

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);
>
>

      reply	other threads:[~2010-03-31  8:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-30 20:11 Soeren Moeller
2010-03-30 20:58 ` Joe Perches
2010-03-31  8:34   ` Søren Møller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6797ac6e1003310134y9c333y1fc6811032b2f174@mail.gmail.com \
    --to=soerenmoeller2001@gmail.com \
    --cc=andre.goddard@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@suse.de \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nm127@freemail.hu \
    --cc=richard@audacityteam.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®