All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] scsi: megaraid/megaraid_sas: Use max helper for comparison and assignment
@ 2023-01-28 10:38 Deepak R Varma
  2023-01-28 10:39 ` [PATCH 1/2] scsi: megaraid: " Deepak R Varma
  2023-01-28 10:39 ` [PATCH 2/2] scsi: megaraid_sas: " Deepak R Varma
  0 siblings, 2 replies; 3+ messages in thread
From: Deepak R Varma @ 2023-01-28 10:38 UTC (permalink / raw)
  To: Kashyap Desai, Sumit Saxena, Shivasharan S, James E.J. Bottomley,
	Martin K. Petersen, megaraidlinux.pdl, linux-scsi, linux-kernel
  Cc: Saurabh Singh Sengar, Praveen Kumar, Deepak R Varma

This patch set proposes to replace the current if/else or "? :" based logical
evaluation and value assignment by the recommended max() helper macro. Resultant
code is better in terms of type checking and improved readability. 

Deepak R Varma (2):
  scsi: megaraid: Use max helper for comparison and assignment
  scsi: megaraid_sas: Use max helper for comparison and assignment

 drivers/scsi/megaraid.c                   | 3 +--
 drivers/scsi/megaraid/megaraid_sas_base.c | 5 +----
 2 files changed, 2 insertions(+), 6 deletions(-)

-- 
2.34.1




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

* [PATCH 1/2] scsi: megaraid: Use max helper for comparison and assignment
  2023-01-28 10:38 [PATCH 0/2] scsi: megaraid/megaraid_sas: Use max helper for comparison and assignment Deepak R Varma
@ 2023-01-28 10:39 ` Deepak R Varma
  2023-01-28 10:39 ` [PATCH 2/2] scsi: megaraid_sas: " Deepak R Varma
  1 sibling, 0 replies; 3+ messages in thread
From: Deepak R Varma @ 2023-01-28 10:39 UTC (permalink / raw)
  To: Kashyap Desai, Sumit Saxena, Shivasharan S, James E.J. Bottomley,
	Martin K. Petersen, megaraidlinux.pdl, linux-scsi, linux-kernel
  Cc: Saurabh Singh Sengar, Praveen Kumar, Deepak R Varma

Simplify code using max() helper macro for logical evaluation and value
assignment.
Proposed change is identified using minmax.cocci semantic patch script.

Signed-off-by: Deepak R Varma <drv@mailo.com>
---
 drivers/scsi/megaraid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index bf491af9f0d6..c9600e395c34 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -3473,8 +3473,7 @@ mega_m_to_n(void __user *arg, nitioctl_t *uioc)
 		/*
 		 * Choose the xferlen bigger of input and output data
 		 */
-		uioc->xferlen = uioc_mimd.outlen > uioc_mimd.inlen ?
-			uioc_mimd.outlen : uioc_mimd.inlen;
+		uioc->xferlen = max(uioc_mimd.outlen, uioc_mimd.inlen);
 
 		if( uioc_mimd.outlen ) uioc->flags = UIOC_RD;
 		if( uioc_mimd.inlen ) uioc->flags |= UIOC_WR;
-- 
2.34.1




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

* [PATCH 2/2] scsi: megaraid_sas: Use max helper for comparison and assignment
  2023-01-28 10:38 [PATCH 0/2] scsi: megaraid/megaraid_sas: Use max helper for comparison and assignment Deepak R Varma
  2023-01-28 10:39 ` [PATCH 1/2] scsi: megaraid: " Deepak R Varma
@ 2023-01-28 10:39 ` Deepak R Varma
  1 sibling, 0 replies; 3+ messages in thread
From: Deepak R Varma @ 2023-01-28 10:39 UTC (permalink / raw)
  To: Kashyap Desai, Sumit Saxena, Shivasharan S, James E.J. Bottomley,
	Martin K. Petersen, megaraidlinux.pdl, linux-scsi, linux-kernel
  Cc: Saurabh Singh Sengar, Praveen Kumar, Deepak R Varma

Simplify code using max() helper macro for logical evaluation and value
assignment.
Proposed change is identified using minmax.cocci semantic patch script.

Signed-off-by: Deepak R Varma <drv@mailo.com>
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 7fa472ab0b94..4ca9b04e1962 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -5993,10 +5993,7 @@ megasas_alloc_irq_vectors(struct megasas_instance *instance)
 			instance->msix_vectors - instance->iopoll_q_count,
 			i, instance->iopoll_q_count);
 
-	if (i > 0)
-		instance->msix_vectors = i;
-	else
-		instance->msix_vectors = 0;
+	instance->msix_vectors = max(i, 0);
 
 	if (instance->smp_affinity_enable)
 		megasas_set_high_iops_queue_affinity_and_hint(instance);
-- 
2.34.1




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

end of thread, other threads:[~2023-01-28 10:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-28 10:38 [PATCH 0/2] scsi: megaraid/megaraid_sas: Use max helper for comparison and assignment Deepak R Varma
2023-01-28 10:39 ` [PATCH 1/2] scsi: megaraid: " Deepak R Varma
2023-01-28 10:39 ` [PATCH 2/2] scsi: megaraid_sas: " Deepak R Varma

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.