diff mbox

[1/5] usb: cdc-ncm: Change alternate setting magic numbers into #defines

Message ID 1329317261-3406-2-git-send-email-toby.gray@realvnc.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Toby Gray Feb. 15, 2012, 2:47 p.m. UTC
The CDC NCM specification describes the alternate settings that a CDC
NCM interface must support. Alternate setting 0 does not allow any
network traffic but allows configuration of the interface. Alternate 1
allows network traffic but doesn't allow configuration of some of the
interface properties.

This change provides #defines for there two numbers to clarify why
usb_set_interface is being called.

Signed-off-by: Toby Gray <toby.gray@realvnc.com>
---
 drivers/net/usb/cdc_ncm.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

Comments

Alexey Orishko Feb. 16, 2012, 6:34 p.m. UTC | #1
On Wed, Feb 15, 2012 at 3:47 PM, Toby Gray <toby.gray@realvnc.com> wrote:

> +/* CDC NCM ch. 5.3 describes alternate setting 0 as having no
> + * endpoints and therefore not allowing any networking traffic. */
> +#define        CDC_NCM_ALTSETTING_RESET        0

Please, use bulk in the both define names to distinguish from control
ep alt settings in the next version of the specification, i.e.
something like CDC_NCM_BULK_ALTSETTING_NO_DATA
This is the setting with no endpoints (no data).

> +/* CDC NCM ch. 5.3 describes alternate setting 1 as having the
> + * required bulk endpoints for normal operation. */
> +#define        CDC_NCM_ALTSETTING_DATA         1

Regards,
Alexey
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 3a539a9..3df51ee 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -87,6 +87,13 @@ 
 	(sizeof(struct usb_cdc_ncm_nth16) + sizeof(struct usb_cdc_ncm_ndp16) + \
 	(CDC_NCM_DPT_DATAGRAMS_MAX + 1) * sizeof(struct usb_cdc_ncm_dpe16))
 
+/* CDC NCM ch. 5.3 describes alternate setting 0 as having no
+ * endpoints and therefore not allowing any networking traffic. */
+#define	CDC_NCM_ALTSETTING_RESET	0
+/* CDC NCM ch. 5.3 describes alternate setting 1 as having the
+ * required bulk endpoints for normal operation. */
+#define	CDC_NCM_ALTSETTING_DATA		1
+
 struct cdc_ncm_data {
 	struct usb_cdc_ncm_nth16 nth16;
 	struct usb_cdc_ncm_ndp16 ndp16;
@@ -549,7 +556,7 @@  advance:
 	iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber;
 
 	/* reset data interface */
-	temp = usb_set_interface(dev->udev, iface_no, 0);
+	temp = usb_set_interface(dev->udev, iface_no, CDC_NCM_ALTSETTING_RESET);
 	if (temp)
 		goto error2;
 
@@ -558,7 +565,7 @@  advance:
 		goto error2;
 
 	/* configure data interface */
-	temp = usb_set_interface(dev->udev, iface_no, 1);
+	temp = usb_set_interface(dev->udev, iface_no, CDC_NCM_ALTSETTING_DATA);
 	if (temp)
 		goto error2;