public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] IB/qib: Use max() macro
@ 2024-08-27  8:22 Shen Lichuan
  2024-08-27 15:00 ` Dennis Dalessandro
  0 siblings, 1 reply; 3+ messages in thread
From: Shen Lichuan @ 2024-08-27  8:22 UTC (permalink / raw)
  To: dennis.dalessandro, jgg, leon
  Cc: linux-rdma, linux-kernel, opensource.kernel, Shen Lichuan

Use the max() macro to simplify the function and improve
its readability.

Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
---
 drivers/infiniband/hw/qib/qib_iba7220.c | 2 +-
 drivers/infiniband/hw/qib/qib_iba7322.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_iba7220.c b/drivers/infiniband/hw/qib/qib_iba7220.c
index 78dfe98ebcf7..4c96b66a93b5 100644
--- a/drivers/infiniband/hw/qib/qib_iba7220.c
+++ b/drivers/infiniband/hw/qib/qib_iba7220.c
@@ -4094,7 +4094,7 @@ static int qib_init_7220_variables(struct qib_devdata *dd)
 	updthresh = 8U; /* update threshold */
 	if (dd->flags & QIB_HAS_SEND_DMA) {
 		dd->cspec->sdmabufcnt =  dd->piobcnt4k;
-		sbufs = updthresh > 3 ? updthresh : 3;
+		sbufs = max(updthresh, 3);
 	} else {
 		dd->cspec->sdmabufcnt = 0;
 		sbufs = dd->piobcnt4k;
diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c
index 9db29916e35a..5a059ec08780 100644
--- a/drivers/infiniband/hw/qib/qib_iba7322.c
+++ b/drivers/infiniband/hw/qib/qib_iba7322.c
@@ -6633,7 +6633,7 @@ static int qib_init_7322_variables(struct qib_devdata *dd)
 	 */
 	if (dd->flags & QIB_HAS_SEND_DMA) {
 		dd->cspec->sdmabufcnt = dd->piobcnt4k;
-		sbufs = updthresh > 3 ? updthresh : 3;
+		sbufs = max(updthresh, 3);
 	} else {
 		dd->cspec->sdmabufcnt = 0;
 		sbufs = dd->piobcnt4k;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] IB/qib: Use max() macro
  2024-08-27  8:22 [PATCH v1] IB/qib: Use max() macro Shen Lichuan
@ 2024-08-27 15:00 ` Dennis Dalessandro
  2024-08-29  8:58   ` Leon Romanovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Dennis Dalessandro @ 2024-08-27 15:00 UTC (permalink / raw)
  To: Shen Lichuan, jgg, leon; +Cc: linux-rdma, linux-kernel, opensource.kernel

On 8/27/24 4:22 AM, Shen Lichuan wrote:
> Use the max() macro to simplify the function and improve
> its readability.
> 
> Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
> ---
>  drivers/infiniband/hw/qib/qib_iba7220.c | 2 +-
>  drivers/infiniband/hw/qib/qib_iba7322.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/qib/qib_iba7220.c b/drivers/infiniband/hw/qib/qib_iba7220.c
> index 78dfe98ebcf7..4c96b66a93b5 100644
> --- a/drivers/infiniband/hw/qib/qib_iba7220.c
> +++ b/drivers/infiniband/hw/qib/qib_iba7220.c
> @@ -4094,7 +4094,7 @@ static int qib_init_7220_variables(struct qib_devdata *dd)
>  	updthresh = 8U; /* update threshold */
>  	if (dd->flags & QIB_HAS_SEND_DMA) {
>  		dd->cspec->sdmabufcnt =  dd->piobcnt4k;
> -		sbufs = updthresh > 3 ? updthresh : 3;
> +		sbufs = max(updthresh, 3);
>  	} else {
>  		dd->cspec->sdmabufcnt = 0;
>  		sbufs = dd->piobcnt4k;
> diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c
> index 9db29916e35a..5a059ec08780 100644
> --- a/drivers/infiniband/hw/qib/qib_iba7322.c
> +++ b/drivers/infiniband/hw/qib/qib_iba7322.c
> @@ -6633,7 +6633,7 @@ static int qib_init_7322_variables(struct qib_devdata *dd)
>  	 */
>  	if (dd->flags & QIB_HAS_SEND_DMA) {
>  		dd->cspec->sdmabufcnt = dd->piobcnt4k;
> -		sbufs = updthresh > 3 ? updthresh : 3;
> +		sbufs = max(updthresh, 3);
>  	} else {
>  		dd->cspec->sdmabufcnt = 0;
>  		sbufs = dd->piobcnt4k;

I don't see how this improves readability or makes the function simpler. I'm not
opposed to it, just don't see it as an improvement.

-Denny

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v1] IB/qib: Use max() macro
  2024-08-27 15:00 ` Dennis Dalessandro
@ 2024-08-29  8:58   ` Leon Romanovsky
  0 siblings, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2024-08-29  8:58 UTC (permalink / raw)
  To: Dennis Dalessandro
  Cc: Shen Lichuan, jgg, linux-rdma, linux-kernel, opensource.kernel

On Tue, Aug 27, 2024 at 11:00:11AM -0400, Dennis Dalessandro wrote:
> On 8/27/24 4:22 AM, Shen Lichuan wrote:
> > Use the max() macro to simplify the function and improve
> > its readability.
> > 
> > Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
> > ---
> >  drivers/infiniband/hw/qib/qib_iba7220.c | 2 +-
> >  drivers/infiniband/hw/qib/qib_iba7322.c | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/infiniband/hw/qib/qib_iba7220.c b/drivers/infiniband/hw/qib/qib_iba7220.c
> > index 78dfe98ebcf7..4c96b66a93b5 100644
> > --- a/drivers/infiniband/hw/qib/qib_iba7220.c
> > +++ b/drivers/infiniband/hw/qib/qib_iba7220.c
> > @@ -4094,7 +4094,7 @@ static int qib_init_7220_variables(struct qib_devdata *dd)
> >  	updthresh = 8U; /* update threshold */
> >  	if (dd->flags & QIB_HAS_SEND_DMA) {
> >  		dd->cspec->sdmabufcnt =  dd->piobcnt4k;
> > -		sbufs = updthresh > 3 ? updthresh : 3;
> > +		sbufs = max(updthresh, 3);
> >  	} else {
> >  		dd->cspec->sdmabufcnt = 0;
> >  		sbufs = dd->piobcnt4k;
> > diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c
> > index 9db29916e35a..5a059ec08780 100644
> > --- a/drivers/infiniband/hw/qib/qib_iba7322.c
> > +++ b/drivers/infiniband/hw/qib/qib_iba7322.c
> > @@ -6633,7 +6633,7 @@ static int qib_init_7322_variables(struct qib_devdata *dd)
> >  	 */
> >  	if (dd->flags & QIB_HAS_SEND_DMA) {
> >  		dd->cspec->sdmabufcnt = dd->piobcnt4k;
> > -		sbufs = updthresh > 3 ? updthresh : 3;
> > +		sbufs = max(updthresh, 3);
> >  	} else {
> >  		dd->cspec->sdmabufcnt = 0;
> >  		sbufs = dd->piobcnt4k;
> 
> I don't see how this improves readability or makes the function simpler. I'm not
> opposed to it, just don't see it as an improvement.

He got same comment from Jakub K. (netdev) too, so let's drop this patch.

Thanks

> 
> -Denny

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-29  8:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-27  8:22 [PATCH v1] IB/qib: Use max() macro Shen Lichuan
2024-08-27 15:00 ` Dennis Dalessandro
2024-08-29  8:58   ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox