From: "Bjørn Mork" <bjorn@mork.no>
To: <netdev@vger.kernel.org>
Cc: linux-usb@vger.kernel.org,
"Alexey Orishko" <alexey.orishko@gmail.com>,
"Oliver Neukum" <oliver@neukum.org>,
"Enrico Mioso" <mrkiko.rs@gmail.com>,
"David Laight" <David.Laight@ACULAB.COM>,
"Stephen Rothwell" <sfr@canb.auug.org.au>,
"Bjørn Mork" <bjorn@mork.no>
Subject: [PATCH net-next] net: cdc_ncm: fix 64bit division build error
Date: Mon, 19 May 2014 09:21:09 +0200 [thread overview]
Message-ID: <1400484069-13702-1-git-send-email-bjorn@mork.no> (raw)
The upper timer_interval limit is arbitrary and much higher
than anything usable in the real world. Reducing it from 15s
to ~4s to make the timer_interval fit in an u32 does not make
much difference. The limit is still outside the practical
bounds.
This eliminates the need for a 64bit timer_interval, fixing a
build error related to 64bit division:
drivers/built-in.o: In function `cdc_ncm_get_coalesce':
ak8975.c:(.text+0x1ac994): undefined reference to `__aeabi_uldivmod'
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
Thanks a lot for reporting this! I believe it makes more sense to change
to a u32 than using do_div here.
Bjørn
drivers/net/usb/cdc_ncm.c | 4 ++--
include/linux/usb/cdc_ncm.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 2d0caf1eea25..ad2a386a6e92 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -138,7 +138,7 @@ static int cdc_ncm_get_coalesce(struct net_device *netdev,
ec->tx_max_coalesced_frames = ctx->tx_max / ctx->max_datagram_size;
/* the timer will fire CDC_NCM_TIMER_PENDING_CNT times in a row */
- ec->tx_coalesce_usecs = (ctx->timer_interval * CDC_NCM_TIMER_PENDING_CNT) / NSEC_PER_USEC;
+ ec->tx_coalesce_usecs = ctx->timer_interval / (NSEC_PER_USEC / CDC_NCM_TIMER_PENDING_CNT);
return 0;
}
@@ -164,7 +164,7 @@ static int cdc_ncm_set_coalesce(struct net_device *netdev,
return -EINVAL;
spin_lock_bh(&ctx->mtx);
- ctx->timer_interval = ec->tx_coalesce_usecs * NSEC_PER_USEC / CDC_NCM_TIMER_PENDING_CNT;
+ ctx->timer_interval = ec->tx_coalesce_usecs * (NSEC_PER_USEC / CDC_NCM_TIMER_PENDING_CNT);
if (!ctx->timer_interval)
ctx->tx_timer_pending = 0;
spin_unlock_bh(&ctx->mtx);
diff --git a/include/linux/usb/cdc_ncm.h b/include/linux/usb/cdc_ncm.h
index 8c5e38819828..7c9b484735c5 100644
--- a/include/linux/usb/cdc_ncm.h
+++ b/include/linux/usb/cdc_ncm.h
@@ -78,7 +78,7 @@
#define CDC_NCM_TIMER_PENDING_CNT 2
#define CDC_NCM_TIMER_INTERVAL_USEC 400UL
#define CDC_NCM_TIMER_INTERVAL_MIN 5UL
-#define CDC_NCM_TIMER_INTERVAL_MAX (15UL * USEC_PER_SEC)
+#define CDC_NCM_TIMER_INTERVAL_MAX (U32_MAX / NSEC_PER_USEC)
#define cdc_ncm_comm_intf_is_mbim(x) ((x)->desc.bInterfaceSubClass == USB_CDC_SUBCLASS_MBIM && \
(x)->desc.bInterfaceProtocol == USB_CDC_PROTO_NONE)
@@ -104,7 +104,7 @@ struct cdc_ncm_ctx {
spinlock_t mtx;
atomic_t stop;
- u64 timer_interval;
+ u32 timer_interval;
u32 max_ndp_size;
u32 tx_timer_pending;
--
2.0.0.rc2
next reply other threads:[~2014-05-19 7:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-19 7:21 Bjørn Mork [this message]
2014-05-21 2:07 ` [PATCH net-next] net: cdc_ncm: fix 64bit division build error Stephen Rothwell
2014-05-21 5:56 ` David Miller
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=1400484069-13702-1-git-send-email-bjorn@mork.no \
--to=bjorn@mork.no \
--cc=David.Laight@ACULAB.COM \
--cc=alexey.orishko@gmail.com \
--cc=linux-usb@vger.kernel.org \
--cc=mrkiko.rs@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=oliver@neukum.org \
--cc=sfr@canb.auug.org.au \
/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).