aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-07-18 06:19:52 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-07-24 06:36:09 -0400
commit9c9ec147709e63e4e8ac6a037c6bb50688ff8e9c (patch)
treed66805c819ffa2ae42bf5743ac77f077c903ad19 /drivers
parent4d88de4beb6f327dfc7c2221eab532dad5b2bb3e (diff)
UBI: fix checkpatch.pl errors and warnings
Just out or curiousity ran checkpatch.pl for whole UBI, and discovered there are quite a few of stylistic issues. Fix them. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/ubi/build.c8
-rw-r--r--drivers/mtd/ubi/cdev.c4
-rw-r--r--drivers/mtd/ubi/eba.c7
-rw-r--r--drivers/mtd/ubi/gluebi.c4
-rw-r--r--drivers/mtd/ubi/io.c8
-rw-r--r--drivers/mtd/ubi/scan.c9
-rw-r--r--drivers/mtd/ubi/ubi.h3
-rw-r--r--drivers/mtd/ubi/upd.c8
-rw-r--r--drivers/mtd/ubi/vmt.c4
-rw-r--r--drivers/mtd/ubi/vtbl.c12
-rw-r--r--drivers/mtd/ubi/wl.c92
11 files changed, 78 insertions, 81 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 4418a2369b56..535d9a8a6ba8 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -51,14 +51,13 @@
51 * @name: MTD device name or number string 51 * @name: MTD device name or number string
52 * @vid_hdr_offs: VID header offset 52 * @vid_hdr_offs: VID header offset
53 */ 53 */
54struct mtd_dev_param 54struct mtd_dev_param {
55{
56 char name[MTD_PARAM_LEN_MAX]; 55 char name[MTD_PARAM_LEN_MAX];
57 int vid_hdr_offs; 56 int vid_hdr_offs;
58}; 57};
59 58
60/* Numbers of elements set in the @mtd_dev_param array */ 59/* Numbers of elements set in the @mtd_dev_param array */
61static int mtd_devs = 0; 60static int mtd_devs;
62 61
63/* MTD devices specification parameters */ 62/* MTD devices specification parameters */
64static struct mtd_dev_param mtd_dev_param[UBI_MAX_DEVICES]; 63static struct mtd_dev_param mtd_dev_param[UBI_MAX_DEVICES];
@@ -781,7 +780,8 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
781 if (!ubi_devices[ubi_num]) 780 if (!ubi_devices[ubi_num])
782 break; 781 break;
783 if (ubi_num == UBI_MAX_DEVICES) { 782 if (ubi_num == UBI_MAX_DEVICES) {
784 dbg_err("only %d UBI devices may be created", UBI_MAX_DEVICES); 783 dbg_err("only %d UBI devices may be created",
784 UBI_MAX_DEVICES);
785 return -ENFILE; 785 return -ENFILE;
786 } 786 }
787 } else { 787 } else {
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index bc8199c6a9f5..03c759b4eeb5 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -39,9 +39,9 @@
39#include <linux/stat.h> 39#include <linux/stat.h>
40#include <linux/ioctl.h> 40#include <linux/ioctl.h>
41#include <linux/capability.h> 41#include <linux/capability.h>
42#include <linux/uaccess.h>
42#include <linux/smp_lock.h> 43#include <linux/smp_lock.h>
43#include <mtd/ubi-user.h> 44#include <mtd/ubi-user.h>
44#include <asm/uaccess.h>
45#include <asm/div64.h> 45#include <asm/div64.h>
46#include "ubi.h" 46#include "ubi.h"
47 47
@@ -352,7 +352,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
352} 352}
353 353
354#else 354#else
355#define vol_cdev_direct_write(file, buf, count, offp) -EPERM 355#define vol_cdev_direct_write(file, buf, count, offp) (-EPERM)
356#endif /* CONFIG_MTD_UBI_DEBUG_USERSPACE_IO */ 356#endif /* CONFIG_MTD_UBI_DEBUG_USERSPACE_IO */
357 357
358static ssize_t vol_cdev_write(struct file *file, const char __user *buf, 358static ssize_t vol_cdev_write(struct file *file, const char __user *buf,
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index e14208152c36..e04bcf1dff87 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -189,9 +189,7 @@ static struct ubi_ltree_entry *ltree_add_entry(struct ubi_device *ubi,
189 le->users += 1; 189 le->users += 1;
190 spin_unlock(&ubi->ltree_lock); 190 spin_unlock(&ubi->ltree_lock);
191 191
192 if (le_free) 192 kfree(le_free);
193 kfree(le_free);
194
195 return le; 193 return le;
196} 194}
197 195
@@ -503,9 +501,8 @@ static int recover_peb(struct ubi_device *ubi, int pnum, int vol_id, int lnum,
503 struct ubi_vid_hdr *vid_hdr; 501 struct ubi_vid_hdr *vid_hdr;
504 502
505 vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS); 503 vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS);
506 if (!vid_hdr) { 504 if (!vid_hdr)
507 return -ENOMEM; 505 return -ENOMEM;
508 }
509 506
510 mutex_lock(&ubi->buf_mutex); 507 mutex_lock(&ubi->buf_mutex);
511 508
diff --git a/drivers/mtd/ubi/gluebi.c b/drivers/mtd/ubi/gluebi.c
index 49f52dceea93..605812bb0b1a 100644
--- a/drivers/mtd/ubi/gluebi.c
+++ b/drivers/mtd/ubi/gluebi.c
@@ -249,8 +249,8 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr)
249 if (err) 249 if (err)
250 goto out_err; 250 goto out_err;
251 251
252 instr->state = MTD_ERASE_DONE; 252 instr->state = MTD_ERASE_DONE;
253 mtd_erase_callback(instr); 253 mtd_erase_callback(instr);
254 return 0; 254 return 0;
255 255
256out_err: 256out_err:
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 2bebb39d19b3..a84f0db0a03a 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -167,8 +167,8 @@ retry:
167 } 167 }
168 168
169 if (read != len && retries++ < UBI_IO_RETRIES) { 169 if (read != len && retries++ < UBI_IO_RETRIES) {
170 dbg_io("error %d while reading %d bytes from PEB %d:%d, " 170 dbg_io("error %d while reading %d bytes from PEB %d:%d,"
171 "read only %zd bytes, retry", 171 " read only %zd bytes, retry",
172 err, len, pnum, offset, read); 172 err, len, pnum, offset, read);
173 yield(); 173 yield();
174 goto retry; 174 goto retry;
@@ -705,8 +705,8 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
705 705
706 if (hdr_crc != crc) { 706 if (hdr_crc != crc) {
707 if (verbose) { 707 if (verbose) {
708 ubi_warn("bad EC header CRC at PEB %d, calculated %#08x," 708 ubi_warn("bad EC header CRC at PEB %d, calculated "
709 " read %#08x", pnum, crc, hdr_crc); 709 "%#08x, read %#08x", pnum, crc, hdr_crc);
710 ubi_dbg_dump_ec_hdr(ec_hdr); 710 ubi_dbg_dump_ec_hdr(ec_hdr);
711 } 711 }
712 return UBI_IO_BAD_EC_HDR; 712 return UBI_IO_BAD_EC_HDR;
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 40eca9ce5fab..0bb7488862d2 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -248,7 +248,8 @@ static int compare_lebs(struct ubi_device *ubi, const struct ubi_scan_leb *seb,
248 unsigned long long sqnum2 = be64_to_cpu(vid_hdr->sqnum); 248 unsigned long long sqnum2 = be64_to_cpu(vid_hdr->sqnum);
249 249
250 if (seb->sqnum == 0 && sqnum2 == 0) { 250 if (seb->sqnum == 0 && sqnum2 == 0) {
251 long long abs, v1 = seb->leb_ver, v2 = be32_to_cpu(vid_hdr->leb_ver); 251 long long abs;
252 long long v1 = seb->leb_ver, v2 = be32_to_cpu(vid_hdr->leb_ver);
252 253
253 /* 254 /*
254 * UBI constantly increases the logical eraseblock version 255 * UBI constantly increases the logical eraseblock version
@@ -752,7 +753,8 @@ struct ubi_scan_leb *ubi_scan_get_free_peb(struct ubi_device *ubi,
752 * This function returns a zero if the physical eraseblock was successfully 753 * This function returns a zero if the physical eraseblock was successfully
753 * handled and a negative error code in case of failure. 754 * handled and a negative error code in case of failure.
754 */ 755 */
755static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si, int pnum) 756static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
757 int pnum)
756{ 758{
757 long long uninitialized_var(ec); 759 long long uninitialized_var(ec);
758 int err, bitflips = 0, vol_id, ec_corr = 0; 760 int err, bitflips = 0, vol_id, ec_corr = 0;
@@ -1301,8 +1303,7 @@ static int paranoid_check_si(struct ubi_device *ubi, struct ubi_scan_info *si)
1301 if (err < 0) { 1303 if (err < 0) {
1302 kfree(buf); 1304 kfree(buf);
1303 return err; 1305 return err;
1304 } 1306 } else if (err)
1305 else if (err)
1306 buf[pnum] = 1; 1307 buf[pnum] = 1;
1307 } 1308 }
1308 1309
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index 274c67916b34..14a5596d2d9e 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -473,7 +473,8 @@ int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol,
473 const void __user *buf, int count); 473 const void __user *buf, int count);
474 474
475/* misc.c */ 475/* misc.c */
476int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf, int length); 476int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf,
477 int length);
477int ubi_check_volume(struct ubi_device *ubi, int vol_id); 478int ubi_check_volume(struct ubi_device *ubi, int vol_id);
478void ubi_calculate_reserved(struct ubi_device *ubi); 479void ubi_calculate_reserved(struct ubi_device *ubi);
479 480
diff --git a/drivers/mtd/ubi/upd.c b/drivers/mtd/ubi/upd.c
index 1230a5e1b530..3b8beb8545c4 100644
--- a/drivers/mtd/ubi/upd.c
+++ b/drivers/mtd/ubi/upd.c
@@ -39,7 +39,7 @@
39 */ 39 */
40 40
41#include <linux/err.h> 41#include <linux/err.h>
42#include <asm/uaccess.h> 42#include <linux/uaccess.h>
43#include <asm/div64.h> 43#include <asm/div64.h>
44#include "ubi.h" 44#include "ubi.h"
45 45
@@ -246,7 +246,8 @@ static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
246 return 0; 246 return 0;
247 } 247 }
248 248
249 err = ubi_eba_write_leb(ubi, vol, lnum, buf, 0, len, UBI_UNKNOWN); 249 err = ubi_eba_write_leb(ubi, vol, lnum, buf, 0, len,
250 UBI_UNKNOWN);
250 } else { 251 } else {
251 /* 252 /*
252 * When writing static volume, and this is the last logical 253 * When writing static volume, and this is the last logical
@@ -418,7 +419,8 @@ int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol,
418 if (vol->upd_received == vol->upd_bytes) { 419 if (vol->upd_received == vol->upd_bytes) {
419 int len = ALIGN((int)vol->upd_bytes, ubi->min_io_size); 420 int len = ALIGN((int)vol->upd_bytes, ubi->min_io_size);
420 421
421 memset(vol->upd_buf + vol->upd_bytes, 0xFF, len - vol->upd_bytes); 422 memset(vol->upd_buf + vol->upd_bytes, 0xFF,
423 len - vol->upd_bytes);
422 len = ubi_calc_data_len(ubi, vol->upd_buf, len); 424 len = ubi_calc_data_len(ubi, vol->upd_buf, len);
423 err = ubi_eba_atomic_leb_change(ubi, vol, vol->ch_lnum, 425 err = ubi_eba_atomic_leb_change(ubi, vol, vol->ch_lnum,
424 vol->upd_buf, len, UBI_UNKNOWN); 426 vol->upd_buf, len, UBI_UNKNOWN);
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index 4be4014c70df..852482d8b18f 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -253,7 +253,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
253 goto out_unlock; 253 goto out_unlock;
254 } 254 }
255 255
256 /* Calculate how many eraseblocks are requested */ 256 /* Calculate how many eraseblocks are requested */
257 vol->usable_leb_size = ubi->leb_size - ubi->leb_size % req->alignment; 257 vol->usable_leb_size = ubi->leb_size - ubi->leb_size % req->alignment;
258 bytes = req->bytes; 258 bytes = req->bytes;
259 if (do_div(bytes, vol->usable_leb_size)) 259 if (do_div(bytes, vol->usable_leb_size))
@@ -858,7 +858,7 @@ static int paranoid_check_volume(struct ubi_device *ubi, int vol_id)
858 858
859 if (alignment != vol->alignment || data_pad != vol->data_pad || 859 if (alignment != vol->alignment || data_pad != vol->data_pad ||
860 upd_marker != vol->upd_marker || vol_type != vol->vol_type || 860 upd_marker != vol->upd_marker || vol_type != vol->vol_type ||
861 name_len!= vol->name_len || strncmp(name, vol->name, name_len)) { 861 name_len != vol->name_len || strncmp(name, vol->name, name_len)) {
862 ubi_err("volume info is different"); 862 ubi_err("volume info is different");
863 goto fail; 863 goto fail;
864 } 864 }
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c
index 23c5376234b2..10c22257f601 100644
--- a/drivers/mtd/ubi/vtbl.c
+++ b/drivers/mtd/ubi/vtbl.c
@@ -461,7 +461,8 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
461 if (!leb_corrupted[0]) { 461 if (!leb_corrupted[0]) {
462 /* LEB 0 is OK */ 462 /* LEB 0 is OK */
463 if (leb[1]) 463 if (leb[1])
464 leb_corrupted[1] = memcmp(leb[0], leb[1], ubi->vtbl_size); 464 leb_corrupted[1] = memcmp(leb[0], leb[1],
465 ubi->vtbl_size);
465 if (leb_corrupted[1]) { 466 if (leb_corrupted[1]) {
466 ubi_warn("volume table copy #2 is corrupted"); 467 ubi_warn("volume table copy #2 is corrupted");
467 err = create_vtbl(ubi, si, 1, leb[0]); 468 err = create_vtbl(ubi, si, 1, leb[0]);
@@ -859,11 +860,10 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si)
859 860
860out_free: 861out_free:
861 vfree(ubi->vtbl); 862 vfree(ubi->vtbl);
862 for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) 863 for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) {
863 if (ubi->volumes[i]) { 864 kfree(ubi->volumes[i]);
864 kfree(ubi->volumes[i]); 865 ubi->volumes[i] = NULL;
865 ubi->volumes[i] = NULL; 866 }
866 }
867 return err; 867 return err;
868} 868}
869 869
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 6821952bcdb8..2a5d2a0e14ad 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -475,52 +475,47 @@ retry:
475 } 475 }
476 476
477 switch (dtype) { 477 switch (dtype) {
478 case UBI_LONGTERM: 478 case UBI_LONGTERM:
479 /* 479 /*
480 * For long term data we pick a physical eraseblock 480 * For long term data we pick a physical eraseblock with high
481 * with high erase counter. But the highest erase 481 * erase counter. But the highest erase counter we can pick is
482 * counter we can pick is bounded by the the lowest 482 * bounded by the the lowest erase counter plus
483 * erase counter plus %WL_FREE_MAX_DIFF. 483 * %WL_FREE_MAX_DIFF.
484 */ 484 */
485 e = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF); 485 e = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF);
486 protect = LT_PROTECTION; 486 protect = LT_PROTECTION;
487 break; 487 break;
488 case UBI_UNKNOWN: 488 case UBI_UNKNOWN:
489 /* 489 /*
490 * For unknown data we pick a physical eraseblock with 490 * For unknown data we pick a physical eraseblock with medium
491 * medium erase counter. But we by no means can pick a 491 * erase counter. But we by no means can pick a physical
492 * physical eraseblock with erase counter greater or 492 * eraseblock with erase counter greater or equivalent than the
493 * equivalent than the lowest erase counter plus 493 * lowest erase counter plus %WL_FREE_MAX_DIFF.
494 * %WL_FREE_MAX_DIFF. 494 */
495 */ 495 first = rb_entry(rb_first(&ubi->free), struct ubi_wl_entry, rb);
496 first = rb_entry(rb_first(&ubi->free), 496 last = rb_entry(rb_last(&ubi->free), struct ubi_wl_entry, rb);
497 struct ubi_wl_entry, rb);
498 last = rb_entry(rb_last(&ubi->free),
499 struct ubi_wl_entry, rb);
500 497
501 if (last->ec - first->ec < WL_FREE_MAX_DIFF) 498 if (last->ec - first->ec < WL_FREE_MAX_DIFF)
502 e = rb_entry(ubi->free.rb_node, 499 e = rb_entry(ubi->free.rb_node,
503 struct ubi_wl_entry, rb); 500 struct ubi_wl_entry, rb);
504 else { 501 else {
505 medium_ec = (first->ec + WL_FREE_MAX_DIFF)/2; 502 medium_ec = (first->ec + WL_FREE_MAX_DIFF)/2;
506 e = find_wl_entry(&ubi->free, medium_ec); 503 e = find_wl_entry(&ubi->free, medium_ec);
507 } 504 }
508 protect = U_PROTECTION; 505 protect = U_PROTECTION;
509 break; 506 break;
510 case UBI_SHORTTERM: 507 case UBI_SHORTTERM:
511 /* 508 /*
512 * For short term data we pick a physical eraseblock 509 * For short term data we pick a physical eraseblock with the
513 * with the lowest erase counter as we expect it will 510 * lowest erase counter as we expect it will be erased soon.
514 * be erased soon. 511 */
515 */ 512 e = rb_entry(rb_first(&ubi->free), struct ubi_wl_entry, rb);
516 e = rb_entry(rb_first(&ubi->free), 513 protect = ST_PROTECTION;
517 struct ubi_wl_entry, rb); 514 break;
518 protect = ST_PROTECTION; 515 default:
519 break; 516 protect = 0;
520 default: 517 e = NULL;
521 protect = 0; 518 BUG();
522 e = NULL;
523 BUG();
524 } 519 }
525 520
526 /* 521 /*
@@ -584,7 +579,8 @@ found:
584 * This function returns zero in case of success and a negative error code in 579 * This function returns zero in case of success and a negative error code in
585 * case of failure. 580 * case of failure.
586 */ 581 */
587static int sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, int torture) 582static int sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e,
583 int torture)
588{ 584{
589 int err; 585 int err;
590 struct ubi_ec_hdr *ec_hdr; 586 struct ubi_ec_hdr *ec_hdr;
@@ -1060,8 +1056,8 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
1060 spin_unlock(&ubi->wl_lock); 1056 spin_unlock(&ubi->wl_lock);
1061 1057
1062 /* 1058 /*
1063 * One more erase operation has happened, take care about protected 1059 * One more erase operation has happened, take care about
1064 * physical eraseblocks. 1060 * protected physical eraseblocks.
1065 */ 1061 */
1066 check_protection_over(ubi); 1062 check_protection_over(ubi);
1067 1063