diff mbox

net/mlx4_core: Use min_t instead of if for consistency

Message ID 1494490852-5567-1-git-send-email-yuval.shaia@oracle.com (mailing list archive)
State Superseded
Headers show

Commit Message

Yuval Shaia May 11, 2017, 8:20 a.m. UTC
Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
---
 drivers/net/ethernet/mellanox/mlx4/main.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Johannes Thumshirn May 11, 2017, 8:28 a.m. UTC | #1
On 05/11/2017 10:20 AM, Yuval Shaia wrote:
> +		nreq = min_t(nreq, MAX_MSIX);

Ahm...
include/linux/kernel.h +802
#define min_t(type, x, y)				\
	__min(type, type,				\
	      __UNIQUE_ID(min1_), __UNIQUE_ID(min2_),	\
	      x, y)

Did you compile this patch?
Leon Romanovsky May 11, 2017, 8:28 a.m. UTC | #2
On Thu, May 11, 2017 at 11:20:52AM +0300, Yuval Shaia wrote:
> Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
> ---
>  drivers/net/ethernet/mellanox/mlx4/main.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
> index 7032054..a58b15a 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/main.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/main.c
> @@ -2862,12 +2862,11 @@ static void mlx4_enable_msi_x(struct mlx4_dev *dev)
>  	int port = 0;
>
>  	if (msi_x) {
> -		int nreq = dev->caps.num_ports * num_online_cpus() + 1;
> +		int nreq = min_t(int,
> +				 dev->caps.num_ports * num_online_cpus() + 1,
> +				 dev->caps.num_eqs - dev->caps.reserved_eqs);
>
> -		nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs,
> -			     nreq);
> -		if (nreq > MAX_MSIX)
> -			nreq = MAX_MSIX;
> +		nreq = min_t(nreq, MAX_MSIX);

I don't see min_t (int, ..) here.

>
>  		entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
>  		if (!entries)
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
kernel test robot May 11, 2017, 1:35 p.m. UTC | #3
Hi Yuval,

[auto build test ERROR on net-next/master]
[also build test ERROR on v4.11 next-20170511]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Yuval-Shaia/net-mlx4_core-Use-min_t-instead-of-if-for-consistency/20170511-163038
config: powerpc-ppc64_defconfig (attached as .config)
compiler: powerpc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=powerpc 

All errors (new ones prefixed by >>):

   drivers/net/ethernet/mellanox/mlx4/main.c: In function 'mlx4_enable_msi_x':
>> drivers/net/ethernet/mellanox/mlx4/main.c:2869:30: error: macro "min_t" requires 3 arguments, but only 2 given
      nreq = min_t(nreq, MAX_MSIX);
                                 ^
>> drivers/net/ethernet/mellanox/mlx4/main.c:2869:10: error: 'min_t' undeclared (first use in this function)
      nreq = min_t(nreq, MAX_MSIX);
             ^~~~~
   drivers/net/ethernet/mellanox/mlx4/main.c:2869:10: note: each undeclared identifier is reported only once for each function it appears in

vim +/min_t +2869 drivers/net/ethernet/mellanox/mlx4/main.c

  2863	
  2864		if (msi_x) {
  2865			int nreq = min_t(int,
  2866					 dev->caps.num_ports * num_online_cpus() + 1,
  2867					 dev->caps.num_eqs - dev->caps.reserved_eqs);
  2868	
> 2869			nreq = min_t(nreq, MAX_MSIX);
  2870	
  2871			entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
  2872			if (!entries)

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 7032054..a58b15a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2862,12 +2862,11 @@  static void mlx4_enable_msi_x(struct mlx4_dev *dev)
 	int port = 0;
 
 	if (msi_x) {
-		int nreq = dev->caps.num_ports * num_online_cpus() + 1;
+		int nreq = min_t(int,
+				 dev->caps.num_ports * num_online_cpus() + 1,
+				 dev->caps.num_eqs - dev->caps.reserved_eqs);
 
-		nreq = min_t(int, dev->caps.num_eqs - dev->caps.reserved_eqs,
-			     nreq);
-		if (nreq > MAX_MSIX)
-			nreq = MAX_MSIX;
+		nreq = min_t(nreq, MAX_MSIX);
 
 		entries = kcalloc(nreq, sizeof *entries, GFP_KERNEL);
 		if (!entries)