From owner-svn-src-all@freebsd.org Tue Nov 10 13:18:46 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 56F7843035F; Tue, 10 Nov 2020 13:18:46 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CVpN61zlYz3tjl; Tue, 10 Nov 2020 13:18:46 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3709F2379B; Tue, 10 Nov 2020 13:18:46 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AADIjWu039321; Tue, 10 Nov 2020 13:18:46 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AADIjwn039317; Tue, 10 Nov 2020 13:18:45 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <202011101318.0AADIjwn039317@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Tue, 10 Nov 2020 13:18:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367560 - in stable/12: share/man/man4 sys/dev/usb sys/dev/usb/input X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/12: share/man/man4 sys/dev/usb sys/dev/usb/input X-SVN-Commit-Revision: 367560 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Nov 2020 13:18:46 -0000 Author: hselasky Date: Tue Nov 10 13:18:44 2020 New Revision: 367560 URL: https://svnweb.freebsd.org/changeset/base/367560 Log: MFC r367236: Implement the USB_GET_DEVICEINFO ioctl(2) for uhid(4). Submitted by: pedro martelletto Sponsored by: Mellanox Technologies // NVIDIA Networking Modified: stable/12/share/man/man4/uhid.4 stable/12/sys/dev/usb/input/uhid.c stable/12/sys/dev/usb/usb_generic.c stable/12/sys/dev/usb/usb_generic.h Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/uhid.4 ============================================================================== --- stable/12/share/man/man4/uhid.4 Tue Nov 10 13:16:37 2020 (r367559) +++ stable/12/share/man/man4/uhid.4 Tue Nov 10 13:18:44 2020 (r367560) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 1, 2018 +.Dd Oct 31, 2020 .Dt UHID 4 .Os .Sh NAME @@ -131,6 +131,11 @@ and the .Va ugd_maxlen fields. This call may fail if the device does not support this feature. +.It Dv USB_GET_DEVICEINFO Pq Vt "struct usb_device_info" +Returns information about the device, like USB vendor ID and USB product ID. +This call will not issue any USB transactions. +Also refer to +.Xr ugen 4 . .El .Pp Use Modified: stable/12/sys/dev/usb/input/uhid.c ============================================================================== --- stable/12/sys/dev/usb/input/uhid.c Tue Nov 10 13:16:37 2020 (r367559) +++ stable/12/sys/dev/usb/input/uhid.c Tue Nov 10 13:18:44 2020 (r367560) @@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #define USB_DEBUG_VAR uhid_debug #include @@ -143,11 +144,13 @@ static usb_fifo_cmd_t uhid_stop_write; static usb_fifo_open_t uhid_open; static usb_fifo_close_t uhid_close; static usb_fifo_ioctl_t uhid_ioctl; +static usb_fifo_ioctl_t uhid_ioctl_post; static struct usb_fifo_methods uhid_fifo_methods = { .f_open = &uhid_open, .f_close = &uhid_close, .f_ioctl = &uhid_ioctl, + .f_ioctl_post = &uhid_ioctl_post, .f_start_read = &uhid_start_read, .f_stop_read = &uhid_stop_read, .f_start_write = &uhid_start_write, @@ -644,6 +647,24 @@ uhid_ioctl(struct usb_fifo *fifo, u_long cmd, void *ad case USB_GET_REPORT_ID: *(int *)addr = 0; /* XXX: we only support reportid 0? */ + break; + + default: + error = ENOIOCTL; + break; + } + return (error); +} + +static int +uhid_ioctl_post(struct usb_fifo *fifo, u_long cmd, void *addr, + int fflags) +{ + int error; + + switch (cmd) { + case USB_GET_DEVICEINFO: + error = ugen_fill_deviceinfo(fifo, addr); break; default: Modified: stable/12/sys/dev/usb/usb_generic.c ============================================================================== --- stable/12/sys/dev/usb/usb_generic.c Tue Nov 10 13:16:37 2020 (r367559) +++ stable/12/sys/dev/usb/usb_generic.c Tue Nov 10 13:18:44 2020 (r367560) @@ -109,8 +109,6 @@ static int ugen_set_interface(struct usb_fifo *, uint8 static int ugen_get_cdesc(struct usb_fifo *, struct usb_gen_descriptor *); static int ugen_get_sdesc(struct usb_fifo *, struct usb_gen_descriptor *); static int ugen_get_iface_driver(struct usb_fifo *f, struct usb_gen_descriptor *ugd); -static int usb_gen_fill_deviceinfo(struct usb_fifo *, - struct usb_device_info *); static int ugen_re_enumerate(struct usb_fifo *); static int ugen_iface_ioctl(struct usb_fifo *, u_long, void *, int); static uint8_t ugen_fs_get_complete(struct usb_fifo *, uint8_t *); @@ -817,7 +815,7 @@ ugen_get_iface_driver(struct usb_fifo *f, struct usb_g } /*------------------------------------------------------------------------* - * usb_gen_fill_deviceinfo + * ugen_fill_deviceinfo * * This function dumps information about an USB device to the * structure pointed to by the "di" argument. @@ -826,8 +824,8 @@ ugen_get_iface_driver(struct usb_fifo *f, struct usb_g * 0: Success * Else: Failure *------------------------------------------------------------------------*/ -static int -usb_gen_fill_deviceinfo(struct usb_fifo *f, struct usb_device_info *di) +int +ugen_fill_deviceinfo(struct usb_fifo *f, struct usb_device_info *di) { struct usb_device *udev; struct usb_device *hub; @@ -2216,7 +2214,7 @@ ugen_ioctl_post(struct usb_fifo *f, u_long cmd, void * case USB_DEVICEINFO: case USB_GET_DEVICEINFO: - error = usb_gen_fill_deviceinfo(f, addr); + error = ugen_fill_deviceinfo(f, addr); break; case USB_DEVICESTATS: Modified: stable/12/sys/dev/usb/usb_generic.h ============================================================================== --- stable/12/sys/dev/usb/usb_generic.h Tue Nov 10 13:16:37 2020 (r367559) +++ stable/12/sys/dev/usb/usb_generic.h Tue Nov 10 13:18:44 2020 (r367560) @@ -31,5 +31,6 @@ extern struct usb_fifo_methods usb_ugen_methods; int ugen_do_request(struct usb_fifo *f, struct usb_ctl_request *ur); +int ugen_fill_deviceinfo(struct usb_fifo *f, struct usb_device_info *di); #endif /* _USB_GENERIC_H_ */