Skip to contentSkip to conversation

media: flexcop-usb: probe cleanups

PATCH RESEND New Johan Hovold 1 participant 4 messages Aug 22, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover media: flexcop-usb: probe cleanups

This series cleans up the probe helper functions a bit to make the code more readable.

It has been two months and two completely ignored reminders since this was first posted so resending.

Can someone please pick this up and let me know when that has been done?

Note that these apply on top of the fix resent here:

	https://lore.kernel.org/r/[email protected]

Johan

Johan Hovold (3):
media: flexcop-usb: clean up endpoint sanity checks
media: flexcop-usb: clean up URB initialisation
media: flexcop-usb: use usb_endpoint_maxp()

 drivers/media/usb/b2c2/flexcop-usb.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw

PATCH RESEND 1/3 media: flexcop-usb: clean up endpoint sanity checks

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.

---
 drivers/media/usb/b2c2/flexcop-usb.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/media/usb/b2c2/flexcop-usb.c +8 -4
index e012b21c4fd7..31dd37d8236c 100644
@@ -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) {
Signature · 1 line
2.35.1
#2 lore raw

PATCH RESEND 2/3 media: flexcop-usb: clean up URB initialisation

In reply to Johan Hovold

Clean up URB initialisation somewhat by introducing a temporary variable and separating declaration and non-trivial initialisation.

---
 drivers/media/usb/b2c2/flexcop-usb.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/media/usb/b2c2/flexcop-usb.c +6 -4
index 31dd37d8236c..7102b346db05 100644
@@ -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);
Signature · 1 line
2.35.1
#3 lore raw

PATCH RESEND 3/3 media: flexcop-usb: use usb_endpoint_maxp()

In reply to Johan Hovold

Use the usb_endpoint_maxp() helper instead of open coding.

---
 drivers/media/usb/b2c2/flexcop-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/b2c2/flexcop-usb.c +1 -1
index 7102b346db05..790787f0eba8 100644
@@ -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",
Signature · 1 line
2.35.1