From: "Bjørn Mork" <bjorn@mork.no>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: netdev@vger.kernel.org
Subject: Re: net: qmi_wwan: bind to both control and data interface
Date: Fri, 22 Jun 2012 19:34:56 +0200 [thread overview]
Message-ID: <87pq8rjlmn.fsf@nemi.mork.no> (raw)
In-Reply-To: <20120622165616.GI5390@mwanda> (Dan Carpenter's message of "Fri, 22 Jun 2012 19:56:17 +0300")
Dan Carpenter <dan.carpenter@oracle.com> writes:
> On Fri, Jun 22, 2012 at 06:27:17PM +0200, Bjørn Mork wrote:
>
>> Thanks for the notification, but this was intentional while touching the
>> code anyway. The test always was redundant because the parsing code
>> ensure that cdc_union cannot be NULL at that point.
>>
>
> Yeah. I see that now. I think it would be more readable if the
> check were rewritten like this. That way you can see immediately
> that it's checking for USB_CDC_UNION_TYPE without scrolling back and
> forth in the code.
>
> diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
> index f1e7791..23cb13c 100644
> --- a/drivers/net/usb/qmi_wwan.c
> +++ b/drivers/net/usb/qmi_wwan.c
> @@ -129,7 +129,6 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
> struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
> struct usb_cdc_union_desc *cdc_union = NULL;
> struct usb_cdc_ether_desc *cdc_ether = NULL;
> - u32 required = 1 << USB_CDC_HEADER_TYPE | 1 << USB_CDC_UNION_TYPE;
> u32 found = 0;
> struct usb_driver *driver = driver_of(intf);
> struct qmi_wwan_state *info = (void *)&dev->data;
> @@ -197,7 +196,8 @@ next_desc:
> }
>
> /* did we find all the required ones? */
> - if ((found & required) != required) {
> + if (!(found & (1 << USB_CDC_HEADER_TYPE)) ||
> + !(found & (1 << USB_CDC_UNION_TYPE))) {
> dev_err(&intf->dev, "CDC functional descriptors missing\n");
> goto err;
> }
I fully agree. Feel free to add my
Acked-by: Bjørn Mork <bjorn@mork.no>
if you want to submit that.
Bjørn
prev parent reply other threads:[~2012-06-22 17:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-22 14:25 net: qmi_wwan: bind to both control and data interface Dan Carpenter
2012-06-22 16:27 ` Bjørn Mork
2012-06-22 16:56 ` Dan Carpenter
2012-06-22 17:34 ` Bjørn Mork [this message]
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=87pq8rjlmn.fsf@nemi.mork.no \
--to=bjorn@mork.no \
--cc=dan.carpenter@oracle.com \
--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).