mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 15:03:52 +08:00
sfc: replace min/max nesting with clamp()
The clamp() macro explicitly expresses the intent of constraining a value within bounds.Therefore, replacing min(max(a, b), c) with clamp(val, lo, hi) can improve code readability. Signed-off-by: Xichao Zhao <zhao.xichao@vivo.com> Reviewed-by: Joe Damato <joe@dama.to> Reviewed-by: Edward Cree <ecree.xilinx@gmail.com> Link: https://patch.msgid.link/20250812065026.620115-1-zhao.xichao@vivo.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
6a18b85ca7
commit
6398d8a856
@@ -216,8 +216,8 @@ static int efx_allocate_msix_channels(struct efx_nic *efx,
|
||||
|
||||
if (efx_separate_tx_channels) {
|
||||
efx->n_tx_channels =
|
||||
min(max(n_channels / 2, 1U),
|
||||
efx->max_tx_channels);
|
||||
clamp(n_channels / 2, 1U,
|
||||
efx->max_tx_channels);
|
||||
efx->tx_channel_offset =
|
||||
n_channels - efx->n_tx_channels;
|
||||
efx->n_rx_channels =
|
||||
|
||||
@@ -1394,9 +1394,8 @@ static int ef4_probe_interrupts(struct ef4_nic *efx)
|
||||
if (n_channels > extra_channels)
|
||||
n_channels -= extra_channels;
|
||||
if (ef4_separate_tx_channels) {
|
||||
efx->n_tx_channels = min(max(n_channels / 2,
|
||||
1U),
|
||||
efx->max_tx_channels);
|
||||
efx->n_tx_channels = clamp(n_channels / 2, 1U,
|
||||
efx->max_tx_channels);
|
||||
efx->n_rx_channels = max(n_channels -
|
||||
efx->n_tx_channels,
|
||||
1U);
|
||||
|
||||
@@ -217,8 +217,8 @@ static int efx_allocate_msix_channels(struct efx_nic *efx,
|
||||
|
||||
if (efx_siena_separate_tx_channels) {
|
||||
efx->n_tx_channels =
|
||||
min(max(n_channels / 2, 1U),
|
||||
efx->max_tx_channels);
|
||||
clamp(n_channels / 2, 1U,
|
||||
efx->max_tx_channels);
|
||||
efx->tx_channel_offset =
|
||||
n_channels - efx->n_tx_channels;
|
||||
efx->n_rx_channels =
|
||||
|
||||
Reference in New Issue
Block a user