From nobody Wed Dec 11 01:24:46 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Y7Hvg1bLwz5g8MS; Wed, 11 Dec 2024 01:24:47 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Y7Hvg0zM4z3y0B; Wed, 11 Dec 2024 01:24:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733880287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vnNz7sP0HSxn+pBv9WWslwWXrOaDJB4ADJQYJnKEr7s=; b=d4f2pg2DqzZKbS/0voNcx+eZ8Lm2nHbhNzpHAm9Pzl9KQlwC4k1l9TQBM52MW+A3ZwWVMs DEX4Cc11E5hLLhHxNqCOHb9HKk3Nqgnm0U65kDo+xCnc4p1fF2R4iW6mk0a1CwhcgOtIzQ flFYbiGhq5tvAjh6lcx55xbXd1VoLZ0zp+RrFDwUh3ept+oUQktiQN5dXhHhV2jvrpjbmJ N403gcXa2YRpMkGrvo//HZqxHrtl+2DZ1u/0FHZxJcWoxh2Cn92msAhT5V8eGGtXtSf+CL U/d19tlxY4QX1MnQ9VruWx3FbBsue6N2z0lbgkeefWBoif/zSxMuWfeGlT++ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733880287; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vnNz7sP0HSxn+pBv9WWslwWXrOaDJB4ADJQYJnKEr7s=; b=N6esEntRORruA4KqdMQqhYxPzy4pvLQUDXijHdXE4ky6R3Evh/cA/Gi6tq2xzmB3couXZX ZyUHNvoVpMFCXSiwM2gyeY0UPmr2LzR6FLw7yUtpg5+IeFvhDA5c/TUNjeVODlucu6YeJK s7zy0kUnuDfmcKBgOvDQCGYY7yCg+tn33enOVJFiSK0M/MOYFvafBoTXQm6iVUskF73mNA KlP2l8RVrFwmCxmWt8wYv/iT1J+O5//MmqHsEha1bbM9M1UnD/w/SgJgcGJdad0bg+2Xi5 FrB9kFlaI2Dr25oIMp6LF5LnImGs863Xvh10nfQmJVTsARvgLsrZ3uCkuSypKw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733880287; a=rsa-sha256; cv=none; b=gZmvnQqolL3jktaPaIzCqFnkBYKGLVvzSH7XdUJ5O7MVPo1yJc5wqR/fk0udLFcIZMxaLM FpkNz1x4rU5p5ZcfYMl6H2OvC8IhrfLtd49kmje908GkzAgIDnoKiOmvUXxINqSgWyu2eu KxLgk71hd0BQnSSiSALZ5YpN9LyUIst6Zt82qQ4tHziGWYIu6fTu/b5rtKcFy+8wH6XVcb aYPh6QA+b9vDeecTeYNfe4xHaoB5NZotBb16zm2E7gqOOS7KXk+rJSAL1fdb9CPf3GR4LO Ji93L7BEfug8VaEX6/moCswIvImbG5zX+mxn2wNRxzELhREJy46siPtCgAeG+A== 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 4Y7Hvg0LGsznHB; Wed, 11 Dec 2024 01:24:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BB1OkaP024214; Wed, 11 Dec 2024 01:24:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BB1OkEh024211; Wed, 11 Dec 2024 01:24:46 GMT (envelope-from git) Date: Wed, 11 Dec 2024 01:24:46 GMT Message-Id: <202412110124.4BB1OkEh024211@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 51f3d0874f62 - main - usb: serial: propagate errors from ucom_queue_command() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 51f3d0874f6216907c8971c4af9d6be6c93edf7b Auto-Submitted: auto-generated The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=51f3d0874f6216907c8971c4af9d6be6c93edf7b commit 51f3d0874f6216907c8971c4af9d6be6c93edf7b Author: Kyle Evans AuthorDate: 2024-12-11 01:23:10 +0000 Commit: Kyle Evans CommitDate: 2024-12-11 01:23:10 +0000 usb: serial: propagate errors from ucom_queue_command() There's only one error that we can get back right now, but future changes will add some more cases that we need to watch out for. Start by returning errors and propagating them back. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D47950 --- sys/dev/usb/serial/usb_serial.c | 49 ++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/sys/dev/usb/serial/usb_serial.c b/sys/dev/usb/serial/usb_serial.c index 300438010c05..11a2e1078a67 100644 --- a/sys/dev/usb/serial/usb_serial.c +++ b/sys/dev/usb/serial/usb_serial.c @@ -151,7 +151,7 @@ static int ucom_unit_alloc(void); static void ucom_unit_free(int); static int ucom_attach_tty(struct ucom_super_softc *, struct ucom_softc *); static void ucom_detach_tty(struct ucom_super_softc *, struct ucom_softc *); -static void ucom_queue_command(struct ucom_softc *, +static int ucom_queue_command(struct ucom_softc *, usb_proc_callback_t *, struct termios *pt, struct usb_proc_msg *t0, struct usb_proc_msg *t1); static void ucom_shutdown(struct ucom_softc *); @@ -592,7 +592,7 @@ ucom_set_usb_mode(struct ucom_super_softc *ssc, enum usb_hc_mode usb_mode) } } -static void +static int ucom_queue_command(struct ucom_softc *sc, usb_proc_callback_t *fn, struct termios *pt, struct usb_proc_msg *t0, struct usb_proc_msg *t1) @@ -604,7 +604,7 @@ ucom_queue_command(struct ucom_softc *sc, if (usb_proc_is_gone(&ssc->sc_tq)) { DPRINTF("proc is gone\n"); - return; /* nothing to do */ + return (ENXIO); /* nothing to do */ } /* * NOTE: The task cannot get executed before we drop the @@ -637,6 +637,8 @@ ucom_queue_command(struct ucom_softc *sc, */ if (fn == ucom_cfg_start_transfers) sc->sc_last_start_xfer = &task->hdr; + + return (0); } static void @@ -760,9 +762,8 @@ ucom_open(struct tty *tp) * example if the device is not present: */ error = (sc->sc_callback->ucom_pre_open) (sc); - if (error) { - return (error); - } + if (error != 0) + goto out; } sc->sc_flag |= UCOM_FLAG_HL_READY; @@ -782,14 +783,18 @@ ucom_open(struct tty *tp) sc->sc_jitterbuf_in = 0; sc->sc_jitterbuf_out = 0; - ucom_queue_command(sc, ucom_cfg_open, NULL, + error = ucom_queue_command(sc, ucom_cfg_open, NULL, &sc->sc_open_task[0].hdr, &sc->sc_open_task[1].hdr); + if (error != 0) + goto out; /* Queue transfer enable command last */ - ucom_queue_command(sc, ucom_cfg_start_transfers, NULL, - &sc->sc_start_task[0].hdr, + error = ucom_queue_command(sc, ucom_cfg_start_transfers, NULL, + &sc->sc_start_task[0].hdr, &sc->sc_start_task[1].hdr); + if (error != 0) + goto out; if (sc->sc_tty == NULL || (sc->sc_tty->t_termios.c_cflag & CNO_RTSDTR) == 0) ucom_modem(tp, SER_DTR | SER_RTS, 0); @@ -800,7 +805,8 @@ ucom_open(struct tty *tp) ucom_status_change(sc); - return (0); +out: + return (error); } static void @@ -836,7 +842,7 @@ ucom_close(struct tty *tp) } ucom_shutdown(sc); - ucom_queue_command(sc, ucom_cfg_close, NULL, + (void)ucom_queue_command(sc, ucom_cfg_close, NULL, &sc->sc_close_task[0].hdr, &sc->sc_close_task[1].hdr); @@ -1077,9 +1083,12 @@ ucom_line_state(struct ucom_softc *sc, sc->sc_pls_set |= set_bits; sc->sc_pls_clr |= clear_bits; - /* defer driver programming */ - ucom_queue_command(sc, ucom_cfg_line_state, NULL, - &sc->sc_line_state_task[0].hdr, + /* + * defer driver programming - we don't propagate any error from + * this call because we'll catch such errors further up the call stack. + */ + (void)ucom_queue_command(sc, ucom_cfg_line_state, NULL, + &sc->sc_line_state_task[0].hdr, &sc->sc_line_state_task[1].hdr); } @@ -1236,7 +1245,7 @@ ucom_status_change(struct ucom_softc *sc) } DPRINTF("\n"); - ucom_queue_command(sc, ucom_cfg_status_change, NULL, + (void)ucom_queue_command(sc, ucom_cfg_status_change, NULL, &sc->sc_status_task[0].hdr, &sc->sc_status_task[1].hdr); } @@ -1310,14 +1319,18 @@ ucom_param(struct tty *tp, struct termios *t) sc->sc_flag &= ~UCOM_FLAG_GP_DATA; /* Queue baud rate programming command first */ - ucom_queue_command(sc, ucom_cfg_param, t, + error = ucom_queue_command(sc, ucom_cfg_param, t, &sc->sc_param_task[0].hdr, &sc->sc_param_task[1].hdr); + if (error != 0) + goto done; /* Queue transfer enable command last */ - ucom_queue_command(sc, ucom_cfg_start_transfers, NULL, - &sc->sc_start_task[0].hdr, + error = ucom_queue_command(sc, ucom_cfg_start_transfers, NULL, + &sc->sc_start_task[0].hdr, &sc->sc_start_task[1].hdr); + if (error != 0) + goto done; if (t->c_cflag & CRTS_IFLOW) { sc->sc_flag |= UCOM_FLAG_RTS_IFLOW;