Skip to content

Commit

Permalink
net: cdc_ncm: fix 64bit division build error
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Bjørn Mork authored and David S. Miller committed May 21, 2014
1 parent b6052af commit 7d10d26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions drivers/net/usb/cdc_ncm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions include/linux/usb/cdc_ncm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down

0 comments on commit 7d10d26

Please sign in to comment.