From owner-dev-commits-src-all@freebsd.org Wed Jun 2 12:24:53 2021 Return-Path: Delivered-To: dev-commits-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 7B08C6418DA; Wed, 2 Jun 2021 12:24:53 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Fw7Wn1G4zz3FpV; Wed, 2 Jun 2021 12:24:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E31B816BE5; Wed, 2 Jun 2021 12:24:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 152COqom019186; Wed, 2 Jun 2021 12:24:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 152COqYc019185; Wed, 2 Jun 2021 12:24:52 GMT (envelope-from git) Date: Wed, 2 Jun 2021 12:24:52 GMT Message-Id: <202106021224.152COqYc019185@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: ae9aba942b58 - stable/13 - Update usb_timings_sysctl_handler() to accept any value for timings between 0 milliseconds and 2 seconds inclusivly. Some style fixes while at it. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ae9aba942b58ff235c5aafd599fe37821c8f79f5 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jun 2021 12:24:53 -0000 The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=ae9aba942b58ff235c5aafd599fe37821c8f79f5 commit ae9aba942b58ff235c5aafd599fe37821c8f79f5 Author: Hans Petter Selasky AuthorDate: 2021-05-18 13:16:29 +0000 Commit: Hans Petter Selasky CommitDate: 2021-06-02 11:25:20 +0000 Update usb_timings_sysctl_handler() to accept any value for timings between 0 milliseconds and 2 seconds inclusivly. Some style fixes while at it. The USB specification has minimum values and maximum values, and not only minimum values. Sponsored by: Mellanox Technologies // NVIDIA Networking (cherry picked from commit 00e501d720d46386e6c8d0ebb4b3a8e98cb0390e) --- sys/dev/usb/usb_debug.c | 57 +++++++++++-------------------------------------- 1 file changed, 13 insertions(+), 44 deletions(-) diff --git a/sys/dev/usb/usb_debug.c b/sys/dev/usb/usb_debug.c index 5b5d141508c3..5e521f7ec3a5 100644 --- a/sys/dev/usb/usb_debug.c +++ b/sys/dev/usb/usb_debug.c @@ -249,71 +249,40 @@ unsigned int usb_extra_power_up_time = USB_EXTRA_POWER_UP_TIME; /*------------------------------------------------------------------------* * usb_timings_sysctl_handler * - * This function updates timings variables, adjusting them where necessary. + * This function is used to update USB timing variables. *------------------------------------------------------------------------*/ static int usb_timings_sysctl_handler(SYSCTL_HANDLER_ARGS) { int error = 0; - unsigned int val; + unsigned val; /* * Attempt to get a coherent snapshot by making a copy of the data. */ if (arg1) - val = *(unsigned int *)arg1; + val = *(unsigned *)arg1; else val = arg2; - error = SYSCTL_OUT(req, &val, sizeof(int)); + error = SYSCTL_OUT(req, &val, sizeof(unsigned)); if (error || !req->newptr) return (error); if (!arg1) - return EPERM; + return (EPERM); - error = SYSCTL_IN(req, &val, sizeof(unsigned int)); + error = SYSCTL_IN(req, &val, sizeof(unsigned)); if (error) return (error); /* - * Now make sure the values are decent, and certainly no lower than - * what the USB spec prescribes. + * Make sure the specified value is not too big. Accept any + * value from 0 milliseconds to 2 seconds inclusivly for all + * parameters. */ - unsigned int *p = (unsigned int *)arg1; - if (p == &usb_port_reset_delay) { - if (val < USB_PORT_RESET_DELAY_SPEC) - return (EINVAL); - } else if (p == &usb_port_root_reset_delay) { - if (val < USB_PORT_ROOT_RESET_DELAY_SPEC) - return (EINVAL); - } else if (p == &usb_port_reset_recovery) { - if (val < USB_PORT_RESET_RECOVERY_SPEC) - return (EINVAL); - } else if (p == &usb_port_powerup_delay) { - if (val < USB_PORT_POWERUP_DELAY_SPEC) - return (EINVAL); - } else if (p == &usb_port_resume_delay) { - if (val < USB_PORT_RESUME_DELAY_SPEC) - return (EINVAL); - } else if (p == &usb_set_address_settle) { - if (val < USB_SET_ADDRESS_SETTLE_SPEC) - return (EINVAL); - } else if (p == &usb_resume_delay) { - if (val < USB_RESUME_DELAY_SPEC) - return (EINVAL); - } else if (p == &usb_resume_wait) { - if (val < USB_RESUME_WAIT_SPEC) - return (EINVAL); - } else if (p == &usb_resume_recovery) { - if (val < USB_RESUME_RECOVERY_SPEC) - return (EINVAL); - } else if (p == &usb_extra_power_up_time) { - if (val < USB_EXTRA_POWER_UP_TIME_SPEC) - return (EINVAL); - } else { - /* noop */ - } + if (val > 2000) + return (EINVAL); - *p = val; - return 0; + *(unsigned *)arg1 = val; + return (0); } #endif