* [PATCH 01/12] consolidate print* in a single header
2013-01-29 8:45 [PATCH] introduce compiletime loglevel Sascha Hauer
@ 2013-01-29 8:45 ` Sascha Hauer
2013-01-29 8:45 ` [PATCH 02/12] mtd m25p80: consistenly switch to dev_* messages Sascha Hauer
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2013-01-29 8:45 UTC (permalink / raw)
To: barebox
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
include/common.h | 17 +---------------
include/driver.h | 29 ---------------------------
include/printk.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 59 insertions(+), 45 deletions(-)
create mode 100644 include/printk.h
diff --git a/include/common.h b/include/common.h
index b1c96de..32a5d96 100644
--- a/include/common.h
+++ b/include/common.h
@@ -29,6 +29,7 @@
#include <linux/kernel.h>
#include <linux/stddef.h>
#include <asm/common.h>
+#include <printk.h>
/*
* sanity check. The Linux Kernel defines only one of __LITTLE_ENDIAN and
@@ -48,22 +49,6 @@
#error "None of __LITTLE_ENDIAN and __BIG_ENDIAN are defined"
#endif
-#define pr_info(fmt, arg...) printf(fmt, ##arg)
-#define pr_notice(fmt, arg...) printf(fmt, ##arg)
-#define pr_err(fmt, arg...) printf(fmt, ##arg)
-#define pr_warning(fmt, arg...) printf(fmt, ##arg)
-#define pr_crit(fmt, arg...) printf(fmt, ##arg)
-#define pr_alert(fmt, arg...) printf(fmt, ##arg)
-#define pr_emerg(fmt, arg...) printf(fmt, ##arg)
-
-#ifdef DEBUG
-#define pr_debug(fmt, arg...) printf(fmt, ##arg)
-#else
-#define pr_debug(fmt, arg...) do {} while(0)
-#endif
-
-#define debug(fmt, arg...) pr_debug(fmt, ##arg)
-
#define BUG() do { \
printf("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
panic("BUG!"); \
diff --git a/include/driver.h b/include/driver.h
index 7ad0374..31f5d69 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -358,35 +358,6 @@ static inline int dev_close_default(struct device_d *dev, struct filep *f)
return 0;
}
-/* debugging and troubleshooting/diagnostic helpers. */
-
-int dev_printf(const struct device_d *dev, const char *format, ...)
- __attribute__ ((format(__printf__, 2, 3)));
-
-
-#define dev_emerg(dev, format, arg...) \
- dev_printf((dev) , format , ## arg)
-#define dev_alert(dev, format, arg...) \
- dev_printf((dev) , format , ## arg)
-#define dev_crit(dev, format, arg...) \
- dev_printf((dev) , format , ## arg)
-#define dev_err(dev, format, arg...) \
- dev_printf(dev , format , ## arg)
-#define dev_warn(dev, format, arg...) \
- dev_printf((dev) , format , ## arg)
-#define dev_notice(dev, format, arg...) \
- dev_printf((dev) , format , ## arg)
-#define dev_info(dev, format, arg...) \
- dev_printf((dev) , format , ## arg)
-
-#if defined(DEBUG)
-#define dev_dbg(dev, format, arg...) \
- dev_printf((dev) , format , ## arg)
-#else
-#define dev_dbg(dev, format, arg...) \
- ({ if (0) dev_printf((dev), format, ##arg); 0; })
-#endif
-
struct bus_type {
char *name;
int (*match)(struct device_d *dev, struct driver_d *drv);
diff --git a/include/printk.h b/include/printk.h
new file mode 100644
index 0000000..9e6f4bd
--- /dev/null
+++ b/include/printk.h
@@ -0,0 +1,58 @@
+#ifndef __PRINTK_H
+#define __PRINTK_H
+
+#define MSG_EMERG 0 /* system is unusable */
+#define MSG_ALERT 1 /* action must be taken immediately */
+#define MSG_CRIT 2 /* critical conditions */
+#define MSG_ERR 3 /* error conditions */
+#define MSG_WARNING 4 /* warning conditions */
+#define MSG_NOTICE 5 /* normal but significant condition */
+#define MSG_INFO 6 /* informational */
+#define MSG_DEBUG 7 /* debug-level messages */
+
+/* debugging and troubleshooting/diagnostic helpers. */
+
+int dev_printf(const struct device_d *dev, const char *format, ...)
+ __attribute__ ((format(__printf__, 2, 3)));
+
+
+#define dev_emerg(dev, format, arg...) \
+ dev_printf((dev) , format , ## arg)
+#define dev_alert(dev, format, arg...) \
+ dev_printf((dev) , format , ## arg)
+#define dev_crit(dev, format, arg...) \
+ dev_printf((dev) , format , ## arg)
+#define dev_err(dev, format, arg...) \
+ dev_printf(dev , format , ## arg)
+#define dev_warn(dev, format, arg...) \
+ dev_printf((dev) , format , ## arg)
+#define dev_notice(dev, format, arg...) \
+ dev_printf((dev) , format , ## arg)
+#define dev_info(dev, format, arg...) \
+ dev_printf((dev) , format , ## arg)
+
+#if defined(DEBUG)
+#define dev_dbg(dev, format, arg...) \
+ dev_printf((dev) , format , ## arg)
+#else
+#define dev_dbg(dev, format, arg...) \
+ ({ if (0) dev_printf((dev), format, ##arg); 0; })
+#endif
+
+#define pr_info(fmt, arg...) printk(fmt, ##arg)
+#define pr_notice(fmt, arg...) printk(fmt, ##arg)
+#define pr_err(fmt, arg...) printk(fmt, ##arg)
+#define pr_warning(fmt, arg...) printk(fmt, ##arg)
+#define pr_crit(fmt, arg...) printk(fmt, ##arg)
+#define pr_alert(fmt, arg...) printk(fmt, ##arg)
+#define pr_emerg(fmt, arg...) printk(fmt, ##arg)
+
+#ifdef DEBUG
+#define pr_debug(fmt, arg...) printk(fmt, ##arg)
+#define debug(fmt, arg...) printf(fmt, ##arg)
+#else
+#define pr_debug(fmt, arg...) do {} while(0)
+#define debug(fmt, arg...) do {} while(0)
+#endif
+
+#endif
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 02/12] mtd m25p80: consistenly switch to dev_* messages
2013-01-29 8:45 [PATCH] introduce compiletime loglevel Sascha Hauer
2013-01-29 8:45 ` [PATCH 01/12] consolidate print* in a single header Sascha Hauer
@ 2013-01-29 8:45 ` Sascha Hauer
2013-01-29 8:45 ` [PATCH 03/12] treewide: fix format specifiers Sascha Hauer
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2013-01-29 8:45 UTC (permalink / raw)
To: barebox
Also, fix variable names in m25p80_write debug message.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mtd/devices/m25p80.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 428d126..55b1020 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -408,7 +408,8 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len,
struct spi_transfer t[2];
struct spi_message m;
- debug("m25p80_write %ld bytes at 0x%08lX\n", (unsigned long)count, offset);
+ dev_dbg(&flash->spi->dev, "m25p80_write %ld bytes at 0x%08llx\n",
+ (unsigned long)len, to);
spi_message_init(&m);
memset(t, 0, (sizeof t));
@@ -484,7 +485,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t actual;
int cmd_sz, ret;
- pr_debug("%s: %s to 0x%08x, len %zd\n", dev_name(&flash->spi->dev),
+ dev_dbg(&flash->spi->dev, "%s to 0x%08x, len %zd\n",
__func__, (u32)to, len);
spi_message_init(&m);
@@ -767,7 +768,7 @@ static const struct spi_device_id *jedec_probe(struct spi_device *spi)
*/
tmp = spi_write_then_read(spi, &code, 1, id, 5);
if (tmp < 0) {
- pr_debug("%s: error %d reading JEDEC ID\n",
+ dev_dbg(&spi->dev, "%s: error %d reading JEDEC ID\n",
dev_name(&spi->dev), tmp);
return ERR_PTR(tmp);
}
@@ -923,7 +924,7 @@ static int m25p_probe(struct device_d *dev)
dev_info(dev, "%s (%lld Kbytes)\n", id->name,
(long long)flash->mtd.size >> 10);
- pr_debug("mtd .name = %s, .size = 0x%llx (%lldMiB) "
+ dev_dbg(dev, "mtd .name = %s, .size = 0x%llx (%lldMiB) "
".erasesize = 0x%.8x (%uKiB) .numeraseregions = %d\n",
flash->mtd.name,
(long long)flash->mtd.size, (long long)(flash->mtd.size >> 20),
@@ -932,7 +933,7 @@ static int m25p_probe(struct device_d *dev)
if (flash->mtd.numeraseregions)
for (i = 0; i < flash->mtd.numeraseregions; i++)
- pr_debug("mtd.eraseregions[%d] = { .offset = 0x%llx, "
+ dev_dbg(dev, "mtd.eraseregions[%d] = { .offset = 0x%llx, "
".erasesize = 0x%.8x (%uKiB), "
".numblocks = %d }\n",
i, (long long)flash->mtd.eraseregions[i].offset,
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 03/12] treewide: fix format specifiers
2013-01-29 8:45 [PATCH] introduce compiletime loglevel Sascha Hauer
2013-01-29 8:45 ` [PATCH 01/12] consolidate print* in a single header Sascha Hauer
2013-01-29 8:45 ` [PATCH 02/12] mtd m25p80: consistenly switch to dev_* messages Sascha Hauer
@ 2013-01-29 8:45 ` Sascha Hauer
2013-01-29 8:45 ` [PATCH 04/12] nios2: Let readl return an unsigned int Sascha Hauer
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2013-01-29 8:45 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/esdctl.c | 4 ++--
arch/arm/mach-omap/gpmc.c | 6 +++---
arch/ppc/lib/board.c | 4 ++--
common/environment.c | 10 ++++++----
common/hush.c | 4 +---
common/module.c | 2 +-
common/parser.c | 4 +---
common/resource.c | 26 +++++++++++++++++++-------
common/uimage.c | 5 +++--
drivers/mci/mxs.c | 2 +-
drivers/nor/cfi_flash.c | 14 +++++++++-----
drivers/nor/cfi_flash.h | 4 ++++
fs/tftp.c | 4 ++--
lib/gui/bmp.c | 2 +-
lib/xfuncs.c | 4 ++--
15 files changed, 57 insertions(+), 38 deletions(-)
diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
index dd70e6d..841a9ed 100644
--- a/arch/arm/mach-imx/esdctl.c
+++ b/arch/arm/mach-imx/esdctl.c
@@ -168,8 +168,8 @@ static inline unsigned long imx_v4_sdram_size(void __iomem *esdctlbase, int cs)
static void add_mem(unsigned long base0, unsigned long size0,
unsigned long base1, unsigned long size1)
{
- debug("%s: cs0 base: 0x%08x cs0 size: 0x%08x\n", __func__, base0, size0);
- debug("%s: cs1 base: 0x%08x cs1 size: 0x%08x\n", __func__, base1, size1);
+ debug("%s: cs0 base: 0x%08lx cs0 size: 0x%08lx\n", __func__, base0, size0);
+ debug("%s: cs1 base: 0x%08lx cs1 size: 0x%08lx\n", __func__, base1, size1);
if (base0 + size0 == base1 && size1 > 0) {
/*
diff --git a/arch/arm/mach-omap/gpmc.c b/arch/arm/mach-omap/gpmc.c
index 3aaa4f6..bb84b38 100644
--- a/arch/arm/mach-omap/gpmc.c
+++ b/arch/arm/mach-omap/gpmc.c
@@ -89,7 +89,7 @@ void gpmc_generic_init(unsigned int cfg)
* But NEVER run me in XIP mode! I will Die!
*/
while (x < GPMC_NUM_CS) {
- debug("gpmccs=%d Reg:0x%x <-0x0\n", x, reg);
+ debug("gpmccs=%d Reg:0x%p <-0x0\n", x, reg);
writel(0x0, reg);
reg += GPMC_CONFIG_CS_SIZE;
x++;
@@ -119,14 +119,14 @@ void gpmc_cs_config(char cs, struct gpmc_config *config)
/* Write the CFG1-6 regs */
while (x < 6) {
- debug("gpmccfg%d Reg:0x%x <-0x%08x\n",
+ debug("gpmccfg%d Reg:0x%p <-0x%08x\n",
x, reg, config->cfg[x]);
writel(config->cfg[x], reg);
reg += GPMC_CONFIG_REG_OFF;
x++;
}
/* reg now points to CFG7 */
- debug("gpmccfg%d Reg:0x%x <-0x%08x\n",
+ debug("gpmccfg%d Reg:0x%p <-0x%08x\n",
x, reg, (0x1 << 6) | /* CS enable */
((config->size & 0xF) << 8) | /* Size */
((config->base >> 24) & 0x3F));
diff --git a/arch/ppc/lib/board.c b/arch/ppc/lib/board.c
index d219862..18d2588 100644
--- a/arch/ppc/lib/board.c
+++ b/arch/ppc/lib/board.c
@@ -52,8 +52,8 @@ void board_init_r (ulong end_of_ram)
*/
malloc_end = (_text_base - (128 << 10)) & ~(4095);
- debug("malloc_end: 0x%08x\n", malloc_end);
- debug("TEXT_BASE after relocation: 0x%08x\n", _text_base);
+ debug("malloc_end: 0x%08lx\n", malloc_end);
+ debug("TEXT_BASE after relocation: 0x%08lx\n", _text_base);
mem_malloc_init((void *)(malloc_end - MALLOC_SIZE), (void *)(malloc_end - 1));
diff --git a/common/environment.c b/common/environment.c
index e11cd9d..379e76e 100644
--- a/common/environment.c
+++ b/common/environment.c
@@ -106,11 +106,13 @@ int file_save_action(const char *filename, struct stat *statbuf,
memcpy(data->writep, path, len);
inode->size = ENVFS_32(len);
data->writep += PAD4(len);
- debug("handling symlink %s size %ld namelen %d headerlen %d\n", filename + strlen(data->base),
- len, namelen, ENVFS_32(inode->headerlen));
+ debug("handling symlink %s size %d namelen %d headerlen %d\n",
+ filename + strlen(data->base),
+ len, namelen, ENVFS_32(inode->headerlen));
} else {
- debug("handling file %s size %ld namelen %d headerlen %d\n", filename + strlen(data->base),
- statbuf->st_size, namelen, ENVFS_32(inode->headerlen));
+ debug("handling file %s size %lld namelen %d headerlen %d\n",
+ filename + strlen(data->base),
+ statbuf->st_size, namelen, ENVFS_32(inode->headerlen));
inode->size = ENVFS_32(statbuf->st_size);
fd = open(filename, O_RDONLY);
diff --git a/common/hush.c b/common/hush.c
index f9e6411..1f468f6 100644
--- a/common/hush.c
+++ b/common/hush.c
@@ -937,14 +937,12 @@ static int run_list_real(struct p_context *ctx, struct pipe *pi)
return rcode;
}
-#ifdef DEBUG
/* broken, of course, but OK for testing */
-static char *indenter(int i)
+static __maybe_unused char *indenter(int i)
{
static char blanks[] = " ";
return &blanks[sizeof(blanks) - i - 1];
}
-#endif
/* return code is the exit status of the pipe */
static int free_pipe(struct pipe *pi, int indent)
diff --git a/common/module.c b/common/module.c
index 4cb8ef3..109fe5c 100644
--- a/common/module.c
+++ b/common/module.c
@@ -104,7 +104,7 @@ static int simplify_symbols(Elf32_Shdr *sechdrs,
sym[i].st_value
= resolve_symbol(sechdrs,
strtab + sym[i].st_name);
- debug("undef : %20s 0x%08x 0x%08lx\n", strtab + sym[i].st_name, sym[i].st_value);
+ debug("undef : %20s 0x%08x\n", strtab + sym[i].st_name, sym[i].st_value);
/* Ok if resolved. */
if (sym[i].st_value != 0)
diff --git a/common/parser.c b/common/parser.c
index fd578c7..4d993df 100644
--- a/common/parser.c
+++ b/common/parser.c
@@ -58,9 +58,7 @@ static void process_macros (const char *input, char *output)
/* 1 = waiting for '(' or '{' */
/* 2 = waiting for ')' or '}' */
/* 3 = waiting for ''' */
-#ifdef DEBUG
- char *output_start = output;
-#endif
+ char __maybe_unused *output_start = output;
pr_debug("[PROCESS_MACROS] INPUT len %d: \"%s\"\n", strlen (input),
input);
diff --git a/common/resource.c b/common/resource.c
index ea6abe8..5795e79 100644
--- a/common/resource.c
+++ b/common/resource.c
@@ -43,15 +43,21 @@ struct resource *request_region(struct resource *parent,
struct resource *r, *new;
if (end < start) {
- debug("%s: request region 0x%08x:0x%08x: end < start\n",
- __func__, start, end);
+ debug("%s: request region 0x%08llx:0x%08llx: end < start\n",
+ __func__,
+ (unsigned long long)start,
+ (unsigned long long)end);
return NULL;
}
/* outside parent resource? */
if (start < parent->start || end > parent->end) {
- debug("%s: 0x%08x:0x%08x outside parent resource 0x%08x:0x%08x\n",
- __func__, start, end, parent->start, parent->end);
+ debug("%s: 0x%08llx:0x%08llx outside parent resource 0x%08llx:0x%08llx\n",
+ __func__,
+ (unsigned long long)start,
+ (unsigned long long)end,
+ (unsigned long long)parent->start,
+ (unsigned long long)parent->end);
return NULL;
}
@@ -64,13 +70,19 @@ struct resource *request_region(struct resource *parent,
goto ok;
if (start > r->end)
continue;
- debug("%s: 0x%08x:0x%08x conflicts with 0x%08x:0x%08x\n",
- __func__, start, end, r->start, r->end);
+ debug("%s: 0x%08llx:0x%08llx conflicts with 0x%08llx:0x%08llx\n",
+ __func__,
+ (unsigned long long)start,
+ (unsigned long long)end,
+ (unsigned long long)r->start,
+ (unsigned long long)r->end);
return NULL;
}
ok:
- debug("%s ok: 0x%08x:0x%08x\n", __func__, start, end);
+ debug("%s ok: 0x%08llx:0x%08llx\n", __func__,
+ (unsigned long long)start,
+ (unsigned long long)end);
new = xzalloc(sizeof(*new));
init_resource(new, name);
diff --git a/common/uimage.c b/common/uimage.c
index 1ac0b7d..06f97f0 100644
--- a/common/uimage.c
+++ b/common/uimage.c
@@ -440,8 +440,9 @@ struct resource *uimage_load_to_sdram(struct uimage_handle *handle,
uimage_resource = request_sdram_region("uimage",
start, size);
if (!uimage_resource) {
- printf("unable to request SDRAM 0x%08x-0x%08x\n",
- start, start + size - 1);
+ printf("unable to request SDRAM 0x%08llx-0x%08llx\n",
+ (unsigned long long)start,
+ (unsigned long long)start + size - 1);
return NULL;
}
diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c
index ed644d1..b5b3665 100644
--- a/drivers/mci/mxs.c
+++ b/drivers/mci/mxs.c
@@ -724,7 +724,7 @@ static int mxs_mci_probe(struct device_d *hw_dev)
mxs_mci->index = 3;
break;
default:
- pr_debug("Unknown SSP unit at address 0x%08x\n", mxs_mci->regs);
+ pr_debug("Unknown SSP unit at address 0x%p\n", mxs_mci->regs);
return 0;
}
#endif
diff --git a/drivers/nor/cfi_flash.c b/drivers/nor/cfi_flash.c
index 6154940..637f98b 100644
--- a/drivers/nor/cfi_flash.c
+++ b/drivers/nor/cfi_flash.c
@@ -461,7 +461,7 @@ static int __cfi_erase(struct cdev *cdev, size_t count, loff_t offset,
unsigned long start, end;
int i, ret = 0;
- debug("%s: erase 0x%08lx (size %d)\n", __func__, offset, count);
+ debug("%s: erase 0x%08llx (size %zu)\n", __func__, offset, count);
start = find_sector(finfo, (unsigned long)finfo->base + offset);
end = find_sector(finfo, (unsigned long)finfo->base + offset +
@@ -633,7 +633,7 @@ static int cfi_protect(struct cdev *cdev, size_t count, loff_t offset, int prot)
int i, ret = 0;
const char *action = (prot? "protect" : "unprotect");
- printf("%s: %s 0x%p (size %d)\n", __func__,
+ printf("%s: %s 0x%p (size %zu)\n", __func__,
action, finfo->base + offset, count);
start = find_sector(finfo, (unsigned long)finfo->base + offset);
@@ -654,7 +654,8 @@ static ssize_t cfi_write(struct cdev *cdev, const void *buf, size_t count, loff_
struct flash_info *finfo = (struct flash_info *)cdev->priv;
int ret;
- debug("cfi_write: buf=0x%p addr=0x%08lx count=0x%08x\n",buf, finfo->base + offset, count);
+ debug("cfi_write: buf=0x%p addr=0x%p count=0x%08zx\n",
+ buf, finfo->base + offset, count);
ret = write_buff(finfo, buf, (unsigned long)finfo->base + offset, count);
return ret == 0 ? count : -1;
@@ -840,7 +841,10 @@ void flash_write_cmd(struct flash_info *info, flash_sect_t sect,
addr = flash_make_addr (info, sect, offset);
flash_make_cmd (info, cmd, &cword);
- debug("%s: %p %lX %X => %p %llX\n", __FUNCTION__, info, sect, offset, addr, cword);
+
+ debug("%s: %p %lX %X => %p " CFI_WORD_FMT "\n", __func__,
+ info, sect, offset, addr, cword);
+
flash_write_word(info, cword, addr);
}
@@ -862,7 +866,7 @@ int flash_isequal(struct flash_info *info, flash_sect_t sect,
debug ("is= %4.4x %4.4x\n", flash_read16(addr), (u16)cword);
retval = (flash_read16(addr) == cword);
} else if (bankwidth_is_4(info)) {
- debug ("is= %8.8lx %8.8lx\n", flash_read32(addr), (u32)cword);
+ debug ("is= %8.8x %8.8x\n", flash_read32(addr), (u32)cword);
retval = (flash_read32(addr) == cword);
} else if (bankwidth_is_8(info)) {
#ifdef DEBUG
diff --git a/drivers/nor/cfi_flash.h b/drivers/nor/cfi_flash.h
index 8f818ba..944cdde 100644
--- a/drivers/nor/cfi_flash.h
+++ b/drivers/nor/cfi_flash.h
@@ -29,12 +29,16 @@ typedef unsigned long flash_sect_t;
#if defined(CONFIG_DRIVER_CFI_BANK_WIDTH_8)
typedef u64 cfiword_t;
+#define CFI_WORD_FMT "0x%016llx"
#elif defined(CONFIG_DRIVER_CFI_BANK_WIDTH_4)
typedef u32 cfiword_t;
+#define CFI_WORD_FMT "0x%08x"
#elif defined(CONFIG_DRIVER_CFI_BANK_WIDTH_2)
typedef u16 cfiword_t;
+#define CFI_WORD_FMT "0x%04x"
#else
typedef u8 cfiword_t;
+#define CFI_WORD_FMT "0x%02x"
#endif
struct cfi_cmd_set;
diff --git a/fs/tftp.c b/fs/tftp.c
index 98cbb37..b40353b 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -512,7 +512,7 @@ static int tftp_write(struct device_d *_dev, FILE *f, const void *inbuf,
size_t size, now;
int ret;
- debug("%s: %d\n", __func__, insize);
+ debug("%s: %zu\n", __func__, insize);
size = insize;
@@ -547,7 +547,7 @@ static int tftp_read(struct device_d *dev, FILE *f, void *buf, size_t insize)
size_t outsize = 0, now;
int ret;
- debug("%s %d\n", __func__, insize);
+ debug("%s %zu\n", __func__, insize);
tftp_timer_reset(priv);
diff --git a/lib/gui/bmp.c b/lib/gui/bmp.c
index fce0e69..6bf8cd0 100644
--- a/lib/gui/bmp.c
+++ b/lib/gui/bmp.c
@@ -24,7 +24,7 @@ struct image *bmp_open(char *inbuf, int insize)
img->bits_per_pixel = le16_to_cpu(bmp->header.bit_count);
pr_debug("bmp: %d x %d x %d data@0x%p\n", img->width, img->height,
- img->bit_per_pixel, img->data);
+ img->bits_per_pixel, img->data);
return img;
}
diff --git a/lib/xfuncs.c b/lib/xfuncs.c
index 4649280..db85720 100644
--- a/lib/xfuncs.c
+++ b/lib/xfuncs.c
@@ -30,7 +30,7 @@ void *xmalloc(size_t size)
if (!(p = malloc(size)))
panic("ERROR: out of memory\n");
- debug("xmalloc %p (size %d)\n", p, size);
+ debug("xmalloc %p (size %zu)\n", p, size);
return p;
}
@@ -43,7 +43,7 @@ void *xrealloc(void *ptr, size_t size)
if (!(p = realloc(ptr, size)))
panic("ERROR: out of memory\n");
- debug("xrealloc %p -> %p (size %d)\n", ptr, p, size);
+ debug("xrealloc %p -> %p (size %zu)\n", ptr, p, size);
return p;
}
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 04/12] nios2: Let readl return an unsigned int
2013-01-29 8:45 [PATCH] introduce compiletime loglevel Sascha Hauer
` (2 preceding siblings ...)
2013-01-29 8:45 ` [PATCH 03/12] treewide: fix format specifiers Sascha Hauer
@ 2013-01-29 8:45 ` Sascha Hauer
2013-01-29 8:45 ` [PATCH 05/12] nios2: Use unsigned long for __kernel_size_t Sascha Hauer
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2013-01-29 8:45 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/nios2/include/asm/io.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/nios2/include/asm/io.h b/arch/nios2/include/asm/io.h
index a88f0e2..8ee48e0 100644
--- a/arch/nios2/include/asm/io.h
+++ b/arch/nios2/include/asm/io.h
@@ -37,7 +37,7 @@
({unsigned short val;\
asm volatile("ldhio %0, 0(%1)" : "=r"(val) : "r" (addr)); val; })
#define readl(addr)\
- ({unsigned long val;\
+ ({unsigned int val;\
asm volatile("ldwio %0, 0(%1)" : "=r"(val) : "r" (addr)); val; })
#define writeb(val, addr)\
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 05/12] nios2: Use unsigned long for __kernel_size_t
2013-01-29 8:45 [PATCH] introduce compiletime loglevel Sascha Hauer
` (3 preceding siblings ...)
2013-01-29 8:45 ` [PATCH 04/12] nios2: Let readl return an unsigned int Sascha Hauer
@ 2013-01-29 8:45 ` Sascha Hauer
2013-01-29 8:45 ` [PATCH 06/12] blackfin: " Sascha Hauer
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2013-01-29 8:45 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/nios2/include/asm/posix_types.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/nios2/include/asm/posix_types.h b/arch/nios2/include/asm/posix_types.h
index 12906b3..5a901ff 100644
--- a/arch/nios2/include/asm/posix_types.h
+++ b/arch/nios2/include/asm/posix_types.h
@@ -27,7 +27,7 @@ typedef int __kernel_pid_t;
typedef unsigned short __kernel_ipc_pid_t;
typedef unsigned short __kernel_uid_t;
typedef unsigned short __kernel_gid_t;
-typedef unsigned int __kernel_size_t;
+typedef unsigned long __kernel_size_t;
typedef int __kernel_ssize_t;
typedef int __kernel_ptrdiff_t;
typedef long __kernel_time_t;
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 06/12] blackfin: Use unsigned long for __kernel_size_t
2013-01-29 8:45 [PATCH] introduce compiletime loglevel Sascha Hauer
` (4 preceding siblings ...)
2013-01-29 8:45 ` [PATCH 05/12] nios2: Use unsigned long for __kernel_size_t Sascha Hauer
@ 2013-01-29 8:45 ` Sascha Hauer
2013-01-29 8:45 ` [PATCH 07/12] USB ehci: Use dev_* for messages Sascha Hauer
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2013-01-29 8:45 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/blackfin/include/asm/posix_types.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/blackfin/include/asm/posix_types.h b/arch/blackfin/include/asm/posix_types.h
index b1bf245..9992929 100644
--- a/arch/blackfin/include/asm/posix_types.h
+++ b/arch/blackfin/include/asm/posix_types.h
@@ -38,7 +38,7 @@ typedef int __kernel_pid_t;
typedef unsigned short __kernel_ipc_pid_t;
typedef unsigned short __kernel_uid_t;
typedef unsigned short __kernel_gid_t;
-typedef unsigned int __kernel_size_t;
+typedef unsigned long __kernel_size_t;
typedef int __kernel_ssize_t;
typedef int __kernel_ptrdiff_t;
typedef long __kernel_time_t;
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 07/12] USB ehci: Use dev_* for messages
2013-01-29 8:45 [PATCH] introduce compiletime loglevel Sascha Hauer
` (5 preceding siblings ...)
2013-01-29 8:45 ` [PATCH 06/12] blackfin: " Sascha Hauer
@ 2013-01-29 8:45 ` Sascha Hauer
2013-01-29 8:45 ` [PATCH 08/12] introduce compile time loglevel Sascha Hauer
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2013-01-29 8:45 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/usb/host/ehci-hcd.c | 73 +++++++++++++++++++++++--------------------
1 file changed, 39 insertions(+), 34 deletions(-)
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index ad8cf2f..9cce6b6 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -148,7 +148,7 @@ static int ehci_reset(struct ehci_priv *ehci)
ehci_writel(&ehci->hcor->or_usbcmd, cmd);
ret = handshake(&ehci->hcor->or_usbcmd, CMD_RESET, 0, 250 * 1000);
if (ret < 0) {
- printf("EHCI fail to reset\n");
+ dev_err(ehci->dev, "fail to reset\n");
goto out;
}
@@ -187,7 +187,7 @@ static int ehci_td_buffer(struct qTD *td, void *buf, size_t sz)
}
if (idx == 5) {
- debug("out of buffer pointers (%u bytes left)\n", sz);
+ pr_debug("out of buffer pointers (%u bytes left)\n", sz);
return -1;
}
@@ -210,10 +210,10 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
int ret = 0, i;
uint64_t start, timeout_val;
- debug("dev=%p, pipe=%lx, buffer=%p, length=%d, req=%p\n", dev, pipe,
+ dev_dbg(ehci->dev, "pipe=%lx, buffer=%p, length=%d, req=%p\n", pipe,
buffer, length, req);
if (req != NULL)
- debug("req=%u (%#x), type=%u (%#x), value=%u (%#x), index=%u\n",
+ dev_dbg(ehci->dev, "(req=%u (%#x), type=%u (%#x), value=%u (%#x), index=%u\n",
req->request, req->request,
req->requesttype, req->requesttype,
le16_to_cpu(req->value), le16_to_cpu(req->value),
@@ -258,7 +258,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
(0 << 15) | (0 << 12) | (3 << 10) | (2 << 8) | (0x80 << 0);
td->qt_token = cpu_to_hc32(token);
if (ehci_td_buffer(td, req, sizeof(*req)) != 0) {
- debug("unable construct SETUP td\n");
+ dev_dbg(ehci->dev, "unable construct SETUP td\n");
goto fail;
}
*tdp = cpu_to_hc32((uint32_t) td);
@@ -280,7 +280,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
((usb_pipein(pipe) ? 1 : 0) << 8) | (0x80 << 0);
td->qt_token = cpu_to_hc32(token);
if (ehci_td_buffer(td, buffer, length) != 0) {
- printf("unable construct DATA td\n");
+ dev_err(ehci->dev, "unable construct DATA td\n");
goto fail;
}
*tdp = cpu_to_hc32((uint32_t) td);
@@ -325,7 +325,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
ret = handshake(&ehci->hcor->or_usbsts, STD_ASS, STD_ASS, 100 * 1000);
if (ret < 0) {
- printf("EHCI fail timeout STD_ASS set\n");
+ dev_err(ehci->dev, "fail timeout STD_ASS set\n");
goto fail;
}
@@ -364,7 +364,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
ret = handshake(&ehci->hcor->or_usbsts, STD_ASS, 0,
100 * 1000);
if (ret < 0) {
- printf("EHCI fail timeout STD_ASS reset\n");
+ dev_err(ehci->dev, "fail timeout STD_ASS reset\n");
goto fail;
}
@@ -372,7 +372,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
token = hc32_to_cpu(qh->qt_token);
if (!(token & 0x80)) {
- debug("TOKEN=0x%08x\n", token);
+ dev_dbg(ehci->dev, "TOKEN=0x%08x\n", token);
switch (token & 0xfc) {
case 0:
toggle = token >> 31;
@@ -398,7 +398,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
dev->act_len = length - ((token >> 16) & 0x7fff);
} else {
dev->act_len = 0;
- debug("dev=%u, usbsts=%#x, p[1]=%#x, p[2]=%#x\n",
+ dev_dbg(ehci->dev, "dev=%u, usbsts=%#x, p[1]=%#x, p[2]=%#x\n",
dev->devnum, ehci_readl(&ehci->hcor->or_usbsts),
ehci_readl(&ehci->hcor->or_portsc[0]),
ehci_readl(&ehci->hcor->or_portsc[1]));
@@ -407,7 +407,7 @@ ehci_submit_async(struct usb_device *dev, unsigned long pipe, void *buffer,
return (dev->status != USB_ST_NOT_PROC) ? 0 : -1;
fail:
- printf("fail1\n");
+ dev_err(ehci->dev, "fail1\n");
td = (void *)hc32_to_cpu(qh->qt_next);
while (td != (void *)QT_NEXT_TERMINATE) {
qh->qt_next = td->qt_next;
@@ -461,14 +461,14 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
uint32_t *status_reg;
if (le16_to_cpu(req->index) >= CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS) {
- printf("The request port(%d) is not configured\n",
+ dev_err(ehci->dev, "The request port(%d) is not configured\n",
le16_to_cpu(req->index) - 1);
return -1;
}
status_reg = (uint32_t *)&ehci->hcor->or_portsc[le16_to_cpu(req->index) - 1];
srclen = 0;
- debug("req=%u (%#x), type=%u (%#x), value=%u, index=%u\n",
+ dev_dbg(ehci->dev, "req=%u (%#x), type=%u (%#x), value=%u, index=%u\n",
req->request, req->request,
req->requesttype, req->requesttype,
le16_to_cpu(req->value), le16_to_cpu(req->index));
@@ -479,17 +479,17 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
switch (le16_to_cpu(req->value) >> 8) {
case USB_DT_DEVICE:
- debug("USB_DT_DEVICE request\n");
+ dev_dbg(ehci->dev, "USB_DT_DEVICE request\n");
srcptr = &descriptor.device;
srclen = 0x12;
break;
case USB_DT_CONFIG:
- debug("USB_DT_CONFIG config\n");
+ dev_dbg(ehci->dev, "USB_DT_CONFIG config\n");
srcptr = &descriptor.config;
srclen = 0x19;
break;
case USB_DT_STRING:
- debug("USB_DT_STRING config\n");
+ dev_dbg(ehci->dev, "USB_DT_STRING config\n");
switch (le16_to_cpu(req->value) & 0xff) {
case 0: /* Language */
srcptr = "\4\3\1\0";
@@ -506,34 +506,34 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
srclen = 42;
break;
default:
- debug("unknown value DT_STRING %x\n",
+ dev_dbg(ehci->dev, "unknown value DT_STRING %x\n",
le16_to_cpu(req->value));
goto unknown;
}
break;
default:
- debug("unknown value %x\n", le16_to_cpu(req->value));
+ dev_dbg(ehci->dev, "unknown value %x\n", le16_to_cpu(req->value));
goto unknown;
}
break;
case ((USB_DIR_IN | USB_RT_HUB) << 8) | USB_REQ_GET_DESCRIPTOR:
switch (le16_to_cpu(req->value) >> 8) {
case USB_DT_HUB:
- debug("USB_DT_HUB config\n");
+ dev_dbg(ehci->dev, "USB_DT_HUB config\n");
srcptr = &descriptor.hub;
srclen = 0x8;
break;
default:
- debug("unknown value %x\n", le16_to_cpu(req->value));
+ dev_dbg(ehci->dev, "unknown value %x\n", le16_to_cpu(req->value));
goto unknown;
}
break;
case USB_REQ_SET_ADDRESS | (USB_RECIP_DEVICE << 8):
- debug("USB_REQ_SET_ADDRESS\n");
+ dev_dbg(ehci->dev, "USB_REQ_SET_ADDRESS\n");
ehci->rootdev = le16_to_cpu(req->value);
break;
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
- debug("USB_REQ_SET_CONFIGURATION\n");
+ dev_dbg(ehci->dev, "USB_REQ_SET_CONFIGURATION\n");
/* Nothing to do */
break;
case USB_REQ_GET_STATUS | ((USB_DIR_IN | USB_RT_HUB) << 8):
@@ -563,7 +563,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
if (!ret)
tmpbuf[0] |= USB_PORT_STAT_RESET;
else
- printf("port(%d) reset error\n",
+ dev_err(ehci->dev, "port(%d) reset error\n",
le16_to_cpu(req->index) - 1);
}
if (reg & EHCI_PS_PP)
@@ -616,7 +616,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
!ehci_is_TDI() &&
EHCI_PS_IS_LOWSPEED(reg)) {
/* Low speed device, give up ownership. */
- debug("port %d low speed --> companion\n",
+ dev_dbg(ehci->dev, "port %d low speed --> companion\n",
req->index - 1);
reg |= EHCI_PS_PO;
ehci_writel(status_reg, reg);
@@ -648,13 +648,13 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
ehci->portreset |=
1 << le16_to_cpu(req->index);
else
- printf("port(%d) reset error\n",
+ dev_err(ehci->dev, "port(%d) reset error\n",
le16_to_cpu(req->index) - 1);
}
break;
default:
- debug("unknown feature %x\n", le16_to_cpu(req->value));
+ dev_dbg(ehci->dev, "unknown feature %x\n", le16_to_cpu(req->value));
goto unknown;
}
/* unblock posted writes */
@@ -682,7 +682,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
ehci->portreset &= ~(1 << le16_to_cpu(req->index));
break;
default:
- debug("unknown feature %x\n", le16_to_cpu(req->value));
+ dev_dbg(ehci->dev, "unknown feature %x\n", le16_to_cpu(req->value));
goto unknown;
}
ehci_writel(status_reg, reg);
@@ -690,7 +690,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
(void) ehci_readl(&ehci->hcor->or_usbcmd);
break;
default:
- debug("Unknown request\n");
+ dev_dbg(ehci->dev, "Unknown request\n");
goto unknown;
}
@@ -699,14 +699,14 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
if (srcptr != NULL && len > 0)
memcpy(buffer, srcptr, len);
else
- debug("Len is 0\n");
+ dev_dbg(ehci->dev, "Len is 0\n");
dev->act_len = len;
dev->status = 0;
return 0;
unknown:
- debug("requesttype=%x, request=%x, value=%x, index=%x, length=%x\n",
+ dev_dbg(ehci->dev, "requesttype=%x, request=%x, value=%x, index=%x, length=%x\n",
req->requesttype, req->request, le16_to_cpu(req->value),
le16_to_cpu(req->index), le16_to_cpu(req->length));
@@ -793,9 +793,11 @@ static int
submit_bulk_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
int length, int timeout)
{
+ struct usb_host *host = dev->host;
+ struct ehci_priv *ehci = to_ehci(host);
if (usb_pipetype(pipe) != PIPE_BULK) {
- debug("non-bulk pipe (type=%lu)", usb_pipetype(pipe));
+ dev_dbg(ehci->dev, "non-bulk pipe (type=%lu)", usb_pipetype(pipe));
return -1;
}
return ehci_submit_async(dev, pipe, buffer, length, NULL);
@@ -809,7 +811,7 @@ submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
struct ehci_priv *ehci = to_ehci(host);
if (usb_pipetype(pipe) != PIPE_CONTROL) {
- debug("non-control pipe (type=%lu)", usb_pipetype(pipe));
+ dev_dbg(ehci->dev, "non-control pipe (type=%lu)", usb_pipetype(pipe));
return -1;
}
@@ -825,7 +827,10 @@ static int
submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
int length, int interval)
{
- debug("dev=%p, pipe=%lu, buffer=%p, length=%d, interval=%d",
+ struct usb_host *host = dev->host;
+ struct ehci_priv *ehci = to_ehci(host);
+
+ dev_dbg(ehci->dev, "dev=%p, pipe=%lu, buffer=%p, length=%d, interval=%d",
dev, pipe, buffer, length, interval);
return -1;
}
@@ -878,7 +883,7 @@ static int ehci_probe(struct device_d *dev)
data.flags = EHCI_HAS_TT;
if (dev->num_resources < 2) {
- printf("echi: need 2 resources base and data");
+ dev_err(dev, "need 2 resources base and data");
return -ENODEV;
}
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 08/12] introduce compile time loglevel
2013-01-29 8:45 [PATCH] introduce compiletime loglevel Sascha Hauer
` (6 preceding siblings ...)
2013-01-29 8:45 ` [PATCH 07/12] USB ehci: Use dev_* for messages Sascha Hauer
@ 2013-01-29 8:45 ` Sascha Hauer
2013-01-29 8:45 ` [PATCH 09/12] introduce pr_fmt Sascha Hauer
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2013-01-29 8:45 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/Kconfig | 16 +++++++++++++
include/printk.h | 66 +++++++++++++++++++++++++++++++-----------------------
2 files changed, 54 insertions(+), 28 deletions(-)
diff --git a/common/Kconfig b/common/Kconfig
index b60b78b..30d6107 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -637,6 +637,22 @@ endmenu
menu "Debugging"
+config COMPILE_LOGLEVEL
+ int "loglevel"
+ default 6
+ help
+ This defines the maximum loglevel compiled into the binary. Less important
+ messages will be compiled away resulting in a smaller binary.
+
+ 0 system is unusable (emerg)
+ 1 action must be taken immediately (alert)
+ 2 critical conditions (crit)
+ 3 error conditions (err)
+ 4 warning conditions (warn)
+ 5 normal but significant condition (notice)
+ 6 informational (info)
+ 7 debug-level messages (debug)
+
config DEBUG_INFO
bool
prompt "enable debug symbols"
diff --git a/include/printk.h b/include/printk.h
index 9e6f4bd..82be308 100644
--- a/include/printk.h
+++ b/include/printk.h
@@ -10,49 +10,59 @@
#define MSG_INFO 6 /* informational */
#define MSG_DEBUG 7 /* debug-level messages */
+#ifdef DEBUG
+#define LOGLEVEL MSG_DEBUG
+#else
+#define LOGLEVEL CONFIG_COMPILE_LOGLEVEL
+#endif
+
/* debugging and troubleshooting/diagnostic helpers. */
int dev_printf(const struct device_d *dev, const char *format, ...)
__attribute__ ((format(__printf__, 2, 3)));
+#define __dev_printf(level, dev, format, args...) \
+ ({ \
+ int ret = 0; \
+ if (level <= LOGLEVEL) \
+ ret = dev_printf(dev, format, ##args); \
+ ret; \
+ })
+
#define dev_emerg(dev, format, arg...) \
- dev_printf((dev) , format , ## arg)
+ __dev_printf(0, (dev) , format , ## arg)
#define dev_alert(dev, format, arg...) \
- dev_printf((dev) , format , ## arg)
+ __dev_printf(1, (dev) , format , ## arg)
#define dev_crit(dev, format, arg...) \
- dev_printf((dev) , format , ## arg)
+ __dev_printf(2, (dev) , format , ## arg)
#define dev_err(dev, format, arg...) \
- dev_printf(dev , format , ## arg)
+ __dev_printf(3, (dev) , format , ## arg)
#define dev_warn(dev, format, arg...) \
- dev_printf((dev) , format , ## arg)
+ __dev_printf(4, (dev) , format , ## arg)
#define dev_notice(dev, format, arg...) \
- dev_printf((dev) , format , ## arg)
+ __dev_printf(5, (dev) , format , ## arg)
#define dev_info(dev, format, arg...) \
- dev_printf((dev) , format , ## arg)
-
-#if defined(DEBUG)
+ __dev_printf(6, (dev) , format , ## arg)
#define dev_dbg(dev, format, arg...) \
- dev_printf((dev) , format , ## arg)
-#else
-#define dev_dbg(dev, format, arg...) \
- ({ if (0) dev_printf((dev), format, ##arg); 0; })
-#endif
+ __dev_printf(7, (dev) , format , ## arg)
-#define pr_info(fmt, arg...) printk(fmt, ##arg)
-#define pr_notice(fmt, arg...) printk(fmt, ##arg)
-#define pr_err(fmt, arg...) printk(fmt, ##arg)
-#define pr_warning(fmt, arg...) printk(fmt, ##arg)
-#define pr_crit(fmt, arg...) printk(fmt, ##arg)
-#define pr_alert(fmt, arg...) printk(fmt, ##arg)
-#define pr_emerg(fmt, arg...) printk(fmt, ##arg)
+#define __pr_printk(level, format, args...) \
+ ({ \
+ int ret = 0; \
+ if (level <= LOGLEVEL) \
+ ret = printk(format, ##args); \
+ ret; \
+ })
-#ifdef DEBUG
-#define pr_debug(fmt, arg...) printk(fmt, ##arg)
-#define debug(fmt, arg...) printf(fmt, ##arg)
-#else
-#define pr_debug(fmt, arg...) do {} while(0)
-#define debug(fmt, arg...) do {} while(0)
-#endif
+#define pr_emerg(fmt, arg...) __pr_printk(0, fmt, ##arg)
+#define pr_alert(fmt, arg...) __pr_printk(1, fmt, ##arg)
+#define pr_crit(fmt, arg...) __pr_printk(2, fmt, ##arg)
+#define pr_warning(fmt, arg...) __pr_printk(3, fmt, ##arg)
+#define pr_err(fmt, arg...) __pr_printk(4, fmt, ##arg)
+#define pr_notice(fmt, arg...) __pr_printk(5, fmt, ##arg)
+#define pr_info(fmt, arg...) __pr_printk(6, fmt, ##arg)
+#define pr_debug(fmt, arg...) __pr_printk(7, fmt, ##arg)
+#define debug(fmt, arg...) __pr_printk(7, fmt, ##arg)
#endif
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 09/12] introduce pr_fmt
2013-01-29 8:45 [PATCH] introduce compiletime loglevel Sascha Hauer
` (7 preceding siblings ...)
2013-01-29 8:45 ` [PATCH 08/12] introduce compile time loglevel Sascha Hauer
@ 2013-01-29 8:45 ` Sascha Hauer
2013-01-29 8:45 ` [PATCH 10/12] ARM mmu: Use pr_debug Sascha Hauer
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2013-01-29 8:45 UTC (permalink / raw)
To: barebox
With this the files can give more context to their pr_* messages by
specifying a
at the beginning of the files. Basically the same mechanism as in the
Kernel.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
include/printk.h | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/include/printk.h b/include/printk.h
index 82be308..1d45616 100644
--- a/include/printk.h
+++ b/include/printk.h
@@ -55,14 +55,18 @@ int dev_printf(const struct device_d *dev, const char *format, ...)
ret; \
})
-#define pr_emerg(fmt, arg...) __pr_printk(0, fmt, ##arg)
-#define pr_alert(fmt, arg...) __pr_printk(1, fmt, ##arg)
-#define pr_crit(fmt, arg...) __pr_printk(2, fmt, ##arg)
-#define pr_warning(fmt, arg...) __pr_printk(3, fmt, ##arg)
-#define pr_err(fmt, arg...) __pr_printk(4, fmt, ##arg)
-#define pr_notice(fmt, arg...) __pr_printk(5, fmt, ##arg)
-#define pr_info(fmt, arg...) __pr_printk(6, fmt, ##arg)
-#define pr_debug(fmt, arg...) __pr_printk(7, fmt, ##arg)
-#define debug(fmt, arg...) __pr_printk(7, fmt, ##arg)
+#ifndef pr_fmt
+#define pr_fmt(fmt) fmt
+#endif
+
+#define pr_emerg(fmt, arg...) __pr_printk(0, pr_fmt(fmt), ##arg)
+#define pr_alert(fmt, arg...) __pr_printk(1, pr_fmt(fmt), ##arg)
+#define pr_crit(fmt, arg...) __pr_printk(2, pr_fmt(fmt), ##arg)
+#define pr_warning(fmt, arg...) __pr_printk(3, pr_fmt(fmt), ##arg)
+#define pr_err(fmt, arg...) __pr_printk(4, pr_fmt(fmt), ##arg)
+#define pr_notice(fmt, arg...) __pr_printk(5, pr_fmt(fmt), ##arg)
+#define pr_info(fmt, arg...) __pr_printk(6, pr_fmt(fmt), ##arg)
+#define pr_debug(fmt, arg...) __pr_printk(7, pr_fmt(fmt), ##arg)
+#define debug(fmt, arg...) __pr_printk(7, pr_fmt(fmt), ##arg)
#endif
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 10/12] ARM mmu: Use pr_debug
2013-01-29 8:45 [PATCH] introduce compiletime loglevel Sascha Hauer
` (8 preceding siblings ...)
2013-01-29 8:45 ` [PATCH 09/12] introduce pr_fmt Sascha Hauer
@ 2013-01-29 8:45 ` Sascha Hauer
2013-01-29 8:45 ` [PATCH 11/12] ARM pcm038: Specify pr_fmt and change messages to pr_* Sascha Hauer
2013-01-29 8:45 ` [PATCH 12/12] mtd nand: " Sascha Hauer
11 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2013-01-29 8:45 UTC (permalink / raw)
To: barebox
Also, specify a pr_fmt and add missing GPL header.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/cpu/mmu.c | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 40b7ec4..4b6db37 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -1,3 +1,24 @@
+/*
+ * start-pbl.c
+ *
+ * Copyright (c) 2009-2013 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#define pr_fmt(fmt) "mmu: " fmt
+
#include <common.h>
#include <init.h>
#include <asm/mmu.h>
@@ -138,7 +159,7 @@ static int arm_mmu_remap_sdram(struct memory_bank *bank)
int i, pte;
u32 *ptes;
- debug("remapping SDRAM from 0x%08lx (size 0x%08lx)\n",
+ pr_debug("remapping SDRAM from 0x%08lx (size 0x%08lx)\n",
phys, bank->size);
/*
@@ -150,7 +171,7 @@ static int arm_mmu_remap_sdram(struct memory_bank *bank)
ptes = xmemalign(PAGE_SIZE, num_ptes * sizeof(u32));
- debug("ptes: 0x%p ttb_start: 0x%08lx ttb_end: 0x%08lx\n",
+ pr_debug("ptes: 0x%p ttb_start: 0x%08lx ttb_end: 0x%08lx\n",
ptes, ttb_start, ttb_end);
for (i = 0; i < num_ptes; i++) {
@@ -242,7 +263,7 @@ static int mmu_init(void)
ttb = memalign(0x10000, 0x4000);
- debug("ttb: 0x%p\n", ttb);
+ pr_debug("ttb: 0x%p\n", ttb);
/* Set the ttb register */
asm volatile ("mcr p15,0,%0,c2,c0,0" : : "r"(ttb) /*:*/);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 11/12] ARM pcm038: Specify pr_fmt and change messages to pr_*
2013-01-29 8:45 [PATCH] introduce compiletime loglevel Sascha Hauer
` (9 preceding siblings ...)
2013-01-29 8:45 ` [PATCH 10/12] ARM mmu: Use pr_debug Sascha Hauer
@ 2013-01-29 8:45 ` Sascha Hauer
2013-01-29 8:45 ` [PATCH 12/12] mtd nand: " Sascha Hauer
11 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2013-01-29 8:45 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/boards/pcm038/pcm038.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boards/pcm038/pcm038.c b/arch/arm/boards/pcm038/pcm038.c
index ea50a78..5e9c0fd 100644
--- a/arch/arm/boards/pcm038/pcm038.c
+++ b/arch/arm/boards/pcm038/pcm038.c
@@ -13,6 +13,7 @@
*
*
*/
+#define pr_fmt(fmt) "pcm038: " fmt
#include <common.h>
#include <net.h>
@@ -170,7 +171,7 @@ static int pcm038_power_init(void)
/* Clocks have changed. Notify clients */
clock_notifier_call_chain();
} else {
- printf("Failed to initialize PMIC. Will continue with low CPU speed\n");
+ pr_err("Failed to initialize PMIC. Will continue with low CPU speed\n");
}
}
@@ -315,7 +316,7 @@ static int pcm038_devices_init(void)
envdev = "NOR";
}
- printf("Using environment in %s Flash\n", envdev);
+ pr_notice("Using environment in %s Flash\n", envdev);
if (imx_iim_read(1, 1, &uid, 6) == 6)
armlinux_set_serial(uid);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 12/12] mtd nand: Specify pr_fmt and change messages to pr_*
2013-01-29 8:45 [PATCH] introduce compiletime loglevel Sascha Hauer
` (10 preceding siblings ...)
2013-01-29 8:45 ` [PATCH 11/12] ARM pcm038: Specify pr_fmt and change messages to pr_* Sascha Hauer
@ 2013-01-29 8:45 ` Sascha Hauer
11 siblings, 0 replies; 13+ messages in thread
From: Sascha Hauer @ 2013-01-29 8:45 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/mtd/nand/nand_base.c | 39 ++++++++++++++++++++-----------------
drivers/mtd/nand/nand_bbt.c | 43 ++++++++++++++++++++++-------------------
drivers/mtd/nand/nand_write.c | 4 +++-
include/linux/mtd/mtd.h | 2 +-
4 files changed, 48 insertions(+), 40 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index fe9a6e7..411aba7 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -31,6 +31,9 @@
* published by the Free Software Foundation.
*
*/
+
+#define pr_fmt(fmt) "nand: " fmt
+
#include <common.h>
#include <errno.h>
#include <clock.h>
@@ -1074,19 +1077,19 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
chip->read_byte(mtd) != 'F' || chip->read_byte(mtd) != 'I')
return 0;
- printk(KERN_INFO "ONFI flash detected ... ");
+ pr_info("ONFI flash detected ... ");
chip->cmdfunc(mtd, NAND_CMD_PARAM, 0, -1);
for (i = 0; i < 3; i++) {
chip->read_buf(mtd, (uint8_t *)p, sizeof(*p));
if (onfi_crc16(ONFI_CRC_BASE, (uint8_t *)p, 254) ==
le16_to_cpu(p->crc)) {
- printk(KERN_INFO "ONFI param page %d valid\n", i);
+ pr_info("ONFI param page %d valid\n", i);
break;
}
}
if (i == 3) {
- printk(KERN_INFO "no valid ONFI param page found\n");
+ pr_info("no valid ONFI param page found\n");
return 0;
}
@@ -1106,7 +1109,7 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
chip->onfi_version = 0;
if (!chip->onfi_version) {
- printk(KERN_INFO "unsupported ONFI version: %d\n", val);
+ pr_info("unsupported ONFI version: %d\n", val);
return 0;
}
@@ -1170,7 +1173,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
id_data[1] = chip->read_byte(mtd);
if (id_data[0] != *maf_id || id_data[1] != dev_id) {
- printk(KERN_ERR "%s: second ID read did not match "
+ pr_err("%s: second ID read did not match "
"%02x,%02x against %02x,%02x\n", __func__,
*maf_id, dev_id, id_data[0], id_data[1]);
return ERR_PTR(-ENODEV);
@@ -1191,7 +1194,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
if (ret)
goto ident_done;
else {
- printk(KERN_ERR "NAND type unknown: %02x,%02x\n", *maf_id, dev_id);
+ pr_err("NAND type unknown: %02x,%02x\n", *maf_id, dev_id);
return ERR_PTR(-ENODEV);
}
}
@@ -1329,10 +1332,10 @@ ident_done:
* chip correct !
*/
if (busw != (chip->options & NAND_BUSWIDTH_16)) {
- printk(KERN_INFO "NAND device: Manufacturer ID:"
+ pr_info("NAND device: Manufacturer ID:"
" 0x%02x, Chip ID: 0x%02x (%s %s)\n", *maf_id,
dev_id, nand_manuf_ids[maf_idx].name, mtd->name);
- printk(KERN_WARNING "NAND bus width %d instead %d bit\n",
+ pr_warning("NAND bus width %d instead %d bit\n",
(chip->options & NAND_BUSWIDTH_16) ? 16 : 8,
busw ? 16 : 8);
return ERR_PTR(-EINVAL);
@@ -1367,7 +1370,7 @@ ident_done:
if (mtd->writesize > 512 && chip->cmdfunc == nand_command)
chip->cmdfunc = nand_command_lp;
- printk("NAND device: Manufacturer ID: 0x%02x, Chip ID: 0x%02x (%s %s),"
+ pr_notice("Manufacturer ID: 0x%02x, Chip ID: 0x%02x (%s %s),"
" page size: %d, OOB size: %d\n",
*maf_id, dev_id, nand_manuf_ids[maf_idx].name,
chip->onfi_version ? chip->onfi_params.model : type->name,
@@ -1393,7 +1396,7 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips)
struct nand_flash_dev *type;
if (chip->options & NAND_BUSWIDTH_AUTO && !chip->set_buswidth) {
- printk(KERN_ERR "buswidth detection but no buswidth callback\n");
+ pr_err("buswidth detection but no buswidth callback\n");
return -EINVAL;
}
@@ -1406,7 +1409,7 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips)
type = nand_get_flash_type(mtd, chip, busw, &nand_maf_id);
if (IS_ERR(type)) {
- printk(KERN_WARNING "No NAND device found (%ld)!\n", PTR_ERR(type));
+ pr_warning("No NAND device found (%ld)!\n", PTR_ERR(type));
chip->select_chip(mtd, -1);
return PTR_ERR(type);
}
@@ -1422,7 +1425,7 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips)
break;
}
if (i > 1)
- printk(KERN_INFO "%d NAND chips detected\n", i);
+ pr_info("%d NAND chips detected\n", i);
/* Store the number of chips and calc total size for mtd */
chip->numchips = i;
@@ -1436,13 +1439,13 @@ static void __maybe_unused nand_check_hwecc(struct mtd_info *mtd, struct nand_ch
if ((!chip->ecc.calculate || !chip->ecc.correct ||
!chip->ecc.hwctl) &&
(!chip->ecc.read_page || !chip->ecc.write_page)) {
- printk(KERN_WARNING "No ECC functions supplied, "
+ pr_warning("No ECC functions supplied, "
"Hardware ECC not possible\n");
BUG();
}
if (mtd->writesize < chip->ecc.size) {
- printk(KERN_WARNING "%d byte HW ECC not possible on "
+ pr_warning("%d byte HW ECC not possible on "
"%d byte page size\n",
chip->ecc.size, mtd->writesize);
BUG();
@@ -1486,7 +1489,7 @@ int nand_scan_tail(struct mtd_info *mtd)
chip->ecc.layout = &nand_oob_64;
break;
default:
- printk(KERN_WARNING "No oob scheme defined for "
+ pr_warning("No oob scheme defined for "
"oobsize %d\n", mtd->oobsize);
BUG();
}
@@ -1527,7 +1530,7 @@ int nand_scan_tail(struct mtd_info *mtd)
#endif
#ifdef CONFIG_NAND_ECC_NONE
case NAND_ECC_NONE:
- printk(KERN_WARNING "NAND_ECC_NONE selected by board driver. "
+ pr_warning("NAND_ECC_NONE selected by board driver. "
"This is not recommended !!\n");
chip->ecc.read_page = nand_read_page_raw;
#ifdef CONFIG_MTD_WRITE
@@ -1540,7 +1543,7 @@ int nand_scan_tail(struct mtd_info *mtd)
break;
#endif
default:
- printk(KERN_WARNING "Invalid NAND_ECC_MODE %d\n",
+ pr_warning("Invalid NAND_ECC_MODE %d\n",
chip->ecc.mode);
BUG();
}
@@ -1561,7 +1564,7 @@ int nand_scan_tail(struct mtd_info *mtd)
*/
chip->ecc.steps = mtd->writesize / chip->ecc.size;
if(chip->ecc.steps * chip->ecc.size != mtd->writesize) {
- printk(KERN_WARNING "Invalid ecc parameters\n");
+ pr_warning("Invalid ecc parameters\n");
BUG();
}
chip->ecc.total = chip->ecc.steps * chip->ecc.bytes;
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index 3cbf886..f7ae7cd 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -51,6 +51,9 @@
* - the space necessary for a bbt in FLASH does not exceed a block boundary
*
*/
+
+#define pr_fmt(fmt) "nand: " fmt
+
#include <common.h>
#include <linux/types.h>
#include <linux/mtd/mtd.h>
@@ -160,10 +163,10 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
res = mtd->read(mtd, from, len, &retlen, buf);
if (res < 0) {
if (retlen != len) {
- printk(KERN_INFO "nand_bbt: Error reading bad block table\n");
+ pr_info("nand_bbt: Error reading bad block table\n");
return res;
}
- printk(KERN_WARNING "nand_bbt: ECC error while reading bad block table\n");
+ pr_warning("nand_bbt: ECC error while reading bad block table\n");
}
/* Analyse data */
@@ -174,7 +177,7 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
if (tmp == msk)
continue;
if (reserved_block_code && (tmp == reserved_block_code)) {
- printk(KERN_DEBUG "nand_read_bbt: Reserved block at 0x%08x\n",
+ pr_debug("nand_read_bbt: Reserved block at 0x%08x\n",
((offs << 2) + (act >> 1)) << this->bbt_erase_shift);
this->bbt[offs + (act >> 3)] |= 0x2 << (act & 0x06);
mtd->ecc_stats.bbtblocks++;
@@ -182,7 +185,7 @@ static int read_bbt(struct mtd_info *mtd, uint8_t *buf, int page, int num,
}
/* Leave it for now, if its matured we can move this
* message to MTD_DEBUG_LEVEL0 */
- printk(KERN_DEBUG "nand_read_bbt: Bad block at 0x%08x\n",
+ pr_debug("nand_read_bbt: Bad block at 0x%08x\n",
((offs << 2) + (act >> 1)) << this->bbt_erase_shift);
/* Factory marked bad or worn out ? */
if (tmp == 0)
@@ -292,7 +295,7 @@ static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf,
scan_read_raw(mtd, buf, td->pages[0] << this->page_shift,
mtd->writesize);
td->version[0] = buf[mtd->writesize + td->veroffs];
- printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n",
+ pr_debug("Bad block table at page %d, version 0x%02X\n",
td->pages[0], td->version[0]);
}
@@ -301,7 +304,7 @@ static int read_abs_bbts(struct mtd_info *mtd, uint8_t *buf,
scan_read_raw(mtd, buf, md->pages[0] << this->page_shift,
mtd->writesize);
md->version[0] = buf[mtd->writesize + md->veroffs];
- printk(KERN_DEBUG "Bad block table at page %d, version 0x%02X\n",
+ pr_debug("Bad block table at page %d, version 0x%02X\n",
md->pages[0], md->version[0]);
}
return 1;
@@ -380,7 +383,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
loff_t from;
size_t readlen;
- printk(KERN_INFO "Scanning device for bad blocks\n");
+ pr_info("Scanning device for bad blocks\n");
if (bd->options & NAND_BBT_SCANALLPAGES)
len = 1 << (this->bbt_erase_shift - this->page_shift);
@@ -409,7 +412,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
from = 0;
} else {
if (chip >= this->numchips) {
- printk(KERN_WARNING "create_bbt(): chipnr (%d) > available chips (%d)\n",
+ pr_warning("create_bbt(): chipnr (%d) > available chips (%d)\n",
chip + 1, this->numchips);
return -EINVAL;
}
@@ -433,7 +436,7 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf,
if (ret) {
this->bbt[i >> 3] |= 0x03 << (i & 0x6);
- printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n",
+ pr_warning("Bad eraseblock %d at 0x%08x\n",
i >> 1, (unsigned int)from);
mtd->ecc_stats.badblocks++;
}
@@ -517,9 +520,9 @@ static int search_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
/* Check, if we found a bbt for each requested chip */
for (i = 0; i < chips; i++) {
if (td->pages[i] == -1)
- printk(KERN_WARNING "Bad block table not found for chip %d\n", i);
+ pr_warning("Bad block table not found for chip %d\n", i);
else
- printk(KERN_DEBUG "Bad block table found at page %d, version 0x%02X\n", td->pages[i],
+ pr_debug("Bad block table found at page %d, version 0x%02X\n", td->pages[i],
td->version[i]);
}
return 0;
@@ -634,7 +637,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
if (!md || md->pages[chip] != page)
goto write;
}
- printk(KERN_ERR "No space left to write bad block table\n");
+ pr_err("No space left to write bad block table\n");
return -ENOSPC;
write:
@@ -669,12 +672,12 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
res = mtd->read(mtd, to, len, &retlen, buf);
if (res < 0) {
if (retlen != len) {
- printk(KERN_INFO "nand_bbt: Error "
+ pr_info("nand_bbt: Error "
"reading block for writing "
"the bad block table\n");
return res;
}
- printk(KERN_WARNING "nand_bbt: ECC error "
+ pr_warning("nand_bbt: ECC error "
"while reading block for writing "
"bad block table\n");
}
@@ -735,7 +738,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
if (res < 0)
goto outerr;
- printk(KERN_DEBUG "Bad block table written to 0x%08x, version "
+ pr_debug("Bad block table written to 0x%08x, version "
"0x%02X\n", (unsigned int)to, td->version[chip]);
/* Mark it as used */
@@ -744,7 +747,7 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf,
return 0;
outerr:
- printk(KERN_WARNING
+ pr_warning(
"nand_bbt: Error while writing bad block table %d\n", res);
return res;
}
@@ -975,7 +978,7 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
/* Allocate memory (2bit per block) and clear the memory bad block table */
this->bbt = kzalloc(len, GFP_KERNEL);
if (!this->bbt) {
- printk(KERN_ERR "nand_scan_bbt: Out of memory\n");
+ pr_err("nand_scan_bbt: Out of memory\n");
return -ENOMEM;
}
@@ -984,7 +987,7 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
*/
if (!td) {
if ((res = nand_memory_bbt(mtd, bd))) {
- printk(KERN_ERR "nand_bbt: Can't scan flash and build the RAM-based BBT\n");
+ pr_err("nand_bbt: Can't scan flash and build the RAM-based BBT\n");
kfree(this->bbt);
this->bbt = NULL;
}
@@ -996,7 +999,7 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
len += (len >> this->page_shift) * mtd->oobsize;
buf = vmalloc(len);
if (!buf) {
- printk(KERN_ERR "nand_bbt: Out of memory\n");
+ pr_err("nand_bbt: Out of memory\n");
kfree(this->bbt);
this->bbt = NULL;
return -ENOMEM;
@@ -1047,7 +1050,7 @@ int nand_update_bbt(struct mtd_info *mtd, loff_t offs)
len += (len >> this->page_shift) * mtd->oobsize;
buf = kmalloc(len, GFP_KERNEL);
if (!buf) {
- printk(KERN_ERR "nand_update_bbt: Out of memory\n");
+ pr_err("nand_update_bbt: Out of memory\n");
return -ENOMEM;
}
diff --git a/drivers/mtd/nand/nand_write.c b/drivers/mtd/nand/nand_write.c
index 9997127..d68df33 100644
--- a/drivers/mtd/nand/nand_write.c
+++ b/drivers/mtd/nand/nand_write.c
@@ -1,3 +1,5 @@
+#define pr_fmt(fmt) "nand: " fmt
+
#include <common.h>
#include <errno.h>
#include <clock.h>
@@ -624,7 +626,7 @@ int nand_erase_nand(struct mtd_info *mtd, struct erase_info *instr,
*/
if (nand_block_checkbad(mtd, ((loff_t) page) <<
chip->page_shift, 0, allowbbt)) {
- printk(KERN_WARNING "nand_erase: attempt to erase a "
+ pr_warn("nand_erase: attempt to erase a "
"bad block at page 0x%08x\n", page);
instr->state = MTD_ERASE_FAILED;
goto erase_exit;
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index be8ad71..cb8b3bc 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -265,7 +265,7 @@ int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs);
#define MTD_DEBUG(n, args...) \
do { \
if (n <= CONFIG_MTD_DEBUG_VERBOSE) \
- printk(KERN_INFO args); \
+ pr_info( args); \
} while(0)
#else /* CONFIG_MTD_DEBUG */
#define MTD_DEBUG(n, args...) do { } while(0)
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 13+ messages in thread