mtd/fs/jffs2 compr.c,1.40,1.41 proc.c,1.2,1.3
havasi at infradead.org
havasi at infradead.org
Thu Jun 24 05:53:11 EDT 2004
Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/home/havasi/mtd/fs/jffs2
Modified Files:
compr.c proc.c
Log Message:
- replace COMPRESSOR_LIST_{UN}LOCK with spin_{un}lock
- adding KERN_XXX into printk messages
Index: compr.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/compr.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- compr.c 23 Jun 2004 16:34:39 -0000 1.40
+++ compr.c 24 Jun 2004 09:51:38 -0000 1.41
@@ -15,9 +15,6 @@
#include "compr.h"
-#define COMPRESSOR_LIST_LOCK spin_lock(&jffs2_compressor_list_lock)
-#define COMPRESSOR_LIST_UNLOCK spin_unlock(&jffs2_compressor_list_lock)
-
static spinlock_t jffs2_compressor_list_lock = SPIN_LOCK_UNLOCKED;
/* Available compressors are on this list */
@@ -74,23 +71,23 @@
case JFFS2_COMPR_MODE_PRIORITY:
output_buf = kmalloc(*cdatalen,GFP_KERNEL);
if (!output_buf) {
- printk("JFFS2: No memory for compressor allocation. Compression failed.\n");
+ printk(KERN_WARNING "JFFS2: No memory for compressor allocation. Compression failed.\n");
goto out;
}
orig_slen = *datalen;
orig_dlen = *cdatalen;
- COMPRESSOR_LIST_LOCK;
+ spin_lock(&jffs2_compressor_list_lock);
list_for_each_entry(this, &jffs2_compressor_list, list) {
/* Skip decompress-only backwards-compatibility and disabled modules */
if ((!this->compress)||(this->disabled))
continue;
this->usecount++;
- COMPRESSOR_LIST_UNLOCK;
+ spin_unlock(&jffs2_compressor_list_lock);
*datalen = orig_slen;
*cdatalen = orig_dlen;
compr_ret = this->compress(data_in, output_buf, datalen, cdatalen, NULL);
- COMPRESSOR_LIST_LOCK;
+ spin_lock(&jffs2_compressor_list_lock);
this->usecount--;
if (!compr_ret) {
ret = this->compr;
@@ -100,31 +97,31 @@
break;
}
}
- COMPRESSOR_LIST_UNLOCK;
+ spin_unlock(&jffs2_compressor_list_lock);
if (ret == JFFS2_COMPR_NONE) kfree(output_buf);
break;
case JFFS2_COMPR_MODE_SIZE:
orig_slen = *datalen;
orig_dlen = *cdatalen;
- COMPRESSOR_LIST_LOCK;
+ spin_lock(&jffs2_compressor_list_lock);
list_for_each_entry(this, &jffs2_compressor_list, list) {
/* Skip decompress-only backwards-compatibility and disabled modules */
if ((!this->compress)||(this->disabled))
continue;
/* Allocating memory for output buffer if necessary */
if ((this->compr_buf_size<orig_dlen)&&(this->compr_buf)) {
- COMPRESSOR_LIST_UNLOCK;
+ spin_unlock(&jffs2_compressor_list_lock);
kfree(this->compr_buf);
- COMPRESSOR_LIST_LOCK;
+ spin_lock(&jffs2_compressor_list_lock);
this->compr_buf_size=0;
this->compr_buf=NULL;
}
if (!this->compr_buf) {
- COMPRESSOR_LIST_UNLOCK;
+ spin_unlock(&jffs2_compressor_list_lock);
tmp_buf = kmalloc(orig_dlen,GFP_KERNEL);
- COMPRESSOR_LIST_LOCK;
+ spin_lock(&jffs2_compressor_list_lock);
if (!tmp_buf) {
- printk("JFFS2: No memory for compressor allocation. (%d bytes)\n",orig_dlen);
+ printk(KERN_WARNING "JFFS2: No memory for compressor allocation. (%d bytes)\n",orig_dlen);
continue;
}
else {
@@ -133,11 +130,11 @@
}
}
this->usecount++;
- COMPRESSOR_LIST_UNLOCK;
+ spin_unlock(&jffs2_compressor_list_lock);
*datalen = orig_slen;
*cdatalen = orig_dlen;
compr_ret = this->compress(data_in, this->compr_buf, datalen, cdatalen, NULL);
- COMPRESSOR_LIST_LOCK;
+ spin_lock(&jffs2_compressor_list_lock);
this->usecount--;
if (!compr_ret) {
if ((!best_dlen)||(best_dlen>*cdatalen)) {
@@ -158,10 +155,10 @@
best->stat_compr_new_size += best_dlen;
ret = best->compr;
}
- COMPRESSOR_LIST_UNLOCK;
+ spin_unlock(&jffs2_compressor_list_lock);
break;
default:
- printk("JFFS2: unknow compression mode.\n");
+ printk(KERN_ERR "JFFS2: unknow compression mode.\n");
}
out:
if (ret == JFFS2_COMPR_NONE) {
@@ -193,26 +190,26 @@
memset(data_out, 0, datalen);
break;
default:
- COMPRESSOR_LIST_LOCK;
+ spin_lock(&jffs2_compressor_list_lock);
list_for_each_entry(this, &jffs2_compressor_list, list) {
if (comprtype == this->compr) {
this->usecount++;
- COMPRESSOR_LIST_UNLOCK;
+ spin_unlock(&jffs2_compressor_list_lock);
ret = this->decompress(cdata_in, data_out, cdatalen, datalen, NULL);
- COMPRESSOR_LIST_LOCK;
+ spin_lock(&jffs2_compressor_list_lock);
if (ret) {
- printk("Decompressor \"%s\" returned %d\n", this->name, ret);
+ printk(KERN_WARNING "Decompressor \"%s\" returned %d\n", this->name, ret);
}
else {
this->stat_decompr_blocks++;
}
this->usecount--;
- COMPRESSOR_LIST_UNLOCK;
+ spin_unlock(&jffs2_compressor_list_lock);
return ret;
}
}
- printk("JFFS2 compression type 0x%02x not avaiable.\n", comprtype);
- COMPRESSOR_LIST_UNLOCK;
+ printk(KERN_WARNING "JFFS2 compression type 0x%02x not avaiable.\n", comprtype);
+ spin_unlock(&jffs2_compressor_list_lock);
return -EIO;
}
return 0;
@@ -223,7 +220,7 @@
struct jffs2_compressor *this;
if (!comp->name) {
- printk("NULL compressor name at registering JFFS2 compressor. Failed.\n");
+ printk(KERN_WARNING "NULL compressor name at registering JFFS2 compressor. Failed.\n");
return -1;
}
comp->compr_buf_size=0;
@@ -233,9 +230,9 @@
comp->stat_compr_new_size=0;
comp->stat_compr_blocks=0;
comp->stat_decompr_blocks=0;
- D1(printk("Registering JFFS2 compressor \"%s\"\n", comp->name));
+ D1(printk(KERN_DEBUG "Registering JFFS2 compressor \"%s\"\n", comp->name));
- COMPRESSOR_LIST_LOCK;
+ spin_lock(&jffs2_compressor_list_lock);
list_for_each_entry(this, &jffs2_compressor_list, list) {
if (this->priority < comp->priority) {
@@ -246,10 +243,10 @@
list_add_tail(&comp->list, &jffs2_compressor_list);
out:
D2(list_for_each_entry(this, &jffs2_compressor_list, list) {
- printk("Compressor \"%s\", prio %d\n", this->name, this->priority);
+ printk(KERN_DEBUG "Compressor \"%s\", prio %d\n", this->name, this->priority);
})
- COMPRESSOR_LIST_UNLOCK;
+ spin_unlock(&jffs2_compressor_list_lock);
return 0;
}
@@ -258,21 +255,21 @@
{
D2(struct jffs2_compressor *this;)
- D1(printk("Unregistering JFFS2 compressor \"%s\"\n", comp->name));
+ D1(printk(KERN_DEBUG "Unregistering JFFS2 compressor \"%s\"\n", comp->name));
- COMPRESSOR_LIST_LOCK;
+ spin_lock(&jffs2_compressor_list_lock);
if (comp->usecount) {
- COMPRESSOR_LIST_UNLOCK;
- printk("JFFS2: Compressor modul is in use. Unregister failed.\n");
+ spin_unlock(&jffs2_compressor_list_lock);
+ printk(KERN_WARNING "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) {
- printk("Compressor \"%s\", prio %d\n", this->name, this->priority);
+ printk(KERN_DEBUG "Compressor \"%s\", prio %d\n", this->name, this->priority);
})
- COMPRESSOR_LIST_UNLOCK;
+ spin_unlock(&jffs2_compressor_list_lock);
return 0;
}
@@ -308,7 +305,7 @@
act_buf += sprintf(act_buf,"%10s ","none");
act_buf += sprintf(act_buf,"compr: %d blocks (%d) decompr: %d blocks\n", none_stat_compr_blocks,
none_stat_compr_size, none_stat_decompr_blocks);
- COMPRESSOR_LIST_LOCK;
+ spin_lock(&jffs2_compressor_list_lock);
list_for_each_entry(this, &jffs2_compressor_list, list) {
act_buf += sprintf(act_buf,"%10s ",this->name);
if ((this->disabled)||(!this->compress))
@@ -320,7 +317,7 @@
this->stat_decompr_blocks);
act_buf += sprintf(act_buf,"\n");
}
- COMPRESSOR_LIST_UNLOCK;
+ spin_unlock(&jffs2_compressor_list_lock);
return buf;
}
@@ -358,16 +355,16 @@
static int jffs2_compressor_Xable(const char *name, int disabled)
{
struct jffs2_compressor *this;
- COMPRESSOR_LIST_LOCK;
+ spin_lock(&jffs2_compressor_list_lock);
list_for_each_entry(this, &jffs2_compressor_list, list) {
if (!strcmp(this->name, name)) {
this->disabled = disabled;
- COMPRESSOR_LIST_UNLOCK;
+ spin_unlock(&jffs2_compressor_list_lock);
return 0;
}
}
- COMPRESSOR_LIST_UNLOCK;
- printk("JFFS2: compressor %s not found.\n",name);
+ spin_unlock(&jffs2_compressor_list_lock);
+ printk(KERN_WARNING "JFFS2: compressor %s not found.\n",name);
return 1;
}
@@ -384,7 +381,7 @@
int jffs2_set_compressor_priority(const char *name, int priority)
{
struct jffs2_compressor *this,*comp;
- COMPRESSOR_LIST_LOCK;
+ spin_lock(&jffs2_compressor_list_lock);
list_for_each_entry(this, &jffs2_compressor_list, list) {
if (!strcmp(this->name, name)) {
this->priority = priority;
@@ -392,8 +389,8 @@
goto reinsert;
}
}
- COMPRESSOR_LIST_UNLOCK;
- printk("JFFS2: compressor %s not found.\n",name);
+ spin_unlock(&jffs2_compressor_list_lock);
+ printk(KERN_WARNING "JFFS2: compressor %s not found.\n",name);
return 1;
reinsert:
/* list is sorted in the order of priority, so if
@@ -403,12 +400,12 @@
list_for_each_entry(this, &jffs2_compressor_list, list) {
if (this->priority < comp->priority) {
list_add(&comp->list, this->list.prev);
- COMPRESSOR_LIST_UNLOCK;
+ spin_unlock(&jffs2_compressor_list_lock);
return 0;
}
}
list_add_tail(&comp->list, &jffs2_compressor_list);
- COMPRESSOR_LIST_UNLOCK;
+ spin_unlock(&jffs2_compressor_list_lock);
return 0;
}
@@ -442,13 +439,13 @@
/* Setting default compression mode */
#ifdef CONFIG_JFFS2_CMODE_NONE
jffs2_compression_mode = JFFS2_COMPR_MODE_NONE;
- D1(printk("JFFS2: default compression mode: none\n");)
+ D1(printk(KERN_INFO "JFFS2: default compression mode: none\n");)
#else
#ifdef CONFIG_JFFS2_CMODE_SIZE
jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE;
- D1(printk("JFFS2: default compression mode: size\n");)
+ D1(printk(KERN_INFO "JFFS2: default compression mode: size\n");)
#else
- D1(printk("JFFS2: default compression mode: priority\n");)
+ D1(printk(KERN_INFO "JFFS2: default compression mode: priority\n");)
#endif
#endif
return 0;
Index: proc.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/proc.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- proc.c 23 Jun 2004 16:34:40 -0000 1.2
+++ proc.c 24 Jun 2004 09:51:38 -0000 1.3
@@ -96,11 +96,11 @@
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);
+ printk(KERN_WARNING "JFFS2: error switching compression mode. Invalid parameter (%s)?\n",compr_name);
}
}
else {
- printk("JFFS2: error: parameter missing\n");
+ printk(KERN_WARNING "JFFS2: error: parameter missing\n");
}
kfree(compr_name);
return count;
@@ -138,7 +138,7 @@
compr_name = kmalloc(count+1,GFP_KERNEL);
compr_cmd = kmalloc(count+1,GFP_KERNEL);
if (!compr_name) {
- printk("JFFS2: unable to allocate memory\n");
+ printk(KERN_WARNING "JFFS2: unable to allocate memory\n");
goto list_write_end;
}
compr_name[0] = 0;
@@ -155,7 +155,7 @@
jffs2_disable_compressor_name(compr_name);
goto list_write_end;
}
- printk("JFFS2: usage of /proc/fs/jffs2/compr_list:\n"
+ printk(KERN_WARNING "JFFS2: usage of /proc/fs/jffs2/compr_list:\n"
" echo \"enable COMPRESSOR_NAME\" >/proc/fs/jffs2/compr_list\n"
" echo \"disable COMPRESSOR_NAME\" >/proc/fs/jffs2/compr_list\n"
" echo \"priority NEW_PRIORITY COMPRESSOR_NAME\" >/proc/fs/jffs2/compr_list\n");
More information about the linux-mtd-cvs
mailing list