Skip to content

Commit f7023b3

Browse files
tobluxkuba-moo
authored andcommitted
net: mvpp2: Improve data types and use min()
Change the data type of the variable freq in mvpp2_rx_time_coal_set() and mvpp2_tx_time_coal_set() to u32 because port->priv->tclk also has the data type u32. Change the data type of the function parameter clk_hz in mvpp2_usec_to_cycles() and mvpp2_cycles_to_usec() to u32 accordingly and remove the following Coccinelle/coccicheck warning reported by do_div.cocci: WARNING: do_div() does a 64-by-32 division, please consider using div64_ul instead Use min() to simplify the code and improve its readability. Compile-tested only. Signed-off-by: Thorsten Blum <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 275a63c commit f7023b3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2766,29 +2766,29 @@ static void mvpp2_tx_pkts_coal_set(struct mvpp2_port *port,
27662766
}
27672767
}
27682768

2769-
static u32 mvpp2_usec_to_cycles(u32 usec, unsigned long clk_hz)
2769+
static u32 mvpp2_usec_to_cycles(u32 usec, u32 clk_hz)
27702770
{
27712771
u64 tmp = (u64)clk_hz * usec;
27722772

27732773
do_div(tmp, USEC_PER_SEC);
27742774

2775-
return tmp > U32_MAX ? U32_MAX : tmp;
2775+
return min(tmp, U32_MAX);
27762776
}
27772777

2778-
static u32 mvpp2_cycles_to_usec(u32 cycles, unsigned long clk_hz)
2778+
static u32 mvpp2_cycles_to_usec(u32 cycles, u32 clk_hz)
27792779
{
27802780
u64 tmp = (u64)cycles * USEC_PER_SEC;
27812781

27822782
do_div(tmp, clk_hz);
27832783

2784-
return tmp > U32_MAX ? U32_MAX : tmp;
2784+
return min(tmp, U32_MAX);
27852785
}
27862786

27872787
/* Set the time delay in usec before Rx interrupt */
27882788
static void mvpp2_rx_time_coal_set(struct mvpp2_port *port,
27892789
struct mvpp2_rx_queue *rxq)
27902790
{
2791-
unsigned long freq = port->priv->tclk;
2791+
u32 freq = port->priv->tclk;
27922792
u32 val = mvpp2_usec_to_cycles(rxq->time_coal, freq);
27932793

27942794
if (val > MVPP2_MAX_ISR_RX_THRESHOLD) {
@@ -2804,7 +2804,7 @@ static void mvpp2_rx_time_coal_set(struct mvpp2_port *port,
28042804

28052805
static void mvpp2_tx_time_coal_set(struct mvpp2_port *port)
28062806
{
2807-
unsigned long freq = port->priv->tclk;
2807+
u32 freq = port->priv->tclk;
28082808
u32 val = mvpp2_usec_to_cycles(port->tx_time_coal, freq);
28092809

28102810
if (val > MVPP2_MAX_ISR_TX_THRESHOLD) {

0 commit comments

Comments
 (0)