Commit 30544af5 authored by Jeff Kirsher's avatar Jeff Kirsher

e1000e: fix call to do_div() to use u64 arg

We were using s64 for lat_ns (latency nano-second value) since in
our calculations a negative value could be a resultant.  For negative
values, we then assign lat_ns to be zero, so the value passed to
do_div() was never negative, but do_div() expects the argument type
to be u64, so do a cast to resolve a compile warning seen on
PowerPC.

CC: Yanjiang Jin <yanjiang.jin@windriver.com>
CC: Yanir Lubetkin <yanirx.lubetkin@intel.com>
Reported-by: default avatarYanjiang Jin <yanjiang.jin@windriver.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
parent 55e7fe5b
...@@ -1015,7 +1015,7 @@ static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link) ...@@ -1015,7 +1015,7 @@ static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link)
u16 max_snoop, max_nosnoop; u16 max_snoop, max_nosnoop;
u16 max_ltr_enc; /* max LTR latency encoded */ u16 max_ltr_enc; /* max LTR latency encoded */
s64 lat_ns; /* latency (ns) */ s64 lat_ns; /* latency (ns) */
s64 value; u64 value;
u32 rxa; u32 rxa;
if (!hw->adapter->max_frame_size) { if (!hw->adapter->max_frame_size) {
...@@ -1042,12 +1042,13 @@ static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link) ...@@ -1042,12 +1042,13 @@ static s32 e1000_platform_pm_pch_lpt(struct e1000_hw *hw, bool link)
*/ */
lat_ns = ((s64)rxa * 1024 - lat_ns = ((s64)rxa * 1024 -
(2 * (s64)hw->adapter->max_frame_size)) * 8 * 1000; (2 * (s64)hw->adapter->max_frame_size)) * 8 * 1000;
if (lat_ns < 0) if (lat_ns < 0) {
lat_ns = 0; value = 0;
else } else {
do_div(lat_ns, speed); value = lat_ns;
do_div(value, speed);
}
value = lat_ns;
while (value > PCI_LTR_VALUE_MASK) { while (value > PCI_LTR_VALUE_MASK) {
scale++; scale++;
value = DIV_ROUND_UP(value, (1 << 5)); value = DIV_ROUND_UP(value, (1 << 5));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment