summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2024-07-15 09:05:52 -0700
committerJakub Kicinski <kuba@kernel.org>2024-07-15 09:05:58 -0700
commitba7a0f4436ac73850a4110acf04d65f6e8a67d82 (patch)
tree18a7c26090620816b0813d2cf6dda5d9b2d31875 /drivers/net/ethernet
parent0970bf676f86c2c4d9bf7e672f5504d390c9fce6 (diff)
Revert "net: mvpp2: Improve data types and use min()"
This reverts commit f7023b3d697c6a7dfe2d9c70e0d8c2c580ccbd76. Russell indicates that assuming 32bits are sufficient isn't necessarily safe. Link: https://lore.kernel.org/20240711154741.174745-1-thorsten.blum@toblux.com/ Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 33b08786992f..8c45ad983abc 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -2766,29 +2766,29 @@ static void mvpp2_tx_pkts_coal_set(struct mvpp2_port *port,
}
}
-static u32 mvpp2_usec_to_cycles(u32 usec, u32 clk_hz)
+static u32 mvpp2_usec_to_cycles(u32 usec, unsigned long clk_hz)
{
u64 tmp = (u64)clk_hz * usec;
do_div(tmp, USEC_PER_SEC);
- return min(tmp, U32_MAX);
+ return tmp > U32_MAX ? U32_MAX : tmp;
}
-static u32 mvpp2_cycles_to_usec(u32 cycles, u32 clk_hz)
+static u32 mvpp2_cycles_to_usec(u32 cycles, unsigned long clk_hz)
{
u64 tmp = (u64)cycles * USEC_PER_SEC;
do_div(tmp, clk_hz);
- return min(tmp, U32_MAX);
+ return tmp > U32_MAX ? U32_MAX : tmp;
}
/* Set the time delay in usec before Rx interrupt */
static void mvpp2_rx_time_coal_set(struct mvpp2_port *port,
struct mvpp2_rx_queue *rxq)
{
- u32 freq = port->priv->tclk;
+ unsigned long freq = port->priv->tclk;
u32 val = mvpp2_usec_to_cycles(rxq->time_coal, freq);
if (val > MVPP2_MAX_ISR_RX_THRESHOLD) {
@@ -2804,7 +2804,7 @@ static void mvpp2_rx_time_coal_set(struct mvpp2_port *port,
static void mvpp2_tx_time_coal_set(struct mvpp2_port *port)
{
- u32 freq = port->priv->tclk;
+ unsigned long freq = port->priv->tclk;
u32 val = mvpp2_usec_to_cycles(port->tx_time_coal, freq);
if (val > MVPP2_MAX_ISR_TX_THRESHOLD) {