mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Peter Holik" <peter@holik.at>
To: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>
Cc: "LKML" <linux-kernel@vger.kernel.org>,
	"Netdev" <netdev@vger.kernel.org>,
	linux-usb@vger.kernel.org
Subject: Re: [Resend][PATCH] usb driver for intellon int51x1 based PLC like  devolo dlan duo
Date: Sat, 18 Apr 2009 17:33:15 +0200 (CEST)	[thread overview]
Message-ID: <0681089db5bdc5acc805ed52130dc9a5.squirrel@webmail.it-technology.at> (raw)
In-Reply-To: <Pine.LNX.4.64.0904181311470.3600@wrl-59.cs.helsinki.fi>

>> +static struct sk_buff *int51x1_tx_fixup(struct usbnet *dev,
>> +		struct sk_buff *skb, gfp_t flags)
>> +{
>> +	int pack_len = skb->len;
>> +	int headroom = skb_headroom(skb);
>> +	int tailroom = skb_tailroom(skb);
>> +	int need_tail = 0;
>> +	__le16 *len;
>> +
>> +	/*
>> +	 * usbnet would send a ZLP if packetlength mod urbsize == 0 for us,
>> +	 * but we need to know ourself, because this would add to the length
>> +	 * we send down to the device...
>> +	 */
>> +	if (!((pack_len + INT51X1_HEADER_SIZE) % dev->maxpacket))
>> +		need_tail = 1;
>> +
>> +	/* if packet and our header is smaler than 64 pad to 64 (+ ZLP) */
>> +	if ((pack_len + INT51X1_HEADER_SIZE + need_tail) < dev->maxpacket + 1)
>> +		need_tail = dev->maxpacket + 1 - pack_len - INT51X1_HEADER_SIZE;
>
> This is totally crazy code fragment, first need_tail is used like a
> boolean? But on the same some +1 scalar trick is being done? Is there some
> reason why DIV_ROUND_UP (linux/kernel.h) won't do what you want here and
> then you can trivally find diff = new - old ?
>

maybe this version is not so crazy for you?

        /* if packet and our header is smaler than 64 pad to 64 (+ ZLP) */
        if ((pack_len + INT51X1_HEADER_SIZE) < dev->maxpacket)
                need_tail = dev->maxpacket - pack_len - INT51X1_HEADER_SIZE + 1;
        /*
         * usbnet would send a ZLP if packetlength mod urbsize == 0 for us,
         * but we need to know ourself, because this would add to the length
         * we send down to the device...
         */
        else if (!((pack_len + INT51X1_HEADER_SIZE) % dev->maxpacket))
                need_tail = 1;

cu Peter


  parent reply	other threads:[~2009-04-18 15:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-18  9:31 Peter Holik
2009-04-18 10:37 ` Ilpo Järvinen
2009-04-18 12:16   ` Peter Holik
2009-04-18 15:33   ` Peter Holik [this message]
2009-04-18 15:45     ` Ilpo Järvinen
2009-04-18 16:42       ` [PATCH 0/2] " Peter Holik
2009-04-21  8:57         ` David Miller
2009-04-18 14:43 [Resend][PATCH] " Peter Holik

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=0681089db5bdc5acc805ed52130dc9a5.squirrel@webmail.it-technology.at \
    --to=peter@holik.at \
    --cc=ilpo.jarvinen@helsinki.fi \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®