Skip to content

Commit 9c9ec14

Browse files
Artem BityutskiyArtem Bityutskiy
authored andcommitted
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>
1 parent 4d88de4 commit 9c9ec14

12 files changed

Lines changed: 86 additions & 89 deletions

File tree

‎drivers/mtd/ubi/build.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,13 @@
5151
* @name: MTD device name or number string
5252
* @vid_hdr_offs: VID header offset
5353
*/
54-
struct mtd_dev_param
55-
{
54+
struct mtd_dev_param {
5655
char name[MTD_PARAM_LEN_MAX];
5756
int vid_hdr_offs;
5857
};
5958

6059
/* Numbers of elements set in the @mtd_dev_param array */
61-
static int mtd_devs = 0;
60+
static int mtd_devs;
6261

6362
/* MTD devices specification parameters */
6463
static 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)
781780
if (!ubi_devices[ubi_num])
782781
break;
783782
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);
785785
return -ENFILE;
786786
}
787787
} else {

‎drivers/mtd/ubi/cdev.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
#include <linux/stat.h>
4040
#include <linux/ioctl.h>
4141
#include <linux/capability.h>
42+
#include <linux/uaccess.h>
4243
#include <linux/smp_lock.h>
4344
#include <mtd/ubi-user.h>
44-
#include <asm/uaccess.h>
4545
#include <asm/div64.h>
4646
#include "ubi.h"
4747

@@ -352,7 +352,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
352352
}
353353

354354
#else
355-
#define vol_cdev_direct_write(file, buf, count, offp) -EPERM
355+
#define vol_cdev_direct_write(file, buf, count, offp) (-EPERM)
356356
#endif /* CONFIG_MTD_UBI_DEBUG_USERSPACE_IO */
357357

358358
static ssize_t vol_cdev_write(struct file *file, const char __user *buf,

‎drivers/mtd/ubi/eba.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,7 @@ static struct ubi_ltree_entry *ltree_add_entry(struct ubi_device *ubi,
189189
le->users += 1;
190190
spin_unlock(&ubi->ltree_lock);
191191

192-
if (le_free)
193-
kfree(le_free);
194-
192+
kfree(le_free);
195193
return le;
196194
}
197195

@@ -503,9 +501,8 @@ static int recover_peb(struct ubi_device *ubi, int pnum, int vol_id, int lnum,
503501
struct ubi_vid_hdr *vid_hdr;
504502

505503
vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS);
506-
if (!vid_hdr) {
504+
if (!vid_hdr)
507505
return -ENOMEM;
508-
}
509506

510507
mutex_lock(&ubi->buf_mutex);
511508

‎drivers/mtd/ubi/gluebi.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ static int gluebi_erase(struct mtd_info *mtd, struct erase_info *instr)
249249
if (err)
250250
goto out_err;
251251

252-
instr->state = MTD_ERASE_DONE;
253-
mtd_erase_callback(instr);
252+
instr->state = MTD_ERASE_DONE;
253+
mtd_erase_callback(instr);
254254
return 0;
255255

256256
out_err:

‎drivers/mtd/ubi/io.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,
167167
}
168168

169169
if (read != len && retries++ < UBI_IO_RETRIES) {
170-
dbg_io("error %d while reading %d bytes from PEB %d:%d, "
171-
"read only %zd bytes, retry",
170+
dbg_io("error %d while reading %d bytes from PEB %d:%d,"
171+
" read only %zd bytes, retry",
172172
err, len, pnum, offset, read);
173173
yield();
174174
goto retry;
@@ -705,8 +705,8 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
705705

706706
if (hdr_crc != crc) {
707707
if (verbose) {
708-
ubi_warn("bad EC header CRC at PEB %d, calculated %#08x,"
709-
" read %#08x", pnum, crc, hdr_crc);
708+
ubi_warn("bad EC header CRC at PEB %d, calculated "
709+
"%#08x, read %#08x", pnum, crc, hdr_crc);
710710
ubi_dbg_dump_ec_hdr(ec_hdr);
711711
}
712712
return UBI_IO_BAD_EC_HDR;

‎drivers/mtd/ubi/scan.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ static int compare_lebs(struct ubi_device *ubi, const struct ubi_scan_leb *seb,
248248
unsigned long long sqnum2 = be64_to_cpu(vid_hdr->sqnum);
249249

250250
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);
252253

253254
/*
254255
* UBI constantly increases the logical eraseblock version
@@ -752,7 +753,8 @@ struct ubi_scan_leb *ubi_scan_get_free_peb(struct ubi_device *ubi,
752753
* This function returns a zero if the physical eraseblock was successfully
753754
* handled and a negative error code in case of failure.
754755
*/
755-
static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si, int pnum)
756+
static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
757+
int pnum)
756758
{
757759
long long uninitialized_var(ec);
758760
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)
13011303
if (err < 0) {
13021304
kfree(buf);
13031305
return err;
1304-
}
1305-
else if (err)
1306+
} else if (err)
13061307
buf[pnum] = 1;
13071308
}
13081309

‎drivers/mtd/ubi/ubi.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,8 @@ int ubi_more_leb_change_data(struct ubi_device *ubi, struct ubi_volume *vol,
473473
const void __user *buf, int count);
474474

475475
/* misc.c */
476-
int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf, int length);
476+
int ubi_calc_data_len(const struct ubi_device *ubi, const void *buf,
477+
int length);
477478
int ubi_check_volume(struct ubi_device *ubi, int vol_id);
478479
void ubi_calculate_reserved(struct ubi_device *ubi);
479480

‎drivers/mtd/ubi/upd.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
*/
4040

4141
#include <linux/err.h>
42-
#include <asm/uaccess.h>
42+
#include <linux/uaccess.h>
4343
#include <asm/div64.h>
4444
#include "ubi.h"
4545

@@ -246,7 +246,8 @@ static int write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
246246
return 0;
247247
}
248248

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);
250251
} else {
251252
/*
252253
* 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,
418419
if (vol->upd_received == vol->upd_bytes) {
419420
int len = ALIGN((int)vol->upd_bytes, ubi->min_io_size);
420421

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);
422424
len = ubi_calc_data_len(ubi, vol->upd_buf, len);
423425
err = ubi_eba_atomic_leb_change(ubi, vol, vol->ch_lnum,
424426
vol->upd_buf, len, UBI_UNKNOWN);

‎drivers/mtd/ubi/vmt.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
253253
goto out_unlock;
254254
}
255255

256-
/* Calculate how many eraseblocks are requested */
256+
/* Calculate how many eraseblocks are requested */
257257
vol->usable_leb_size = ubi->leb_size - ubi->leb_size % req->alignment;
258258
bytes = req->bytes;
259259
if (do_div(bytes, vol->usable_leb_size))
@@ -858,7 +858,7 @@ static int paranoid_check_volume(struct ubi_device *ubi, int vol_id)
858858

859859
if (alignment != vol->alignment || data_pad != vol->data_pad ||
860860
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)) {
862862
ubi_err("volume info is different");
863863
goto fail;
864864
}

‎drivers/mtd/ubi/vtbl.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,8 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
461461
if (!leb_corrupted[0]) {
462462
/* LEB 0 is OK */
463463
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);
465466
if (leb_corrupted[1]) {
466467
ubi_warn("volume table copy #2 is corrupted");
467468
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)
859860

860861
out_free:
861862
vfree(ubi->vtbl);
862-
for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++)
863-
if (ubi->volumes[i]) {
864-
kfree(ubi->volumes[i]);
865-
ubi->volumes[i] = NULL;
866-
}
863+
for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) {
864+
kfree(ubi->volumes[i]);
865+
ubi->volumes[i] = NULL;
866+
}
867867
return err;
868868
}
869869

0 commit comments

Comments
 (0)