[PATCH 1/4] cp210x: Replace USB magic numbers with symbolic names

From: Petr Tesarik
Date: Fri Jul 24 2015 - 02:49:32 EST


From: Petr Tesarik <ptesarik@xxxxxxx>

The request type is in fact made of three fields that already have
symbolic constants.

While I was rewriting those lines, I also converted the pre-processor
defines into an enum, so they are seen by debuggers.

Signed-off-by: Petr Tesarik <ptesarik@xxxxxxxx>
---
drivers/usb/serial/cp210x.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index eac7cca..1bae015 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -226,10 +226,16 @@ static struct usb_serial_driver * const serial_drivers[] = {
};

/* Config request types */
-#define REQTYPE_HOST_TO_INTERFACE 0x41
-#define REQTYPE_INTERFACE_TO_HOST 0xc1
-#define REQTYPE_HOST_TO_DEVICE 0x40
-#define REQTYPE_DEVICE_TO_HOST 0xc0
+enum cp210x_request_type {
+ REQTYPE_HOST_TO_INTERFACE =
+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
+ REQTYPE_INTERFACE_TO_HOST =
+ USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
+ REQTYPE_HOST_TO_DEVICE =
+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+ REQTYPE_DEVICE_TO_HOST =
+ USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+};

/* Config request codes */
#define CP210X_IFC_ENABLE 0x00
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/