Patchwork libata: use __ratelimit

login
register
mail settings
Submitter Akinobu Mita
Date April 12, 2010, 12:11 p.m.
Message ID <1271074301-3812-1-git-send-email-akinobu.mita@gmail.com>
Download mbox | patch
Permalink /patch/49965/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Akinobu Mita - April 12, 2010, 12:11 p.m.
Use __ratelimit() instead of its own private rate limit implementation.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: linux-ide@vger.kernel.org
---
 drivers/ata/libata-core.c |   19 +++----------------
 1 files changed, 3 insertions(+), 16 deletions(-)
Jeff Garzik - April 23, 2010, 2:07 a.m.
On 04/12/2010 08:11 AM, Akinobu Mita wrote:
> Use __ratelimit() instead of its own private rate limit implementation.
>
> Signed-off-by: Akinobu Mita<akinobu.mita@gmail.com>
> Cc: Jeff Garzik<jgarzik@pobox.com>
> Cc: linux-ide@vger.kernel.org
> ---
>   drivers/ata/libata-core.c |   19 +++----------------
>   1 files changed, 3 insertions(+), 16 deletions(-)

applied


--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 49cffb6..1e0ce69 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -65,6 +65,7 @@ 
 #include <linux/libata.h>
 #include <asm/byteorder.h>
 #include <linux/cdrom.h>
+#include <linux/ratelimit.h>
 
 #include "libata.h"
 
@@ -6700,25 +6701,11 @@  static void __exit ata_exit(void)
 subsys_initcall(ata_init);
 module_exit(ata_exit);
 
-static unsigned long ratelimit_time;
-static DEFINE_SPINLOCK(ata_ratelimit_lock);
+static DEFINE_RATELIMIT_STATE(ratelimit, HZ / 5, 1);
 
 int ata_ratelimit(void)
 {
-	int rc;
-	unsigned long flags;
-
-	spin_lock_irqsave(&ata_ratelimit_lock, flags);
-
-	if (time_after(jiffies, ratelimit_time)) {
-		rc = 1;
-		ratelimit_time = jiffies + (HZ/5);
-	} else
-		rc = 0;
-
-	spin_unlock_irqrestore(&ata_ratelimit_lock, flags);
-
-	return rc;
+	return __ratelimit(&ratelimit);
 }
 
 /**