From nobody Mon Apr 6 10:30:38 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64EC03876D5; Mon, 30 Mar 2026 10:26:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774866385; cv=none; b=ZND387F7hgMiAX7l+vD2OJCdr64Fb4WQCeiCEKAW7xarg3tplCF/B2DaRFvy18b3ly5OrpjyFwrsr/DuOBS6EVsxskU7eZO9ISa+tDtsvj8cJbtPZL8R2urHqNad1cJovgVCQk2CwNGaLqX79FYzJ7CAP/mBDQNh5+Xd457Pozc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774866385; c=relaxed/simple; bh=rgFKg/d+FUAaOw5JbZeHPHlGozeIL8CU5+819cW2K9Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=euNh4CNZnMyFwMipv78OHloXzPf5Laui80qbHbknABGA6fCf8RinIbtvsMngrKA4wncrgSt+WzWZ2ZiD/gZsoTIAVTmz0tkehf9pgMODyl/H2ueoa/cZSo9ZlfiQ4UvZwhxSgjihwOIaCj/oMo/MHHHTr6ON3A/NZE7BcRBD0ww= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A8TJeq/F; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A8TJeq/F" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2782AC2BCB2; Mon, 30 Mar 2026 10:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774866385; bh=rgFKg/d+FUAaOw5JbZeHPHlGozeIL8CU5+819cW2K9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A8TJeq/FipNLvABEzeHajmIWnQiJEyS8rETi6plHyLvVpkyF92kSIZutj0v8/9lXL Al+FtJXW9KEKWjA2MgDT1g/+FZ+j5imyWXw54+r1/Q0+MNePfdd1C6tmORb4sT1XMk OSpLn9hUtBN20FyxaWQZsLfJf4Upq5UUsN2d50MmDgHtEHxwHGayoLChSxdneND6MN xef0waIGxnOr4u7xYP7KBXBKIpN7rNGn11L1tLxltDr96l9fuguuEm4m1AXH4trzZU o+/vAmVwhMpIirlAAzx54Ig/KR/jxPAFTTlkvKYPpvC27p8dptCWWlRKc7TH5r9B9F wiSGTtloT2cUQ== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1w79p8-000000070qo-3yyK; Mon, 30 Mar 2026 12:26:22 +0200 From: Johan Hovold To: Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 1/2] net: hso: refactor endpoint lookup Date: Mon, 30 Mar 2026 12:26:10 +0200 Message-ID: <20260330102611.1671546-2-johan@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260330102611.1671546-1-johan@kernel.org> References: <20260330102611.1671546-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the common USB helpers for looking up bulk and interrupt endpoints instead of a custom implementation. Signed-off-by: Johan Hovold --- drivers/net/usb/hso.c | 65 +++++++++++-------------------------------- 1 file changed, 17 insertions(+), 48 deletions(-) diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index 1825f7cf5dc0..c1aec67688ae 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -298,8 +298,6 @@ static int hso_mux_submit_intr_urb(struct hso_shared_in= t *mux_int, struct usb_device *usb, gfp_t gfp); static void handle_usb_error(int status, const char *function, struct hso_device *hso_dev); -static struct usb_endpoint_descriptor *hso_get_ep(struct usb_interface *in= tf, - int type, int dir); static int hso_get_mux_ports(struct usb_interface *intf, unsigned char *po= rts); static void hso_free_interface(struct usb_interface *intf); static int hso_start_serial_device(struct hso_device *hso_dev, gfp_t flags= ); @@ -2497,16 +2495,11 @@ static struct hso_device *hso_create_net_device(str= uct usb_interface *interface, hso_net->net =3D net; hso_net->parent =3D hso_dev; =20 - hso_net->in_endp =3D hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, - USB_DIR_IN); - if (!hso_net->in_endp) { - dev_err(&interface->dev, "Can't find BULK IN endpoint\n"); - goto err_net; - } - hso_net->out_endp =3D hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, - USB_DIR_OUT); - if (!hso_net->out_endp) { - dev_err(&interface->dev, "Can't find BULK OUT endpoint\n"); + result =3D usb_find_common_endpoints(interface->cur_altsetting, + &hso_net->in_endp, &hso_net->out_endp, + NULL, NULL); + if (result) { + dev_err(&interface->dev, "Can't find BULK endpoints\n"); goto err_net; } SET_NETDEV_DEV(net, &interface->dev); @@ -2608,10 +2601,12 @@ static void hso_free_serial_device(struct hso_devic= e *hso_dev) static struct hso_device *hso_create_bulk_serial_device( struct usb_interface *interface, int port) { + struct usb_host_interface *iface_desc =3D interface->cur_altsetting; struct hso_device *hso_dev; struct hso_serial *serial; int num_urbs; struct hso_tiocmget *tiocmget; + int ret; =20 hso_dev =3D hso_create_device(interface, port); if (!hso_dev) @@ -2634,10 +2629,8 @@ static struct hso_device *hso_create_bulk_serial_dev= ice( if (!serial->tiocmget->serial_state_notification) goto exit; tiocmget =3D serial->tiocmget; - tiocmget->endp =3D hso_get_ep(interface, - USB_ENDPOINT_XFER_INT, - USB_DIR_IN); - if (!tiocmget->endp) { + ret =3D usb_find_int_in_endpoint(iface_desc, &tiocmget->endp); + if (ret) { dev_err(&interface->dev, "Failed to find INT IN ep\n"); goto exit; } @@ -2656,17 +2649,10 @@ static struct hso_device *hso_create_bulk_serial_de= vice( BULK_URB_TX_SIZE)) goto exit; =20 - serial->in_endp =3D hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, - USB_DIR_IN); - if (!serial->in_endp) { - dev_err(&interface->dev, "Failed to find BULK IN ep\n"); - goto exit2; - } - - if (! - (serial->out_endp =3D - hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, USB_DIR_OUT))) { - dev_err(&interface->dev, "Failed to find BULK OUT ep\n"); + ret =3D usb_find_common_endpoints(iface_desc, &serial->in_endp, + &serial->out_endp, NULL, NULL); + if (ret) { + dev_err(&interface->dev, "Failed to find BULK eps\n"); goto exit2; } =20 @@ -2754,13 +2740,14 @@ static struct hso_shared_int *hso_create_shared_int(struct usb_interface *interfa= ce) { struct hso_shared_int *mux =3D kzalloc_obj(*mux); + int ret; =20 if (!mux) return NULL; =20 - mux->intr_endp =3D hso_get_ep(interface, USB_ENDPOINT_XFER_INT, - USB_DIR_IN); - if (!mux->intr_endp) { + ret =3D usb_find_int_in_endpoint(interface->cur_altsetting, + &mux->intr_endp); + if (ret) { dev_err(&interface->dev, "Can't find INT IN endpoint\n"); goto exit; } @@ -3134,24 +3121,6 @@ static void hso_free_interface(struct usb_interface = *interface) =20 /* Helper functions */ =20 -/* Get the endpoint ! */ -static struct usb_endpoint_descriptor *hso_get_ep(struct usb_interface *in= tf, - int type, int dir) -{ - int i; - struct usb_host_interface *iface =3D intf->cur_altsetting; - struct usb_endpoint_descriptor *endp; - - for (i =3D 0; i < iface->desc.bNumEndpoints; i++) { - endp =3D &iface->endpoint[i].desc; - if (((endp->bEndpointAddress & USB_ENDPOINT_DIR_MASK) =3D=3D dir) && - (usb_endpoint_type(endp) =3D=3D type)) - return endp; - } - - return NULL; -} - /* Get the byte that describes which ports are enabled */ static int hso_get_mux_ports(struct usb_interface *intf, unsigned char *po= rts) { --=20 2.52.0 From nobody Mon Apr 6 10:30:38 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64F763B637E; Mon, 30 Mar 2026 10:26:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774866385; cv=none; b=jsdDo7wSR2R0aptFfi2SoUP6s7fOhC+qQbjsdE7eabZEHq7i+jkRnmm8seujN0ID2qYdTnvlxifBd0evNlgn2Z0F1nmgSlRPM5v/1v7aVY5yuF2Q2yKcjiKua1ixWfOiFEa4MfDXnL0JtFItjg/xkST4h6/9ZUMCnNgINzP1NRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774866385; c=relaxed/simple; bh=T9uIlKF64yOcg9bZtE+cTBedhjk9S9RgTUSXgAnuvIw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TPmpX1Ah1ZwQqfSvCUH2R82AdsMkb798GbHbkjpkZ6RGIfYvuOfFwjUqUfDGdSQbl5937u2BBzvw/5an9/We9s+JpR3VLBtS1j8Ff+fvO3zpTFwfq7BAd68isNDfKULd4NMuhzCCrJWzePdZ5cYXuKpGATASeZsmpsIFDOzasE0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=T3Lk3LeT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="T3Lk3LeT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21D52C4CEF7; Mon, 30 Mar 2026 10:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774866385; bh=T9uIlKF64yOcg9bZtE+cTBedhjk9S9RgTUSXgAnuvIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T3Lk3LeTfciLzYIG75jBzdIlDdDiBmouF5ORvWGPOHx12VEIo6la8O327J2sZk3/e fXDSOERPW4rywuTPQeYzcfPtPw1avW980TYA13Dl2aMHwTfS+l/eolVC3gcYMWn2Vt KhIp7fKVr1MK42KrpJJiCmc6IgayIZhmyiM71ySP67dneW4Qea3SfCP6+tdNWbGu47 GqPHK+ichN9sfmqgQjLDfXu4vmfPt2lktGVJ1estQdrQ0uXz4tY57sga7toFsLTqrD mcUjGBZsq2/Q7m+T/Hjuc3iDEuWkAqhnqWg0W2dVxLUC/3sEnA+SXH8yQ3URnAeuEW sD1cTcOQLCcCA== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1w79p8-000000070qq-42E7; Mon, 30 Mar 2026 12:26:22 +0200 From: Johan Hovold To: Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 2/2] net: ipeth: refactor endpoint lookup Date: Mon, 30 Mar 2026 12:26:11 +0200 Message-ID: <20260330102611.1671546-3-johan@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260330102611.1671546-1-johan@kernel.org> References: <20260330102611.1671546-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the common USB helper for looking up bulk and interrupt endpoints instead of open coding. Signed-off-by: Johan Hovold --- drivers/net/usb/ipheth.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c index a19789b57190..bb1364f85bd1 100644 --- a/drivers/net/usb/ipheth.c +++ b/drivers/net/usb/ipheth.c @@ -573,11 +573,10 @@ static int ipheth_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device *udev =3D interface_to_usbdev(intf); + struct usb_endpoint_descriptor *ep_in, *ep_out; struct usb_host_interface *hintf; - struct usb_endpoint_descriptor *endp; struct ipheth_device *dev; struct net_device *netdev; - int i; int retval; =20 netdev =3D alloc_etherdev(sizeof(struct ipheth_device)); @@ -603,19 +602,16 @@ static int ipheth_probe(struct usb_interface *intf, goto err_endpoints; } =20 - for (i =3D 0; i < hintf->desc.bNumEndpoints; i++) { - endp =3D &hintf->endpoint[i].desc; - if (usb_endpoint_is_bulk_in(endp)) - dev->bulk_in =3D endp->bEndpointAddress; - else if (usb_endpoint_is_bulk_out(endp)) - dev->bulk_out =3D endp->bEndpointAddress; - } - if (!(dev->bulk_in && dev->bulk_out)) { - retval =3D -ENODEV; + retval =3D usb_find_common_endpoints_reverse(hintf, &ep_in, &ep_out, + NULL, NULL); + if (retval) { dev_err(&intf->dev, "Unable to find endpoints\n"); goto err_endpoints; } =20 + dev->bulk_in =3D ep_in->bEndpointAddress; + dev->bulk_out =3D ep_out->bEndpointAddress; + dev->ctrl_buf =3D kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL); if (dev->ctrl_buf =3D=3D NULL) { retval =3D -ENOMEM; --=20 2.52.0