Re: [PATCH 1/2] dump_audio_bmcontrols(): tell users about faulty bmControl bits

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Daniel Mack wrote:

Daniel Mack wrote:

Signed-off-by: Daniel Mack <daniel@xxxxxxxx>
[...]
diff --git a/lsusb.c b/lsusb.c
index 43ce219..b0b073d 100644
--- a/lsusb.c
+++ b/lsusb.c
@@ -939,12 +939,16 @@ static void dump_audio_bmcontrols(const char *prefix, int bmcontrols, const stru
			break;
-		case USB_AUDIO_CLASS_2:
-			if (bmcontrols & (1 << (list->bit * 2)))
-				printf("%s%s Control (%s)\n", prefix, list->name,
-					bmcontrols & (2 << (list->bit * 2)) ? "read/write" : "read-only");
+		case USB_AUDIO_CLASS_2: {
+			const char *ctrl_type[] = { "read-only", "ILLEGAL (0b10)", "read/write" };
+			int ctrl = (bmcontrols >> (list->bit * 2)) & 0x3;
+
+			if (ctrl)
+				printf("%s%s Control (%s)\n", prefix, list->name, ctrl_type[ctrl-1]);
			break;
+		}
+
		} /* switch */
   Hm, why this { at the same indent level?

because the 'case' block opens a '{'. I couldn't find a better solution
for this, except for making the variables non-local.

   I think you should have indented your code one level more then:

		case USB_AUDIO_CLASS_2:
			{
			/* ... */
			}

Daniel

WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux