Skip to contentSkip to conversation

drivers/scsi/tmscsim.c: replace shift loop by ilog2]

PATCH In review Joe Perches 2 participants 2 messages May 20, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/scsi/tmscsim.c: replace shift loop by ilog2]

Hello Kurt.

If you're still interested in tmscim.

Your [email protected] address bounces....

btw: Your MAINTAINERS entry is out of date.

MAINTAINERS-DC390/AM53C974 SCSI driver

MAINTAINERS:M:  Kurt Garloff <[email protected]>
MAINTAINERS:W:  http://www.garloff.de/kurt/linux/dc390/
MAINTAINERS-M:  Guennadi Liakhovetski <[email protected]>
MAINTAINERS-S:  Maintained
MAINTAINERS-F:  drivers/scsi/tmscsim.*

-------- Forwarded Message --------
From: Joe Perches <[email protected]>
To: Fabian Frederick <[email protected]>
Cc: linux-kernel <[email protected]>, Kurt Garloff <[email protected]>, akpm <[email protected]>
Subject: Re: [PATCH 1/1] drivers/scsi/tmscsim.c: replace shift loop by ilog2

drivers/scsi/tmscsim.c

Quoted 8 lines · Fabian Frederick
Cc Kurt Garloff <[email protected]>
Cc Andrew Morton <[email protected]>
---
 drivers/scsi/tmscsim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/tmscsim.c +0 -0

[]

drivers/scsi/tmscsim.c dc390_Reselect( struct dc390_acb* pACB ) · line 1617

Quoted 9 lines
drivers/scsi/tmscsim.c +1 -1
@@ -1611,7 +1611,7 @@ dc390_Reselect( struct dc390_acb* pACB )
       printk (KERN_ERR "DC390: Reselection must select host adapter: %02x!\n", lun);
     else
       lun ^= 1 << pACB->pScsiHost->this_id; /* Mask AdapterID */
-    id = 0; while (lun >>= 1) id++;
+    id = ilog2(lun);
     /* Get LUN */
     lun = DC390_read8 (ScsiFifo);
     if (!(lun & IDENTIFY_BASE)) printk (KERN_ERR "DC390: Resel: Expect identify message!\n");

Hey Fabian.

You've submitted several of these now.

Have you gone through all of these to make sure that the ilog2(<foo>) uses are always using a non-zero <foo>?

If so, that should be mentioned in the changelog.

These should probably add #include <linux/log2.h>

It would have been nicer to use a patch series and a cover letter so I could make this reply to to cover letter.

Please take the time to setup and use git send-email instead of sylpheed.

#1 lore raw

Hi

Quoted 45 lines · Joe Perches

Hello Kurt.

If you're still interested in tmscim.

Your [email protected] address bounces....

btw: Your MAINTAINERS entry is out of date.

MAINTAINERS-DC390/AM53C974 SCSI driver

MAINTAINERS:M:  Kurt Garloff <[email protected]>
MAINTAINERS:W:  http://www.garloff.de/kurt/linux/dc390/
MAINTAINERS-M:  Guennadi Liakhovetski <[email protected]>
MAINTAINERS-S:  Maintained
MAINTAINERS-F:  drivers/scsi/tmscsim.*

-------- Forwarded Message --------
From: Joe Perches <[email protected]>
To: Fabian Frederick <[email protected]>
Cc: linux-kernel <[email protected]>, Kurt Garloff <[email protected]>, akpm <[email protected]>
Subject: Re: [PATCH 1/1] drivers/scsi/tmscsim.c: replace shift loop by ilog2

drivers/scsi/tmscsim.c

Quoted 8 lines · Fabian Frederick
Cc Kurt Garloff <[email protected]>
Cc Andrew Morton <[email protected]>
---
 drivers/scsi/tmscsim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/tmscsim.c +0 -0

[]

drivers/scsi/tmscsim.c dc390_Reselect( struct dc390_acb* pACB ) · line 1617

Quoted 9 lines
drivers/scsi/tmscsim.c +1 -1
@@ -1611,7 +1611,7 @@ dc390_Reselect( struct dc390_acb* pACB )
       printk (KERN_ERR "DC390: Reselection must select host adapter: %02x!\n", lun);
     else
       lun ^= 1 << pACB->pScsiHost->this_id; /* Mask AdapterID */
-    id = 0; while (lun >>= 1) id++;
+    id = ilog2(lun);
     /* Get LUN */
     lun = DC390_read8 (ScsiFifo);
     if (!(lun & IDENTIFY_BASE)) printk (KERN_ERR "DC390: Resel: Expect identify message!\n");

Hey Fabian.

Quoted 5 lines

You've submitted several of these now.

Have you gone through all of these to make sure
that the ilog2(<foo>) uses are always using a
non-zero <foo>?

I think here at least, lun indeed can be 0, at least there's a test there:

    if (!(lun & (1 << pACB->pScsiHost->this_id)))
      printk (KERN_ERR "DC390: Reselection must select host adapter: %02x!\n", lun);

So, it is possible, that the "1 << this_id" bit is not set, then possibly it can be 0 too... Although from the hardware / SCSI PoV I'm not sure TBH. To be on the safe side we could at least add a check for 0 and only use ilog2, for != 0.

Thanks
Guennadi

Quoted 13 lines

If so, that should be mentioned in the changelog.

These should probably add #include <linux/log2.h>

It would have been nicer to use a patch series
and a cover letter so I could make this reply to
to cover letter.

Please take the time to setup and use git send-email instead of sylpheed.

Quoted 6 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/