public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/14] use printk_once
@ 2009-08-09 19:53 Marcin Slusarz
  2009-08-09 19:53 ` [PATCH 01/14] alpha: " Marcin Slusarz
                   ` (14 more replies)
  0 siblings, 15 replies; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:53 UTC (permalink / raw)
  To: LKML

 arch/alpha/kernel/pci_iommu.c      |    6 +-----
 arch/ia64/kernel/unaligned.c       |    6 ++----
 arch/ia64/sn/kernel/io_common.c    |    8 ++------
 arch/powerpc/kernel/iommu.c        |    6 +-----
 arch/powerpc/kernel/irq.c          |    5 ++---
 arch/powerpc/sysdev/ppc4xx_pci.c   |    9 ++-------
 arch/sh/mm/ioremap_64.c            |    6 +-----
 arch/x86/kernel/irq_32.c           |    5 ++---
 arch/x86/kvm/x86.c                 |    7 +------
 drivers/ata/pata_rz1000.c          |    4 +---
 drivers/block/paride/pcd.c         |   12 ++++--------
 drivers/block/sx8.c                |    4 +---
 drivers/block/viodasd.c            |   12 +++---------
 drivers/char/tty_ioctl.c           |    4 +---
 drivers/char/vt.c                  |    6 +-----
 drivers/ide/ide-proc.c             |    8 +-------
 drivers/infiniband/hw/cxgb3/iwch.c |    4 +---
 drivers/infiniband/hw/mlx4/main.c  |    6 +-----
 drivers/net/mlx4/en_main.c         |    6 +-----
 drivers/net/mv643xx_eth.c          |    4 +---
 drivers/scsi/53c700.c              |    6 +-----
 drivers/scsi/cxgb3i/cxgb3i_init.c  |    7 +------
 lib/vsprintf.c                     |   14 ++------------
 net/ax25/af_ax25.c                 |    6 +-----
 net/dsa/dsa.c                      |    4 +---
 net/ipv4/raw.c                     |    6 ++----
 net/netfilter/xt_recent.c          |   10 +++-------
 net/socket.c                       |    8 ++------
 28 files changed, 43 insertions(+), 146 deletions(-)

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

* [PATCH 01/14] alpha: use printk_once
  2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
@ 2009-08-09 19:53 ` Marcin Slusarz
  2009-08-09 19:53 ` [PATCH 02/14] ia64: " Marcin Slusarz
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:53 UTC (permalink / raw)
  To: LKML; +Cc: Ivan Kokshaysky, Richard Henderson, Andrew Morton, linux-alpha

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-alpha@vger.kernel.org
---
 arch/alpha/kernel/pci_iommu.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/arch/alpha/kernel/pci_iommu.c b/arch/alpha/kernel/pci_iommu.c
index bfb880a..d15aedf 100644
--- a/arch/alpha/kernel/pci_iommu.c
+++ b/arch/alpha/kernel/pci_iommu.c
@@ -268,11 +268,7 @@ pci_map_single_1(struct pci_dev *pdev, void *cpu_addr, size_t size,
 	   assume it doesn't support sg mapping, and, since we tried to
 	   use direct_map above, it now must be considered an error. */
 	if (! alpha_mv.mv_pci_tbi) {
-		static int been_here = 0; /* Only print the message once. */
-		if (!been_here) {
-		    printk(KERN_WARNING "pci_map_single: no HW sg\n");
-		    been_here = 1;
-		}
+		printk_once(KERN_WARNING "pci_map_single: no HW sg\n");
 		return 0;
 	}
 
-- 
1.6.3.3


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

* [PATCH 02/14] ia64: use printk_once
  2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
  2009-08-09 19:53 ` [PATCH 01/14] alpha: " Marcin Slusarz
@ 2009-08-09 19:53 ` Marcin Slusarz
  2009-08-09 19:53 ` [PATCH 03/14] powerpc: " Marcin Slusarz
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:53 UTC (permalink / raw)
  To: LKML; +Cc: Tony Luck, Fenghua Yu, linux-ia64

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-ia64@vger.kernel.org
---
 arch/ia64/kernel/unaligned.c    |    6 ++----
 arch/ia64/sn/kernel/io_common.c |    8 ++------
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/arch/ia64/kernel/unaligned.c b/arch/ia64/kernel/unaligned.c
index 6db0859..776dd40 100644
--- a/arch/ia64/kernel/unaligned.c
+++ b/arch/ia64/kernel/unaligned.c
@@ -60,7 +60,6 @@ dump (const char *str, void *vp, size_t len)
  */
 int no_unaligned_warning;
 int unaligned_dump_stack;
-static int noprint_warning;
 
 /*
  * For M-unit:
@@ -1357,9 +1356,8 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs)
 			/* watch for command names containing %s */
 			printk(KERN_WARNING "%s", buf);
 		} else {
-			if (no_unaligned_warning && !noprint_warning) {
-				noprint_warning = 1;
-				printk(KERN_WARNING "%s(%d) encountered an "
+			if (no_unaligned_warning) {
+				printk_once(KERN_WARNING "%s(%d) encountered an "
 				       "unaligned exception which required\n"
 				       "kernel assistance, which degrades "
 				       "the performance of the application.\n"
diff --git a/arch/ia64/sn/kernel/io_common.c b/arch/ia64/sn/kernel/io_common.c
index 25831c4..308e659 100644
--- a/arch/ia64/sn/kernel/io_common.c
+++ b/arch/ia64/sn/kernel/io_common.c
@@ -119,7 +119,6 @@ sn_pcidev_info_get(struct pci_dev *dev)
  * Additionally note that the struct sn_flush_device_war also has to be
  * removed from arch/ia64/sn/include/xtalk/hubdev.h
  */
-static u8 war_implemented = 0;
 
 static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device,
 			       struct sn_flush_device_common *common)
@@ -128,11 +127,8 @@ static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device,
 	struct sn_flush_device_war *dev_entry;
 	struct ia64_sal_retval isrv = {0,0,0,0};
 
-	if (!war_implemented) {
-		printk(KERN_WARNING "PROM version < 4.50 -- implementing old "
-		       "PROM flush WAR\n");
-		war_implemented = 1;
-	}
+	printk_once(KERN_WARNING
+		"PROM version < 4.50 -- implementing old PROM flush WAR\n");
 
 	war_list = kzalloc(DEV_PER_WIDGET * sizeof(*war_list), GFP_KERNEL);
 	BUG_ON(!war_list);
-- 
1.6.3.3


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

* [PATCH 03/14] powerpc: use printk_once
  2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
  2009-08-09 19:53 ` [PATCH 01/14] alpha: " Marcin Slusarz
  2009-08-09 19:53 ` [PATCH 02/14] ia64: " Marcin Slusarz
@ 2009-08-09 19:53 ` Marcin Slusarz
  2009-08-10  8:00   ` Wolfram Sang
  2009-08-09 19:53 ` [PATCH 04/14] sh: " Marcin Slusarz
                   ` (11 subsequent siblings)
  14 siblings, 1 reply; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:53 UTC (permalink / raw)
  To: LKML; +Cc: Benjamin Herrenschmidt, Paul Mackerras, linuxppc-dev

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@ozlabs.org
---
 arch/powerpc/kernel/iommu.c      |    6 +-----
 arch/powerpc/kernel/irq.c        |    5 ++---
 arch/powerpc/sysdev/ppc4xx_pci.c |    9 ++-------
 3 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index fd51578..c7fa258 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -502,7 +502,6 @@ static void iommu_table_clear(struct iommu_table *tbl)
 struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
 {
 	unsigned long sz;
-	static int welcomed = 0;
 	struct page *page;
 
 	/* Set aside 1/4 of the table for large allocations. */
@@ -523,11 +522,8 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
 
 	iommu_table_clear(tbl);
 
-	if (!welcomed) {
-		printk(KERN_INFO "IOMMU table initialized, virtual merging %s\n",
+	printk_once(KERN_INFO "IOMMU table initialized, virtual merging %s\n",
 		       novmerge ? "disabled" : "enabled");
-		welcomed = 1;
-	}
 
 	return tbl;
 }
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index f7f376e..05ebd21 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -231,7 +231,6 @@ skip:
 void fixup_irqs(cpumask_t map)
 {
 	unsigned int irq;
-	static int warned;
 
 	for_each_irq(irq) {
 		cpumask_t mask;
@@ -246,8 +245,8 @@ void fixup_irqs(cpumask_t map)
 		}
 		if (irq_desc[irq].chip->set_affinity)
 			irq_desc[irq].chip->set_affinity(irq, &mask);
-		else if (irq_desc[irq].action && !(warned++))
-			printk("Cannot set affinity for irq %i\n", irq);
+		else if (irq_desc[irq].action)
+			printk_once("Cannot set affinity for irq %i\n", irq);
 	}
 
 	local_irq_enable();
diff --git a/arch/powerpc/sysdev/ppc4xx_pci.c b/arch/powerpc/sysdev/ppc4xx_pci.c
index 6ff9d71..4282dff 100644
--- a/arch/powerpc/sysdev/ppc4xx_pci.c
+++ b/arch/powerpc/sysdev/ppc4xx_pci.c
@@ -1243,19 +1243,14 @@ static int ppc4xx_pciex_validate_bdf(struct ppc4xx_pciex_port *port,
 				     struct pci_bus *bus,
 				     unsigned int devfn)
 {
-	static int message;
-
 	/* Endpoint can not generate upstream(remote) config cycles */
 	if (port->endpoint && bus->number != port->hose->first_busno)
 		return PCIBIOS_DEVICE_NOT_FOUND;
 
 	/* Check we are within the mapped range */
 	if (bus->number > port->hose->last_busno) {
-		if (!message) {
-			printk(KERN_WARNING "Warning! Probing bus %u"
-			       " out of range !\n", bus->number);
-			message++;
-		}
+		printk_once(KERN_WARNING
+			"Warning! Probing bus %u out of range!\n", bus->number);
 		return PCIBIOS_DEVICE_NOT_FOUND;
 	}
 
-- 
1.6.3.3


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

* [PATCH 04/14] sh: use printk_once
  2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
                   ` (2 preceding siblings ...)
  2009-08-09 19:53 ` [PATCH 03/14] powerpc: " Marcin Slusarz
@ 2009-08-09 19:53 ` Marcin Slusarz
  2009-08-13  3:04   ` Paul Mundt
  2009-08-09 19:54 ` [PATCH 05/14] x86: " Marcin Slusarz
                   ` (10 subsequent siblings)
  14 siblings, 1 reply; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:53 UTC (permalink / raw)
  To: LKML; +Cc: Paul Mundt, linux-sh

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: linux-sh@vger.kernel.org
---
 arch/sh/mm/ioremap_64.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/arch/sh/mm/ioremap_64.c b/arch/sh/mm/ioremap_64.c
index 828c859..b16843d 100644
--- a/arch/sh/mm/ioremap_64.c
+++ b/arch/sh/mm/ioremap_64.c
@@ -94,7 +94,6 @@ static struct resource *shmedia_find_resource(struct resource *root,
 static void __iomem *shmedia_alloc_io(unsigned long phys, unsigned long size,
 				      const char *name, unsigned long flags)
 {
-	static int printed_full;
 	struct xresource *xres;
 	struct resource *res;
 	char *tack;
@@ -108,11 +107,8 @@ static void __iomem *shmedia_alloc_io(unsigned long phys, unsigned long size,
 		tack = xres->xname;
 		res = &xres->xres;
 	} else {
-		if (!printed_full) {
-			printk(KERN_NOTICE "%s: done with statics, "
+		printk_once(KERN_NOTICE "%s: done with statics, "
 			       "switching to kmalloc\n", __func__);
-			printed_full = 1;
-		}
 		tlen = strlen(name);
 		tack = kmalloc(sizeof(struct resource) + tlen + 1, GFP_KERNEL);
 		if (!tack)
-- 
1.6.3.3


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

* [PATCH 05/14] x86: use printk_once
  2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
                   ` (3 preceding siblings ...)
  2009-08-09 19:53 ` [PATCH 04/14] sh: " Marcin Slusarz
@ 2009-08-09 19:54 ` Marcin Slusarz
  2009-08-09 20:30   ` [tip:x86/cleanups] x86: Use printk_once() tip-bot for Marcin Slusarz
  2009-08-09 19:54 ` [PATCH 06/14] ata: use printk_once Marcin Slusarz
                   ` (9 subsequent siblings)
  14 siblings, 1 reply; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:54 UTC (permalink / raw)
  To: LKML; +Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
---
 arch/x86/kernel/irq_32.c |    5 ++---
 arch/x86/kvm/x86.c       |    7 +------
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
index 3b09634..7d35d0f 100644
--- a/arch/x86/kernel/irq_32.c
+++ b/arch/x86/kernel/irq_32.c
@@ -218,7 +218,6 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
 void fixup_irqs(void)
 {
 	unsigned int irq;
-	static int warned;
 	struct irq_desc *desc;
 
 	for_each_irq_desc(irq, desc) {
@@ -236,8 +235,8 @@ void fixup_irqs(void)
 		}
 		if (desc->chip->set_affinity)
 			desc->chip->set_affinity(irq, affinity);
-		else if (desc->action && !(warned++))
-			printk("Cannot set affinity for irq %i\n", irq);
+		else if (desc->action)
+			printk_once("Cannot set affinity for irq %i\n", irq);
 	}
 
 #if 0
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index fe5474a..0572c90 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2261,12 +2261,7 @@ static int emulator_cmpxchg_emulated(unsigned long addr,
 				     unsigned int bytes,
 				     struct kvm_vcpu *vcpu)
 {
-	static int reported;
-
-	if (!reported) {
-		reported = 1;
-		printk(KERN_WARNING "kvm: emulating exchange as write\n");
-	}
+	printk_once(KERN_WARNING "kvm: emulating exchange as write\n");
 #ifndef CONFIG_X86_64
 	/* guests cmpxchg8b have to be emulated atomically */
 	if (bytes == 8) {
-- 
1.6.3.3


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

* [PATCH 06/14] ata: use printk_once
  2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
                   ` (4 preceding siblings ...)
  2009-08-09 19:54 ` [PATCH 05/14] x86: " Marcin Slusarz
@ 2009-08-09 19:54 ` Marcin Slusarz
  2009-08-09 19:54 ` [PATCH 07/14] block: " Marcin Slusarz
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:54 UTC (permalink / raw)
  To: LKML; +Cc: Jeff Garzik, linux-ide

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: linux-ide@vger.kernel.org
---
 drivers/ata/pata_rz1000.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/ata/pata_rz1000.c b/drivers/ata/pata_rz1000.c
index 0c574c0..a5e4dfe 100644
--- a/drivers/ata/pata_rz1000.c
+++ b/drivers/ata/pata_rz1000.c
@@ -85,7 +85,6 @@ static int rz1000_fifo_disable(struct pci_dev *pdev)
 
 static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	static int printed_version;
 	static const struct ata_port_info info = {
 		.flags = ATA_FLAG_SLAVE_POSS,
 		.pio_mask = ATA_PIO4,
@@ -93,8 +92,7 @@ static int rz1000_init_one (struct pci_dev *pdev, const struct pci_device_id *en
 	};
 	const struct ata_port_info *ppi[] = { &info, NULL };
 
-	if (!printed_version++)
-		printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
+	printk_once(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
 
 	if (rz1000_fifo_disable(pdev) == 0)
 		return ata_pci_sff_init_one(pdev, ppi, &rz1000_sht, NULL);
-- 
1.6.3.3


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

* [PATCH 07/14] block: use printk_once
  2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
                   ` (5 preceding siblings ...)
  2009-08-09 19:54 ` [PATCH 06/14] ata: use printk_once Marcin Slusarz
@ 2009-08-09 19:54 ` Marcin Slusarz
  2009-08-09 19:54 ` [PATCH 08/14] tty/vt: " Marcin Slusarz
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:54 UTC (permalink / raw)
  To: LKML; +Cc: Jens Axboe, Tim Waugh

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Tim Waugh <tim@cyberelk.net>
---
 drivers/block/paride/pcd.c |   12 ++++--------
 drivers/block/sx8.c        |    4 +---
 drivers/block/viodasd.c    |   12 +++---------
 3 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/drivers/block/paride/pcd.c b/drivers/block/paride/pcd.c
index 911dfd9..9f3518c 100644
--- a/drivers/block/paride/pcd.c
+++ b/drivers/block/paride/pcd.c
@@ -219,8 +219,6 @@ static int pcd_sector;		/* address of next requested sector */
 static int pcd_count;		/* number of blocks still to do */
 static char *pcd_buf;		/* buffer for request in progress */
 
-static int pcd_warned;		/* Have we logged a phase warning ? */
-
 /* kernel glue structures */
 
 static int pcd_block_open(struct block_device *bdev, fmode_t mode)
@@ -417,12 +415,10 @@ static int pcd_completion(struct pcd_unit *cd, char *buf, char *fun)
 					printk
 					    ("%s: %s: Unexpected phase %d, d=%d, k=%d\n",
 					     cd->name, fun, p, d, k);
-				if ((verbose < 2) && !pcd_warned) {
-					pcd_warned = 1;
-					printk
-					    ("%s: WARNING: ATAPI phase errors\n",
-					     cd->name);
-				}
+				if (verbose < 2)
+					printk_once(
+					    "%s: WARNING: ATAPI phase errors\n",
+					    cd->name);
 				mdelay(1);
 			}
 			if (k++ > PCD_TMO) {
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index da403b6..f5cd2e8 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -1564,15 +1564,13 @@ static int carm_init_shm(struct carm_host *host)
 
 static int carm_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	static unsigned int printed_version;
 	struct carm_host *host;
 	unsigned int pci_dac;
 	int rc;
 	struct request_queue *q;
 	unsigned int i;
 
-	if (!printed_version++)
-		printk(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
+	printk_once(KERN_DEBUG DRV_NAME " version " DRV_VERSION "\n");
 
 	rc = pci_enable_device(pdev);
 	if (rc)
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c
index 390d69b..b441ce3 100644
--- a/drivers/block/viodasd.c
+++ b/drivers/block/viodasd.c
@@ -416,15 +416,9 @@ retry:
 		goto retry;
 	}
 	if (we.max_disk > (MAX_DISKNO - 1)) {
-		static int warned;
-
-		if (warned == 0) {
-			warned++;
-			printk(VIOD_KERN_INFO
-				"Only examining the first %d "
-				"of %d disks connected\n",
-				MAX_DISKNO, we.max_disk + 1);
-		}
+		printk_once(VIOD_KERN_INFO
+			"Only examining the first %d of %d disks connected\n",
+			MAX_DISKNO, we.max_disk + 1);
 	}
 
 	/* Send the close event to OS/400.  We DON'T expect a response */
-- 
1.6.3.3


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

* [PATCH 08/14] tty/vt: use printk_once
  2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
                   ` (6 preceding siblings ...)
  2009-08-09 19:54 ` [PATCH 07/14] block: " Marcin Slusarz
@ 2009-08-09 19:54 ` Marcin Slusarz
  2009-08-09 19:54 ` [PATCH 09/14] ide: " Marcin Slusarz
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:54 UTC (permalink / raw)
  To: LKML; +Cc: Greg Kroah-Hartman

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/char/tty_ioctl.c |    4 +---
 drivers/char/vt.c        |    6 +-----
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
index ad6ba4e..8e67d5c 100644
--- a/drivers/char/tty_ioctl.c
+++ b/drivers/char/tty_ioctl.c
@@ -393,9 +393,7 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
 		termios->c_cflag |= (BOTHER << IBSHIFT);
 #else
 	if (ifound == -1 || ofound == -1) {
-		static int warned;
-		if (!warned++)
-			printk(KERN_WARNING "tty: Unable to return correct "
+		printk_once(KERN_WARNING "tty: Unable to return correct "
 			  "speed data as your architecture needs updating.\n");
 	}
 #endif
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 404f4c1..5d77fb3 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -2129,11 +2129,7 @@ static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int co
 	currcons = vc->vc_num;
 	if (!vc_cons_allocated(currcons)) {
 	    /* could this happen? */
-	    static int error = 0;
-	    if (!error) {
-		error = 1;
-		printk("con_write: tty %d not allocated\n", currcons+1);
-	    }
+		printk_once("con_write: tty %d not allocated\n", currcons+1);
 	    release_console_sem();
 	    return 0;
 	}
-- 
1.6.3.3


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

* [PATCH 09/14] ide: use printk_once
  2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
                   ` (7 preceding siblings ...)
  2009-08-09 19:54 ` [PATCH 08/14] tty/vt: " Marcin Slusarz
@ 2009-08-09 19:54 ` Marcin Slusarz
  2009-08-10  2:52   ` David Miller
  2009-08-09 19:54 ` [PATCH 10/14] infiniband: " Marcin Slusarz
                   ` (5 subsequent siblings)
  14 siblings, 1 reply; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:54 UTC (permalink / raw)
  To: LKML; +Cc: David S. Miller, linux-ide, Bartlomiej Zolnierkiewicz

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: linux-ide@vger.kernel.org
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-proc.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)

diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index 3242698..6e58e7e 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -236,14 +236,8 @@ static const struct ide_proc_devset ide_generic_settings[] = {
 
 static void proc_ide_settings_warn(void)
 {
-	static int warned;
-
-	if (warned)
-		return;
-
-	printk(KERN_WARNING "Warning: /proc/ide/hd?/settings interface is "
+	printk_once(KERN_WARNING "Warning: /proc/ide/hd?/settings interface is "
 			    "obsolete, and will be removed soon!\n");
-	warned = 1;
 }
 
 static int proc_ide_read_settings
-- 
1.6.3.3


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

* [PATCH 10/14] infiniband: use printk_once
  2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
                   ` (8 preceding siblings ...)
  2009-08-09 19:54 ` [PATCH 09/14] ide: " Marcin Slusarz
@ 2009-08-09 19:54 ` Marcin Slusarz
  2009-08-10  5:00   ` Roland Dreier
  2009-08-09 19:54 ` [PATCH 11/14] drivers/net: " Marcin Slusarz
                   ` (4 subsequent siblings)
  14 siblings, 1 reply; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:54 UTC (permalink / raw)
  To: LKML; +Cc: Roland Dreier, Sean Hefty, Hal Rosenstock, general

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Roland Dreier <rolandd@cisco.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: general@lists.openfabrics.org
---
 drivers/infiniband/hw/cxgb3/iwch.c |    4 +---
 drivers/infiniband/hw/mlx4/main.c  |    6 +-----
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb3/iwch.c b/drivers/infiniband/hw/cxgb3/iwch.c
index 26fc0a4..9cc99df 100644
--- a/drivers/infiniband/hw/cxgb3/iwch.c
+++ b/drivers/infiniband/hw/cxgb3/iwch.c
@@ -105,11 +105,9 @@ static void rnic_init(struct iwch_dev *rnicp)
 static void open_rnic_dev(struct t3cdev *tdev)
 {
 	struct iwch_dev *rnicp;
-	static int vers_printed;
 
 	PDBG("%s t3cdev %p\n", __func__,  tdev);
-	if (!vers_printed++)
-		printk(KERN_INFO MOD "Chelsio T3 RDMA Driver - version %s\n",
+	printk_once(KERN_INFO MOD "Chelsio T3 RDMA Driver - version %s\n",
 		       DRV_VERSION);
 	rnicp = (struct iwch_dev *)ib_alloc_device(sizeof(*rnicp));
 	if (!rnicp) {
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index ae3d759..0b2f77a 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -540,15 +540,11 @@ static struct device_attribute *mlx4_class_attributes[] = {
 
 static void *mlx4_ib_add(struct mlx4_dev *dev)
 {
-	static int mlx4_ib_version_printed;
 	struct mlx4_ib_dev *ibdev;
 	int num_ports = 0;
 	int i;
 
-	if (!mlx4_ib_version_printed) {
-		printk(KERN_INFO "%s", mlx4_ib_version);
-		++mlx4_ib_version_printed;
-	}
+	printk_once(KERN_INFO "%s", mlx4_ib_version);
 
 	mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
 		num_ports++;
-- 
1.6.3.3


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

* [PATCH 11/14] drivers/net: use printk_once
  2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
                   ` (9 preceding siblings ...)
  2009-08-09 19:54 ` [PATCH 10/14] infiniband: " Marcin Slusarz
@ 2009-08-09 19:54 ` Marcin Slusarz
  2009-08-10  2:52   ` David Miller
  2009-08-09 19:54 ` [PATCH 12/14] scsi: " Marcin Slusarz
                   ` (3 subsequent siblings)
  14 siblings, 1 reply; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:54 UTC (permalink / raw)
  To: LKML; +Cc: netdev

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: netdev@vger.kernel.org
---
 drivers/net/mlx4/en_main.c |    6 +-----
 drivers/net/mv643xx_eth.c  |    4 +---
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/mlx4/en_main.c b/drivers/net/mlx4/en_main.c
index 9ed4a15..18e9e4f 100644
--- a/drivers/net/mlx4/en_main.c
+++ b/drivers/net/mlx4/en_main.c
@@ -151,15 +151,11 @@ static void mlx4_en_remove(struct mlx4_dev *dev, void *endev_ptr)
 
 static void *mlx4_en_add(struct mlx4_dev *dev)
 {
-	static int mlx4_en_version_printed;
 	struct mlx4_en_dev *mdev;
 	int i;
 	int err;
 
-	if (!mlx4_en_version_printed) {
-		printk(KERN_INFO "%s", mlx4_en_version);
-		mlx4_en_version_printed++;
-	}
+	printk_once(KERN_INFO "%s", mlx4_en_version);
 
 	mdev = kzalloc(sizeof *mdev, GFP_KERNEL);
 	if (!mdev) {
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 0f32db3..dbb1d9c 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -2622,14 +2622,12 @@ static void infer_hw_params(struct mv643xx_eth_shared_private *msp)
 
 static int mv643xx_eth_shared_probe(struct platform_device *pdev)
 {
-	static int mv643xx_eth_version_printed;
 	struct mv643xx_eth_shared_platform_data *pd = pdev->dev.platform_data;
 	struct mv643xx_eth_shared_private *msp;
 	struct resource *res;
 	int ret;
 
-	if (!mv643xx_eth_version_printed++)
-		printk(KERN_NOTICE "MV-643xx 10/100/1000 ethernet "
+	printk_once(KERN_NOTICE "MV-643xx 10/100/1000 ethernet "
 			"driver version %s\n", mv643xx_eth_driver_version);
 
 	ret = -EINVAL;
-- 
1.6.3.3


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

* [PATCH 12/14] scsi: use printk_once
  2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
                   ` (10 preceding siblings ...)
  2009-08-09 19:54 ` [PATCH 11/14] drivers/net: " Marcin Slusarz
@ 2009-08-09 19:54 ` Marcin Slusarz
  2009-08-11 16:40   ` James Bottomley
  2009-08-09 19:54 ` [PATCH 13/14] vsprintf: use WARN_ON_ONCE Marcin Slusarz
                   ` (2 subsequent siblings)
  14 siblings, 1 reply; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:54 UTC (permalink / raw)
  To: LKML; +Cc: James E.J. Bottomley, linux-scsi

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: linux-scsi@vger.kernel.org
---
 drivers/scsi/53c700.c             |    6 +-----
 drivers/scsi/cxgb3i/cxgb3i_init.c |    7 +------
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index f5a9add..c5f4fa7 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -291,7 +291,6 @@ NCR_700_detect(struct scsi_host_template *tpnt,
 	__u8 *memory;
 	__u32 *script;
 	struct Scsi_Host *host;
-	static int banner = 0;
 	int j;
 
 	if(tpnt->sdev_attrs == NULL)
@@ -385,10 +384,7 @@ NCR_700_detect(struct scsi_host_template *tpnt,
 	else
 		hostdata->rev = (NCR_700_readb(host, CTEST7_REG)>>4) & 0x0f;
 	hostdata->fast = (NCR_700_readb(host, CTEST9_REG) == 0);
-	if (banner == 0) {
-		printk(KERN_NOTICE "53c700: Version " NCR_700_VERSION " By James.Bottomley@HansenPartnership.com\n");
-		banner = 1;
-	}
+	printk_once(KERN_NOTICE "53c700: Version " NCR_700_VERSION " By James.Bottomley@HansenPartnership.com\n");
 	printk(KERN_NOTICE "scsi%d: %s rev %d %s\n", host->host_no,
 	       hostdata->chip710 ? "53c710" :
 	       (hostdata->fast ? "53c700-66" : "53c700"),
diff --git a/drivers/scsi/cxgb3i/cxgb3i_init.c b/drivers/scsi/cxgb3i/cxgb3i_init.c
index 042d9bc..8c9285f 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_init.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_init.c
@@ -43,12 +43,7 @@ static struct cxgb3_client t3c_client = {
  */
 static void open_s3_dev(struct t3cdev *t3dev)
 {
-	static int vers_printed;
-
-	if (!vers_printed) {
-		printk(KERN_INFO "%s", version);
-		vers_printed = 1;
-	}
+	printk_once(KERN_INFO "%s", version);
 
 	cxgb3i_ddp_init(t3dev);
 	cxgb3i_sdev_add(t3dev, &t3c_client);
-- 
1.6.3.3


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

* [PATCH 13/14] vsprintf: use WARN_ON_ONCE
  2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
                   ` (11 preceding siblings ...)
  2009-08-09 19:54 ` [PATCH 12/14] scsi: " Marcin Slusarz
@ 2009-08-09 19:54 ` Marcin Slusarz
  2009-08-09 19:54 ` [PATCH 14/14] net: use printk_once Marcin Slusarz
  2009-08-09 20:36 ` [PATCH 00/14] " Joe Perches
  14 siblings, 0 replies; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:54 UTC (permalink / raw)
  To: LKML

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
---
 lib/vsprintf.c |   14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 756ccaf..a63bb18 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -983,13 +983,8 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
 
 	/* Reject out-of-range values early.  Large positive sizes are
 	   used for unknown buffer sizes. */
-	if (unlikely((int) size < 0)) {
-		/* There can be only one.. */
-		static char warn = 1;
-		WARN_ON(warn);
-		warn = 0;
+	if (WARN_ON_ONCE((int) size < 0))
 		return 0;
-	}
 
 	str = buf;
 	end = buf + size;
@@ -1439,13 +1434,8 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
 
 	struct printf_spec spec = {0};
 
-	if (unlikely((int) size < 0)) {
-		/* There can be only one.. */
-		static char warn = 1;
-		WARN_ON(warn);
-		warn = 0;
+	if (WARN_ON_ONCE((int) size < 0))
 		return 0;
-	}
 
 	str = buf;
 	end = buf + size;
-- 
1.6.3.3


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

* [PATCH 14/14] net: use printk_once
  2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
                   ` (12 preceding siblings ...)
  2009-08-09 19:54 ` [PATCH 13/14] vsprintf: use WARN_ON_ONCE Marcin Slusarz
@ 2009-08-09 19:54 ` Marcin Slusarz
  2009-08-10  2:52   ` David Miller
  2009-08-09 20:36 ` [PATCH 00/14] " Joe Perches
  14 siblings, 1 reply; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-09 19:54 UTC (permalink / raw)
  To: LKML; +Cc: David S. Miller, netdev

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---
 net/ax25/af_ax25.c        |    6 +-----
 net/dsa/dsa.c             |    4 +---
 net/ipv4/raw.c            |    6 ++----
 net/netfilter/xt_recent.c |   10 +++-------
 net/socket.c              |    8 ++------
 5 files changed, 9 insertions(+), 25 deletions(-)

diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index da0f64f..39c895b 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -1792,12 +1792,8 @@ static int ax25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 
 		/* old structure? */
 		if (cmd == SIOCAX25GETINFOOLD) {
-			static int warned = 0;
-			if (!warned) {
-				printk(KERN_INFO "%s uses old SIOCAX25GETINFO\n",
+			printk_once(KERN_INFO "%s uses old SIOCAX25GETINFO\n",
 					current->comm);
-				warned=1;
-			}
 
 			if (copy_to_user(argp, &ax25_info, sizeof(struct ax25_info_struct_deprecated))) {
 				res = -EFAULT;
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 71489f6..ecd2dfb 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -302,14 +302,12 @@ static struct net_device *dev_to_net_device(struct device *dev)
 
 static int dsa_probe(struct platform_device *pdev)
 {
-	static int dsa_version_printed;
 	struct dsa_platform_data *pd = pdev->dev.platform_data;
 	struct net_device *dev;
 	struct dsa_switch_tree *dst;
 	int i;
 
-	if (!dsa_version_printed++)
-		printk(KERN_NOTICE "Distributed Switch Architecture "
+	printk_once(KERN_NOTICE "Distributed Switch Architecture "
 			"driver version %s\n", dsa_driver_version);
 
 	if (pd == NULL || pd->netdev == NULL)
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 2979f14..f919925 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -470,10 +470,8 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
 		if (msg->msg_namelen < sizeof(*usin))
 			goto out;
 		if (usin->sin_family != AF_INET) {
-			static int complained;
-			if (!complained++)
-				printk(KERN_INFO "%s forgot to set AF_INET in "
-						 "raw sendmsg. Fix it!\n",
+			printk_once(KERN_INFO "%s forgot to set AF_INET in "
+						"raw sendmsg. Fix it!\n",
 						 current->comm);
 			err = -EAFNOSUPPORT;
 			if (usin->sin_family)
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index eb0ceb8..d60d317 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -456,13 +456,9 @@ static int recent_seq_open(struct inode *inode, struct file *file)
 #ifdef CONFIG_NETFILTER_XT_MATCH_RECENT_PROC_COMPAT
 static int recent_old_seq_open(struct inode *inode, struct file *filp)
 {
-	static bool warned_of_old;
-
-	if (unlikely(!warned_of_old)) {
-		printk(KERN_INFO KBUILD_MODNAME ": Use of /proc/net/ipt_recent"
-		       " is deprecated; use /proc/net/xt_recent.\n");
-		warned_of_old = true;
-	}
+	printk_once(KERN_INFO KBUILD_MODNAME ": "
+		"Use of /proc/net/ipt_recent is deprecated; "
+		"use /proc/net/xt_recent.\n");
 	return recent_seq_open(inode, filp);
 }
 
diff --git a/net/socket.c b/net/socket.c
index 791d71a..1d07f69 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1161,12 +1161,8 @@ static int __sock_create(struct net *net, int family, int type, int protocol,
 	   deadlock in module load.
 	 */
 	if (family == PF_INET && type == SOCK_PACKET) {
-		static int warned;
-		if (!warned) {
-			warned = 1;
-			printk(KERN_INFO "%s uses obsolete (PF_INET,SOCK_PACKET)\n",
-			       current->comm);
-		}
+		printk_once(KERN_INFO "%s uses obsolete (PF_INET,SOCK_PACKET)\n",
+			    current->comm);
 		family = PF_PACKET;
 	}
 
-- 
1.6.3.3


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

* [tip:x86/cleanups] x86: Use printk_once()
  2009-08-09 19:54 ` [PATCH 05/14] x86: " Marcin Slusarz
@ 2009-08-09 20:30   ` tip-bot for Marcin Slusarz
  0 siblings, 0 replies; 35+ messages in thread
From: tip-bot for Marcin Slusarz @ 2009-08-09 20:30 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, marcin.slusarz, tglx, mingo

Commit-ID:  9f51e24ee8b5a1595b6a5ac0c2be278a16488e75
Gitweb:     http://git.kernel.org/tip/9f51e24ee8b5a1595b6a5ac0c2be278a16488e75
Author:     Marcin Slusarz <marcin.slusarz@gmail.com>
AuthorDate: Sun, 9 Aug 2009 21:54:00 +0200
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Sun, 9 Aug 2009 22:28:34 +0200

x86: Use printk_once()

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
LKML-Reference: <1249847649-11631-6-git-send-email-marcin.slusarz@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 arch/x86/kernel/irq_32.c |    5 ++---
 arch/x86/kvm/x86.c       |    7 +------
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
index 3b09634..7d35d0f 100644
--- a/arch/x86/kernel/irq_32.c
+++ b/arch/x86/kernel/irq_32.c
@@ -218,7 +218,6 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
 void fixup_irqs(void)
 {
 	unsigned int irq;
-	static int warned;
 	struct irq_desc *desc;
 
 	for_each_irq_desc(irq, desc) {
@@ -236,8 +235,8 @@ void fixup_irqs(void)
 		}
 		if (desc->chip->set_affinity)
 			desc->chip->set_affinity(irq, affinity);
-		else if (desc->action && !(warned++))
-			printk("Cannot set affinity for irq %i\n", irq);
+		else if (desc->action)
+			printk_once("Cannot set affinity for irq %i\n", irq);
 	}
 
 #if 0
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index fe5474a..0572c90 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2261,12 +2261,7 @@ static int emulator_cmpxchg_emulated(unsigned long addr,
 				     unsigned int bytes,
 				     struct kvm_vcpu *vcpu)
 {
-	static int reported;
-
-	if (!reported) {
-		reported = 1;
-		printk(KERN_WARNING "kvm: emulating exchange as write\n");
-	}
+	printk_once(KERN_WARNING "kvm: emulating exchange as write\n");
 #ifndef CONFIG_X86_64
 	/* guests cmpxchg8b have to be emulated atomically */
 	if (bytes == 8) {

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

* Re: [PATCH 00/14] use printk_once
  2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
                   ` (13 preceding siblings ...)
  2009-08-09 19:54 ` [PATCH 14/14] net: use printk_once Marcin Slusarz
@ 2009-08-09 20:36 ` Joe Perches
  14 siblings, 0 replies; 35+ messages in thread
From: Joe Perches @ 2009-08-09 20:36 UTC (permalink / raw)
  To: Marcin Slusarz; +Cc: LKML

Perhaps this could be combined with

pr_<level> once?

Changed printk_once to use bool instead of int, with default set to false not 1.
This reduces data and produces slightly smaller object code.

Changed printk_once macro definitions to (fmt, ...) to match
other printk/pr_<level> definitions.

Signed-off-by: Joe Perches <joe@perches.com>
---
 include/linux/kernel.h |   57 ++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 883cd44..343e505 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -246,12 +246,12 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
 /*
  * Print a one-time message (analogous to WARN_ONCE() et al):
  */
-#define printk_once(x...) ({			\
-	static int __print_once = 1;		\
+#define printk_once(fmt, ...) ({		\
+	static bool __print_once;		\
 						\
-	if (__print_once) {			\
-		__print_once = 0;		\
-		printk(x);			\
+	if (!__print_once) {			\
+		__print_once = true;		\
+		printk(fmt, ##__VA_ARGS__);	\
 	}					\
 })
 
@@ -269,7 +269,7 @@ static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \
 		{ return false; }
 
 /* No effect, but we still get type checking even in the !PRINTK case: */
-#define printk_once(x...) printk(x)
+#define printk_once(fmt, ...) printk(fmt, ##__VA_ARGS__)
 
 static inline void log_buf_kexec_setup(void)
 {
@@ -400,6 +400,51 @@ static inline char *pack_hex_byte(char *buf, u8 byte)
 	({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
 #endif
 
+/* pr_<level>_once variants */
+
+#define pr_emerg_once(fmt, ...) \
+	printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_alert_once(fmt, ...) \
+	printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_crit_once(fmt, ...) \
+	printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_err_once(fmt, ...) \
+	printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_warning_once(fmt, ...) \
+	printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_notice_once(fmt, ...) \
+	printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
+#define pr_info_once(fmt, ...) \
+	printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
+/* No pr_cont_once, use a local guard instead */
+
+/* pr_devel_once() should produce zero code unless DEBUG is defined */
+#ifdef DEBUG
+#define pr_devel_once(fmt, ...) \
+	printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
+#else
+#define pr_devel_once(fmt, ...) \
+	({ if (0) printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
+#endif
+
+/* If you are writing a driver, please use dev_dbg instead */
+#if defined(DEBUG)
+#define pr_debug_once(fmt, ...) \
+	printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
+#elif defined(CONFIG_DYNAMIC_DEBUG)
+/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
+#define pr_debug_once(fmt, ...) ({			\
+	static bool __print_once;			\
+	if (!__print_once) {				\
+		__print_once = true;			\
+		dynamic_pr_debug(fmt, ##__VA_ARGS__);	\
+	}						\
+})
+#else
+#define pr_debug_once(fmt, ...) \
+	({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; })
+#endif
+
 /*
  * General tracing related utility functions - trace_printk(),
  * tracing_on/tracing_off and tracing_start()/tracing_stop
-- 
1.6.3.1.10.g659a0.dirty




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

* Re: [PATCH 14/14] net: use printk_once
  2009-08-09 19:54 ` [PATCH 14/14] net: use printk_once Marcin Slusarz
@ 2009-08-10  2:52   ` David Miller
  0 siblings, 0 replies; 35+ messages in thread
From: David Miller @ 2009-08-10  2:52 UTC (permalink / raw)
  To: marcin.slusarz; +Cc: linux-kernel, netdev

From: Marcin Slusarz <marcin.slusarz@gmail.com>
Date: Sun,  9 Aug 2009 21:54:09 +0200

> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>

Acked-by: David S. Miller <davem@davemloft.net>

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

* Re: [PATCH 09/14] ide: use printk_once
  2009-08-09 19:54 ` [PATCH 09/14] ide: " Marcin Slusarz
@ 2009-08-10  2:52   ` David Miller
  0 siblings, 0 replies; 35+ messages in thread
From: David Miller @ 2009-08-10  2:52 UTC (permalink / raw)
  To: marcin.slusarz; +Cc: linux-kernel, linux-ide, bzolnier

From: Marcin Slusarz <marcin.slusarz@gmail.com>
Date: Sun,  9 Aug 2009 21:54:04 +0200

> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>

Acked-by: David S. Miller <davem@davemloft.net>

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

* Re: [PATCH 11/14] drivers/net: use printk_once
  2009-08-09 19:54 ` [PATCH 11/14] drivers/net: " Marcin Slusarz
@ 2009-08-10  2:52   ` David Miller
  0 siblings, 0 replies; 35+ messages in thread
From: David Miller @ 2009-08-10  2:52 UTC (permalink / raw)
  To: marcin.slusarz; +Cc: linux-kernel, netdev

From: Marcin Slusarz <marcin.slusarz@gmail.com>
Date: Sun,  9 Aug 2009 21:54:06 +0200

> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>

Acked-by: David S. Miller <davem@davemloft.net>

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

* Re: [PATCH 10/14] infiniband: use printk_once
  2009-08-09 19:54 ` [PATCH 10/14] infiniband: " Marcin Slusarz
@ 2009-08-10  5:00   ` Roland Dreier
  2009-08-10  6:36     ` [ofa-general] " Jack Morgenstein
  2009-08-10 16:07     ` Marcin Slusarz
  0 siblings, 2 replies; 35+ messages in thread
From: Roland Dreier @ 2009-08-10  5:00 UTC (permalink / raw)
  To: Marcin Slusarz; +Cc: LKML, Roland Dreier, Sean Hefty, Hal Rosenstock, general


 >  drivers/infiniband/hw/cxgb3/iwch.c |    4 +---
 >  drivers/infiniband/hw/mlx4/main.c  |    6 +-----

 > --- a/drivers/infiniband/hw/mlx4/main.c
 > +++ b/drivers/infiniband/hw/mlx4/main.c
 > @@ -540,15 +540,11 @@ static struct device_attribute *mlx4_class_attributes[] = {
 >  
 >  static void *mlx4_ib_add(struct mlx4_dev *dev)
 >  {
 > -	static int mlx4_ib_version_printed;
 >  	struct mlx4_ib_dev *ibdev;
 >  	int num_ports = 0;
 >  	int i;
 >  
 > -	if (!mlx4_ib_version_printed) {
 > -		printk(KERN_INFO "%s", mlx4_ib_version);
 > -		++mlx4_ib_version_printed;
 > -	}
 > +	printk_once(KERN_INFO "%s", mlx4_ib_version);
 >  
 >  	mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
 >  		num_ports++;

Looks fine but there is near-identical code in
drivers/infiniband/hw/mthca/mthca_main.c that you might as well convert
too.

Thanks,
  Roland

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

* Re: [ofa-general] Re: [PATCH 10/14] infiniband: use printk_once
  2009-08-10  5:00   ` Roland Dreier
@ 2009-08-10  6:36     ` Jack Morgenstein
  2009-08-10  7:36       ` Jiri Slaby
  2009-08-10 17:42       ` Roland Dreier
  2009-08-10 16:07     ` Marcin Slusarz
  1 sibling, 2 replies; 35+ messages in thread
From: Jack Morgenstein @ 2009-08-10  6:36 UTC (permalink / raw)
  To: general; +Cc: Roland Dreier, Marcin Slusarz, LKML

I'm a bit nervous about this one.  
printk_once will print once ONLY if CONFIG_PRINTK is set in include/linux/autoconf.h
(i.e., when the kernel is configured).  Otherwise, it gets defined to printk --
and it will always print in this case.
(see 2.6.30.xx kernel include file "include/linux/kernel.h", lines 235, 249, and 272).

Do you think that distributions will ALWAYS have CONFIG_PRINTK defined?

I would prefer to wait until printk_once printing only once is not config-dependent.

-Jack

On Monday 10 August 2009 08:00, Roland Dreier wrote:
> 
>  >  drivers/infiniband/hw/cxgb3/iwch.c |    4 +---
>  >  drivers/infiniband/hw/mlx4/main.c  |    6 +-----
> 
>  > --- a/drivers/infiniband/hw/mlx4/main.c
>  > +++ b/drivers/infiniband/hw/mlx4/main.c
>  > @@ -540,15 +540,11 @@ static struct device_attribute *mlx4_class_attributes[] = {
>  >  
>  >  static void *mlx4_ib_add(struct mlx4_dev *dev)
>  >  {
>  > -	static int mlx4_ib_version_printed;
>  >  	struct mlx4_ib_dev *ibdev;
>  >  	int num_ports = 0;
>  >  	int i;
>  >  
>  > -	if (!mlx4_ib_version_printed) {
>  > -		printk(KERN_INFO "%s", mlx4_ib_version);
>  > -		++mlx4_ib_version_printed;
>  > -	}
>  > +	printk_once(KERN_INFO "%s", mlx4_ib_version);
>  >  
>  >  	mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
>  >  		num_ports++;
> 
> Looks fine but there is near-identical code in
> drivers/infiniband/hw/mthca/mthca_main.c that you might as well convert
> too.
> 
> Thanks,
>   Roland
> _______________________________________________
> general mailing list
> general@lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general
> 
> To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
> 

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

* Re: [ofa-general] Re: [PATCH 10/14] infiniband: use printk_once
  2009-08-10  6:36     ` [ofa-general] " Jack Morgenstein
@ 2009-08-10  7:36       ` Jiri Slaby
  2009-08-10 17:42       ` Roland Dreier
  1 sibling, 0 replies; 35+ messages in thread
From: Jiri Slaby @ 2009-08-10  7:36 UTC (permalink / raw)
  To: Jack Morgenstein; +Cc: general, Roland Dreier, Marcin Slusarz, LKML

On 08/10/2009 08:36 AM, Jack Morgenstein wrote:
> printk_once will print once ONLY if CONFIG_PRINTK is set in include/linux/autoconf.h
> (i.e., when the kernel is configured).  Otherwise, it gets defined to printk --
> and it will always print in this case.

Not true, in that case printk is defined as inlined 'return 0;'

> (see 2.6.30.xx kernel include file "include/linux/kernel.h", lines 235, 249, and 272).

See line 265 there.

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

* Re: [PATCH 03/14] powerpc: use printk_once
  2009-08-09 19:53 ` [PATCH 03/14] powerpc: " Marcin Slusarz
@ 2009-08-10  8:00   ` Wolfram Sang
  2009-08-10 11:46     ` Michael Ellerman
  0 siblings, 1 reply; 35+ messages in thread
From: Wolfram Sang @ 2009-08-10  8:00 UTC (permalink / raw)
  To: Marcin Slusarz; +Cc: LKML, Paul Mackerras, linuxppc-dev

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


On Sun, Aug 09, 2009 at 09:53:58PM +0200, Marcin Slusarz wrote:
> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: linuxppc-dev@ozlabs.org
> ---
>  arch/powerpc/kernel/iommu.c      |    6 +-----
>  arch/powerpc/kernel/irq.c        |    5 ++---
>  arch/powerpc/sysdev/ppc4xx_pci.c |    9 ++-------
>  3 files changed, 5 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
> index fd51578..c7fa258 100644
> --- a/arch/powerpc/kernel/iommu.c
> +++ b/arch/powerpc/kernel/iommu.c
> @@ -502,7 +502,6 @@ static void iommu_table_clear(struct iommu_table *tbl)
>  struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
>  {
>  	unsigned long sz;
> -	static int welcomed = 0;
>  	struct page *page;
>  
>  	/* Set aside 1/4 of the table for large allocations. */
> @@ -523,11 +522,8 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
>  
>  	iommu_table_clear(tbl);
>  
> -	if (!welcomed) {
> -		printk(KERN_INFO "IOMMU table initialized, virtual merging %s\n",
> +	printk_once(KERN_INFO "IOMMU table initialized, virtual merging %s\n",
>  		       novmerge ? "disabled" : "enabled");
> -		welcomed = 1;
> -	}
>  
>  	return tbl;
>  }
> diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
> index f7f376e..05ebd21 100644
> --- a/arch/powerpc/kernel/irq.c
> +++ b/arch/powerpc/kernel/irq.c
> @@ -231,7 +231,6 @@ skip:
>  void fixup_irqs(cpumask_t map)
>  {
>  	unsigned int irq;
> -	static int warned;
>  
>  	for_each_irq(irq) {
>  		cpumask_t mask;
> @@ -246,8 +245,8 @@ void fixup_irqs(cpumask_t map)
>  		}
>  		if (irq_desc[irq].chip->set_affinity)
>  			irq_desc[irq].chip->set_affinity(irq, &mask);
> -		else if (irq_desc[irq].action && !(warned++))
> -			printk("Cannot set affinity for irq %i\n", irq);
> +		else if (irq_desc[irq].action)
> +			printk_once("Cannot set affinity for irq %i\n", irq);

Maybe we should add a loglevel to this printk (and the other one in fix_irqs)
while we are here?

Other than that:

Acked-by: Wolfram Sang <w.sang@pengutronix.de>

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH 03/14] powerpc: use printk_once
  2009-08-10  8:00   ` Wolfram Sang
@ 2009-08-10 11:46     ` Michael Ellerman
  2009-08-10 11:56       ` Gary Thomas
  0 siblings, 1 reply; 35+ messages in thread
From: Michael Ellerman @ 2009-08-10 11:46 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: Marcin Slusarz, linuxppc-dev, Paul Mackerras, LKML

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

On Mon, 2009-08-10 at 10:00 +0200, Wolfram Sang wrote:
> On Sun, Aug 09, 2009 at 09:53:58PM +0200, Marcin Slusarz wrote:
> > Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> > Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> > Cc: Paul Mackerras <paulus@samba.org>
> > Cc: linuxppc-dev@ozlabs.org
> > ---
> >  arch/powerpc/kernel/iommu.c      |    6 +-----
> >  arch/powerpc/kernel/irq.c        |    5 ++---
> >  arch/powerpc/sysdev/ppc4xx_pci.c |    9 ++-------
> >  3 files changed, 5 insertions(+), 15 deletions(-)
> > 
> > diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
> > index fd51578..c7fa258 100644
> > --- a/arch/powerpc/kernel/iommu.c
> > +++ b/arch/powerpc/kernel/iommu.c
> > @@ -502,7 +502,6 @@ static void iommu_table_clear(struct iommu_table *tbl)
> >  struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
> >  {
> >  	unsigned long sz;
> > -	static int welcomed = 0;
> >  	struct page *page;
> >  
> >  	/* Set aside 1/4 of the table for large allocations. */
> > @@ -523,11 +522,8 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
> >  
> >  	iommu_table_clear(tbl);
> >  
> > -	if (!welcomed) {
> > -		printk(KERN_INFO "IOMMU table initialized, virtual merging %s\n",
> > +	printk_once(KERN_INFO "IOMMU table initialized, virtual merging %s\n",
> >  		       novmerge ? "disabled" : "enabled");
> > -		welcomed = 1;
> > -	}
> >  
> >  	return tbl;
> >  }
> > diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
> > index f7f376e..05ebd21 100644
> > --- a/arch/powerpc/kernel/irq.c
> > +++ b/arch/powerpc/kernel/irq.c
> > @@ -231,7 +231,6 @@ skip:
> >  void fixup_irqs(cpumask_t map)
> >  {
> >  	unsigned int irq;
> > -	static int warned;
> >  
> >  	for_each_irq(irq) {
> >  		cpumask_t mask;
> > @@ -246,8 +245,8 @@ void fixup_irqs(cpumask_t map)
> >  		}
> >  		if (irq_desc[irq].chip->set_affinity)
> >  			irq_desc[irq].chip->set_affinity(irq, &mask);
> > -		else if (irq_desc[irq].action && !(warned++))
> > -			printk("Cannot set affinity for irq %i\n", irq);
> > +		else if (irq_desc[irq].action)
> > +			printk_once("Cannot set affinity for irq %i\n", irq);
> 
> Maybe we should add a loglevel to this printk (and the other one in fix_irqs)
> while we are here?

I think you should drop it, it's stupid. If we actually care about irqs
that don't have a set affinity we should keep a count and report that at
the end of the loop.

cheers

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH 03/14] powerpc: use printk_once
  2009-08-10 11:46     ` Michael Ellerman
@ 2009-08-10 11:56       ` Gary Thomas
  0 siblings, 0 replies; 35+ messages in thread
From: Gary Thomas @ 2009-08-10 11:56 UTC (permalink / raw)
  To: michael; +Cc: Wolfram Sang, linuxppc-dev, Paul Mackerras, Marcin Slusarz, LKML

Michael Ellerman wrote:
> On Mon, 2009-08-10 at 10:00 +0200, Wolfram Sang wrote:
>> On Sun, Aug 09, 2009 at 09:53:58PM +0200, Marcin Slusarz wrote:
>>> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
>>> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>>> Cc: Paul Mackerras <paulus@samba.org>
>>> Cc: linuxppc-dev@ozlabs.org
>>> ---
>>>  arch/powerpc/kernel/iommu.c      |    6 +-----
>>>  arch/powerpc/kernel/irq.c        |    5 ++---
>>>  arch/powerpc/sysdev/ppc4xx_pci.c |    9 ++-------
>>>  3 files changed, 5 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
>>> index fd51578..c7fa258 100644
>>> --- a/arch/powerpc/kernel/iommu.c
>>> +++ b/arch/powerpc/kernel/iommu.c
>>> @@ -502,7 +502,6 @@ static void iommu_table_clear(struct iommu_table *tbl)
>>>  struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
>>>  {
>>>  	unsigned long sz;
>>> -	static int welcomed = 0;
>>>  	struct page *page;
>>>  
>>>  	/* Set aside 1/4 of the table for large allocations. */
>>> @@ -523,11 +522,8 @@ struct iommu_table *iommu_init_table(struct iommu_table *tbl, int nid)
>>>  
>>>  	iommu_table_clear(tbl);
>>>  
>>> -	if (!welcomed) {
>>> -		printk(KERN_INFO "IOMMU table initialized, virtual merging %s\n",
>>> +	printk_once(KERN_INFO "IOMMU table initialized, virtual merging %s\n",
>>>  		       novmerge ? "disabled" : "enabled");
>>> -		welcomed = 1;
>>> -	}
>>>  
>>>  	return tbl;
>>>  }
>>> diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
>>> index f7f376e..05ebd21 100644
>>> --- a/arch/powerpc/kernel/irq.c
>>> +++ b/arch/powerpc/kernel/irq.c
>>> @@ -231,7 +231,6 @@ skip:
>>>  void fixup_irqs(cpumask_t map)
>>>  {
>>>  	unsigned int irq;
>>> -	static int warned;
>>>  
>>>  	for_each_irq(irq) {
>>>  		cpumask_t mask;
>>> @@ -246,8 +245,8 @@ void fixup_irqs(cpumask_t map)
>>>  		}
>>>  		if (irq_desc[irq].chip->set_affinity)
>>>  			irq_desc[irq].chip->set_affinity(irq, &mask);
>>> -		else if (irq_desc[irq].action && !(warned++))
>>> -			printk("Cannot set affinity for irq %i\n", irq);
>>> +		else if (irq_desc[irq].action)
>>> +			printk_once("Cannot set affinity for irq %i\n", irq);
>> Maybe we should add a loglevel to this printk (and the other one in fix_irqs)
>> while we are here?
> 
> I think you should drop it, it's stupid. If we actually care about irqs
> that don't have a set affinity we should keep a count and report that at
> the end of the loop.

In addition, this change would prevent reporting missing
affinity on more than one IRQ if there were such.

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

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

* Re: [PATCH 10/14] infiniband: use printk_once
  2009-08-10  5:00   ` Roland Dreier
  2009-08-10  6:36     ` [ofa-general] " Jack Morgenstein
@ 2009-08-10 16:07     ` Marcin Slusarz
  2009-08-11 16:40       ` Roland Dreier
  1 sibling, 1 reply; 35+ messages in thread
From: Marcin Slusarz @ 2009-08-10 16:07 UTC (permalink / raw)
  To: Roland Dreier; +Cc: LKML, Roland Dreier, Sean Hefty, Hal Rosenstock, general

Roland Dreier wrote:
>  >  drivers/infiniband/hw/cxgb3/iwch.c |    4 +---
>  >  drivers/infiniband/hw/mlx4/main.c  |    6 +-----
> 
>  > --- a/drivers/infiniband/hw/mlx4/main.c
>  > +++ b/drivers/infiniband/hw/mlx4/main.c
>  > @@ -540,15 +540,11 @@ static struct device_attribute *mlx4_class_attributes[] = {
>  >  
>  >  static void *mlx4_ib_add(struct mlx4_dev *dev)
>  >  {
>  > -	static int mlx4_ib_version_printed;
>  >  	struct mlx4_ib_dev *ibdev;
>  >  	int num_ports = 0;
>  >  	int i;
>  >  
>  > -	if (!mlx4_ib_version_printed) {
>  > -		printk(KERN_INFO "%s", mlx4_ib_version);
>  > -		++mlx4_ib_version_printed;
>  > -	}
>  > +	printk_once(KERN_INFO "%s", mlx4_ib_version);
>  >  
>  >  	mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
>  >  		num_ports++;
> 
> Looks fine but there is near-identical code in
> drivers/infiniband/hw/mthca/mthca_main.c that you might as well convert
> too.

Thanks for a hint. Updated patch below.

---
From: Marcin Slusarz <marcin.slusarz@gmail.com>
Date: Mon, 10 Aug 2009 18:01:49 +0200
Subject: [PATCH 10/14 v2] infiniband: use printk_once

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Roland Dreier <rolandd@cisco.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
Cc: general@lists.openfabrics.org
---
 drivers/infiniband/hw/cxgb3/iwch.c       |    4 +---
 drivers/infiniband/hw/mlx4/main.c        |    6 +-----
 drivers/infiniband/hw/mthca/mthca_main.c |    6 +-----
 3 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb3/iwch.c b/drivers/infiniband/hw/cxgb3/iwch.c
index 26fc0a4..9cc99df 100644
--- a/drivers/infiniband/hw/cxgb3/iwch.c
+++ b/drivers/infiniband/hw/cxgb3/iwch.c
@@ -105,11 +105,9 @@ static void rnic_init(struct iwch_dev *rnicp)
 static void open_rnic_dev(struct t3cdev *tdev)
 {
 	struct iwch_dev *rnicp;
-	static int vers_printed;
 
 	PDBG("%s t3cdev %p\n", __func__,  tdev);
-	if (!vers_printed++)
-		printk(KERN_INFO MOD "Chelsio T3 RDMA Driver - version %s\n",
+	printk_once(KERN_INFO MOD "Chelsio T3 RDMA Driver - version %s\n",
 		       DRV_VERSION);
 	rnicp = (struct iwch_dev *)ib_alloc_device(sizeof(*rnicp));
 	if (!rnicp) {
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index ae3d759..0b2f77a 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -540,15 +540,11 @@ static struct device_attribute *mlx4_class_attributes[] = {
 
 static void *mlx4_ib_add(struct mlx4_dev *dev)
 {
-	static int mlx4_ib_version_printed;
 	struct mlx4_ib_dev *ibdev;
 	int num_ports = 0;
 	int i;
 
-	if (!mlx4_ib_version_printed) {
-		printk(KERN_INFO "%s", mlx4_ib_version);
-		++mlx4_ib_version_printed;
-	}
+	printk_once(KERN_INFO "%s", mlx4_ib_version);
 
 	mlx4_foreach_port(i, dev, MLX4_PORT_TYPE_IB)
 		num_ports++;
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index 13da9f1..2e4e043 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -1215,15 +1215,11 @@ int __mthca_restart_one(struct pci_dev *pdev)
 static int __devinit mthca_init_one(struct pci_dev *pdev,
 				    const struct pci_device_id *id)
 {
-	static int mthca_version_printed = 0;
 	int ret;
 
 	mutex_lock(&mthca_device_mutex);
 
-	if (!mthca_version_printed) {
-		printk(KERN_INFO "%s", mthca_version);
-		++mthca_version_printed;
-	}
+	printk_once(KERN_INFO "%s", mthca_version);
 
 	if (id->driver_data >= ARRAY_SIZE(mthca_hca_table)) {
 		printk(KERN_ERR PFX "%s has invalid driver data %lx\n",
-- 
1.6.3.3


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

* Re: [ofa-general] Re: [PATCH 10/14] infiniband: use printk_once
  2009-08-10  6:36     ` [ofa-general] " Jack Morgenstein
  2009-08-10  7:36       ` Jiri Slaby
@ 2009-08-10 17:42       ` Roland Dreier
  2009-08-11  7:17         ` Jack Morgenstein
  1 sibling, 1 reply; 35+ messages in thread
From: Roland Dreier @ 2009-08-10 17:42 UTC (permalink / raw)
  To: Jack Morgenstein; +Cc: general, Marcin Slusarz, LKML


 > I'm a bit nervous about this one.  
 > printk_once will print once ONLY if CONFIG_PRINTK is set in include/linux/autoconf.h
 > (i.e., when the kernel is configured).  Otherwise, it gets defined to printk --
 > and it will always print in this case.
 > (see 2.6.30.xx kernel include file "include/linux/kernel.h", lines 235, 249, and 272).

Umm... if CONFIG_PRINTK is turned off nothing prints, right?

 > Do you think that distributions will ALWAYS have CONFIG_PRINTK defined?

Yes, I suspect they do want to get kernel messages.

 - R.

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

* Re: [ofa-general] Re: [PATCH 10/14] infiniband: use printk_once
  2009-08-10 17:42       ` Roland Dreier
@ 2009-08-11  7:17         ` Jack Morgenstein
  0 siblings, 0 replies; 35+ messages in thread
From: Jack Morgenstein @ 2009-08-11  7:17 UTC (permalink / raw)
  To: Roland Dreier; +Cc: general, Marcin Slusarz, LKML, Jiri Slaby

On Monday 10 August 2009 20:42, Roland Dreier wrote:
> 
>  > I'm a bit nervous about this one.  
>  > printk_once will print once ONLY if CONFIG_PRINTK is set in include/linux/autoconf.h
>  > (i.e., when the kernel is configured).  Otherwise, it gets defined to printk --
>  > and it will always print in this case.
>  > (see 2.6.30.xx kernel include file "include/linux/kernel.h", lines 235, 249, and 272).
> 
> Umm... if CONFIG_PRINTK is turned off nothing prints, right?
Jiri Slaby pointed that out to me -- i.e., that printk itself is defined to do nothing but
return 0 if CONFIG_PRINTK is not defined. (I missed that when looking at file kernel.h).

I thought no answer was needed (sorry about that) -- Jiri was so obviously correct.

I've got no problem with the patch.

-Jack

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

* Re: [PATCH 12/14] scsi: use printk_once
  2009-08-09 19:54 ` [PATCH 12/14] scsi: " Marcin Slusarz
@ 2009-08-11 16:40   ` James Bottomley
  2009-08-11 16:46     ` Roland Dreier
  2009-08-11 16:49     ` Joe Perches
  0 siblings, 2 replies; 35+ messages in thread
From: James Bottomley @ 2009-08-11 16:40 UTC (permalink / raw)
  To: Marcin Slusarz; +Cc: LKML, linux-scsi

On Sun, 2009-08-09 at 21:54 +0200, Marcin Slusarz wrote:
> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
> Cc: linux-scsi@vger.kernel.org
> ---
>  drivers/scsi/53c700.c             |    6 +-----
>  drivers/scsi/cxgb3i/cxgb3i_init.c |    7 +------
>  2 files changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
> index f5a9add..c5f4fa7 100644
> --- a/drivers/scsi/53c700.c
> +++ b/drivers/scsi/53c700.c
> @@ -291,7 +291,6 @@ NCR_700_detect(struct scsi_host_template *tpnt,
>  	__u8 *memory;
>  	__u32 *script;
>  	struct Scsi_Host *host;
> -	static int banner = 0;
>  	int j;
>  
>  	if(tpnt->sdev_attrs == NULL)
> @@ -385,10 +384,7 @@ NCR_700_detect(struct scsi_host_template *tpnt,
>  	else
>  		hostdata->rev = (NCR_700_readb(host, CTEST7_REG)>>4) & 0x0f;
>  	hostdata->fast = (NCR_700_readb(host, CTEST9_REG) == 0);
> -	if (banner == 0) {
> -		printk(KERN_NOTICE "53c700: Version " NCR_700_VERSION " By James.Bottomley@HansenPartnership.com\n");
> -		banner = 1;
> -	}
> +	printk_once(KERN_NOTICE "53c700: Version " NCR_700_VERSION " By James.Bottomley@HansenPartnership.com\n");
>  	printk(KERN_NOTICE "scsi%d: %s rev %d %s\n", host->host_no,
>  	       hostdata->chip710 ? "53c710" :
>  	       (hostdata->fast ? "53c700-66" : "53c700"),
> diff --git a/drivers/scsi/cxgb3i/cxgb3i_init.c b/drivers/scsi/cxgb3i/cxgb3i_init.c
> index 042d9bc..8c9285f 100644
> --- a/drivers/scsi/cxgb3i/cxgb3i_init.c
> +++ b/drivers/scsi/cxgb3i/cxgb3i_init.c
> @@ -43,12 +43,7 @@ static struct cxgb3_client t3c_client = {
>   */
>  static void open_s3_dev(struct t3cdev *t3dev)
>  {
> -	static int vers_printed;
> -
> -	if (!vers_printed) {
> -		printk(KERN_INFO "%s", version);
> -		vers_printed = 1;
> -	}
> +	printk_once(KERN_INFO "%s", version);

There's really no point to this beyond code churn.  Both patterns are
correct uses so conversion buys us nothing.

James



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

* Re: [PATCH 10/14] infiniband: use printk_once
  2009-08-10 16:07     ` Marcin Slusarz
@ 2009-08-11 16:40       ` Roland Dreier
  0 siblings, 0 replies; 35+ messages in thread
From: Roland Dreier @ 2009-08-11 16:40 UTC (permalink / raw)
  To: Marcin Slusarz; +Cc: LKML, Roland Dreier, Sean Hefty, Hal Rosenstock, general

thanks, applied.

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

* Re: [PATCH 12/14] scsi: use printk_once
  2009-08-11 16:40   ` James Bottomley
@ 2009-08-11 16:46     ` Roland Dreier
  2009-08-11 16:50       ` James Bottomley
  2009-08-11 16:49     ` Joe Perches
  1 sibling, 1 reply; 35+ messages in thread
From: Roland Dreier @ 2009-08-11 16:46 UTC (permalink / raw)
  To: James Bottomley; +Cc: Marcin Slusarz, LKML, linux-scsi


 > > -	static int vers_printed;
 > > -
 > > -	if (!vers_printed) {
 > > -		printk(KERN_INFO "%s", version);
 > > -		vers_printed = 1;
 > > -	}
 > > +	printk_once(KERN_INFO "%s", version);

 > There's really no point to this beyond code churn.  Both patterns are
 > correct uses so conversion buys us nothing.

It's a pretty small gain but I do think 6 lines -> 1 line does have value.

 - R.

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

* Re: [PATCH 12/14] scsi: use printk_once
  2009-08-11 16:40   ` James Bottomley
  2009-08-11 16:46     ` Roland Dreier
@ 2009-08-11 16:49     ` Joe Perches
  1 sibling, 0 replies; 35+ messages in thread
From: Joe Perches @ 2009-08-11 16:49 UTC (permalink / raw)
  To: James Bottomley; +Cc: Marcin Slusarz, LKML, linux-scsi

On Tue, 2009-08-11 at 11:40 -0500, James Bottomley wrote:
> On Sun, 2009-08-09 at 21:54 +0200, Marcin Slusarz wrote:
> > --- a/drivers/scsi/cxgb3i/cxgb3i_init.c
> > +++ b/drivers/scsi/cxgb3i/cxgb3i_init.c
> > @@ -43,12 +43,7 @@ static struct cxgb3_client t3c_client = {
> >   */
> >  static void open_s3_dev(struct t3cdev *t3dev)
> >  {
> > -	static int vers_printed;
> > -
> > -	if (!vers_printed) {
> > -		printk(KERN_INFO "%s", version);
> > -		vers_printed = 1;
> > -	}
> > +	printk_once(KERN_INFO "%s", version);
> 
> There's really no point to this beyond code churn.  Both patterns are
> correct uses so conversion buys us nothing.

Standards are for hacks.  Stasis is the best policy.
Using patterns isn't worth the electron movement.
Code shortening and readability?  Humbug.



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

* Re: [PATCH 12/14] scsi: use printk_once
  2009-08-11 16:46     ` Roland Dreier
@ 2009-08-11 16:50       ` James Bottomley
  0 siblings, 0 replies; 35+ messages in thread
From: James Bottomley @ 2009-08-11 16:50 UTC (permalink / raw)
  To: Roland Dreier; +Cc: Marcin Slusarz, LKML, linux-scsi

On Tue, 2009-08-11 at 09:46 -0700, Roland Dreier wrote:
> > > -	static int vers_printed;
>  > > -
>  > > -	if (!vers_printed) {
>  > > -		printk(KERN_INFO "%s", version);
>  > > -		vers_printed = 1;
>  > > -	}
>  > > +	printk_once(KERN_INFO "%s", version);
> 
>  > There's really no point to this beyond code churn.  Both patterns are
>  > correct uses so conversion buys us nothing.
> 
> It's a pretty small gain but I do think 6 lines -> 1 line does have value.

Not at the expense of churning the code base of marginal drivers.

I'm not entirely convinced this is a good pattern to begin with.  If you
add too many patterns you're effectively developing an overly complex
development language and rule set.  Even if I go with this on the basis
of readability (as you say, one line for six), then I still don't think
we should churn the code base to convert correct open coding to it; we
should just use it ongoing.

James



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

* Re: [PATCH 04/14] sh: use printk_once
  2009-08-09 19:53 ` [PATCH 04/14] sh: " Marcin Slusarz
@ 2009-08-13  3:04   ` Paul Mundt
  0 siblings, 0 replies; 35+ messages in thread
From: Paul Mundt @ 2009-08-13  3:04 UTC (permalink / raw)
  To: Marcin Slusarz; +Cc: LKML, linux-sh

On Sun, Aug 09, 2009 at 09:53:59PM +0200, Marcin Slusarz wrote:
> Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
> Cc: Paul Mundt <lethal@linux-sh.org>
> Cc: linux-sh@vger.kernel.org
> ---
>  arch/sh/mm/ioremap_64.c |    6 +-----
>  1 files changed, 1 insertions(+), 5 deletions(-)
> 
Applied, thanks.

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

end of thread, other threads:[~2009-08-13  3:04 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-09 19:53 [PATCH 00/14] use printk_once Marcin Slusarz
2009-08-09 19:53 ` [PATCH 01/14] alpha: " Marcin Slusarz
2009-08-09 19:53 ` [PATCH 02/14] ia64: " Marcin Slusarz
2009-08-09 19:53 ` [PATCH 03/14] powerpc: " Marcin Slusarz
2009-08-10  8:00   ` Wolfram Sang
2009-08-10 11:46     ` Michael Ellerman
2009-08-10 11:56       ` Gary Thomas
2009-08-09 19:53 ` [PATCH 04/14] sh: " Marcin Slusarz
2009-08-13  3:04   ` Paul Mundt
2009-08-09 19:54 ` [PATCH 05/14] x86: " Marcin Slusarz
2009-08-09 20:30   ` [tip:x86/cleanups] x86: Use printk_once() tip-bot for Marcin Slusarz
2009-08-09 19:54 ` [PATCH 06/14] ata: use printk_once Marcin Slusarz
2009-08-09 19:54 ` [PATCH 07/14] block: " Marcin Slusarz
2009-08-09 19:54 ` [PATCH 08/14] tty/vt: " Marcin Slusarz
2009-08-09 19:54 ` [PATCH 09/14] ide: " Marcin Slusarz
2009-08-10  2:52   ` David Miller
2009-08-09 19:54 ` [PATCH 10/14] infiniband: " Marcin Slusarz
2009-08-10  5:00   ` Roland Dreier
2009-08-10  6:36     ` [ofa-general] " Jack Morgenstein
2009-08-10  7:36       ` Jiri Slaby
2009-08-10 17:42       ` Roland Dreier
2009-08-11  7:17         ` Jack Morgenstein
2009-08-10 16:07     ` Marcin Slusarz
2009-08-11 16:40       ` Roland Dreier
2009-08-09 19:54 ` [PATCH 11/14] drivers/net: " Marcin Slusarz
2009-08-10  2:52   ` David Miller
2009-08-09 19:54 ` [PATCH 12/14] scsi: " Marcin Slusarz
2009-08-11 16:40   ` James Bottomley
2009-08-11 16:46     ` Roland Dreier
2009-08-11 16:50       ` James Bottomley
2009-08-11 16:49     ` Joe Perches
2009-08-09 19:54 ` [PATCH 13/14] vsprintf: use WARN_ON_ONCE Marcin Slusarz
2009-08-09 19:54 ` [PATCH 14/14] net: use printk_once Marcin Slusarz
2009-08-10  2:52   ` David Miller
2009-08-09 20:36 ` [PATCH 00/14] " Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox