Skip to contentSkip to conversation

HID: hiddev: allocate minor number hiddev's USB interface is bound to

PATCH In review Jaejoong Kim 2 participants 4 messages Feb 15, 2017 – Mar 2, 2017 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 HID: hiddev: allocate minor number hiddev's USB interface is bound to

When HID device connected to the PC, HID device driver announces which driver is loaded with a kernel info message. In this case, hiddev's minor number is always '0' even though hiddev's real minor number is not zero.

To display hiddev with minor number asked from usb core, we need to fill hiddev's minor number this interface is bound to.

---
Changes in v2:
- fix typo in commit message
---

 drivers/hid/usbhid/hiddev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hid/usbhid/hiddev.c +1 -0
index 700145b..27e1f8d 100644
@@ -910,6 +910,7 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
 		kfree(hiddev);
 		return -1;
 	}
+	hid->minor = usbhid->intf->minor;
 	return 0;
 }
 
Signature · 6 lines
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1487152516-12335-1-git-send-email-climbbb.kim-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

Hi Jiri, Benjamin

Could you please review my hiddev patch?

Thanks, jaejoong

2017-02-15 18:55 GMT+09:00 Jaejoong Kim <[email protected]>:

Quoted 29 lines

When HID device connected to the PC, HID device driver announces which driver is loaded with a kernel info message. In this case, hiddev's minor number is always '0' even though hiddev's real minor number is not zero.

To display hiddev with minor number asked from usb core, we need to fill hiddev's minor number this interface is bound to.

---
Changes in v2:
- fix typo in commit message
---

 drivers/hid/usbhid/hiddev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hid/usbhid/hiddev.c +1 -1
index 700145b..27e1f8d 100644
@@ -910,6 +910,7 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
                kfree(hiddev);
                return -1;
        }
+       hid->minor = usbhid->intf->minor;
        return 0;
 }
 
--
Quoted 2 lines

2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to a message not in the archive
Quoted 9 lines · Jaejoong Kim

When HID device connected to the PC, HID device driver announces which driver is loaded with a kernel info message. In this case, hiddev's minor number is always '0' even though hiddev's real minor number is not zero.

To display hiddev with minor number asked from usb core, we need to fill hiddev's minor number this interface is bound to.

---

That's a single line of code, and I get into some headaches :)

So, the commit that broke this (.minor not being set) is actually commit bd25f4dd69727555 ("HID: hiddev: use usb_find_interface, get rid of BKL"), from 2010-07-11...

And this patch reverts to the intended behavior. But I am wondering if we should really store the minor in struct hid_device if it is only used by hiddev. hidraw does use a minor too, but stores it in struct hidraw directly, so IMO it would make sense to store this in struct hiddev. The problem is that this struct is not exported, and it's going to be some refactoring work to do so.

So, in a way, I am tempted to give my:

But if Jiri feels that a cleanup of hiddev would be required instead, I would follow him :)

Cheers,
Benjamin

Quoted 22 lines

Changes in v2:
- fix typo in commit message
---

 drivers/hid/usbhid/hiddev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hid/usbhid/hiddev.c +1 -0
index 700145b..27e1f8d 100644
@@ -910,6 +910,7 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
 		kfree(hiddev);
 		return -1;
 	}
+	hid->minor = usbhid->intf->minor;
 	return 0;
 }
 
Signature · 1 line
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 20170228170507.GA7064-/m+UfqrgI5QNLKR9yMNcA1aTQe2KTcn/@public.gmane.org

#5 lore raw

Hi Benjamin

Thanks for the review my patch :)

2017-03-01 2:05 GMT+09:00 Benjamin Tissoires <[email protected]>:

Quoted 11 lines · Jaejoong Kim
Quoted 9 lines

When HID device connected to the PC, HID device driver announces which driver is loaded with a kernel info message. In this case, hiddev's minor number is always '0' even though hiddev's real minor number is not zero.

To display hiddev with minor number asked from usb core, we need to fill hiddev's minor number this interface is bound to.

---

Quoted 7 lines

That's a single line of code, and I get into some headaches :)

So, the commit that broke this (.minor not being set) is actually commit bd25f4dd69727555 ("HID: hiddev: use usb_find_interface, get rid of BKL"), from 2010-07-11...

And this patch reverts to the intended behavior.

Could you explain more about 'intended behavior'?

Quoted 7 lines

But I am wondering if we
should really store the minor in struct hid_device if it is only used by hiddev. hidraw does use a minor too, but stores it in struct hidraw directly, so IMO it would make sense to store this in struct hiddev. The problem is that this struct is not exported, and it's going to be some refactoring work to do so.

I agree with you. My patch is just allocate 'right' minor number in struct hid_device.
After got your review mail,I also think struct hiddev and struct hid_device need some refactoring work for minor number handling as you said.

For example, hid-cp2112.c uses a minor number of struct hid_device. Based on comment
for minor in struct hid_device, it is for hiddev not hidraw. But, hid-cp2112's connect_mask
for hid_hw_start is HIDRAW.

I will do some work for this one, so please ignore this patch :)

Thanks, jaejoong

Quoted 28 lines

So, in a way, I am tempted to give my:

But if Jiri feels that a cleanup of hiddev would be required instead, I would follow him :)

Cheers,
Benjamin

Quoted 19 lines

Changes in v2:
- fix typo in commit message
---

 drivers/hid/usbhid/hiddev.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hid/usbhid/hiddev.c +1 -0
index 700145b..27e1f8d 100644
@@ -910,6 +910,7 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
              kfree(hiddev);
              return -1;
      }
+     hid->minor = usbhid->intf->minor;
      return 0;
 }
 
Quoted 3 lines
Quoted 3 lines

--
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html