From nobody Thu Apr 2 07:30:17 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 B2E263BED6E; Mon, 30 Mar 2026 10:11:56 +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=1774865516; cv=none; b=axI5clqsH24YmwV4Sizq+QeNbtRkBqfyYZ8vzFoHmrLBhy34qxoporHA0ZB6v5T3HqxtjZNQ4VKvULvxFUFytdaUSNtpsKEVhXUL0bxozOHn0Qg7oHEuWrWYmNWrtEWEFPDgyx/2kj8uWZLQ+ESpLCJm9l30xM6VLSVqONE2Rvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774865516; c=relaxed/simple; bh=4on6QHPozqnGQIG0eBs3EcvebQJWDyF4s4eHR6wrc/4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t7OzxB6os5ARR6GG5C5YElATckS2P7tny6nl5wBlxkALngPfnaQUtJ+NYHVfc+S215jV5/SjyDlU3adj6mq6Qgu/VfZn2plIkn2r2U/7gXzcgqYaM6a8CV7jpv6zEgg9cRZQuNrzO2eEJnboPsePGzHm+u6tnzkN6hUAcjpL/e0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HyhDzL/K; 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="HyhDzL/K" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AD31C2BCB2; Mon, 30 Mar 2026 10:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774865516; bh=4on6QHPozqnGQIG0eBs3EcvebQJWDyF4s4eHR6wrc/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HyhDzL/KeXaCuhAY8ki8kQtd8oL6SdaR44FapaHdUpOnpI4DArqenLW6xF7HdeRCC DFHoYkuGSXHVFRiZsCCUvAUDsCU4emIdrEtjROOyjXr5vvEFvVWhz8xB4gFhV2ScT+ mDPTwn0TbWwV6dfo5yFhZD3H/SMVAwKapJjbpzgvFmsHksOTKjqZynTu/eWMc1W0AQ 0s9hlrvGSOhaRGu8jB9I37sSEuwAptTuKK2V25PmG1Oi/ruG/icIu3zquilg18AHTm /RCfopXUeV33Ik9jhFHys8+5u4+v55KQBVOPboY7/MnfhqTFyL/YcBBucPJ5gTkadF fO8Rv/z5KnIng== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1w79b8-00000006yvc-1K9C; Mon, 30 Mar 2026 12:11:54 +0200 From: Johan Hovold To: Hans Verkuil , Sean Young , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 1/6] media: si470x-usb: refactor endpoint lookup Date: Mon, 30 Mar 2026 12:11:36 +0200 Message-ID: <20260330101141.1664143-2-johan@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260330101141.1664143-1-johan@kernel.org> References: <20260330101141.1664143-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 interrupt-in endpoints instead of open coding. Signed-off-by: Johan Hovold --- drivers/media/radio/si470x/radio-si470x-usb.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/= radio/si470x/radio-si470x-usb.c index 318b5f6d4202..869b1e7e34b9 100644 --- a/drivers/media/radio/si470x/radio-si470x-usb.c +++ b/drivers/media/radio/si470x/radio-si470x-usb.c @@ -565,8 +565,7 @@ static int si470x_usb_driver_probe(struct usb_interface= *intf, { struct si470x_device *radio; struct usb_host_interface *iface_desc; - struct usb_endpoint_descriptor *endpoint; - int i, int_end_size, retval; + int int_end_size, retval; unsigned char version_warning =3D 0; =20 /* private data allocation and initialization */ @@ -595,12 +594,8 @@ static int si470x_usb_driver_probe(struct usb_interfac= e *intf, iface_desc =3D intf->cur_altsetting; =20 /* Set up interrupt endpoint information. */ - for (i =3D 0; i < iface_desc->desc.bNumEndpoints; ++i) { - endpoint =3D &iface_desc->endpoint[i].desc; - if (usb_endpoint_is_int_in(endpoint)) - radio->int_in_endpoint =3D endpoint; - } - if (!radio->int_in_endpoint) { + retval =3D usb_find_int_in_endpoint(iface_desc, &radio->int_in_endpoint); + if (retval) { dev_info(&intf->dev, "could not find interrupt in endpoint\n"); retval =3D -EIO; goto err_usbbuf; --=20 2.52.0 From nobody Thu Apr 2 07:30:17 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 879043BED40; Mon, 30 Mar 2026 10:11:56 +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=1774865516; cv=none; b=SoV4/LS1MhyqHmumkgbguLBuJw0JT9y+gigL43MWhAJ1lRHmyvjt95vv9UkVKAfhv+e9mj1N+T6By7EfFwBEATL3IyY/ImdIUVQ6/E4FMKO1pHXVzbbPWi5ZY2HbNRQRO8zhc8Vopx5oCfY8Xi6S/vFJjuARg3uOlNzAnJcyqcE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774865516; c=relaxed/simple; bh=w6KzY0XzyjcyMRUlPVjJZv6AcnGT6wLQdMD+us8oX/4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uqxKCqeJMVk3UFYvexRis9d9CFbwpdZhbRMRha/HSLs1WinNMMmQh9/UEzDMvqjswcD4ibqIEzG8kt3wbY+Bu1lS1KnDN5yxrw26dhZX0O4owXuYPswHtI0d67OuLxrOApIDOH7GrYuRqL7MxDssqUDo0MgDfzvjE9zSivEPqSI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ry7RZOy5; 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="ry7RZOy5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D276C2BCB4; Mon, 30 Mar 2026 10:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774865516; bh=w6KzY0XzyjcyMRUlPVjJZv6AcnGT6wLQdMD+us8oX/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ry7RZOy5B1YvtLjvnkCyB2d/qGBT0h9iJ3fkbKdgbJ4iZb+GcQhvmFY90Krz5N7Xi v+rpSbLVXsomwLl+N3erzReMxsfClkBgA0H1ELMsy58LawUXarWrz1t96oyQkr9djd Lk995DyGBQSDGz1B1yVcAfSBWIWzyMQLQoic6aCEmBGUXgc/w7jLQnGC7dohsYNhdT Zp3GDP9NppBduFYYm39ZATlUUZheJ9oiqSkDbANSA9hSSwViup4pAkzsVwUjac4Bxw 1XTkB94EVfHeYuPPbGZrZbww1Bgi4KswXTmXlHSafVRC4tj6kGciI/A8Dnq69xpOAo dxfEIXao27xXw== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1w79b8-00000006yve-1MUj; Mon, 30 Mar 2026 12:11:54 +0200 From: Johan Hovold To: Hans Verkuil , Sean Young , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 2/6] media: imon_raw: refactor endpoint lookup Date: Mon, 30 Mar 2026 12:11:37 +0200 Message-ID: <20260330101141.1664143-3-johan@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260330101141.1664143-1-johan@kernel.org> References: <20260330101141.1664143-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 interrupt-in endpoints instead of open coding. Signed-off-by: Johan Hovold --- drivers/media/rc/imon_raw.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/media/rc/imon_raw.c b/drivers/media/rc/imon_raw.c index 3a526dea6532..295acd6ba9e1 100644 --- a/drivers/media/rc/imon_raw.c +++ b/drivers/media/rc/imon_raw.c @@ -105,26 +105,16 @@ static void imon_ir_rx(struct urb *urb) static int imon_probe(struct usb_interface *intf, const struct usb_device_id *id) { - struct usb_endpoint_descriptor *ir_ep =3D NULL; - struct usb_host_interface *idesc; + struct usb_endpoint_descriptor *ir_ep; struct usb_device *udev; struct rc_dev *rcdev; struct imon *imon; - int i, ret; + int ret; =20 udev =3D interface_to_usbdev(intf); - idesc =3D intf->cur_altsetting; - - for (i =3D 0; i < idesc->desc.bNumEndpoints; i++) { - struct usb_endpoint_descriptor *ep =3D &idesc->endpoint[i].desc; - - if (usb_endpoint_is_int_in(ep)) { - ir_ep =3D ep; - break; - } - } =20 - if (!ir_ep) { + ret =3D usb_find_int_in_endpoint(intf->cur_altsetting, &ir_ep); + if (ret) { dev_err(&intf->dev, "IR endpoint missing"); return -ENODEV; } --=20 2.52.0 From nobody Thu Apr 2 07:30:17 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 924363BED4A; Mon, 30 Mar 2026 10:11:56 +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=1774865516; cv=none; b=ESdUyUXSqyBIOGwTYFPnDyr9CGgskwZGUpWWVuCz68D8SroH5bVuEXhZSMgtplKqwXKRE6doYlcbaSiuJIrnVE7PViSWhtfxFQTdWQgboaJDvNd2mXj445BICXs18bhqLHdwmmXx7VOly8eiIMZENLjdW2STJd1L+8ybptoPzeE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774865516; c=relaxed/simple; bh=vmqS9U+ZM9NT3WFh5nEgoWc0CR8M4Yem0Ykyth1Z57w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PrPA5b4Iu25xiuo5l5yEG2oPO4AyZg5mvQbzB/It2WWBCK7AcCDDElJI6NJz06dd/RIGMIZXaWV6wQ682EkK+ZPdKcH2s8eMax1GbI8qe3zHMLao5p7kjvmai8bytxjQ51B0eRwfau0JgisxUWbQ/H6QDQnFgBCqzinlK1tTkRc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Efo5yv+u; 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="Efo5yv+u" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 717E7C2BCB6; Mon, 30 Mar 2026 10:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774865516; bh=vmqS9U+ZM9NT3WFh5nEgoWc0CR8M4Yem0Ykyth1Z57w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Efo5yv+uBud+ifjcOEiz02N85gmMloAGkqhQgZnYxTQnb+C1smemez9f9iWPKyr9c CIZUAxWbNMR+YN/TOh7uSYuUE5sGe3fy1eleeQV/ya5Vn8//GSWGvsIlIsIkdpoHxm RLmBdhiqAyPwGUt8F4LvDfMGZ5IFhAucOw6q7CwPF3vrM0irmhXBK72pAL6AeqRa+K lptqJUAPGXSnMrKLZbX57GNfJ/TQvEDYm78t37bT1F9sdc1ThLWGWSowmxqLws3+/W W49ecvNrCz1OHYgvnYXCAL9qlylgCK/VeezaxyposTTZLfDMuPD7HjTPYlDe7hvjl5 1/B7Cy5mpmmBg== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1w79b8-00000006yvg-1Oik; Mon, 30 Mar 2026 12:11:54 +0200 From: Johan Hovold To: Hans Verkuil , Sean Young , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 3/6] media: irtoy: refactor endpoint lookup Date: Mon, 30 Mar 2026 12:11:38 +0200 Message-ID: <20260330101141.1664143-4-johan@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260330101141.1664143-1-johan@kernel.org> References: <20260330101141.1664143-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 (and determining max packet size) instead of open coding. Note that the device has two bulk endpoints so there is no functional change here. Signed-off-by: Johan Hovold --- drivers/media/rc/ir_toy.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/drivers/media/rc/ir_toy.c b/drivers/media/rc/ir_toy.c index d6472de5da87..f63f06509786 100644 --- a/drivers/media/rc/ir_toy.c +++ b/drivers/media/rc/ir_toy.c @@ -393,27 +393,15 @@ static int irtoy_probe(struct usb_interface *intf, { struct usb_host_interface *idesc =3D intf->cur_altsetting; struct usb_device *usbdev =3D interface_to_usbdev(intf); - struct usb_endpoint_descriptor *ep_in =3D NULL; - struct usb_endpoint_descriptor *ep_out =3D NULL; - struct usb_endpoint_descriptor *ep =3D NULL; + struct usb_endpoint_descriptor *ep_in, *ep_out; struct irtoy *irtoy; struct rc_dev *rc; struct urb *urb; - int i, pipe, err =3D -ENOMEM; + int pipe, err; =20 - for (i =3D 0; i < idesc->desc.bNumEndpoints; i++) { - ep =3D &idesc->endpoint[i].desc; - - if (!ep_in && usb_endpoint_is_bulk_in(ep) && - usb_endpoint_maxp(ep) =3D=3D MAX_PACKET) - ep_in =3D ep; - - if (!ep_out && usb_endpoint_is_bulk_out(ep) && - usb_endpoint_maxp(ep) =3D=3D MAX_PACKET) - ep_out =3D ep; - } - - if (!ep_in || !ep_out) { + err =3D usb_find_common_endpoints(idesc, &ep_in, &ep_out, NULL, NULL); + if (err || usb_endpoint_maxp(ep_in) !=3D MAX_PACKET || + usb_endpoint_maxp(ep_out) !=3D MAX_PACKET) { dev_err(&intf->dev, "required endpoints not found\n"); return -ENODEV; } @@ -422,6 +410,7 @@ static int irtoy_probe(struct usb_interface *intf, if (!irtoy) return -ENOMEM; =20 + err =3D -ENOMEM; irtoy->in =3D kmalloc(MAX_PACKET, GFP_KERNEL); if (!irtoy->in) goto free_irtoy; --=20 2.52.0 From nobody Thu Apr 2 07:30:17 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 B2F8D3BED6F; Mon, 30 Mar 2026 10:11:56 +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=1774865516; cv=none; b=i/eqPJn4xSMtIGkWYWsgUJ5+56+n/KBExqYNHRNMRRsaRyLxf/qW4PpsUm8Etrnnj8j05g9OLRXiBFHyOe3QQpB0Op9ITEUtMBh8bCsL3y3Ud2dvkQ6kFKG1BBGoqjWFQLturGZdFVUBCainLwYV50Bdbx0HbyDKYdm2g9h4u+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774865516; c=relaxed/simple; bh=Yzz9wzI7bTketJ/FTA9OXRo9U+Vt9chFVgyG0x7s0hY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tjjftBpfYlbylwsFEMH3Db2qYTMO00al2oa/iNZTFEp2hEgxuN7Tzlk02P8hqJ3wIQn7SVI2v5QSiiDY74oQ0nT98hnLpwYc3ve1bUSyKS6JpQNAkkzKfId5S8FMYP/bFuR/WrNFVjQZszgv7ieZWBx4WNUjC+d4ilFO2sXaZJc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=J2nEVVMZ; 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="J2nEVVMZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73DC3C2BCB8; Mon, 30 Mar 2026 10:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774865516; bh=Yzz9wzI7bTketJ/FTA9OXRo9U+Vt9chFVgyG0x7s0hY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J2nEVVMZ6qdy5Vf+WtqCyTXaykKtVzVZ+fUVjU+6KPdCp9peNYFkq515LZJGZYJ5/ /CqaB7TdXWldofmCAnL7epLNnJtN+R9Qi8zB2HNzOfWK7QclO4Uv+baAdfZ3ufDnHw 3Wg6jIdqmhEia2w/h1exe2J1ulZs2SxUcOKiAqnzRzZ30rmbmswaX0hx5GroqpxhLt uGrOV/sdUk7yvdi0zpyXispRClqnocdng+Av4hQDEvjce++CCjRZ6pM+vBWEszcbiR FVrcQz/8QHeW7WZ1/HjyZxHtRIp2/2io1g47tDPVfmqIVnvMhze49KrdR9iTG2FbeD 0H46b1sqZC90A== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1w79b8-00000006yvi-1Qym; Mon, 30 Mar 2026 12:11:54 +0200 From: Johan Hovold To: Hans Verkuil , Sean Young , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 4/6] media: gspca: refactor endpoint lookup Date: Mon, 30 Mar 2026 12:11:39 +0200 Message-ID: <20260330101141.1664143-5-johan@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260330101141.1664143-1-johan@kernel.org> References: <20260330101141.1664143-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 interrupt-in endpoints instead of open coding. Signed-off-by: Johan Hovold --- drivers/media/usb/gspca/gspca.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspc= a.c index 3fc15d16df8e..94f448819d84 100644 --- a/drivers/media/usb/gspca/gspca.c +++ b/drivers/media/usb/gspca/gspca.c @@ -208,22 +208,17 @@ static int alloc_and_submit_int_urb(struct gspca_dev = *gspca_dev, static void gspca_input_create_urb(struct gspca_dev *gspca_dev) { struct usb_interface *intf; - struct usb_host_interface *intf_desc; struct usb_endpoint_descriptor *ep; - int i; + int ret; =20 if (gspca_dev->sd_desc->int_pkt_scan) { intf =3D usb_ifnum_to_if(gspca_dev->dev, gspca_dev->iface); - intf_desc =3D intf->cur_altsetting; - for (i =3D 0; i < intf_desc->desc.bNumEndpoints; i++) { - ep =3D &intf_desc->endpoint[i].desc; - if (usb_endpoint_dir_in(ep) && - usb_endpoint_xfer_int(ep)) { =20 - alloc_and_submit_int_urb(gspca_dev, ep); - break; - } - } + ret =3D usb_find_int_in_endpoint(intf->cur_altsetting, &ep); + if (ret) + return; + + alloc_and_submit_int_urb(gspca_dev, ep); } } =20 --=20 2.52.0 From nobody Thu Apr 2 07:30:17 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 925793BED58; Mon, 30 Mar 2026 10:11:56 +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=1774865516; cv=none; b=QnVKSVr3GRTOxuEQH+uiYGFj7FH/ZABMkSkBHEsEgUXsH6dqQ1si0BUJ4bPWTnDunwbgN6f2165WNEwhH3/qSa7ojhyhggoZGeUqNryRNIPqB2Fsub0pwV2rtlo+i/CLcvdQTdT5Ja+TKpQaUaIJtcwI2mT21UetNf5993HiTfQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774865516; c=relaxed/simple; bh=9/pTkhn2u2LSwJWS3DyDgtL8TAWdS/g1l4ZFCYjsYio=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=er1Vx6xCSTSausFNNWGhDgAzW+YTW9z3dw8FLpavBr4EIUNjyXIzPOk8p1tBSqDVP2x2kFz510xbtNcaMP17TuS2zzCRJooYYKW1yPLev+JcUECsi2CB1DvELM/VTiguR7LvZi1H+iRqWuukZkoiNn/r6z5uOn2nOiyLEpnzNeI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s6jAlVAs; 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="s6jAlVAs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F5B9C2BCB3; Mon, 30 Mar 2026 10:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774865516; bh=9/pTkhn2u2LSwJWS3DyDgtL8TAWdS/g1l4ZFCYjsYio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s6jAlVAscj5D3hAlHXt6P8nkcGjbsXp9T11dY+dUwjTqtONYDTlh9UTWBT+XD8T4l sH5xbxXXRM3NxIexG23NiSLa3ex68nLMt0KpchGwIme1YYP2ICpZVAYYlD7pGrW3l2 Ri2jMaLx+FjSrb68Qe7FXduSK6rRzo9lzyksstLW1SVLFR7NTbyWnVzgtaxB+nDGXu DBrX8acXEuIrCEvbOQwPaCwoOC0ongeopUglUoD1DsVH5EscTcKR/R7uympswkOiyK 8r7lgVdslm5ANekAE6XYU0sKzEuV0KUDbGMqoAREP9QkxAXfjEMHKCHvkFQqUu3K9z HrNPfhQdad1wA== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1w79b8-00000006yvk-1TFJ; Mon, 30 Mar 2026 12:11:54 +0200 From: Johan Hovold To: Hans Verkuil , Sean Young , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 5/6] media: hdpvr: refactor endpoint lookup Date: Mon, 30 Mar 2026 12:11:40 +0200 Message-ID: <20260330101141.1664143-6-johan@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260330101141.1664143-1-johan@kernel.org> References: <20260330101141.1664143-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-in endpoints instead of open coding. Signed-off-by: Johan Hovold --- drivers/media/usb/hdpvr/hdpvr-core.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/media/usb/hdpvr/hdpvr-core.c b/drivers/media/usb/hdpvr= /hdpvr-core.c index d42336836b18..849a2be416bd 100644 --- a/drivers/media/usb/hdpvr/hdpvr-core.c +++ b/drivers/media/usb/hdpvr/hdpvr-core.c @@ -265,13 +265,10 @@ static int hdpvr_probe(struct usb_interface *interfac= e, const struct usb_device_id *id) { struct hdpvr_device *dev; - struct usb_host_interface *iface_desc; struct usb_endpoint_descriptor *endpoint; #if IS_ENABLED(CONFIG_I2C) struct i2c_client *client; #endif - size_t buffer_size; - int i; int dev_num; int retval =3D -ENOMEM; =20 @@ -321,25 +318,18 @@ static int hdpvr_probe(struct usb_interface *interfac= e, =20 /* set up the endpoint information */ /* use only the first bulk-in and bulk-out endpoints */ - iface_desc =3D interface->cur_altsetting; - for (i =3D 0; i < iface_desc->desc.bNumEndpoints; ++i) { - endpoint =3D &iface_desc->endpoint[i].desc; - - if (!dev->bulk_in_endpointAddr && - usb_endpoint_is_bulk_in(endpoint)) { - /* USB interface description is buggy, reported max - * packet size is 512 bytes, windows driver uses 8192 */ - buffer_size =3D 8192; - dev->bulk_in_size =3D buffer_size; - dev->bulk_in_endpointAddr =3D endpoint->bEndpointAddress; - } - - } - if (!dev->bulk_in_endpointAddr) { + if (usb_find_bulk_in_endpoint(interface->cur_altsetting, &endpoint)) { v4l2_err(&dev->v4l2_dev, "Could not find bulk-in endpoint\n"); goto error_put_usb; } =20 + /* + * USB interface description is buggy, reported max packet size is 512 + * bytes, windows driver uses 8192 + */ + dev->bulk_in_size =3D 8192; + dev->bulk_in_endpointAddr =3D endpoint->bEndpointAddress; + /* init the device */ if (hdpvr_device_init(dev)) { v4l2_err(&dev->v4l2_dev, "device init failed\n"); --=20 2.52.0 From nobody Thu Apr 2 07:30:17 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 B5D573BED71; Mon, 30 Mar 2026 10:11:56 +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=1774865516; cv=none; b=qy2ZE0kz+s/KpBmGoYtbnf80lfxs873cbESYHtjuefXIyZ2s3r7SkECvolEKqIlqgr1jhkCH8NSQsDXxspPSImUoqLstP0HxbWbJ9dhAFinGOvDW/gqLH+gWgY09XZVlyJFCIgOt4OFMWEpWme4uEQiFww5Qdr8W7SsiyXaxLuo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774865516; c=relaxed/simple; bh=6VibEfDAOyJ/XX44ABuAxySDVtz6MUTLimWq8vsgG2I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aimJtcBK5crEcMup3YKJTHc5+UlnukUvmcG0ZleNOJOdeQ4Eg/NcU6CO2NAsjWsuL9G0LmVLE3/AgvrUs5a5/8/RzRC804rGuxO7olO0YUtpB+X2/QSJgRRjxJUKUvGuoX6uCriJLqS/V48kXowVrGCEI9TGGHJFNedVO1dXCgY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CxD6eS8d; 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="CxD6eS8d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DD32C2BCB7; Mon, 30 Mar 2026 10:11:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774865516; bh=6VibEfDAOyJ/XX44ABuAxySDVtz6MUTLimWq8vsgG2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CxD6eS8dLSI5fSuDPt9HIxzH6s027/A1HnNeldpnoEBXgJzRMkeIr+562ymzmYrJJ 42sKJjxz3AHoGe4apaOEbcJxxKFNd0Ok24ZIcslt/acboT3fi6R30tvoI/UDZU7mQg EulGARPqdOuw/kbue1wapeLriOi64W4bb+VptFmcTnY42hjALaqVm4ESyIQbIZZ3Rt QTUqwktOGlq4N6qyLOP1/Am//KemvQqMG4i39XT7g4TMSTXVps49TZvzxobdqj5An9 htdXeFx+w4TMOzP285Yr2K6Cx1HGxbpY7BkoyVpgw5QluibhnmwE3jG/8+QGXjIOq7 VJHnBbjcQRWrg== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1w79b8-00000006yvm-1VZD; Mon, 30 Mar 2026 12:11:54 +0200 From: Johan Hovold To: Hans Verkuil , Sean Young , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 6/6] media: s2255: refactor endpoint lookup Date: Mon, 30 Mar 2026 12:11:41 +0200 Message-ID: <20260330101141.1664143-7-johan@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260330101141.1664143-1-johan@kernel.org> References: <20260330101141.1664143-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-in endpoints instead of open coding. Signed-off-by: Johan Hovold --- drivers/media/usb/s2255/s2255drv.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s= 2255drv.c index 2c02873d09b5..0b8182edf8e4 100644 --- a/drivers/media/usb/s2255/s2255drv.c +++ b/drivers/media/usb/s2255/s2255drv.c @@ -2240,18 +2240,14 @@ static int s2255_probe(struct usb_interface *interf= ace, iface_desc =3D interface->cur_altsetting; dev_dbg(&interface->dev, "num EP: %d\n", iface_desc->desc.bNumEndpoints); - for (i =3D 0; i < iface_desc->desc.bNumEndpoints; ++i) { - endpoint =3D &iface_desc->endpoint[i].desc; - if (!dev->read_endpoint && usb_endpoint_is_bulk_in(endpoint)) { - /* we found the bulk in endpoint */ - dev->read_endpoint =3D endpoint->bEndpointAddress; - } - } =20 - if (!dev->read_endpoint) { + if (usb_find_bulk_in_endpoint(iface_desc, &endpoint)) { dev_err(&interface->dev, "Could not find bulk-in endpoint\n"); goto errorEP; } + + dev->read_endpoint =3D endpoint->bEndpointAddress; + timer_setup(&dev->timer, s2255_timer, 0); init_waitqueue_head(&dev->fw_data->wait_fw); for (i =3D 0; i < MAX_CHANNELS; i++) { --=20 2.52.0