From nobody Wed Jan 01 05:46:03 2025 X-Original-To: dev-commits-src-all@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 4YNJjR6BYqz5jNcL; Wed, 01 Jan 2025 05:46:03 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YNJjR3pdQz4P8j; Wed, 1 Jan 2025 05:46:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735710363; 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=njE5KD1yuwAexZDp/OcZ+HwVNJiujNDA5uQMemFG0yY=; b=a7zKXmtJCuJUgZ74LVT0/rrsnyNPCTE5cS50aaTFYW5HS4qT4h9l2biZno2JwOOiPlUFvU UaOjPhcNBmTvZVNrXxcaS60+HAxO465FqOiU13nfUpMpCGkoEXR21OO8ayyE8BulBSVPR3 +boGncg2DVl6F+wQj21BkzlYqgSJn7YeLjiXkhi69B2nEELXsIFewEKR+0dvdEzQtMUjc6 bQE3WPrRqxa8J+If11x0HOmi5/gkW7+VmNhS3nx1WFB1/7rssw3liuEOk+tDVLEK9z1FE3 fKsxvd1MBj/UH02DRejtmkxdEbhuWiwiqZo+htJckKKrHaolyce7vIBOVWdwPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735710363; 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=njE5KD1yuwAexZDp/OcZ+HwVNJiujNDA5uQMemFG0yY=; b=OdawjK4b6EdE/6Ju6FY8NfgaoRg+xBrNEt8QZfs5BcAcAAGWgJN+C2LkTcFjcbFijgxMUG qeegeF3BkCFbNKjH3LOsNX9U1QmUq8SqtQl1DfS3g4NJE6CPRTQV3oK3CH8Abmx3QBAx9o WB0j0+zAbPcfBCDHD7Fv/fJqeHuRAlm9MYkfv79O1nqXSk13NQzuWeiwWw6Rij1U+91Pvk OMTwrjnmXCgQAMZ7F5J/waFoskH/46uEdcrgSC+UM8M0Sva93cohOY9WA2rbKmVSfaUz8c 7BbfyW4kQARaL5HzeqZZ/fbGZRvgOc0U3Rw0xcUPQzgENW1OoLTe5JwvcKWe7A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1735710363; a=rsa-sha256; cv=none; b=EbZJkcMUVHW6lpBiqy1kpDCsRwN0jdMNe3/Riqyw2adY2hCvREDXemTQJgZ18gPSeg3FBh SVz1LNKjBt75/wmqvv1OgFdL3oc1PIv6aSzAhesYF3lhWw8Lueo+kukdV5Gy7Wt8542dtf Gz4qj21k9/BC2tPyiQtV/E5tJjRiJ5bDZF7jM2Bp1fO2vhX1Aqe+mN8qTLdEh0Po1zfgcm dws4KHTnd/2FzMCy4iw/WDUQ1Tk7acJOc1Uz0COGD2GXb5v8iXnzGhGwQPgEU9+oE/61eP JaLy9Tnf/P31ANxOqxuAmNKPUc5pWUfo+eWfh+xVZmI3JBl9LldspZPJ3dPIJQ== 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 4YNJjR3Q2rz1BKg; Wed, 1 Jan 2025 05:46:03 +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 5015k3fv038380; Wed, 1 Jan 2025 05:46:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5015k3G8038376; Wed, 1 Jan 2025 05:46:03 GMT (envelope-from git) Date: Wed, 1 Jan 2025 05:46:03 GMT Message-Id: <202501010546.5015k3G8038376@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kyle Evans Subject: git: 2882d0c61aeb - stable/14 - usb: serial: propagate errors from ucom_queue_command() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 2882d0c61aebab77e8f2cc5b7cace6186bb8cb01 Auto-Submitted: auto-generated The branch stable/14 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=2882d0c61aebab77e8f2cc5b7cace6186bb8cb01 commit 2882d0c61aebab77e8f2cc5b7cace6186bb8cb01 Author: Kyle Evans AuthorDate: 2024-12-11 01:23:10 +0000 Commit: Kyle Evans CommitDate: 2025-01-01 05:45:20 +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 (cherry picked from commit 51f3d0874f6216907c8971c4af9d6be6c93edf7b) --- 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;