linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] HID: Report Descriptor in Sysfs
@ 2011-01-21  6:19 Alan Ott
  2011-01-21  6:19 ` [PATCH 1/1] hid: Add HID Report Descriptor to sysfs Alan Ott
  2011-01-21  9:59 ` [PATCH 0/1] HID: Report Descriptor in Sysfs Jiri Kosina
  0 siblings, 2 replies; 21+ messages in thread
From: Alan Ott @ 2011-01-21  6:19 UTC (permalink / raw)
  To: Jiri Kosina, linux-input, linux-kernel; +Cc: Alan Ott

So I'd like to have access to the HID report descriptor in a sysfs entry, so
I can read it without opening the device.  hid-core seemed like the place to
put it.

Using the /sys/class links, for hidraw devices, this puts a new file,
report_descriptor in the directory:
	/sys/class/hidraw/hidraw0/device/

For my USB device (for example), the new file is in:
	/sys/bus/usb/devices/1-5.3:1.0/0003:046D:C216.0001/

For my Bluetooth device, the new file is in:
	/sys/class/bluetooth/hci0/hci0:11/0005:054C:0268.0002/

I'm not super confident that these file locations are the best place, but I
made a best guess so that it could be discussed.  The current location is
where the hid-core stuff lives.  Is there a reason these directories are
named bus:vendor:product:id (instead of hid-core or something similar)?  Is
there a better way to do this?

Alan.

Alan Ott (1):
  hid: Add HID Report Descriptor to sysfs.

 drivers/hid/hid-core.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)



^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 1/1] hid: Add HID Report Descriptor to sysfs.
  2011-01-21  6:19 [PATCH 0/1] HID: Report Descriptor in Sysfs Alan Ott
@ 2011-01-21  6:19 ` Alan Ott
  2011-01-22 13:55   ` Greg KH
  2011-01-21  9:59 ` [PATCH 0/1] HID: Report Descriptor in Sysfs Jiri Kosina
  1 sibling, 1 reply; 21+ messages in thread
From: Alan Ott @ 2011-01-21  6:19 UTC (permalink / raw)
  To: Jiri Kosina, linux-input, linux-kernel; +Cc: Alan Ott

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;
+}
+
+static DEVICE_ATTR(report_descriptor, S_IRUGO, show_report_descriptor, NULL);
+
 int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
 {
 	static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
@@ -1169,6 +1191,7 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
 	char buf[64];
 	unsigned int i;
 	int len;
+	int ret;
 
 	if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE)
 		connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV);
@@ -1230,6 +1253,11 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
 		bus = "<UNKNOWN>";
 	}
 
+	ret = device_create_file(&hdev->dev, &dev_attr_report_descriptor);
+	if (ret)
+		hid_warn(hdev,
+			 "can't create sysfs report descriptor attribute err: %d\n", ret);
+
 	hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
 		 buf, bus, hdev->version >> 8, hdev->version & 0xff,
 		 type, hdev->name, hdev->phys);
-- 
1.7.0.4



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/1] HID: Report Descriptor in Sysfs
  2011-01-21  6:19 [PATCH 0/1] HID: Report Descriptor in Sysfs Alan Ott
  2011-01-21  6:19 ` [PATCH 1/1] hid: Add HID Report Descriptor to sysfs Alan Ott
@ 2011-01-21  9:59 ` Jiri Kosina
  2011-01-21 14:52   ` Alan Ott
  1 sibling, 1 reply; 21+ messages in thread
From: Jiri Kosina @ 2011-01-21  9:59 UTC (permalink / raw)
  To: Alan Ott; +Cc: linux-input, linux-kernel

On Fri, 21 Jan 2011, Alan Ott wrote:

> So I'd like to have access to the HID report descriptor in a sysfs entry, so
> I can read it without opening the device.  hid-core seemed like the place to
> put it.
> 
> Using the /sys/class links, for hidraw devices, this puts a new file,
> report_descriptor in the directory:
> 	/sys/class/hidraw/hidraw0/device/
> 
> For my USB device (for example), the new file is in:
> 	/sys/bus/usb/devices/1-5.3:1.0/0003:046D:C216.0001/
> 
> For my Bluetooth device, the new file is in:
> 	/sys/class/bluetooth/hci0/hci0:11/0005:054C:0268.0002/
> 
> I'm not super confident that these file locations are the best place, but I
> made a best guess so that it could be discussed.  The current location is
> where the hid-core stuff lives.  Is there a reason these directories are
> named bus:vendor:product:id (instead of hid-core or something similar)?  Is
> there a better way to do this?

Hi Alan,

the report descriptor is provided through debugfs HID interface already. 
Do you feel like that's not enough?

Thanks,

-- 
Jiri Kosina
SUSE Labs, Novell Inc.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/1] HID: Report Descriptor in Sysfs
  2011-01-21  9:59 ` [PATCH 0/1] HID: Report Descriptor in Sysfs Jiri Kosina
@ 2011-01-21 14:52   ` Alan Ott
  2011-01-21 15:09     ` Jiri Kosina
  0 siblings, 1 reply; 21+ messages in thread
From: Alan Ott @ 2011-01-21 14:52 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux-input, linux-kernel

On 01/21/2011 04:59 AM, Jiri Kosina wrote:
> On Fri, 21 Jan 2011, Alan Ott wrote:
>
>    
>> So I'd like to have access to the HID report descriptor in a sysfs entry, so
>> I can read it without opening the device.  hid-core seemed like the place to
>> put it.
>>
>> Using the /sys/class links, for hidraw devices, this puts a new file,
>> report_descriptor in the directory:
>> 	/sys/class/hidraw/hidraw0/device/
>>
>> For my USB device (for example), the new file is in:
>> 	/sys/bus/usb/devices/1-5.3:1.0/0003:046D:C216.0001/
>>
>> For my Bluetooth device, the new file is in:
>> 	/sys/class/bluetooth/hci0/hci0:11/0005:054C:0268.0002/
>>
>> I'm not super confident that these file locations are the best place, but I
>> made a best guess so that it could be discussed.  The current location is
>> where the hid-core stuff lives.  Is there a reason these directories are
>> named bus:vendor:product:id (instead of hid-core or something similar)?  Is
>> there a better way to do this?
>>      
> the report descriptor is provided through debugfs HID interface already.
> Do you feel like that's not enough?
>    

Hi Jiri,

Maybe it is. To be honest I didn't check debugfs. I have two concerns 
about it:
1. Is it wise for userspace programs to rely on:
     a. debugfs being mounted,
     b. its mount point, or
     c. the location or contents of any file in debugfs?
2. /sys/kernel/debug/0003:046D:C216.0002/rdesc is mode 0400 on my system 
(root-only read). Is there a reason it's so restrictive, or could it be 
changed to 0444?

Alan.



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/1] HID: Report Descriptor in Sysfs
  2011-01-21 14:52   ` Alan Ott
@ 2011-01-21 15:09     ` Jiri Kosina
  2011-01-21 15:29       ` Alan Ott
  2011-01-21 20:03       ` Nikolai Kondrashov
  0 siblings, 2 replies; 21+ messages in thread
From: Jiri Kosina @ 2011-01-21 15:09 UTC (permalink / raw)
  To: Alan Ott; +Cc: linux-input, linux-kernel

On Fri, 21 Jan 2011, Alan Ott wrote:

> Maybe it is. To be honest I didn't check debugfs. I have two concerns about
> it:
> 1. Is it wise for userspace programs to rely on:

Ah, I didn't realize that you want it to be used by some acutal userspace 
applications. Out of curiosity -- what is the usage pattern you are 
targetting?

The idea behind debugfs-provided userspace descriptor is that driver 
developer is easily able to inspect the descriptor, and write a kernel 
driver that fixes it up in case it is bogus.
There were also efforts to make the report descriptor replaceable in a 
request_firmware() way, but that never converged to state in which it 
could be applied IIRC.

Thanks,

-- 
Jiri Kosina
SUSE Labs, Novell Inc.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/1] HID: Report Descriptor in Sysfs
  2011-01-21 15:09     ` Jiri Kosina
@ 2011-01-21 15:29       ` Alan Ott
  2011-01-21 16:14         ` Jiri Kosina
  2011-01-21 20:03       ` Nikolai Kondrashov
  1 sibling, 1 reply; 21+ messages in thread
From: Alan Ott @ 2011-01-21 15:29 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux-input, linux-kernel

On 01/21/2011 10:09 AM, Jiri Kosina wrote:
> On Fri, 21 Jan 2011, Alan Ott wrote:
>
>    
>> Maybe it is. To be honest I didn't check debugfs. I have two concerns about
>> it:
>> 1. Is it wise for userspace programs to rely on:
>>      
> Ah, I didn't realize that you want it to be used by some acutal userspace
> applications. Out of curiosity -- what is the usage pattern you are
> targetting?
>    

Well, what I really want is the Usage Page and Usage of the device. For 
some background, I maintain a library called hidapi[1] for accessing HID 
devices in a cross platform way. There are currently four backends, 
Linux-hidraw, Linux-libusb, Mac OS, and Windows.

I've recently received requests for supporting composite HID devices. 
Since a composite device will show up as multiple devices with the same 
VID/PID, one needs a way to differentiate between its different 
interfaces. On Windows and Mac, the platform HID libraries support 
getting the Usage Page and Usage of each interface. On Linux/libusb I 
can request the HID report descriptor and parse it myself, but I have to 
claim the interface to do it, and to do that, I have to detach the 
kernel driver. Needless to say, detaching the kernel driver is not good, 
especially when the library is supposed to be just scanning for devices.

For these reasons, it would be really convenient to get the report 
descriptor from sysfs.

Alan.

[1] http://www.signal11.us/oss/hidapi/



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/1] HID: Report Descriptor in Sysfs
  2011-01-21 15:29       ` Alan Ott
@ 2011-01-21 16:14         ` Jiri Kosina
  2011-01-21 16:57           ` Alan Ott
  0 siblings, 1 reply; 21+ messages in thread
From: Jiri Kosina @ 2011-01-21 16:14 UTC (permalink / raw)
  To: Alan Ott; +Cc: linux-input, linux-kernel

On Fri, 21 Jan 2011, Alan Ott wrote:

> Well, what I really want is the Usage Page and Usage of the device. For some
> background, I maintain a library called hidapi[1] for accessing HID devices in
> a cross platform way. There are currently four backends, Linux-hidraw,
> Linux-libusb, Mac OS, and Windows.
> 
> I've recently received requests for supporting composite HID devices. Since a
> composite device will show up as multiple devices with the same VID/PID, one
> needs a way to differentiate between its different interfaces. On Windows and
> Mac, the platform HID libraries support getting the Usage Page and Usage of
> each interface. On Linux/libusb I can request the HID report descriptor and
> parse it myself, but I have to claim the interface to do it, and to do that, I
> have to detach the kernel driver. Needless to say, detaching the kernel driver
> is not good, especially when the library is supposed to be just scanning for
> devices.
> 
> For these reasons, it would be really convenient to get the report descriptor
> from sysfs.

In this case, you can still get the report descriptor from hidraw (which 
is parallel to any other HID-bus based kernel driver). Woudl that suit 
your needs?

-- 
Jiri Kosina
SUSE Labs, Novell Inc.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/1] HID: Report Descriptor in Sysfs
  2011-01-21 16:14         ` Jiri Kosina
@ 2011-01-21 16:57           ` Alan Ott
  0 siblings, 0 replies; 21+ messages in thread
From: Alan Ott @ 2011-01-21 16:57 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux-input, linux-kernel

On 01/21/2011 11:14 AM, Jiri Kosina wrote:
> On Fri, 21 Jan 2011, Alan Ott wrote:
>
>    
>> Well, what I really want is the Usage Page and Usage of the device. For some
>> background, I maintain a library called hidapi[1] for accessing HID devices in
>> a cross platform way. There are currently four backends, Linux-hidraw,
>> Linux-libusb, Mac OS, and Windows.
>>
>> I've recently received requests for supporting composite HID devices. Since a
>> composite device will show up as multiple devices with the same VID/PID, one
>> needs a way to differentiate between its different interfaces. On Windows and
>> Mac, the platform HID libraries support getting the Usage Page and Usage of
>> each interface. On Linux/libusb I can request the HID report descriptor and
>> parse it myself, but I have to claim the interface to do it, and to do that, I
>> have to detach the kernel driver. Needless to say, detaching the kernel driver
>> is not good, especially when the library is supposed to be just scanning for
>> devices.
>>
>> For these reasons, it would be really convenient to get the report descriptor
>> from sysfs.
>>      
> In this case, you can still get the report descriptor from hidraw (which
> is parallel to any other HID-bus based kernel driver). Woudl that suit
> your needs?
>
>    

Not exactly, because not all HID devices have a hidraw interface 
(because some are blacklisted). These devices are still accessible 
through libusb. Plus, getting it from hidraw involves having permissions 
to open the device[1]. Maybe that's less of a limitation, but since I 
can get everything else from sysfs (vid/pid, strings, device version), 
it seemed to make sense to me to have the hid report descriptor in the 
same place.

Again, if I'm completely wrong about how I should be going about this, 
just let me know.

Alan.


[1] Last year, I suggested adding some interfaces to hidraw to get 
things like the serial number, and it was suggested to me on 
linux-usb[2] that I use sysfs (through libudev) instead. I extrapolated 
that the proper paradigm was to use sysfs to get information about the 
device, and to use the device node itself to actually communicate with 
the device. I could be wrong again.

[2] I didn't realize at the time that I really should have asked on 
linux-input instead of linux-usb.



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/1] HID: Report Descriptor in Sysfs
  2011-01-21 15:09     ` Jiri Kosina
  2011-01-21 15:29       ` Alan Ott
@ 2011-01-21 20:03       ` Nikolai Kondrashov
  2011-01-24 15:17         ` Jiri Kosina
  1 sibling, 1 reply; 21+ messages in thread
From: Nikolai Kondrashov @ 2011-01-21 20:03 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Alan Ott, linux-input, linux-kernel

On 01/21/2011 06:09 PM, Jiri Kosina wrote:
> There were also efforts to make the report descriptor replaceable in a
> request_firmware() way, but that never converged to state in which it
> could be applied IIRC.
I remember seeing messages about it, but couldn't find it.
Do you have any pointers?
I'm interesting in seeing if it's worth it and maybe finishing it.

Thanks :)

Sincerely,
Nick

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/1] hid: Add HID Report Descriptor to sysfs.
  2011-01-21  6:19 ` [PATCH 1/1] hid: Add HID Report Descriptor to sysfs Alan Ott
@ 2011-01-22 13:55   ` Greg KH
  2011-01-23 22:35     ` [PATCH v2 0/1] HID: Report Descriptor in Sysfs Alan Ott
  2011-01-23 22:35     ` [PATCH v2 1/1] hid: Add HID Report Descriptor to sysfs Alan Ott
  0 siblings, 2 replies; 21+ messages in thread
From: Greg KH @ 2011-01-22 13:55 UTC (permalink / raw)
  To: Alan Ott; +Cc: Jiri Kosina, linux-input, linux-kernel

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v2 0/1] HID: Report Descriptor in Sysfs
  2011-01-22 13:55   ` Greg KH
@ 2011-01-23 22:35     ` Alan Ott
  2011-01-23 22:35     ` [PATCH v2 1/1] hid: Add HID Report Descriptor to sysfs Alan Ott
  1 sibling, 0 replies; 21+ messages in thread
From: Alan Ott @ 2011-01-23 22:35 UTC (permalink / raw)
  To: Jiri Kosina, linux-input, linux-kernel, greg, stern, libusb-devel
  Cc: Alan Ott

This is version 2 of the patch, with binary data in the sysfs file instead
of ASCII, as suggested by Alan Stern and Greg KH.

So I'd like to have access to the HID report descriptor in a sysfs entry, so
I can read it without opening the device.  hid-core seemed like the place to
put it.

Using the /sys/class links, for hidraw devices, this puts a new file,
report_descriptor in the directory:
	/sys/class/hidraw/hidraw0/device/

For my USB device (for example), the new file is in:
	/sys/bus/usb/devices/1-5.3:1.0/0003:046D:C216.0001/

For my Bluetooth device, the new file is in:
	/sys/class/bluetooth/hci0/hci0:11/0005:054C:0268.0002/

I'm not super confident that these file locations are the best place, but I
made a best guess so that it could be discussed.  The current location is
where the hid-core stuff lives.  Is there a reason these directories are
named bus:vendor:product:id (instead of hid-core or something similar)?  Is
there a better way to do this?

Alan.

Alan Ott (1):
  hid: Add HID Report Descriptor to sysfs.

 drivers/hid/hid-core.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)



^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v2 1/1] hid: Add HID Report Descriptor to sysfs.
  2011-01-22 13:55   ` Greg KH
  2011-01-23 22:35     ` [PATCH v2 0/1] HID: Report Descriptor in Sysfs Alan Ott
@ 2011-01-23 22:35     ` Alan Ott
  2011-01-23 22:59       ` Greg KH
  1 sibling, 1 reply; 21+ messages in thread
From: Alan Ott @ 2011-01-23 22:35 UTC (permalink / raw)
  To: Jiri Kosina, linux-input, linux-kernel, greg, stern, libusb-devel
  Cc: Alan Ott

Add a new binary sysfs entry called report_descriptor which contains
the HID report descriptor.

Signed-off-by: Alan Ott <alan@signal11.us>
---
 drivers/hid/hid-core.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index d678cf3..32bbd5d 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1159,6 +1159,32 @@ static bool hid_hiddev(struct hid_device *hdev)
 	return !!hid_match_id(hdev, hid_hiddev_list);
 }
 
+
+static ssize_t
+read_report_descriptor(struct file *filp, struct kobject *kobj,
+		struct bin_attribute *attr,
+		char *buf, loff_t off, size_t count)
+{
+	struct device *dev = container_of(kobj, struct device, kobj);
+	struct hid_device *hdev = container_of(dev, struct hid_device, dev);
+
+	if (off >= hdev->rsize)
+		return 0;
+
+	if (off + count > hdev->rsize)
+		count = hdev->rsize - off;
+
+	memcpy(buf, hdev->rdesc + off, count);
+
+	return count;
+}
+
+static struct bin_attribute dev_bin_attr_report_desc = {
+	.attr = { .name = "report_descriptor", .mode = 0444 },
+	.read = read_report_descriptor,
+	.size = HID_MAX_DESCRIPTOR_SIZE,
+};
+
 int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
 {
 	static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
@@ -1169,6 +1195,7 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
 	char buf[64];
 	unsigned int i;
 	int len;
+	int ret;
 
 	if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE)
 		connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV);
@@ -1230,6 +1257,11 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
 		bus = "<UNKNOWN>";
 	}
 
+	ret = device_create_bin_file(&hdev->dev, &dev_bin_attr_report_desc);
+	if (ret)
+		hid_warn(hdev,
+			 "can't create sysfs report descriptor attribute err: %d\n", ret);
+
 	hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
 		 buf, bus, hdev->version >> 8, hdev->version & 0xff,
 		 type, hdev->name, hdev->phys);
@@ -1240,6 +1272,7 @@ EXPORT_SYMBOL_GPL(hid_connect);
 
 void hid_disconnect(struct hid_device *hdev)
 {
+	device_remove_bin_file(&hdev->dev, &dev_bin_attr_report_desc);
 	if (hdev->claimed & HID_CLAIMED_INPUT)
 		hidinput_disconnect(hdev);
 	if (hdev->claimed & HID_CLAIMED_HIDDEV)
-- 
1.7.0.4



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH v2 1/1] hid: Add HID Report Descriptor to sysfs.
  2011-01-23 22:35     ` [PATCH v2 1/1] hid: Add HID Report Descriptor to sysfs Alan Ott
@ 2011-01-23 22:59       ` Greg KH
  2011-01-24  0:36         ` [PATCH v3 0/1] HID: Report Descriptor in Sysfs Alan Ott
                           ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Greg KH @ 2011-01-23 22:59 UTC (permalink / raw)
  To: Alan Ott; +Cc: Jiri Kosina, linux-input, linux-kernel, stern, libusb-devel

On Sun, Jan 23, 2011 at 05:35:07PM -0500, Alan Ott wrote:
> Add a new binary sysfs entry called report_descriptor which contains
> the HID report descriptor.

Oops, I forgot to mention that any new sysfs file needs to be documented
in Documentation/ABI/

Can you please add that documentation to this patch so people know what
the file is, and what it is for?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v3 0/1] HID: Report Descriptor in Sysfs
  2011-01-23 22:59       ` Greg KH
@ 2011-01-24  0:36         ` Alan Ott
  2011-01-24  0:36         ` [PATCH v3 1/1] hid: Add HID Report Descriptor to sysfs Alan Ott
                           ` (2 subsequent siblings)
  3 siblings, 0 replies; 21+ messages in thread
From: Alan Ott @ 2011-01-24  0:36 UTC (permalink / raw)
  To: Jiri Kosina, linux-input, linux-kernel, greg, stern, libusb-devel
  Cc: Alan Ott

This is version 3 of the patch, with binary data in the sysfs file instead
of ASCII, as suggested by Alan Stern and Greg KH.  Also now with
documentation.

Original Description:

So I'd like to have access to the HID report descriptor in a sysfs entry, so
I can read it without opening the device.  hid-core seemed like the place to
put it.

Using the /sys/class links, for hidraw devices, this puts a new file,
report_descriptor in the directory:
	/sys/class/hidraw/hidraw0/device/

For my USB device (for example), the new file is in:
	/sys/bus/usb/devices/1-5.3:1.0/0003:046D:C216.0001/

For my Bluetooth device, the new file is in:
	/sys/class/bluetooth/hci0/hci0:11/0005:054C:0268.0002/

I'm not super confident that these file locations are the best place, but I
made a best guess so that it could be discussed.  The current location is
where the hid-core stuff lives.  Is there a reason these directories are
named bus:vendor:product:id (instead of hid-core or something similar)?  Is
there a better way to do this?

Alan.

Alan Ott (1):
  hid: Add HID Report Descriptor to sysfs.

 Documentation/ABI/testing/sysfs-driver-hid |   10 ++++++++
 drivers/hid/hid-core.c                     |   33 ++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-hid



^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v3 1/1] hid: Add HID Report Descriptor to sysfs.
  2011-01-23 22:59       ` Greg KH
  2011-01-24  0:36         ` [PATCH v3 0/1] HID: Report Descriptor in Sysfs Alan Ott
@ 2011-01-24  0:36         ` Alan Ott
  2011-01-24  3:50         ` [PATCH v4 0/1] HID: Report Descriptor in Sysfs Alan Ott
  2011-01-24  3:50         ` [PATCH v4 1/1] hid: Add HID Report Descriptor to sysfs Alan Ott
  3 siblings, 0 replies; 21+ messages in thread
From: Alan Ott @ 2011-01-24  0:36 UTC (permalink / raw)
  To: Jiri Kosina, linux-input, linux-kernel, greg, stern, libusb-devel
  Cc: Alan Ott

Add a new binary sysfs entry called report_descriptor which contains
the HID report descriptor.

Signed-off-by: Alan Ott <alan@signal11.us>
---
 Documentation/ABI/testing/sysfs-driver-hid |   10 ++++++++
 drivers/hid/hid-core.c                     |   33 ++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-hid

diff --git a/Documentation/ABI/testing/sysfs-driver-hid b/Documentation/ABI/testing/sysfs-driver-hid
new file mode 100644
index 0000000..f30ab4c
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-hid
@@ -0,0 +1,10 @@
+What:		For USB devices	: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/report_descriptor
+		For BT devices	: /sys/class/bluetooth/hci<addr>/<hid-bus>:<vendor-id>:<product-id>.<num>/report_descriptor
+		Symlink		: /sys/class/hidraw/hidraw<num>/device/report_descriptor
+Date:		Jan 2011
+KernelVersion:	2.0.38
+Contact:	Alan Ott <alan@signal11.us>
+Description:	When read, this file returns the device's raw binary HID
+		report descriptor.
+		This file cannot be written.
+Users:		HIDAPI library (http://www.signal11.us/oss/hidapi)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index d678cf3..32bbd5d 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1159,6 +1159,32 @@ static bool hid_hiddev(struct hid_device *hdev)
 	return !!hid_match_id(hdev, hid_hiddev_list);
 }
 
+
+static ssize_t
+read_report_descriptor(struct file *filp, struct kobject *kobj,
+		struct bin_attribute *attr,
+		char *buf, loff_t off, size_t count)
+{
+	struct device *dev = container_of(kobj, struct device, kobj);
+	struct hid_device *hdev = container_of(dev, struct hid_device, dev);
+
+	if (off >= hdev->rsize)
+		return 0;
+
+	if (off + count > hdev->rsize)
+		count = hdev->rsize - off;
+
+	memcpy(buf, hdev->rdesc + off, count);
+
+	return count;
+}
+
+static struct bin_attribute dev_bin_attr_report_desc = {
+	.attr = { .name = "report_descriptor", .mode = 0444 },
+	.read = read_report_descriptor,
+	.size = HID_MAX_DESCRIPTOR_SIZE,
+};
+
 int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
 {
 	static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
@@ -1169,6 +1195,7 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
 	char buf[64];
 	unsigned int i;
 	int len;
+	int ret;
 
 	if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE)
 		connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV);
@@ -1230,6 +1257,11 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
 		bus = "<UNKNOWN>";
 	}
 
+	ret = device_create_bin_file(&hdev->dev, &dev_bin_attr_report_desc);
+	if (ret)
+		hid_warn(hdev,
+			 "can't create sysfs report descriptor attribute err: %d\n", ret);
+
 	hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
 		 buf, bus, hdev->version >> 8, hdev->version & 0xff,
 		 type, hdev->name, hdev->phys);
@@ -1240,6 +1272,7 @@ EXPORT_SYMBOL_GPL(hid_connect);
 
 void hid_disconnect(struct hid_device *hdev)
 {
+	device_remove_bin_file(&hdev->dev, &dev_bin_attr_report_desc);
 	if (hdev->claimed & HID_CLAIMED_INPUT)
 		hidinput_disconnect(hdev);
 	if (hdev->claimed & HID_CLAIMED_HIDDEV)
-- 
1.7.0.4



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH v4 0/1] HID: Report Descriptor in Sysfs
  2011-01-23 22:59       ` Greg KH
  2011-01-24  0:36         ` [PATCH v3 0/1] HID: Report Descriptor in Sysfs Alan Ott
  2011-01-24  0:36         ` [PATCH v3 1/1] hid: Add HID Report Descriptor to sysfs Alan Ott
@ 2011-01-24  3:50         ` Alan Ott
  2011-02-16  4:11           ` Alan Ott
  2011-01-24  3:50         ` [PATCH v4 1/1] hid: Add HID Report Descriptor to sysfs Alan Ott
  3 siblings, 1 reply; 21+ messages in thread
From: Alan Ott @ 2011-01-24  3:50 UTC (permalink / raw)
  To: Randy Dunlap, Jiri Kosina, Alan Ott, linux-doc, linux-kernel,
	linux-input, greg, stern
  Cc: Alan Ott

This is version 4 of the patch, with Documentation as requested by Greg KH,
a version number fixed in the documentation, and sent to the right people
this time. (Sorry for the noise; I forgot to re-run get_maintainer.pl after
I added the docs for v3).

Original email follows:

So I'd like to have access to the HID report descriptor in a sysfs entry, so
I can read it without opening the device.  hid-core seemed like the place to
put it.

Using the /sys/class links, for hidraw devices, this puts a new file,
report_descriptor in the directory:
	/sys/class/hidraw/hidraw0/device/

For my USB device (for example), the new file is in:
	/sys/bus/usb/devices/1-5.3:1.0/0003:046D:C216.0001/

For my Bluetooth device, the new file is in:
	/sys/class/bluetooth/hci0/hci0:11/0005:054C:0268.0002/

I'm not super confident that these file locations are the best place, but I
made a best guess so that it could be discussed.  The current location is
where the hid-core stuff lives.  Is there a reason these directories are
named bus:vendor:product:id (instead of hid-core or something similar)?  Is
there a better way to do this?

Alan.

Alan Ott (1):
  hid: Add HID Report Descriptor to sysfs.

 Documentation/ABI/testing/sysfs-driver-hid |   10 ++++++++
 drivers/hid/hid-core.c                     |   33 ++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-hid



^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH v4 1/1] hid: Add HID Report Descriptor to sysfs.
  2011-01-23 22:59       ` Greg KH
                           ` (2 preceding siblings ...)
  2011-01-24  3:50         ` [PATCH v4 0/1] HID: Report Descriptor in Sysfs Alan Ott
@ 2011-01-24  3:50         ` Alan Ott
  2011-02-17 12:55           ` Antonio Ospite
  3 siblings, 1 reply; 21+ messages in thread
From: Alan Ott @ 2011-01-24  3:50 UTC (permalink / raw)
  To: Randy Dunlap, Jiri Kosina, Alan Ott, linux-doc, linux-kernel,
	linux-input, greg, stern
  Cc: Alan Ott

Add a new binary sysfs entry called report_descriptor which contains
the HID report descriptor.

Signed-off-by: Alan Ott <alan@signal11.us>
---
 Documentation/ABI/testing/sysfs-driver-hid |   10 ++++++++
 drivers/hid/hid-core.c                     |   33 ++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-driver-hid

diff --git a/Documentation/ABI/testing/sysfs-driver-hid b/Documentation/ABI/testing/sysfs-driver-hid
new file mode 100644
index 0000000..b6490e1
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-driver-hid
@@ -0,0 +1,10 @@
+What:		For USB devices	: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/report_descriptor
+		For BT devices	: /sys/class/bluetooth/hci<addr>/<hid-bus>:<vendor-id>:<product-id>.<num>/report_descriptor
+		Symlink		: /sys/class/hidraw/hidraw<num>/device/report_descriptor
+Date:		Jan 2011
+KernelVersion:	2.0.39
+Contact:	Alan Ott <alan@signal11.us>
+Description:	When read, this file returns the device's raw binary HID
+		report descriptor.
+		This file cannot be written.
+Users:		HIDAPI library (http://www.signal11.us/oss/hidapi)
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index d678cf3..32bbd5d 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1159,6 +1159,32 @@ static bool hid_hiddev(struct hid_device *hdev)
 	return !!hid_match_id(hdev, hid_hiddev_list);
 }
 
+
+static ssize_t
+read_report_descriptor(struct file *filp, struct kobject *kobj,
+		struct bin_attribute *attr,
+		char *buf, loff_t off, size_t count)
+{
+	struct device *dev = container_of(kobj, struct device, kobj);
+	struct hid_device *hdev = container_of(dev, struct hid_device, dev);
+
+	if (off >= hdev->rsize)
+		return 0;
+
+	if (off + count > hdev->rsize)
+		count = hdev->rsize - off;
+
+	memcpy(buf, hdev->rdesc + off, count);
+
+	return count;
+}
+
+static struct bin_attribute dev_bin_attr_report_desc = {
+	.attr = { .name = "report_descriptor", .mode = 0444 },
+	.read = read_report_descriptor,
+	.size = HID_MAX_DESCRIPTOR_SIZE,
+};
+
 int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
 {
 	static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
@@ -1169,6 +1195,7 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
 	char buf[64];
 	unsigned int i;
 	int len;
+	int ret;
 
 	if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE)
 		connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV);
@@ -1230,6 +1257,11 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
 		bus = "<UNKNOWN>";
 	}
 
+	ret = device_create_bin_file(&hdev->dev, &dev_bin_attr_report_desc);
+	if (ret)
+		hid_warn(hdev,
+			 "can't create sysfs report descriptor attribute err: %d\n", ret);
+
 	hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
 		 buf, bus, hdev->version >> 8, hdev->version & 0xff,
 		 type, hdev->name, hdev->phys);
@@ -1240,6 +1272,7 @@ EXPORT_SYMBOL_GPL(hid_connect);
 
 void hid_disconnect(struct hid_device *hdev)
 {
+	device_remove_bin_file(&hdev->dev, &dev_bin_attr_report_desc);
 	if (hdev->claimed & HID_CLAIMED_INPUT)
 		hidinput_disconnect(hdev);
 	if (hdev->claimed & HID_CLAIMED_HIDDEV)
-- 
1.7.0.4



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/1] HID: Report Descriptor in Sysfs
  2011-01-21 20:03       ` Nikolai Kondrashov
@ 2011-01-24 15:17         ` Jiri Kosina
  0 siblings, 0 replies; 21+ messages in thread
From: Jiri Kosina @ 2011-01-24 15:17 UTC (permalink / raw)
  To: Nikolai Kondrashov; +Cc: Alan Ott, linux-input, linux-kernel

On Fri, 21 Jan 2011, Nikolai Kondrashov wrote:

> > There were also efforts to make the report descriptor replaceable in a
> > request_firmware() way, but that never converged to state in which it
> > could be applied IIRC.
> I remember seeing messages about it, but couldn't find it.
> Do you have any pointers?
> I'm interesting in seeing if it's worth it and maybe finishing it.

If patchwork woul be working, you'd be able to find it here: 
	
	http://patchwork.kernel.org/patch/69723/

Parts of the thread seem to be on 
http://www.spinics.net/lists/linux-input/msg06537.html

-- 
Jiri Kosina
SUSE Labs, Novell Inc.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v4 0/1] HID: Report Descriptor in Sysfs
  2011-01-24  3:50         ` [PATCH v4 0/1] HID: Report Descriptor in Sysfs Alan Ott
@ 2011-02-16  4:11           ` Alan Ott
  2011-02-17 12:26             ` Jiri Kosina
  0 siblings, 1 reply; 21+ messages in thread
From: Alan Ott @ 2011-02-16  4:11 UTC (permalink / raw)
  To: Alan Ott
  Cc: Randy Dunlap, Jiri Kosina, linux-doc, linux-kernel, linux-input,
	greg, stern, Antonio Ospite

On 01/23/2011 10:50 PM, Alan Ott wrote:
> So I'd like to have access to the HID report descriptor in a sysfs entry, so
> I can read it without opening the device.  hid-core seemed like the place to
> put it.
>
> Using the /sys/class links, for hidraw devices, this puts a new file,
> report_descriptor in the directory:
> 	/sys/class/hidraw/hidraw0/device/
>
> For my USB device (for example), the new file is in:
> 	/sys/bus/usb/devices/1-5.3:1.0/0003:046D:C216.0001/
>
> For my Bluetooth device, the new file is in:
> 	/sys/class/bluetooth/hci0/hci0:11/0005:054C:0268.0002/
>
> I'm not super confident that these file locations are the best place, but I
> made a best guess so that it could be discussed.  The current location is
> where the hid-core stuff lives.  Is there a reason these directories are
> named bus:vendor:product:id (instead of hid-core or something similar)?  Is
> there a better way to do this?
>
> Alan.
>
> Alan Ott (1):
>    hid: Add HID Report Descriptor to sysfs.
>
>   Documentation/ABI/testing/sysfs-driver-hid |   10 ++++++++
>   drivers/hid/hid-core.c                     |   33 ++++++++++++++++++++++++++++
>   2 files changed, 43 insertions(+), 0 deletions(-)
>   create mode 100644 Documentation/ABI/testing/sysfs-driver-hid
>
>    

I Didn't get any responses on the fixed-up patch. Does anyone have any 
issue with this?

Alan.



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v4 0/1] HID: Report Descriptor in Sysfs
  2011-02-16  4:11           ` Alan Ott
@ 2011-02-17 12:26             ` Jiri Kosina
  0 siblings, 0 replies; 21+ messages in thread
From: Jiri Kosina @ 2011-02-17 12:26 UTC (permalink / raw)
  To: Alan Ott
  Cc: Randy Dunlap, linux-doc, linux-kernel, linux-input, greg, stern,
	Antonio Ospite

On Tue, 15 Feb 2011, Alan Ott wrote:

> > Using the /sys/class links, for hidraw devices, this puts a new file,
> > report_descriptor in the directory:
> > 	/sys/class/hidraw/hidraw0/device/
> 
> I Didn't get any responses on the fixed-up patch. Does anyone have any 
> issue with this?

I have applied the patch, thanks Alan.

-- 
Jiri Kosina
SUSE Labs, Novell Inc.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH v4 1/1] hid: Add HID Report Descriptor to sysfs.
  2011-01-24  3:50         ` [PATCH v4 1/1] hid: Add HID Report Descriptor to sysfs Alan Ott
@ 2011-02-17 12:55           ` Antonio Ospite
  0 siblings, 0 replies; 21+ messages in thread
From: Antonio Ospite @ 2011-02-17 12:55 UTC (permalink / raw)
  To: Alan Ott
  Cc: Marcin Tolysz, Randy Dunlap, Jiri Kosina, linux-doc,
	linux-kernel, linux-input, greg, stern

[-- Attachment #1: Type: text/plain, Size: 4554 bytes --]

On Sun, 23 Jan 2011 22:50:18 -0500
Alan Ott <alan@signal11.us> wrote:

> Add a new binary sysfs entry called report_descriptor which contains
> the HID report descriptor.
> 
> Signed-off-by: Alan Ott <alan@signal11.us>

Adding Marcin Tolysz to CC, he is interested in a mechanism to
override the hid_descriptor from userspace dynamically.

Marcin, now that this 'report_descriptor' sysfs attribute has been
accepted as read-only in mainline, maybe you could implement the .write
method for it if your firmware approach to override hid descriptors
would not be accepted. Just pointing at an alternative option, not sure
if it is the best one.

Regards,
   Antonio

> ---
>  Documentation/ABI/testing/sysfs-driver-hid |   10 ++++++++
>  drivers/hid/hid-core.c                     |   33 ++++++++++++++++++++++++++++
>  2 files changed, 43 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/ABI/testing/sysfs-driver-hid
> 
> diff --git a/Documentation/ABI/testing/sysfs-driver-hid b/Documentation/ABI/testing/sysfs-driver-hid
> new file mode 100644
> index 0000000..b6490e1
> --- /dev/null
> +++ b/Documentation/ABI/testing/sysfs-driver-hid
> @@ -0,0 +1,10 @@
> +What:		For USB devices	: /sys/bus/usb/devices/<busnum>-<devnum>:<config num>.<interface num>/<hid-bus>:<vendor-id>:<product-id>.<num>/report_descriptor
> +		For BT devices	: /sys/class/bluetooth/hci<addr>/<hid-bus>:<vendor-id>:<product-id>.<num>/report_descriptor
> +		Symlink		: /sys/class/hidraw/hidraw<num>/device/report_descriptor
> +Date:		Jan 2011
> +KernelVersion:	2.0.39
> +Contact:	Alan Ott <alan@signal11.us>
> +Description:	When read, this file returns the device's raw binary HID
> +		report descriptor.
> +		This file cannot be written.
> +Users:		HIDAPI library (http://www.signal11.us/oss/hidapi)
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index d678cf3..32bbd5d 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -1159,6 +1159,32 @@ static bool hid_hiddev(struct hid_device *hdev)
>  	return !!hid_match_id(hdev, hid_hiddev_list);
>  }
>  
> +
> +static ssize_t
> +read_report_descriptor(struct file *filp, struct kobject *kobj,
> +		struct bin_attribute *attr,
> +		char *buf, loff_t off, size_t count)
> +{
> +	struct device *dev = container_of(kobj, struct device, kobj);
> +	struct hid_device *hdev = container_of(dev, struct hid_device, dev);
> +
> +	if (off >= hdev->rsize)
> +		return 0;
> +
> +	if (off + count > hdev->rsize)
> +		count = hdev->rsize - off;
> +
> +	memcpy(buf, hdev->rdesc + off, count);
> +
> +	return count;
> +}
> +
> +static struct bin_attribute dev_bin_attr_report_desc = {
> +	.attr = { .name = "report_descriptor", .mode = 0444 },
> +	.read = read_report_descriptor,
> +	.size = HID_MAX_DESCRIPTOR_SIZE,
> +};
> +
>  int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
>  {
>  	static const char *types[] = { "Device", "Pointer", "Mouse", "Device",
> @@ -1169,6 +1195,7 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
>  	char buf[64];
>  	unsigned int i;
>  	int len;
> +	int ret;
>  
>  	if (hdev->quirks & HID_QUIRK_HIDDEV_FORCE)
>  		connect_mask |= (HID_CONNECT_HIDDEV_FORCE | HID_CONNECT_HIDDEV);
> @@ -1230,6 +1257,11 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
>  		bus = "<UNKNOWN>";
>  	}
>  
> +	ret = device_create_bin_file(&hdev->dev, &dev_bin_attr_report_desc);
> +	if (ret)
> +		hid_warn(hdev,
> +			 "can't create sysfs report descriptor attribute err: %d\n", ret);
> +
>  	hid_info(hdev, "%s: %s HID v%x.%02x %s [%s] on %s\n",
>  		 buf, bus, hdev->version >> 8, hdev->version & 0xff,
>  		 type, hdev->name, hdev->phys);
> @@ -1240,6 +1272,7 @@ EXPORT_SYMBOL_GPL(hid_connect);
>  
>  void hid_disconnect(struct hid_device *hdev)
>  {
> +	device_remove_bin_file(&hdev->dev, &dev_bin_attr_report_desc);
>  	if (hdev->claimed & HID_CLAIMED_INPUT)
>  		hidinput_disconnect(hdev);
>  	if (hdev->claimed & HID_CLAIMED_HIDDEV)
> -- 
> 1.7.0.4
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


-- 
Antonio Ospite
http://ao2.it

PGP public key ID: 0x4553B001

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2011-02-17 12:55 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-21  6:19 [PATCH 0/1] HID: Report Descriptor in Sysfs Alan Ott
2011-01-21  6:19 ` [PATCH 1/1] hid: Add HID Report Descriptor to sysfs Alan Ott
2011-01-22 13:55   ` Greg KH
2011-01-23 22:35     ` [PATCH v2 0/1] HID: Report Descriptor in Sysfs Alan Ott
2011-01-23 22:35     ` [PATCH v2 1/1] hid: Add HID Report Descriptor to sysfs Alan Ott
2011-01-23 22:59       ` Greg KH
2011-01-24  0:36         ` [PATCH v3 0/1] HID: Report Descriptor in Sysfs Alan Ott
2011-01-24  0:36         ` [PATCH v3 1/1] hid: Add HID Report Descriptor to sysfs Alan Ott
2011-01-24  3:50         ` [PATCH v4 0/1] HID: Report Descriptor in Sysfs Alan Ott
2011-02-16  4:11           ` Alan Ott
2011-02-17 12:26             ` Jiri Kosina
2011-01-24  3:50         ` [PATCH v4 1/1] hid: Add HID Report Descriptor to sysfs Alan Ott
2011-02-17 12:55           ` Antonio Ospite
2011-01-21  9:59 ` [PATCH 0/1] HID: Report Descriptor in Sysfs Jiri Kosina
2011-01-21 14:52   ` Alan Ott
2011-01-21 15:09     ` Jiri Kosina
2011-01-21 15:29       ` Alan Ott
2011-01-21 16:14         ` Jiri Kosina
2011-01-21 16:57           ` Alan Ott
2011-01-21 20:03       ` Nikolai Kondrashov
2011-01-24 15:17         ` Jiri Kosina

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).