From patchwork Mon Aug 22 15:14:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12950794 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E88AC32772 for ; Mon, 22 Aug 2022 15:23:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236360AbiHVPXW (ORCPT ); Mon, 22 Aug 2022 11:23:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236487AbiHVPV7 (ORCPT ); Mon, 22 Aug 2022 11:21:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C196419BA; Mon, 22 Aug 2022 08:15:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 916F7B81252; Mon, 22 Aug 2022 15:15:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D724C433D6; Mon, 22 Aug 2022 15:15:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661181312; bh=mJKU6IxtGb73K0o7zmE3+f0ogV7uh8EFo83lJ4xT0io=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J4aVr/l97IpgBUzDaCdRJ/n1iABrcNKxKymZyyaCC6Ho4J/LEbj+V0crRKqgO1g6y ssjRTLRXrAXO/bNLw0h1rn2HI62SomwIX5acIJyIXBAWsrw9IO9FDbwfZ8YGzQstbL B4xEqA4rWJSoh8OQNSWbqEh7cO7w37NuItsnntAblflS6UnvnO/nBZPVZpDE+O9hHu TA3ED/gxpO5Xu5xrvc9w45bZY+5M6RZOkmTAQzci9sJhujCA8PQ9zFGAlgZg6wvpAk rHI4p6p42M+/falRCWuRFg867pD1i7gFmXlF89OPc76+ylDO+kmeoUcnT1T6Latix9 jbhd1qBPJai7w== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oQ98w-00074h-BM; Mon, 22 Aug 2022 17:15:10 +0200 From: Johan Hovold To: Mauro Carvalho Chehab Cc: Hans Verkuil , Sean Young , linux-media@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH RESEND 1/3] media: flexcop-usb: clean up endpoint sanity checks Date: Mon, 22 Aug 2022 17:14:54 +0200 Message-Id: <20220822151456.27178-2-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220822151456.27178-1-johan@kernel.org> References: <20220822151456.27178-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Add a temporary variable to make the endpoint sanity checks a bit more readable. While at it, fix a typo in the usb_set_interface() comment. Signed-off-by: Johan Hovold --- drivers/media/usb/b2c2/flexcop-usb.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c index e012b21c4fd7..31dd37d8236c 100644 --- a/drivers/media/usb/b2c2/flexcop-usb.c +++ b/drivers/media/usb/b2c2/flexcop-usb.c @@ -501,17 +501,21 @@ static int flexcop_usb_transfer_init(struct flexcop_usb *fc_usb) static int flexcop_usb_init(struct flexcop_usb *fc_usb) { - /* use the alternate setting with the larges buffer */ - int ret = usb_set_interface(fc_usb->udev, 0, 1); + struct usb_host_interface *alt; + int ret; + /* use the alternate setting with the largest buffer */ + ret = usb_set_interface(fc_usb->udev, 0, 1); if (ret) { err("set interface failed."); return ret; } - if (fc_usb->uintf->cur_altsetting->desc.bNumEndpoints < 1) + alt = fc_usb->uintf->cur_altsetting; + + if (alt->desc.bNumEndpoints < 1) return -ENODEV; - if (!usb_endpoint_is_isoc_in(&fc_usb->uintf->cur_altsetting->endpoint[0].desc)) + if (!usb_endpoint_is_isoc_in(&alt->endpoint[0].desc)) return -ENODEV; switch (fc_usb->udev->speed) { From patchwork Mon Aug 22 15:14:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12950793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F814C28D13 for ; Mon, 22 Aug 2022 15:22:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236411AbiHVPWS (ORCPT ); Mon, 22 Aug 2022 11:22:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235607AbiHVPWD (ORCPT ); Mon, 22 Aug 2022 11:22:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FC7B3DBE3; Mon, 22 Aug 2022 08:15:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D855D610A3; Mon, 22 Aug 2022 15:15:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 411D6C433C1; Mon, 22 Aug 2022 15:15:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661181312; bh=/TNMqXAFkzzbD2nFZOZ+zBMA3FkHrzThtNSNS4wQTRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=anMmDAU/uld9xgko3X5FETrFRedS3WY/nROOoODI38BxFOZfWl40rHDS3kkQT8wAD fTihu/DAVOjYjHmNpiae4Xif4oMdiUybw7RzYodfu7HoE9Ge036smsOl0Et9Tfsimq hTUaaZgwaOGWp06MuVG/r5l1VBZTymVP6xVfo2qFYdGh92Yw+C4ajtIslQ5jYzXvYs cvoTg5KUiegWlYqmYdwVQRijF+lInrKN6DFOLubDBKVLgSvO/Bj4DQ9n8ItQWEZPXY +6TW3s0Mskezycy8t2biLpisyzAyja+sBMb6s0Fv23nI0UfWt/BjgBeYiYrUMkAlT5 ypCVM6g3ECDuQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oQ98w-00074j-EV; Mon, 22 Aug 2022 17:15:10 +0200 From: Johan Hovold To: Mauro Carvalho Chehab Cc: Hans Verkuil , Sean Young , linux-media@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH RESEND 2/3] media: flexcop-usb: clean up URB initialisation Date: Mon, 22 Aug 2022 17:14:55 +0200 Message-Id: <20220822151456.27178-3-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220822151456.27178-1-johan@kernel.org> References: <20220822151456.27178-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Clean up URB initialisation somewhat by introducing a temporary variable and separating declaration and non-trivial initialisation. Signed-off-by: Johan Hovold --- drivers/media/usb/b2c2/flexcop-usb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c index 31dd37d8236c..7102b346db05 100644 --- a/drivers/media/usb/b2c2/flexcop-usb.c +++ b/drivers/media/usb/b2c2/flexcop-usb.c @@ -425,12 +425,14 @@ static void flexcop_usb_transfer_exit(struct flexcop_usb *fc_usb) static int flexcop_usb_transfer_init(struct flexcop_usb *fc_usb) { - u16 frame_size = le16_to_cpu( - fc_usb->uintf->cur_altsetting->endpoint[0].desc.wMaxPacketSize); - int bufsize = B2C2_USB_NUM_ISO_URB * B2C2_USB_FRAMES_PER_ISO * - frame_size, i, j, ret; + struct usb_host_interface *alt = fc_usb->uintf->cur_altsetting; + u16 frame_size; + int bufsize, i, j, ret; int buffer_offset = 0; + frame_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); + bufsize = B2C2_USB_NUM_ISO_URB * B2C2_USB_FRAMES_PER_ISO * frame_size; + deb_ts("creating %d iso-urbs with %d frames each of %d bytes size = %d.\n", B2C2_USB_NUM_ISO_URB, B2C2_USB_FRAMES_PER_ISO, frame_size, bufsize); From patchwork Mon Aug 22 15:14:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12950792 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FBA4C28D13 for ; Mon, 22 Aug 2022 15:22:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236494AbiHVPWQ (ORCPT ); Mon, 22 Aug 2022 11:22:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236470AbiHVPV5 (ORCPT ); Mon, 22 Aug 2022 11:21:57 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04CBB40E02; Mon, 22 Aug 2022 08:15:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 02F15CE12E6; Mon, 22 Aug 2022 15:15:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43675C433B5; Mon, 22 Aug 2022 15:15:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661181312; bh=Flt2fNTf33YYN+sp4CP8u8A0ibFdtD0FZot9OODKhMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hrAxaiOh6dVwItj/jEl7ojMqVVBChpG9MdST54WmEYfYLd3Gfj91IQ6lQU0XvBiSg KP/8p4Ha98p6hP2a6/BeAKdaNXWGjk9A/pO4BahtMMBYp8hAHR+jcJXivnAcCTdYz8 2krWE2xJoHW6a8J6WSSAxd1FcqyVdJmKkNe5iYDGyQl56pBAxXzOJ77L/DhIKHudzd 4r2J9AYsrNmKFOEfdv7t67jRz28cmxaReE+labLvfK5NQT8sexrEMwlK6DSdeLnr9V ZYD49hgibMI7GA7Gw8uTUGSFC/I4cyzCoQc1cKd6Ky1aB94L33NSp8rGrZDz6AOl41 7Vc2Pudg1Oe2w== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oQ98w-00074m-H2; Mon, 22 Aug 2022 17:15:10 +0200 From: Johan Hovold To: Mauro Carvalho Chehab Cc: Hans Verkuil , Sean Young , linux-media@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH RESEND 3/3] media: flexcop-usb: use usb_endpoint_maxp() Date: Mon, 22 Aug 2022 17:14:56 +0200 Message-Id: <20220822151456.27178-4-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220822151456.27178-1-johan@kernel.org> References: <20220822151456.27178-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use the usb_endpoint_maxp() helper instead of open coding. Signed-off-by: Johan Hovold --- drivers/media/usb/b2c2/flexcop-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c index 7102b346db05..790787f0eba8 100644 --- a/drivers/media/usb/b2c2/flexcop-usb.c +++ b/drivers/media/usb/b2c2/flexcop-usb.c @@ -430,7 +430,7 @@ static int flexcop_usb_transfer_init(struct flexcop_usb *fc_usb) int bufsize, i, j, ret; int buffer_offset = 0; - frame_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize); + frame_size = usb_endpoint_maxp(&alt->endpoint[0].desc); bufsize = B2C2_USB_NUM_ISO_URB * B2C2_USB_FRAMES_PER_ISO * frame_size; deb_ts("creating %d iso-urbs with %d frames each of %d bytes size = %d.\n",