All of lore.kernel.org
 help / color / mirror / Atom feed
* [KJ] [PATCH] drivers/scsi/u14-34f.c : Use of the time_before() macro
@ 2005-07-16  7:24 Marcelo Feitoza Parisi
  2005-07-18 16:48 ` [KJ] [PATCH] drivers/scsi/u14-34f.c : Use of the time_before() Domen Puncer
  0 siblings, 1 reply; 2+ messages in thread
From: Marcelo Feitoza Parisi @ 2005-07-16  7:24 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #2: u14-34f.patch --]
[-- Type: text/x-patch, Size: 1765 bytes --]

Use of the time_before() macro, defined at linux/jiffies.h, which deal
with wrapping correctly and are nicer to read.

Signed-off-by: Marcelo Feitoza Parisi <marcelo@feitoza.com.br>

--- linux/drivers/scsi/u14-34f.c	2005-07-13 17:52:25.000000000 -0300
+++ linux-kj/drivers/scsi/u14-34f.c	2005-07-16 01:11:52.217178840 -0300
@@ -421,6 +421,7 @@
 #include <linux/init.h>
 #include <linux/ctype.h>
 #include <linux/spinlock.h>
+#include <linux/jiffies.h>
 #include <asm/dma.h>
 #include <asm/irq.h>
 
@@ -746,7 +747,8 @@
 static int board_inquiry(unsigned int j) {
    struct mscp *cpp;
    dma_addr_t id_dma_addr;
-   unsigned int time, limit = 0;
+   unsigned int limit = 0;
+   unsigned long time;
 
    id_dma_addr = pci_map_single(HD(j)->pdev, HD(j)->board_id,
                     sizeof(HD(j)->board_id), PCI_DMA_BIDIRECTIONAL);
@@ -779,7 +781,7 @@
 
    spin_unlock_irq(&driver_lock);
    time = jiffies;
-   while ((jiffies - time) < HZ && limit++ < 20000) udelay(100L);
+   while (time_before(jiffies, time + HZ) && limit++ < 20000) udelay(100L);
    spin_lock_irq(&driver_lock);
 
    if (cpp->adapter_status || HD(j)->cp_stat[0] != FREE) {
@@ -1409,7 +1411,8 @@
 }
 
 static int u14_34f_eh_host_reset(struct scsi_cmnd *SCarg) {
-   unsigned int i, j, time, k, c, limit = 0;
+   unsigned int i, j, k, c, limit = 0;
+   unsigned long time;
    int arg_done = FALSE;
    struct scsi_cmnd *SCpnt;
 
@@ -1496,7 +1499,8 @@
 
    spin_unlock_irq(sh[j]->host_lock);
    time = jiffies;
-   while ((jiffies - time) < (10 * HZ) && limit++ < 200000) udelay(100L);
+   while (time_before(jiffies, time + (10 * HZ))
+		   && limit++ < 200000) udelay(100L);
    spin_lock_irq(sh[j]->host_lock);
 
    printk("%s: reset, interrupts disabled, loops %d.\n", BN(j), limit);

[-- Attachment #3: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

* Re: [KJ] [PATCH] drivers/scsi/u14-34f.c : Use of the time_before()
  2005-07-16  7:24 [KJ] [PATCH] drivers/scsi/u14-34f.c : Use of the time_before() macro Marcelo Feitoza Parisi
@ 2005-07-18 16:48 ` Domen Puncer
  0 siblings, 0 replies; 2+ messages in thread
From: Domen Puncer @ 2005-07-18 16:48 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1451 bytes --]

On 16/07/05 04:24 -0300, Marcelo Feitoza Parisi wrote:

> Use of the time_before() macro, defined at linux/jiffies.h, which deal
> with wrapping correctly and are nicer to read.
> 
> Signed-off-by: Marcelo Feitoza Parisi <marcelo@feitoza.com.br>
> 
> --- linux/drivers/scsi/u14-34f.c	2005-07-13 17:52:25.000000000 -0300
> +++ linux-kj/drivers/scsi/u14-34f.c	2005-07-16 01:11:52.217178840 -0300
> @@ -421,6 +421,7 @@
>  #include <linux/init.h>
>  #include <linux/ctype.h>
>  #include <linux/spinlock.h>
> +#include <linux/jiffies.h>
>  #include <asm/dma.h>
>  #include <asm/irq.h>
>  
> @@ -746,7 +747,8 @@
>  static int board_inquiry(unsigned int j) {
>     struct mscp *cpp;
>     dma_addr_t id_dma_addr;
> -   unsigned int time, limit = 0;
> +   unsigned int limit = 0;
> +   unsigned long time;
>  
>     id_dma_addr = pci_map_single(HD(j)->pdev, HD(j)->board_id,
>                      sizeof(HD(j)->board_id), PCI_DMA_BIDIRECTIONAL);
> @@ -779,7 +781,7 @@
>  
>     spin_unlock_irq(&driver_lock);
>     time = jiffies;
> -   while ((jiffies - time) < HZ && limit++ < 20000) udelay(100L);
> +   while (time_before(jiffies, time + HZ) && limit++ < 20000) udelay(100L);

This looks similar, hehe. I wonder how many times it got copy
pasted.
ssleep() should be better.

> -   while ((jiffies - time) < (10 * HZ) && limit++ < 200000) udelay(100L);
> +   while (time_before(jiffies, time + (10 * HZ))
> +		   && limit++ < 200000) udelay(100L);

Ditto.

[-- Attachment #2: Type: text/plain, Size: 168 bytes --]

_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

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

end of thread, other threads:[~2005-07-18 16:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-16  7:24 [KJ] [PATCH] drivers/scsi/u14-34f.c : Use of the time_before() macro Marcelo Feitoza Parisi
2005-07-18 16:48 ` [KJ] [PATCH] drivers/scsi/u14-34f.c : Use of the time_before() Domen Puncer

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.