Skip to contentSkip to conversation

samples/hidraw: make it possible to select device

PATCH Applied Pavel Machek 2 participants 2 messages Mar 14, 2015 – Mar 15, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 samples/hidraw: make it possible to select device

Makefile that can actually build the example, and allow selecting device to work on.

samples/hidraw/Makefile +2 -0
index 382eeae..a9ab961 100644
@@ -8,3 +8,5 @@ hostprogs-y := hid-example
 always := $(hostprogs-y)
 
 HOSTCFLAGS_hid-example.o += -I$(objtree)/usr/include
+
+all: hid-example
samples/hidraw/hid-example.c +5 -1
index 512a7e5..92e6c15 100644
@@ -46,10 +46,14 @@ int main(int argc, char **argv)
 	char buf[256];
 	struct hidraw_report_descriptor rpt_desc;
 	struct hidraw_devinfo info;
+	char *device = "/dev/hidraw0";
+
+	if (argc > 1)
+		device = argv[1];
 
 	/* Open the Device with non-blocking reads. In real life,
 	   don't use a hard coded path; use libudev instead. */
-	fd = open("/dev/hidraw0", O_RDWR|O_NONBLOCK);
+	fd = open(device, O_RDWR|O_NONBLOCK);
 
 	if (fd < 0) {
 		perror("Unable to open device");
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Applied
#1 lore raw
Quoted 4 lines · Pavel Machek

Makefile that can actually build the example, and allow selecting device to work on.

Applied to for-4.1/upstream. Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs