From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752346AbbCNU52 (ORCPT ); Sat, 14 Mar 2015 16:57:28 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:48968 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751188AbbCNU5Y (ORCPT ); Sat, 14 Mar 2015 16:57:24 -0400 Date: Sat, 14 Mar 2015 21:57:22 +0100 From: Pavel Machek To: trivial@kernel.org, jkosina@suse.cz, kernel list Subject: [PATCH] samples/hidraw: make it possible to select device Message-ID: <20150314205722.GA11289@amd> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Makefile that can actually build the example, and allow selecting device to work on. Signed-off-by: Pavel Machek diff --git a/samples/hidraw/Makefile b/samples/hidraw/Makefile index 382eeae..a9ab961 100644 --- a/samples/hidraw/Makefile +++ b/samples/hidraw/Makefile @@ -8,3 +8,5 @@ hostprogs-y := hid-example always := $(hostprogs-y) HOSTCFLAGS_hid-example.o += -I$(objtree)/usr/include + +all: hid-example diff --git a/samples/hidraw/hid-example.c b/samples/hidraw/hid-example.c index 512a7e5..92e6c15 100644 --- a/samples/hidraw/hid-example.c +++ b/samples/hidraw/hid-example.c @@ -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"); -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html