mtd/drivers/mtd/devices blkmtd.c,1.10,1.11
spse at infradead.org
spse at infradead.org
Wed Sep 4 17:35:25 EDT 2002
Update of /home/cvs/mtd/drivers/mtd/devices
In directory phoenix.infradead.org:/tmp/cvs-serv12059
Modified Files:
blkmtd.c
Log Message:
Add err(), info(), warn(), crit() macros
Tidy up printk messages
Index: blkmtd.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/blkmtd.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- blkmtd.c 3 Mar 2002 15:42:06 -0000 1.10
+++ blkmtd.c 4 Sep 2002 21:35:23 -0000 1.11
@@ -62,6 +62,12 @@
#endif
+#define err(format, arg...) printk(KERN_ERR "blkmtd: " format "\n" , ## arg)
+#define info(format, arg...) printk(KERN_INFO "blkmtd: " format "\n" , ## arg)
+#define warn(format, arg...) printk(KERN_WARNING "blkmtd: " format "\n" , ## arg)
+#define crit(format, arg...) printk(KERN_CRIT "blkmtd: " format "\n" , ## arg)
+
+
/* Default erase size in K, always make it a multiple of PAGE_SIZE */
#define CONFIG_MTD_BLKDEV_ERASESIZE 128
#define VERSION "1.9"
@@ -137,7 +143,7 @@
/* writepage() - should never be called - catch it anyway */
static int blkmtd_writepage(struct page *page)
{
- printk("blkmtd: writepage called!!!\n");
+ info("writepage called!!!");
return -EIO;
}
@@ -152,7 +158,7 @@
unsigned long *blocks;
if(!rawdevice) {
- printk(KERN_ERR "blkmtd: readpage: PANIC rawdevice == NULL\n");
+ err("readpage: PANIC rawdevice == NULL");
return -EIO;
}
dev = to_kdev_t(rawdevice->binding->bd_dev);
@@ -202,16 +208,16 @@
DEBUG(3, "blkmtd: readpage: getting kiovec\n");
err = alloc_kiovec(1, &iobuf);
if (err) {
- printk(KERN_CRIT "blkmtd: cant allocate kiobuf\n");
+ crit("cant allocate kiobuf");
SetPageError(page);
return err;
}
- /* Pre 2.4.4 doesnt have space for the block list in the kiobuf */
+ /* Pre 2.4.4 doesn't have space for the block list in the kiobuf */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4)
blocks = kmalloc(KIO_MAX_SECTORS * sizeof(unsigned long), GFP_KERNEL);
if(blocks == NULL) {
- printk(KERN_CRIT "blkmtd: cant allocate iobuf blocks\n");
+ crit("cant allocate iobuf blocks");
free_kiovec(1, &iobuf);
SetPageError(page);
return -ENOMEM;
@@ -257,7 +263,7 @@
#endif
if(err != PAGE_SIZE) {
- printk(KERN_ERR "blkmtd: readpage: error reading page %ld\n", page->index);
+ err("readpage: error reading page %ld", page->index);
memset(page_address(page), 0, PAGE_SIZE);
SetPageError(page);
err = -EIO;
@@ -299,15 +305,15 @@
exit_sighand(tsk);
if(alloc_kiovec(1, &iobuf)) {
- printk(KERN_CRIT "blkmtd: write_queue_task cant allocate kiobuf\n");
+ crit("write_queue_task cant allocate kiobuf");
return 0;
}
- /* Pre 2.4.4 doesnt have space for the block list in the kiobuf */
+ /* Pre 2.4.4 doesn't have space for the block list in the kiobuf */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4)
blocks = kmalloc(KIO_MAX_SECTORS * sizeof(unsigned long), GFP_KERNEL);
if(blocks == NULL) {
- printk(KERN_CRIT "blkmtd: write_queue_task cant allocate iobuf blocks\n");
+ crit("write_queue_task cant allocate iobuf blocks");
free_kiovec(1, &iobuf);
return 0;
}
@@ -343,7 +349,7 @@
int max_sectors = KIO_MAX_SECTORS >> (item->rawdevice->sector_bits - 9);
kdev_t dev = to_kdev_t(item->rawdevice->binding->bd_dev);
- /* If we are writing to the last page on the device and it doesnt end
+ /* If we are writing to the last page on the device and it doesn't end
* on a page boundary, subtract the number of sectors that dont exist.
*/
if(item->rawdevice->partial_last_page &&
@@ -522,8 +528,7 @@
/* check readonly */
if(rawdevice->readonly) {
- printk(KERN_ERR "blkmtd: error: trying to erase readonly device %s\n",
- device);
+ err("error: trying to erase readonly device %s", device);
instr->state = MTD_ERASE_FAILED;
goto erase_callback;
}
@@ -548,8 +553,7 @@
if(!numregions) {
/* Not a valid erase block */
- printk(KERN_ERR "blkmtd: erase: invalid erase request 0x%lX @ 0x%08X\n",
- len, from);
+ err("erase: invalid erase request 0x%lX @ 0x%08X", len, from);
instr->state = MTD_ERASE_FAILED;
err = -EIO;
}
@@ -659,7 +663,7 @@
wait_on_page(page);
if(!Page_Uptodate(page)) {
/* error reading page */
- printk(KERN_ERR "blkmtd: read: page not uptodate\n");
+ err("read: page not uptodate");
page_cache_release(page);
return -EIO;
}
@@ -714,7 +718,7 @@
/* handle readonly and out of range numbers */
if(rawdevice->readonly) {
- printk(KERN_ERR "blkmtd: error: trying to write to a readonly device %s\n", device);
+ err("error: trying to write to a readonly device %s", device);
return -EROFS;
}
@@ -796,7 +800,7 @@
page = grab_cache_page(&rawdevice->as, pagenr);
DEBUG(3, "blkmtd: write: got page %d from page cache\n", pagenr);
if(!page) {
- printk(KERN_WARNING "blkmtd: write: cant grab cache page %d\n", pagenr);
+ warn("write: cant grab cache page %d", pagenr);
err = -EIO;
goto write_err;
}
@@ -930,6 +934,7 @@
static void __devexit cleanup_blkmtd(void)
{
+ int index = mtd_rawdevice->mtd_info.index;
#ifdef BLKMTD_PROC_DEBUG
if(blkmtd_proc) {
remove_proc_entry("blkmtd_debug", NULL);
@@ -962,7 +967,7 @@
UnlockPage(erase_page);
__free_pages(erase_page, 0);
}
- printk(KERN_INFO "blkmtd: unloaded for %s\n", device);
+ info("mtd%d: unloaded for %s", index, device);
}
#ifndef MODULE
@@ -973,7 +978,6 @@
static int __init param_blkmtd_device(char *str)
{
device = str;
- printk("blkmtd device = %s", device);
return 1;
}
@@ -1048,10 +1052,9 @@
int regions;
int i;
- printk("blkmtd: starting\n");
/* Check args */
if(device == 0) {
- printk(KERN_ERR "blkmtd: error, missing `device' name\n");
+ err("error: missing `device' name");
return -EINVAL;
}
@@ -1078,7 +1081,7 @@
file = filp_open(device, mode, 0);
if(IS_ERR(file)) {
- printk(KERN_ERR "blkmtd: error, cant open device %s\n", device);
+ err("error: cant open device %s", device);
DEBUG(2, "blkmtd: filp_open returned %ld\n", PTR_ERR(file));
return 1;
}
@@ -1087,7 +1090,7 @@
numbers */
inode = file->f_dentry->d_inode;
if(!S_ISBLK(inode->i_mode)) {
- printk(KERN_ERR "blkmtd: %s not a block device\n", device);
+ err("%s not a block device", device);
filp_close(file, NULL);
return 1;
}
@@ -1098,7 +1101,7 @@
#endif
if(!rdev) {
- printk(KERN_ERR "blkmtd: bad block device: `%s'\n", device);
+ err("bad block device: `%s'", device);
return 1;
}
@@ -1107,7 +1110,7 @@
DEBUG(1, "blkmtd: found a block device major = %d, minor = %d\n", maj, min);
if(maj == MTD_BLOCK_MAJOR) {
- printk(KERN_ERR "blkmtd: attempting to use an MTD device as a block device\n");
+ err("attempting to use an MTD device as a block device");
return 1;
}
@@ -1128,7 +1131,7 @@
DEBUG(1, "blkmtd: size = %ld\n", (long int)size);
if(size == 0) {
- printk(KERN_ERR "blkmtd: cant determine size\n");
+ err("cant determine size");
return 1;
}
@@ -1235,10 +1238,10 @@
DEBUG(3, "blkmtd: init: kernel task @ %p\n", write_queue_task);
DEBUG(2, "blkmtd: init: starting kernel task\n");
kernel_thread(write_queue_task, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
- DEBUG(2, "blkmtd: init: started\n");
- printk(KERN_INFO "blkmtd loaded: version = %s using %s erase_size = %dK %s\n",
- VERSION, device, erase_size, (readonly) ? "(read-only)" : "");
}
+ info("version " VERSION);
+ info("mtd%d: [%s] erase_size = %dK %s",mtd_rawdevice->mtd_info.index,
+ device, erase_size, (readonly) ? "(read-only)" : "");
#ifdef BLKMTD_PROC_DEBUG
/* create proc entry */
@@ -1246,7 +1249,7 @@
blkmtd_proc = create_proc_read_entry("blkmtd_debug", 0444,
NULL, blkmtd_proc_read, NULL);
if(blkmtd_proc == NULL) {
- printk(KERN_ERR "Cant create /proc/blkmtd_debug\n");
+ err("Cant create /proc/blkmtd_debug");
} else {
blkmtd_proc->owner = THIS_MODULE;
}
More information about the linux-mtd-cvs
mailing list