linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: dc395x: Replace arithmetic addition by bitwise OR
@ 2023-02-07  8:49 Deepak R Varma
       [not found] ` <02269e84-5ca8-f150-b225-c4d8898624ec@neukum.org>
  2023-02-08  9:26 ` Oliver Neukum
  0 siblings, 2 replies; 3+ messages in thread
From: Deepak R Varma @ 2023-02-07  8:49 UTC (permalink / raw)
  To: Oliver Neukum, Ali Akcaagac, Jamie Lenehan, James E.J. Bottomley,
	Martin K. Petersen, dc395x, linux-scsi, linux-kernel
  Cc: Saurabh Singh Sengar, Praveen Kumar, Deepak R Varma

When adding two bit-field mask values, an OR operation offers higher
performance over an arithmetic operation.
Also, while at it, resolve the checkpatch incorrectly split line
warning.
Issue identified using orplus.cocci semantic patch script.

Signed-off-by: Deepak R Varma <drv@mailo.com>
---
 drivers/scsi/dc395x.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index 670a836a6ba1..e2adf8e84277 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -760,8 +760,7 @@ static void waiting_process_next(struct AdapterCtlBlk *acb)
 	struct ScsiReqBlk *srb;
 	struct list_head *dcb_list_head = &acb->dcb_list;
 
-	if (acb->active_dcb
-	    || (acb->acb_flag & (RESET_DETECT + RESET_DONE + RESET_DEV)))
+	if (acb->active_dcb || (acb->acb_flag & (RESET_DETECT | RESET_DONE | RESET_DEV)))
 		return;
 
 	if (timer_pending(&acb->waiting_timer))
@@ -844,7 +843,7 @@ static void send_srb(struct AdapterCtlBlk *acb, struct ScsiReqBlk *srb)
 
 	if (dcb->max_command <= list_size(&dcb->srb_going_list) ||
 	    acb->active_dcb ||
-	    (acb->acb_flag & (RESET_DETECT + RESET_DONE + RESET_DEV))) {
+	    (acb->acb_flag & (RESET_DETECT | RESET_DONE | RESET_DEV))) {
 		list_add_tail(&srb->list, &dcb->srb_waiting_list);
 		waiting_process_next(acb);
 		return;
@@ -1125,7 +1124,7 @@ static void reset_dev_param(struct AdapterCtlBlk *acb)
 	list_for_each_entry(dcb, &acb->dcb_list, list) {
 		u8 period_index;
 
-		dcb->sync_mode &= ~(SYNC_NEGO_DONE + WIDE_NEGO_DONE);
+		dcb->sync_mode &= ~(SYNC_NEGO_DONE | WIDE_NEGO_DONE);
 		dcb->sync_period = 0;
 		dcb->sync_offset = 0;
 
@@ -1683,7 +1682,7 @@ static void msgout_phase0(struct AdapterCtlBlk *acb, struct ScsiReqBlk *srb,
 		u16 *pscsi_status)
 {
 	dprintkdbg(DBG_0, "msgout_phase0: (0x%p)\n", srb->cmd);
-	if (srb->state & (SRB_UNEXPECT_RESEL + SRB_ABORT_SENT))
+	if (srb->state & (SRB_UNEXPECT_RESEL | SRB_ABORT_SENT))
 		*pscsi_status = PH_BUS_FREE;	/*.. initial phase */
 
 	DC395x_write16(acb, TRM_S1040_SCSI_CONTROL, DO_DATALATCH);	/* it's important for atn stop */
@@ -2899,7 +2898,7 @@ static void disconnect(struct AdapterCtlBlk *acb)
 		doing_srb_done(acb, DID_ABORT, srb->cmd, 1);
 		waiting_process_next(acb);
 	} else {
-		if ((srb->state & (SRB_START_ + SRB_MSGOUT))
+		if ((srb->state & (SRB_START_ | SRB_MSGOUT))
 		    || !(srb->
 			 state & (SRB_DISCONNECT | SRB_COMPLETED))) {
 			/*
-- 
2.34.1




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

* Re: [PATCH] scsi: dc395x: Replace arithmetic addition by bitwise OR
       [not found] ` <02269e84-5ca8-f150-b225-c4d8898624ec@neukum.org>
@ 2023-02-07 17:50   ` Deepak R Varma
  0 siblings, 0 replies; 3+ messages in thread
From: Deepak R Varma @ 2023-02-07 17:50 UTC (permalink / raw)
  To: Oliver Neukum
  Cc: Ali Akcaagac, Jamie Lenehan, James E.J. Bottomley,
	Martin K. Petersen, dc395x, linux-scsi, linux-kernel,
	Saurabh Singh Sengar, Praveen Kumar, Deepak R Varma

On Tue, Feb 07, 2023 at 03:25:09PM +0100, Oliver Neukum wrote:
> 
> 
> On 07.02.23 09:49, Deepak R Varma wrote:
> > When adding two bit-field mask values, an OR operation offers higher
> > performance over an arithmetic operation.
> 
> Hi,
> 
> I am sorry, but this change log makes no sense. These are constants.
> The compiler turns that into one value in any case.

Hello Oliver,
Yes, I received a feedback for another similar patch. Please disregard my patch
proposal.

> If you do a clean up, say so.
I did not understand this comment. Are you suggesting another opportunity that I
can take up? Could you share some details please?

Thank you.
deepak

> 
> 	Regards
> 		Oliver
> 



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

* Re: [PATCH] scsi: dc395x: Replace arithmetic addition by bitwise OR
  2023-02-07  8:49 [PATCH] scsi: dc395x: Replace arithmetic addition by bitwise OR Deepak R Varma
       [not found] ` <02269e84-5ca8-f150-b225-c4d8898624ec@neukum.org>
@ 2023-02-08  9:26 ` Oliver Neukum
  1 sibling, 0 replies; 3+ messages in thread
From: Oliver Neukum @ 2023-02-08  9:26 UTC (permalink / raw)
  To: Deepak R Varma, Ali Akcaagac, Jamie Lenehan,
	James E.J. Bottomley, Martin K. Petersen, dc395x, linux-scsi,
	linux-kernel
  Cc: Saurabh Singh Sengar, Praveen Kumar


On 07.02.23 09:49, Deepak R Varma wrote:
> When adding two bit-field mask values, an OR operation offers higher
> performance over an arithmetic operation.

Hi,

I am sorry, but this change log makes no sense. These are constants.
The compiler turns that into one value in any case.
If you do a clean up, say so.

	Regards
		Oliver


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

end of thread, other threads:[~2023-02-08  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07  8:49 [PATCH] scsi: dc395x: Replace arithmetic addition by bitwise OR Deepak R Varma
     [not found] ` <02269e84-5ca8-f150-b225-c4d8898624ec@neukum.org>
2023-02-07 17:50   ` Deepak R Varma
2023-02-08  9:26 ` Oliver Neukum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).