lkml.org 
[lkml]   [2011]   [Jan]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/1] hid: Add HID Report Descriptor to sysfs.
On Fri, Jan 21, 2011 at 01:19:45AM -0500, Alan Ott wrote:
> Add a new sysfs entry called report_descriptor which contains the HID report
> descriptor.
>
> Signed-off-by: Alan Ott <alan@signal11.us>
> ---
> drivers/hid/hid-core.c | 28 ++++++++++++++++++++++++++++
> 1 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index d678cf3..0ff1ba2 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -1159,6 +1159,28 @@ static bool hid_hiddev(struct hid_device *hdev)
> return !!hid_match_id(hdev, hid_hiddev_list);
> }
>
> +
> +static ssize_t show_report_descriptor(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + int i, cur = 0;
> + struct hid_device *hdev = container_of(dev, struct hid_device, dev);
> +
> + for (i = 0; i < hdev->rsize; i++) {
> + if (cur + 4 >= PAGE_SIZE)
> + break;
> + sprintf(buf + cur, "%02hhx ", hdev->rdesc[i]);
> + cur += 3;
> + }
> + /* Replace the last space with a newline. */
> + buf[cur-1] = '\n';
> + buf[PAGE_SIZE-1] = '\0';
> + return cur + 1;
> +}

If you are going to do this this way through sysfs, please make this a
binary file, not a text one.

thanks,

greg k-h


\
 
 \ /
  Last update: 2011-01-22 15:13    [W:0.118 / U:6.344 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site