All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Added a check for NULL pointer in hid_add_device
@ 2013-06-25 17:51 Michael Banken
  2013-06-26 14:03 ` Benjamin Tissoires
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Banken @ 2013-06-25 17:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: rydberg, srinivas.pandruvada, erazor_de, benjamin.tissoires,
	jkosina, lorenz, linux-kernel, Michael Banken

This check greatly simplifies creating a dummy hid device.
With this check in place a hid dummy can be created simply by allocating and adding the device.
This used to be possible in earlier Kernel versions.

Signed-off-by: Michael Banken <michael.banken@mathe.stud.uni-erlangen.de>
Signed-off-by: Lorenz Haspel <lorenz@badgers.com>
---
 drivers/hid/hid-core.c |   37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 0951a9a..88c573e 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -2289,24 +2289,27 @@ int hid_add_device(struct hid_device *hdev)
 	if (hid_ignore(hdev))
 		return -ENODEV;
 
-	/*
-	 * Read the device report descriptor once and use as template
-	 * for the driver-specific modifications.
-	 */
-	ret = hdev->ll_driver->parse(hdev);
-	if (ret)
-		return ret;
-	if (!hdev->dev_rdesc)
-		return -ENODEV;
-
-	/*
-	 * Scan generic devices for group information
-	 */
-	if (hid_ignore_special_drivers ||
-	    !hid_match_id(hdev, hid_have_special_driver)) {
-		ret = hid_scan_report(hdev);
+	if (hdev->ll_driver != NULL) {
+		/*
+		 * Read the device report descriptor once and use as template
+			 * for the driver-specific modifications.
+		 */
+		ret = hdev->ll_driver->parse(hdev);
 		if (ret)
-			hid_warn(hdev, "bad device descriptor (%d)\n", ret);
+			return ret;
+		if (!hdev->dev_rdesc)
+			return -ENODEV;
+
+		/*
+		 * Scan generic devices for group information
+		 */
+		if (hid_ignore_special_drivers ||
+		    !hid_match_id(hdev, hid_have_special_driver)) {
+			ret = hid_scan_report(hdev);
+			if (ret)
+				hid_warn(hdev,
+					"bad device descriptor (%d)\n", ret);
+		}
 	}
 
 	/* XXX hack, any other cleaner solution after the driver core
-- 
1.7.10.4


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

end of thread, other threads:[~2013-06-28 10:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-25 17:51 [PATCH] Added a check for NULL pointer in hid_add_device Michael Banken
2013-06-26 14:03 ` Benjamin Tissoires
2013-06-26 15:45   ` michael.banken
2013-06-28 10:52     ` David Herrmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.