linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Mitsuhiro KOGA" <shiena.jp@gmail.com>
To: "Antonino A. Daplas" <adaplas@gmail.com>
Cc: akpm@osdl.org, thomas@winischhofer.net,
	linux-fbdev-devel@lists.sourceforge.net,
	linux-usb-devel@lists.sourceforge.net
Subject: Re: [PATCH 2.6.18-rc4] sisusbvga: fix sisusb.c
Date: Thu, 17 Aug 2006 00:33:26 +0900	[thread overview]
Message-ID: <6cb5f1c10608160833w4aba9f94va5b011fe49a7aef2@mail.gmail.com> (raw)
In-Reply-To: <1155733001.15309.13.camel@daplas.org>

2006/8/16, Antonino A. Daplas <adaplas@gmail.com>:
> On Wed, 2006-08-16 at 20:31 +0900, Mitsuhiro KOGA wrote:
> > Hi,
> >
>
> >  static void
> >  sisusb_free_buffers(struct sisusb_usb_data *sisusb)
> >  {
> > @@ -408,7 +465,11 @@ static int sisusb_send_bulk_msg(struct s
> >
> >               } else if (fromkern) {
> >
> > -                     memcpy(buffer, kernbuffer, passsize);
> > +                     if ((len & 3) == 0)
> > +                             sisusb_memcpy((u16 *)buffer, (u16 *)kernbuffer, passsize / 2);
> > +                     else
> > +                             memcpy(buffer, kernbuffer, passsize);
>
> What happens if (len & 3) != 0? It ends up doing a regular memcpy()
> without the reordering.  Better if you move the if (len & 3) == 0 check
> to sisusb_memcpy(), so instead of
>
>                        if ((len & 3) == 0)
>                                sisusb_memcpy((u16 *)buffer, (u16 )kernbuffer, passsize / 2);
>                        else
>                                memcpy(buffer, kernbuffer, passsize);
>

(a) if (len & 3) != 0
When former data length is 4 or less, struct sisusb_packet is used.
It becomes 10 in length for writing.
Because data is not used, it becomes 6 in length for reading.

struct sisusb_packet {
    unsigned short header;
    u32 address;
    u32 data;
} __attribute__((__packed__));

(b) if (len & 3) == 0
When former data length is larger than 4,
it corresponds to this case because the length of (data & ~3) is passed.
As for the data of the remainder, the logic of (a) is used.


> it simply condenses into
>
>                         sisusb_memcpy().
>
>

yes.
I also think that it is good.

> > +
> >                       kernbuffer += passsize;
> >
> >               }
> > @@ -872,25 +933,9 @@ static int sisusb_write_mem_bulk(struct
> >                       if (userbuffer) {
> >                               if (copy_from_user(&buf, userbuffer, 3))
> >                                       return -EFAULT;
> > -#ifdef __BIG_ENDIAN
> > -                             swap32 = (buf[0] << 16) |
> > -                                      (buf[1] <<  8) |
> > -                                      buf[2];
> > -#else
> > -                             swap32 = (buf[2] << 16) |
> > -                                      (buf[1] <<  8) |
> > -                                      buf[0];
> > -#endif
> > +                             sisusb_order_wmem_24bit(&buf, &swap32);
> >                       } else
> > -#ifdef __BIG_ENDIAN
> > -                             swap32 = (kernbuffer[0] << 16) |
> > -                                      (kernbuffer[1] <<  8) |
> > -                                      kernbuffer[2];
> > -#else
> > -                             swap32 = (kernbuffer[2] << 16) |
> > -                                      (kernbuffer[1] <<  8) |
> > -                                      kernbuffer[0];
> > -#endif
> > +                             sisusb_order_wmem_24bit(kernbuffer, &swap32);
> >
> >                       ret = sisusb_write_memio_24bit(sisusb,
> >                                                       SISUSB_TYPE_MEM,
> > @@ -907,7 +952,7 @@ static int sisusb_write_mem_bulk(struct
> >                               if (get_user(swap32, (u32 __user *)userbuffer))
> >                                       return -EFAULT;
> >                       } else
> > -                             swap32 = *((u32 *)kernbuffer);
> > +                             sisusb_order_mem_32bit((u32 *)kernbuffer, &swap32);
> >
> >                       ret = sisusb_write_memio_long(sisusb,
> >                                                       SISUSB_TYPE_MEM,
> > @@ -1227,15 +1272,7 @@ static int sisusb_read_mem_bulk(struct s
> >                                                               addr, &swap32);
> >                       if (!ret) {
> >                               (*bytes_read) += 3;
> > -#ifdef __BIG_ENDIAN
> > -                             buf[0] = (swap32 >> 16) & 0xff;
> > -                             buf[1] = (swap32 >> 8) & 0xff;
> > -                             buf[2] = swap32 & 0xff;
> > -#else
> > -                             buf[2] = (swap32 >> 16) & 0xff;
> > -                             buf[1] = (swap32 >> 8) & 0xff;
> > -                             buf[0] = swap32 & 0xff;
> > -#endif
> > +                             sisusb_order_rmem_24bit(&swap32, &buf[0]);
> >                               if (userbuffer) {
> >                                       if (copy_to_user(userbuffer, &buf[0], 3))
> >                                               return -EFAULT;
> > @@ -1259,7 +1296,7 @@ static int sisusb_read_mem_bulk(struct s
> >
> >                                       userbuffer += 4;
> >                               } else {
> > -                                     *((u32 *)kernbuffer) = swap32;
> > +                                     sisusb_order_mem_32bit((u32 *)kernbuffer, &swap32);
> >                                       kernbuffer += 4;
> >                               }
> >                               addr += 4;
> > @@ -3435,6 +3472,9 @@ static void sisusb_disconnect(struct usb
>
> I would agree with Geert. Combine all into a single #ifdef/#else/#endif.
> Since we are still in the reviewing phase, do not submit incremental
> patches.

Thank you for your advice. I understand.


--
Mitsuhiro KOGA
<shiena.jp@gmail.com>

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

  reply	other threads:[~2006-08-16 15:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-13 20:47 [PATCH 2.6.18-rc4] sisusbvga: fix sisusb.c Mitsuhiro KOGA
2006-08-15  0:09 ` Antonino A. Daplas
2006-08-16 11:31   ` Mitsuhiro KOGA
2006-08-16 11:41     ` [Linux-fbdev-devel] " Geert Uytterhoeven
2006-08-16 12:06       ` Mitsuhiro KOGA
2006-08-16 12:56     ` Antonino A. Daplas
2006-08-16 15:33       ` Mitsuhiro KOGA [this message]
2006-08-24  6:34         ` Mitsuhiro KOGA
  -- strict thread matches above, loose matches on Subject: below --
2006-08-13 21:13 Mitsuhiro KOGA

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=6cb5f1c10608160833w4aba9f94va5b011fe49a7aef2@mail.gmail.com \
    --to=shiena.jp@gmail.com \
    --cc=adaplas@gmail.com \
    --cc=akpm@osdl.org \
    --cc=linux-fbdev-devel@lists.sourceforge.net \
    --cc=linux-usb-devel@lists.sourceforge.net \
    --cc=thomas@winischhofer.net \
    /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;
as well as URLs for NNTP newsgroup(s).