From: Alan Ott <alan@signal11.us>
To: Antonio Ospite <ospite@studenti.unina.it>
Cc: Jiri Kosina <jkosina@suse.cz>,
Alexey Dobriyan <adobriyan@gmail.com>, Tejun Heo <tj@kernel.org>,
Marcel Holtmann <marcel@holtmann.org>,
Alan Stern <stern@rowland.harvard.edu>,
Greg Kroah-Hartman <gregkh@suse.de>,
Stephane Chatty <chatty@enac.fr>,
Michael Poole <mdpoole@troilus.org>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-usb@vger.kernel.org
Subject: Re: [PATCH] HID: Add Support for Setting and Getting Feature Reports from hidraw
Date: Wed, 09 Jun 2010 11:20:32 -0400 [thread overview]
Message-ID: <4C0FB140.90700@signal11.us> (raw)
In-Reply-To: <20100609104235.ccce2289.ospite@studenti.unina.it>
On 06/09/2010 04:42 AM, Antonio Ospite wrote:
> I was only thinking about the interface to userspace,
> HIDIOCGRDESC/HIDIOCSRDESC sounded more general to me (and look like
> HIDIOCGREPORT/HIDIOCSREPORT from hiddev) if they could be made to work
> with different report types, but as I said I didn't look at the
> current code very well, so my remark are surely quite naive.
>
I see what you mean, re-using the _struct_ not the code. You would have to add
a report_id, like you said, but it would break the current userspace.
Along those lines, I wouldn't be opposed to making the ioctl instead of taking
a variable-length buffer, take a struct. Something like:
struct hidraw_report {
int report_number;
int size;
char data[HID_MAX_BUFFER_SIZE /*or something similar*/];
};
The thing I ran into is that the user would most conveniently create
the entire struct in userspace, using much more space than is probably necessary
(since most reports aren't going to be anywhere close to the max allowable
size, and the max allowable size must be sufficiently large).
The user _could_ do something like:
char *buf = malloc(sizeof(int)*2 + requried_data_length);
ioctl(fd, ...SREPORT, (hidraw_report*)buf);
but I don't envision most users doing that as it would be error-prone.
This would require hidraw to copy_from_user() only size bytes from the data
field, not the entire thing.
I'm open to doing it this way if it seems to fit existing paradigms better,
but like I said, it will (for most users) require more memory in userspace.
>>> but I didn't actually implement this, so I don't know if it was
>>> feasible, for instance one problem I didn't investigate further was
>>> about the default value of the aforementioned report_type field in
>>> order to keep the current behavior of HIDIOCGRDESC.
>>>
>>>
>> I'm not sure what you mean here, as the report_type field is not part of
>> hidraw_report_descriptor.
>>
>>
> I was thinking about _adding_ that field, but again, pretty arbitrarily
> thought.
>
>
>> Thanks for testing my patch. Please let me know if you have problems
>> with it.
>>
>>
> It works basically ok for my needs, thanks again, waiting for comments
> from usb/HID people.
>
> Note that there are some checkpatch.pl errors in the current patch, and
> also a style fix mixed with functional ones (@@ -315,7 +411,7 @@), you
> may want to sort these out in a v2.
>
>
I didn't worry about the 80 column warnings, because many of them are
copy/paste from existing code in the same file, and fixing them would have
meant either making the code inconsistent in format with the code around it,
or making formatting corrections which would have violated the "make the
patch do only one thing" rule. I would appreciate some guidance as to what
is the best way to handle this kind of thing.
That said, I had fixed the trailing whitespace errors, but apparently messed
up when generating my patch. I'll put out a v2 shortly.
> After this gets in, some more style fixes to hidraw.c could be made,
> I'll do these. Maybe some naming cleanup can be made too,
> hid_output_raw_report could become hid_set_raw_report for instance, but
> I am waiting for the topic to settle first.
>
Agreed. I've made note of a handful of other (small) things which could
be made a bit better as well. I'm holding off on that stuff until we get this
functionality ironed out.
Thanks,
Alan.
next prev parent reply other threads:[~2010-06-09 15:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1275969108-14948-1-git-send-email-alan@signal11.us>
[not found] ` <1275969108-14948-1-git-send-email-alan-yzvJWuRpmD1zbRFIqnYvSA@public.gmane.org>
2010-06-08 6:32 ` [PATCH] HID: Add Support for Setting and Getting Feature Reports from hidraw Antonio Ospite
2010-06-08 13:42 ` Alan Ott
2010-06-09 8:42 ` Antonio Ospite
2010-06-09 15:20 ` Alan Ott [this message]
2010-06-09 15:54 ` [PATCH v2] " Alan Ott
2010-06-10 10:45 ` Antonio Ospite
2010-06-10 13:09 ` Jiri Kosina
2010-06-16 15:19 ` Jiri Kosina
2010-07-10 18:33 ` [PATCH v3 0/1] " Alan Ott
2010-07-10 18:33 ` [PATCH v3 1/1] " Alan Ott
2010-06-08 3:51 [PATCH] " Alan Ott
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=4C0FB140.90700@signal11.us \
--to=alan@signal11.us \
--cc=adobriyan@gmail.com \
--cc=chatty@enac.fr \
--cc=gregkh@suse.de \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=mdpoole@troilus.org \
--cc=ospite@studenti.unina.it \
--cc=stern@rowland.harvard.edu \
--cc=tj@kernel.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;
as well as URLs for NNTP newsgroup(s).