[PATCH 1/2] mtd: nand: generalized error messages with __func__

Igor Grinberg grinberg at compulab.co.il
Thu May 26 01:14:05 EDT 2011


On 05/26/11 00:59, Brian Norris wrote:

> These simple printk error messages can be a little simpler to maintain
> when they use the __func__ identifier.

While this is a good thing you are doing, I'd suggest using pr_err macro
and may be even pr_fmt.

pr_err() will save you from the need to define the log level each time.
pr_fmt will save you the need to add %s: and __func__.

> Signed-off-by: Brian Norris <computersforpeace at gmail.com>
> ---
>  drivers/mtd/nand/nand_bbt.c  |    8 ++++----
>  drivers/mtd/nand/rtc_from4.c |    2 +-
>  2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
> index ccbeaa1..7936a6c 100644
> --- a/drivers/mtd/nand/nand_bbt.c
> +++ b/drivers/mtd/nand/nand_bbt.c
> @@ -1164,7 +1164,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");
> +		printk(KERN_ERR "%s: Out of memory\n", __func__);
>  		return -ENOMEM;
>  	}
>  
> @@ -1187,7 +1187,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");
> +		printk(KERN_ERR "%s: Out of memory\n", __func__);
>  		kfree(this->bbt);
>  		this->bbt = NULL;
>  		return -ENOMEM;
> @@ -1237,7 +1237,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");
> +		printk(KERN_ERR "%s: Out of memory\n", __func__);
>  		return -ENOMEM;
>  	}
>  
> @@ -1351,7 +1351,7 @@ static int nand_create_default_bbt_descr(struct nand_chip *this)
>  	}
>  	bd = kzalloc(sizeof(*bd), GFP_KERNEL);
>  	if (!bd) {
> -		printk(KERN_ERR "nand_create_default_bbt_descr: Out of memory\n");
> +		printk(KERN_ERR "%s: Out of memory\n", __func__);
>  		return -ENOMEM;
>  	}
>  	bd->options = this->options & BBT_SCAN_OPTIONS;
> diff --git a/drivers/mtd/nand/rtc_from4.c b/drivers/mtd/nand/rtc_from4.c
> index c9f9127..7e02c94 100644
> --- a/drivers/mtd/nand/rtc_from4.c
> +++ b/drivers/mtd/nand/rtc_from4.c
> @@ -444,7 +444,7 @@ static int rtc_from4_errstat(struct mtd_info *mtd, struct nand_chip *this,
>  		len = mtd->writesize;
>  		buf = kmalloc(len, GFP_KERNEL);
>  		if (!buf) {
> -			printk(KERN_ERR "rtc_from4_errstat: Out of memory!\n");
> +			printk(KERN_ERR "%s: Out of memory!\n", __func__);
>  			er_stat = 1;
>  			goto out;
>  		}

-- 
Regards,
Igor.




More information about the linux-mtd mailing list