* [PATCH RESEND 1/3] media: flexcop-usb: clean up endpoint sanity checks
2022-08-22 15:14 [PATCH RESEND 0/3] media: flexcop-usb: probe cleanups Johan Hovold
@ 2022-08-22 15:14 ` Johan Hovold
2022-08-22 15:14 ` [PATCH RESEND 2/3] media: flexcop-usb: clean up URB initialisation Johan Hovold
2022-08-22 15:14 ` [PATCH RESEND 3/3] media: flexcop-usb: use usb_endpoint_maxp() Johan Hovold
2 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2022-08-22 15:14 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Hans Verkuil, Sean Young, linux-media, linux-usb, linux-kernel,
Johan Hovold
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 <johan@kernel.org>
---
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) {
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH RESEND 2/3] media: flexcop-usb: clean up URB initialisation
2022-08-22 15:14 [PATCH RESEND 0/3] media: flexcop-usb: probe cleanups Johan Hovold
2022-08-22 15:14 ` [PATCH RESEND 1/3] media: flexcop-usb: clean up endpoint sanity checks Johan Hovold
@ 2022-08-22 15:14 ` Johan Hovold
2022-08-22 15:14 ` [PATCH RESEND 3/3] media: flexcop-usb: use usb_endpoint_maxp() Johan Hovold
2 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2022-08-22 15:14 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Hans Verkuil, Sean Young, linux-media, linux-usb, linux-kernel,
Johan Hovold
Clean up URB initialisation somewhat by introducing a temporary variable
and separating declaration and non-trivial initialisation.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
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);
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH RESEND 3/3] media: flexcop-usb: use usb_endpoint_maxp()
2022-08-22 15:14 [PATCH RESEND 0/3] media: flexcop-usb: probe cleanups Johan Hovold
2022-08-22 15:14 ` [PATCH RESEND 1/3] media: flexcop-usb: clean up endpoint sanity checks Johan Hovold
2022-08-22 15:14 ` [PATCH RESEND 2/3] media: flexcop-usb: clean up URB initialisation Johan Hovold
@ 2022-08-22 15:14 ` Johan Hovold
2 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2022-08-22 15:14 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Hans Verkuil, Sean Young, linux-media, linux-usb, linux-kernel,
Johan Hovold
Use the usb_endpoint_maxp() helper instead of open coding.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
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",
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread