Re: [PATCH 1/1] hid: Add HID Report Descriptor to sysfs.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
> ---
>  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
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux