From: Oliver Neukum <oliver@neukum.org>
To: Ondrej Zary <linux@rainbow-software.org>
Cc: linux-usb@vger.kernel.org, daniel.ritz@gmx.ch,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] [RFC] NEXIO (or iNexio) support for usbtouchscreen
Date: Fri, 20 Nov 2009 19:43:46 +0100 [thread overview]
Message-ID: <200911201943.46696.oliver@neukum.org> (raw)
In-Reply-To: <200911201021.45410.linux@rainbow-software.org>
Am Freitag, 20. November 2009 10:21:43 schrieb Ondrej Zary:
> On Thursday 19 November 2009, Oliver Neukum wrote:
> > > +struct nexio_priv {
> > > + struct urb *ack;
> > > + char ack_buf[2];
> > > +};
> >
> > No. Every buffer needs to have an exclusive cache line for DMA
> > to work on the incoherent archotectures. Therefore you must allocate
> > each buffer with its own kmalloc.
>
> OK, thanks for your patience.
No problem. I should have explained better.
> > > + /* read replies */
> > > + for (i = 0; i < 3; i++) {
> > > + memset(buf, 0, NEXIO_BUFSIZE);
> > > + ret = usb_bulk_msg(dev, usb_rcvbulkpipe(dev, NEXIO_INPUT_EP),
> > > + buf, NEXIO_BUFSIZE, &actual_len,
> > > + NEXIO_TIMEOUT);
> > > + if (ret < 0 || actual_len < 1 || buf[1] != actual_len)
> > > + continue;
> > > + switch (buf[0]) {
> > > + case 0x83: /* firmware version */
> > > + firmware_ver = kstrdup(&buf[2], GFP_KERNEL);
On second thought this is not nice. If a device is broken enough to report
a name or a firmware version twice, you produce a memory leak.
Do you know very buggy devices to exist?
> > > + break;
> > > + case 0x84: /* device name */
> > > + device_name = kstrdup(&buf[2], GFP_KERNEL);
> > > + break;
> > > + }
> > > + }
> > > + printk(KERN_INFO "Nexio device: %s, firmware version: %s\n",
> > > + device_name, firmware_ver);
> >
> > How do you know device_name and firmware_ver are not NULL?
>
> printk works fine with NULL, it prints <NULL>. Is it necessary to add more
> code only to make the output nice?
No, for niceness it is not necessary. The question is whether you want
to treat this as an error or print a warning. That is a matter of taste.
> Looks like a bug in the original usbtouchscreen code. There's no locking.
> Will a spinlock in usbtouch_open() and usbtouch_disconnect() fix it? Or
> do you see more problems here?
You must not call usb_kill_urb() with a spinlock held.
I'll lokk at the usbtouchscreen code.
The new version looks good to me.
Regards
Oliver
next prev parent reply other threads:[~2009-11-20 18:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-16 14:14 [PATCH] " Ondrej Zary
2009-11-17 15:25 ` Oliver Neukum
2009-11-18 12:18 ` [PATCH v2] [RFC] " Ondrej Zary
2009-11-18 15:25 ` Oliver Neukum
2009-11-19 12:40 ` [PATCH v3] " Ondrej Zary
2009-11-19 16:56 ` Oliver Neukum
2009-11-20 9:21 ` [PATCH v4] " Ondrej Zary
2009-11-20 18:43 ` Oliver Neukum [this message]
2009-11-20 22:41 ` Ondrej Zary
2009-11-21 9:17 ` Oliver Neukum
2009-11-23 10:04 ` [PATCH 1/3] usbtouchscreen: convert from usb_device to usb_interface Ondrej Zary
2009-11-23 10:04 ` [PATCH 2/3] usbtouchscreen: find input endpoint automatically Ondrej Zary
2009-11-23 10:05 ` [PATCH 3/3] usbtouchscreen: add NEXIO (or iNexio) support Ondrej Zary
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=200911201943.46696.oliver@neukum.org \
--to=oliver@neukum.org \
--cc=daniel.ritz@gmx.ch \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@rainbow-software.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
Powered by JetHome