From patchwork Thu Jun 9 14:26:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 83802 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1nzJ7K-00De69-PV; Thu, 09 Jun 2022 14:26:35 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245427AbiFIO0c (ORCPT + 1 other); Thu, 9 Jun 2022 10:26:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243680AbiFIO03 (ORCPT ); Thu, 9 Jun 2022 10:26:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC7C36FA1A; Thu, 9 Jun 2022 07:26:27 -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 8753561E14; Thu, 9 Jun 2022 14:26:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBD75C34115; Thu, 9 Jun 2022 14:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654784787; bh=mJKU6IxtGb73K0o7zmE3+f0ogV7uh8EFo83lJ4xT0io=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I/GeapL4ZDGvqQVLPJ4mHudaXE56U/lDUQgXq3iPESeTAYN3rD2KCGIM8Oos1iWQb IcrZaVuXyCXoVkt6D7JaqZ1bu5uGpmzCyzSPSNBTBW/+L5GgpELAmqGQzeGBXn22Cf 8e8nCo8M6waOrraC069U68L52LUp/QbVJu/lUbei4Mb0mBJsYj789geBPfVnKLq3PF wSFqPMpqfXg3lopLVb/BTmJSwO3LzRhtEvRfsg0Fv2EAOJwgWLQ4fFlpEmntSYAJmO vYsQLdExNEKiJ8ogQG2IB3LRws9Oz/14noxkGQB0HATZQbZj1PeFwDCdr/Fxd9VCgh 3OgJvUGoSFyRw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1nzJ79-00069L-9r; Thu, 09 Jun 2022 16:26:23 +0200 From: Johan Hovold To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 1/3] media: flexcop-usb: clean up endpoint sanity checks Date: Thu, 9 Jun 2022 16:26:03 +0200 Message-Id: <20220609142605.23620-2-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220609142605.23620-1-johan@kernel.org> References: <20220609142605.23620-1-johan@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -3.1 (---) X-LSpam-Report: No, score=-3.1 required=5.0 tests=BAYES_00=-1.9,DKIMWL_WL_HIGH=0.001,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DKIM_VALID_EF=-0.1,MAILING_LIST_MULTI=-1 autolearn=ham autolearn_force=no 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 Thu Jun 9 14:26:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 83803 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1nzJ7L-00De69-QV; Thu, 09 Jun 2022 14:26:36 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245618AbiFIO0d (ORCPT + 1 other); Thu, 9 Jun 2022 10:26:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243830AbiFIO03 (ORCPT ); Thu, 9 Jun 2022 10:26:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 158582DC23B; Thu, 9 Jun 2022 07:26:28 -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 A605D61DDF; Thu, 9 Jun 2022 14:26:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16F86C341C4; Thu, 9 Jun 2022 14:26:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654784787; bh=/TNMqXAFkzzbD2nFZOZ+zBMA3FkHrzThtNSNS4wQTRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hmsx1unYC9DAg/0BWCk/6+3msjIV8TD9HmDDtDV1AzOsXfwZKke2B3Y6uf2IYcwLY rmzFWSt7IElyFoLrASe8r1x77YXD/0Oy/eryBsUwvtzxwkww7go+JYMUThMmDJOvNh iFSO0YyBDdTIlgAu7LmvEicYpezNzr+quBULi0CBqyYRf/3v7lTIB1rqqYeRgps2S5 v/b2mugsw9KL9jJcuQ/O843s/GKHbpX7jV/1yNkJrpt8Hcqy1VYHf1CUj/5td1DxdK QL6snTaSE6W1qUzocZBX96T5/+EgH8Ww5WbUfwONknxYtAV9IvAAHpcjxATuJJPQLI Jmn9S1u8Bjghw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1nzJ79-00069N-Cj; Thu, 09 Jun 2022 16:26:23 +0200 From: Johan Hovold To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 2/3] media: flexcop-usb: clean up URB initialisation Date: Thu, 9 Jun 2022 16:26:04 +0200 Message-Id: <20220609142605.23620-3-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220609142605.23620-1-johan@kernel.org> References: <20220609142605.23620-1-johan@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -3.1 (---) X-LSpam-Report: No, score=-3.1 required=5.0 tests=BAYES_00=-1.9,DKIMWL_WL_HIGH=0.001,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DKIM_VALID_EF=-0.1,MAILING_LIST_MULTI=-1 autolearn=ham autolearn_force=no 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 Thu Jun 9 14:26:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 83804 Received: from vger.kernel.org ([23.128.96.18]) by www.linuxtv.org with esmtp (Exim 4.92) (envelope-from ) id 1nzJ7M-00De69-Ls; Thu, 09 Jun 2022 14:26:36 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343489AbiFIO0e (ORCPT + 1 other); Thu, 9 Jun 2022 10:26:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244864AbiFIO0a (ORCPT ); Thu, 9 Jun 2022 10:26:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B8A46D868; Thu, 9 Jun 2022 07:26:29 -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 3215BB82E02; Thu, 9 Jun 2022 14:26:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0D31C3411B; Thu, 9 Jun 2022 14:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1654784787; bh=Flt2fNTf33YYN+sp4CP8u8A0ibFdtD0FZot9OODKhMk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z6Dbrwic5F84F51X07thTu9oMbZDMstjM+01q3iZ7hvl4W6So34zHGBwTY04bVELT KQ3HmjdcYPUbJX84ocs/zCjqF7eHhAZBr+KvZkLSRGo+7S1rY0rfv7+fw5jmLufKSj 3R//aePQBVc3LWUQVS4jQdPaXZUWHeQnMwzM899FVP/fLwQ0puxtrXy290aN0YbxPS 1m+t3t6xcBATTALQqe2pZPEdiW2w4ThXap9FvLFNy7ZXNwc8F03vhC0mZvt3xqTFIP QExUthrDaSDOwVQRGoOrTCK49wHqswfEn4fnHN/qnlKom7/lAPvMCU1CvrNjO5s8c7 0fa8cRvGwBeOA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1nzJ79-00069P-Fc; Thu, 09 Jun 2022 16:26:23 +0200 From: Johan Hovold To: Mauro Carvalho Chehab , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 3/3] media: flexcop-usb: use usb_endpoint_maxp() Date: Thu, 9 Jun 2022 16:26:05 +0200 Message-Id: <20220609142605.23620-4-johan@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220609142605.23620-1-johan@kernel.org> References: <20220609142605.23620-1-johan@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-LSpam-Score: -3.1 (---) X-LSpam-Report: No, score=-3.1 required=5.0 tests=BAYES_00=-1.9,DKIMWL_WL_HIGH=0.001,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DKIM_VALID_EF=-0.1,MAILING_LIST_MULTI=-1 autolearn=ham autolearn_force=no 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",