mtd/fs/jffs2 compr.c, 1.39, 1.40 compr.h, 1.4, 1.5 compr_lzari.c, 1.2, 1.3 compr_lzo.c, 1.2, 1.3 compr_rtime.c, 1.13, 1.14 compr_rubin.c, 1.19, 1.20 compr_zlib.c, 1.27, 1.28 proc.c, 1.1, 1.2

havasi at infradead.org havasi at infradead.org
Wed Jun 23 12:36:13 EDT 2004


Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/home/havasi/mtd/fs/jffs2

Modified Files:
	compr.c compr.h compr_lzari.c compr_lzo.c compr_rtime.c 
	compr_rubin.c compr_zlib.c proc.c 
Log Message:
Applying David's suggestion:
- replace JFFS2_PRINT macro with printk
- replace JFFS2_MALLOC(_BIG) and JFFS2_FREE(_BIG) macros with
  kmalloc, kfree / vmalloc, vfree




Index: compr.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/compr.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- compr.c	23 Jun 2004 14:59:46 -0000	1.39
+++ compr.c	23 Jun 2004 16:34:39 -0000	1.40
@@ -72,9 +72,9 @@
         case JFFS2_COMPR_MODE_NONE:
                 break;
         case JFFS2_COMPR_MODE_PRIORITY:
-                output_buf = JFFS2_MALLOC(*cdatalen);
+                output_buf = kmalloc(*cdatalen,GFP_KERNEL);
                 if (!output_buf) {
-                        JFFS2_PRINT("JFFS2: No memory for compressor allocation. Compression failed.\n");
+                        printk("JFFS2: No memory for compressor allocation. Compression failed.\n");
                         goto out;
                 }
                 orig_slen = *datalen;
@@ -101,7 +101,7 @@
                         }
                 }
                 COMPRESSOR_LIST_UNLOCK;
-                if (ret == JFFS2_COMPR_NONE) JFFS2_FREE(output_buf);
+                if (ret == JFFS2_COMPR_NONE) kfree(output_buf);
                 break;
         case JFFS2_COMPR_MODE_SIZE:
                 orig_slen = *datalen;
@@ -114,17 +114,17 @@
                         /* Allocating memory for output buffer if necessary */
                         if ((this->compr_buf_size<orig_dlen)&&(this->compr_buf)) {
                                 COMPRESSOR_LIST_UNLOCK;
-                                JFFS2_FREE(this->compr_buf);
+                                kfree(this->compr_buf);
                                 COMPRESSOR_LIST_LOCK;
                                 this->compr_buf_size=0;
                                 this->compr_buf=NULL;
                         }
                         if (!this->compr_buf) {
                                 COMPRESSOR_LIST_UNLOCK;
-                                tmp_buf = JFFS2_MALLOC(orig_dlen);
+                                tmp_buf = kmalloc(orig_dlen,GFP_KERNEL);
                                 COMPRESSOR_LIST_LOCK;
                                 if (!tmp_buf) {
-                                        JFFS2_PRINT("JFFS2: No memory for compressor allocation. (%d bytes)\n",orig_dlen);
+                                        printk("JFFS2: No memory for compressor allocation. (%d bytes)\n",orig_dlen);
                                         continue;
                                 }
                                 else {
@@ -161,7 +161,7 @@
                 COMPRESSOR_LIST_UNLOCK;
                 break;
         default:
-                JFFS2_PRINT("JFFS2: unknow compression mode.\n");
+                printk("JFFS2: unknow compression mode.\n");
         }
  out:
         if (ret == JFFS2_COMPR_NONE) {
@@ -201,7 +201,7 @@
                                 ret = this->decompress(cdata_in, data_out, cdatalen, datalen, NULL);
                                 COMPRESSOR_LIST_LOCK;
                                 if (ret) {
-                                        JFFS2_PRINT("Decompressor \"%s\" returned %d\n", this->name, ret);
+                                        printk("Decompressor \"%s\" returned %d\n", this->name, ret);
                                 }
                                 else {
                                         this->stat_decompr_blocks++;
@@ -211,7 +211,7 @@
                                 return ret;
                         }
                 }
-		JFFS2_PRINT("JFFS2 compression type 0x%02x not avaiable.\n", comprtype);
+		printk("JFFS2 compression type 0x%02x not avaiable.\n", comprtype);
                 COMPRESSOR_LIST_UNLOCK;
 		return -EIO;
 	}
@@ -223,7 +223,7 @@
         struct jffs2_compressor *this;
 
         if (!comp->name) {
-                JFFS2_PRINT("NULL compressor name at registering JFFS2 compressor. Failed.\n");
+                printk("NULL compressor name at registering JFFS2 compressor. Failed.\n");
                 return -1;
         }
         comp->compr_buf_size=0;
@@ -233,7 +233,7 @@
         comp->stat_compr_new_size=0;
         comp->stat_compr_blocks=0;
         comp->stat_decompr_blocks=0;
-        D1(JFFS2_PRINT("Registering JFFS2 compressor \"%s\"\n", comp->name));
+        D1(printk("Registering JFFS2 compressor \"%s\"\n", comp->name));
 
         COMPRESSOR_LIST_LOCK;
 
@@ -246,7 +246,7 @@
         list_add_tail(&comp->list, &jffs2_compressor_list);
 out:
         D2(list_for_each_entry(this, &jffs2_compressor_list, list) {
-                JFFS2_PRINT("Compressor \"%s\", prio %d\n", this->name, this->priority);
+                printk("Compressor \"%s\", prio %d\n", this->name, this->priority);
         })
 
         COMPRESSOR_LIST_UNLOCK;
@@ -258,19 +258,19 @@
 {
         D2(struct jffs2_compressor *this;)
 
-        D1(JFFS2_PRINT("Unregistering JFFS2 compressor \"%s\"\n", comp->name));
+        D1(printk("Unregistering JFFS2 compressor \"%s\"\n", comp->name));
 
         COMPRESSOR_LIST_LOCK;
 
         if (comp->usecount) {
                 COMPRESSOR_LIST_UNLOCK;
-                JFFS2_PRINT("JFFS2: Compressor modul is in use. Unregister failed.\n");
+                printk("JFFS2: Compressor modul is in use. Unregister failed.\n");
                 return -1;
         }
         list_del(&comp->list);
 
         D2(list_for_each_entry(this, &jffs2_compressor_list, list) {
-                JFFS2_PRINT("Compressor \"%s\", prio %d\n", this->name, this->priority);
+                printk("Compressor \"%s\", prio %d\n", this->name, this->priority);
         })
         COMPRESSOR_LIST_UNLOCK;
         return 0;
@@ -285,7 +285,7 @@
         struct jffs2_compressor *this;
         char *buf, *act_buf;
 
-        act_buf = buf = JFFS2_MALLOC(JFFS2_STAT_BUF_SIZE);
+        act_buf = buf = kmalloc(JFFS2_STAT_BUF_SIZE,GFP_KERNEL);
         list_for_each_entry(this, &jffs2_compressor_list, list) {
                 act_buf += sprintf(act_buf, "%10s priority:%d ", this->name, this->priority);
                 if ((this->disabled)||(!this->compress))
@@ -302,7 +302,7 @@
         struct jffs2_compressor *this;
         char *buf, *act_buf;
 
-        act_buf = buf = JFFS2_MALLOC(JFFS2_STAT_BUF_SIZE);
+        act_buf = buf = kmalloc(JFFS2_STAT_BUF_SIZE,GFP_KERNEL);
 
         act_buf += sprintf(act_buf,"JFFS2 compressor statistics:\n");
         act_buf += sprintf(act_buf,"%10s   ","none");
@@ -367,7 +367,7 @@
                 }
         }
         COMPRESSOR_LIST_UNLOCK;
-        JFFS2_PRINT("JFFS2: compressor %s not found.\n",name);
+        printk("JFFS2: compressor %s not found.\n",name);
         return 1;
 }
 
@@ -393,7 +393,7 @@
                 }
         }
         COMPRESSOR_LIST_UNLOCK;
-        JFFS2_PRINT("JFFS2: compressor %s not found.\n",name);        
+        printk("JFFS2: compressor %s not found.\n",name);        
         return 1;
 reinsert:
         /* list is sorted in the order of priority, so if
@@ -417,7 +417,7 @@
 void jffs2_free_comprbuf(unsigned char *comprbuf, unsigned char *orig)
 {
         if (orig != comprbuf)
-                JFFS2_FREE(comprbuf);
+                kfree(comprbuf);
 }
 
 int jffs2_compressors_init(void) 
@@ -442,13 +442,13 @@
 /* Setting default compression mode */
 #ifdef CONFIG_JFFS2_CMODE_NONE
         jffs2_compression_mode = JFFS2_COMPR_MODE_NONE;
-        D1(JFFS2_PRINT("JFFS2: default compression mode: none\n");)
+        D1(printk("JFFS2: default compression mode: none\n");)
 #else
 #ifdef CONFIG_JFFS2_CMODE_SIZE
         jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE;
-        D1(JFFS2_PRINT("JFFS2: default compression mode: size\n");)
+        D1(printk("JFFS2: default compression mode: size\n");)
 #else
-        D1(JFFS2_PRINT("JFFS2: default compression mode: priority\n");)
+        D1(printk("JFFS2: default compression mode: priority\n");)
 #endif
 #endif
         return 0;

Index: compr.h
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/compr.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- compr.h	23 Jun 2004 14:59:47 -0000	1.4
+++ compr.h	23 Jun 2004 16:34:39 -0000	1.5
@@ -41,13 +41,6 @@
 #define JFFS2_COMPR_MODE_PRIORITY   1
 #define JFFS2_COMPR_MODE_SIZE       2
 
-#define JFFS2_MALLOC(a)             kmalloc(a,GFP_KERNEL)
-#define JFFS2_FREE(a)               kfree(a)
-#define JFFS2_MALLOC_BIG(a)         vmalloc(a)
-#define JFFS2_FREE_BIG(a)           vfree(a)
-
-#define JFFS2_PRINT(...)            printk(__VA_ARGS__)
-
 void jffs2_set_compression_mode(int mode);
 int jffs2_get_compression_mode(void);
 


Index: compr_lzo.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/compr_lzo.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- compr_lzo.c	23 Jun 2004 14:59:47 -0000	1.2
+++ compr_lzo.c	23 Jun 2004 16:34:39 -0000	1.3
@@ -2261,11 +2261,11 @@
         req   = (msize<<1) + 20;
         if ((!cmprssmem)||(cmprssmem_size<req)) {
                 if (!cmprssmem) {
-                        JFFS2_FREE_BIG(cmprssmem);
+                        vfree(cmprssmem);
                         cmprssmem = NULL;
                         cmprssmem_size = 0;
                 }
-                cmprssmem = JFFS2_MALLOC_BIG(req);
+                cmprssmem = vmalloc(req);
                 if (!cmprssmem) {
                         return -1;
                 }
@@ -2315,7 +2315,7 @@
 
 int jffs2_lzo_init (void)
 {
-        wrkmem = (lzo_bytep) JFFS2_MALLOC_BIG(lzo1x_compressor_memsize);
+        wrkmem = (lzo_bytep) vmalloc(lzo1x_compressor_memsize);
         if (!wrkmem) return -1;
         jffs2_register_compressor(&jffs2_lzo_comp);
         return 0;
@@ -2324,6 +2324,6 @@
 void jffs2_lzo_exit (void)
 {
 	jffs2_unregister_compressor (&jffs2_lzo_comp);
-	if (cmprssmem) JFFS2_FREE_BIG(cmprssmem);
-        JFFS2_FREE_BIG(wrkmem);
+	if (cmprssmem) vfree(cmprssmem);
+        vfree(wrkmem);
 }




Index: proc.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/proc.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- proc.c	25 May 2004 11:25:25 -0000	1.1
+++ proc.c	23 Jun 2004 16:34:40 -0000	1.2
@@ -54,7 +54,7 @@
         
         if (strlen(stat)<off) {
 	        *eof = 1;
-                JFFS2_FREE(stat);
+                kfree(stat);
 	        return len;
         }        
         for (i=off;((stat[i]!=0)&&(len<count));i++,len++) {
@@ -62,7 +62,7 @@
         }
         if (off+len>=strlen(stat)) *eof = 1;
         else *eof = 0;
-        JFFS2_FREE(stat);
+        kfree(stat);
 	return len;
 }
 
@@ -93,7 +93,7 @@
         char *compr_name;
 
         /* collect the name of the compression mode and set it */
-        compr_name = JFFS2_MALLOC(count+1);
+        compr_name = kmalloc(count+1,GFP_KERNEL);
         if (sscanf(buffer,"%s",compr_name)>0) {
                 if (jffs2_set_compression_mode_name(compr_name)) {
                         printk("JFFS2: error switching compression mode. Invalid parameter (%s)?\n",compr_name);
@@ -102,7 +102,7 @@
         else {
                 printk("JFFS2: error: parameter missing\n");
         }
-        JFFS2_FREE(compr_name);
+        kfree(compr_name);
         return count;
 }
 
@@ -116,12 +116,12 @@
         if (strlen(list)+1>count) {
                 /* it should not happen */
 	        *eof = 1;
-                JFFS2_FREE(list);
+                kfree(list);
                 return 0;
         }
 	len += sprintf(page,"%s",list);
 	*eof = 1;
-        JFFS2_FREE(list);
+        kfree(list);
 	return len;
 }
 
@@ -135,8 +135,8 @@
         int prior;
         char *compr_name,*compr_cmd;
 
-        compr_name = JFFS2_MALLOC(count+1);
-        compr_cmd = JFFS2_MALLOC(count+1);
+        compr_name = kmalloc(count+1,GFP_KERNEL);
+        compr_cmd = kmalloc(count+1,GFP_KERNEL);
         if (!compr_name) {
                 printk("JFFS2: unable to allocate memory\n");
                 goto list_write_end;
@@ -160,8 +160,8 @@
                "  echo \"disable COMPRESSOR_NAME\" >/proc/fs/jffs2/compr_list\n"
                "  echo \"priority NEW_PRIORITY COMPRESSOR_NAME\" >/proc/fs/jffs2/compr_list\n");
 list_write_end:
-        JFFS2_FREE(compr_cmd);
-        JFFS2_FREE(compr_name);
+        kfree(compr_cmd);
+        kfree(compr_name);
 	return count;
 }
 





More information about the linux-mtd-cvs mailing list