netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: linux-usb@vger.kernel.org, netdev@vger.kernel.org,
	davem@davemloft.net, gregKH@linuxfoundation.org, bjorn@mork.no
Cc: Oliver Neukum <oneukum@suse.com>, Oliver Neukum <ONeukum@suse.com>
Subject: [PATCH 4/5] cdc-wdm: use the common CDC parser
Date: Thu, 14 Jul 2016 15:41:33 +0200	[thread overview]
Message-ID: <1468503694-9482-5-git-send-email-oneukum@suse.com> (raw)
In-Reply-To: <1468503694-9482-1-git-send-email-oneukum@suse.com>

Now that the common parser resides in USB core, it can
be used for CDC-WDM.

Signed-off-by: Oliver Neukum <ONeukum@suse.com>
---
 drivers/usb/class/cdc-wdm.c | 30 +++++-------------------------
 1 file changed, 5 insertions(+), 25 deletions(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 61ea879..337948c 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -875,38 +875,18 @@ static int wdm_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	int rv = -EINVAL;
 	struct usb_host_interface *iface;
 	struct usb_endpoint_descriptor *ep;
-	struct usb_cdc_dmm_desc *dmhd;
+	struct usb_cdc_parsed_header hdr;
 	u8 *buffer = intf->altsetting->extra;
 	int buflen = intf->altsetting->extralen;
 	u16 maxcom = WDM_DEFAULT_BUFSIZE;
 
 	if (!buffer)
 		goto err;
-	while (buflen > 2) {
-		if (buffer[1] != USB_DT_CS_INTERFACE) {
-			dev_err(&intf->dev, "skipping garbage\n");
-			goto next_desc;
-		}
 
-		switch (buffer[2]) {
-		case USB_CDC_HEADER_TYPE:
-			break;
-		case USB_CDC_DMM_TYPE:
-			dmhd = (struct usb_cdc_dmm_desc *)buffer;
-			maxcom = le16_to_cpu(dmhd->wMaxCommand);
-			dev_dbg(&intf->dev,
-				"Finding maximum buffer length: %d", maxcom);
-			break;
-		default:
-			dev_err(&intf->dev,
-				"Ignoring extra header, type %d, length %d\n",
-				buffer[2], buffer[0]);
-			break;
-		}
-next_desc:
-		buflen -= buffer[0];
-		buffer += buffer[0];
-	}
+	cdc_parse_cdc_header(&hdr, intf, buffer, buflen);
+
+	if (hdr.usb_cdc_dmm_desc)
+		maxcom = le16_to_cpu(hdr.usb_cdc_dmm_desc->wMaxCommand);
 
 	iface = intf->cur_altsetting;
 	if (iface->desc.bNumEndpoints != 1)
-- 
2.1.4

  parent reply	other threads:[~2016-07-14 13:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-14 13:41 [PATCH 0 / 5] move the common CDC parser Oliver Neukum
2016-07-14 13:41 ` [PATCH 1/5] usbnet: move the CDC parser into USB core Oliver Neukum
     [not found] ` <1468503694-9482-1-git-send-email-oneukum-IBi9RG/b67k@public.gmane.org>
2016-07-14 13:41   ` [PATCH 2/5] cdc-acm: use the common parser Oliver Neukum
2016-07-14 13:41   ` [PATCH 3/5] cdc-acm: cleanup error handling Oliver Neukum
2016-07-14 13:41   ` [PATCH 5/5] cdc-acm: beautify probe() Oliver Neukum
2016-07-14 13:41 ` Oliver Neukum [this message]
2016-07-15 18:51 ` [PATCH 0 / 5] move the common CDC parser David Miller
     [not found]   ` <20160715.115147.1896139966807241395.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2016-07-15 21:57     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1468503694-9482-5-git-send-email-oneukum@suse.com \
    --to=oneukum@suse.com \
    --cc=bjorn@mork.no \
    --cc=davem@davemloft.net \
    --cc=gregKH@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).