From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-mtd@lists.infradead.org,
Boris Brezillon <boris.brezillon@free-electrons.com>,
Brian Norris <computersforpeace@gmail.com>,
Cyrille Pitchen <cyrille.pitchen@atmel.com>,
David Woodhouse <dwmw2@infradead.org>,
Denys Vlasenko <dvlasenk@redhat.com>,
Marek Vasut <marek.vasut@gmail.com>,
Richard Weinberger <richard@nod.at>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 18/18] mtd-cfi_cmdset_0020: Add some spaces for better code readability
Date: Wed, 11 Jan 2017 20:55:20 +0000 [thread overview]
Message-ID: <0e5ee358-fb62-5d0b-81cf-d73a1a47f6d4@users.sourceforge.net> (raw)
In-Reply-To: <71189baa-8780-b80a-0b4d-9dae74763ba3@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 11 Jan 2017 20:55:40 +0100
Use space characters at some source code places according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/mtd/chips/cfi_cmdset_0020.c | 99 ++++++++++++++++++++-----------------
1 file changed, 55 insertions(+), 44 deletions(-)
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
index 60de9d58dcc6..f6b2bf056849 100644
--- a/drivers/mtd/chips/cfi_cmdset_0020.c
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
@@ -75,24 +75,24 @@ static void cfi_tell_features(struct cfi_pri_intelext *extp)
printk(" - Protection Bits: %s\n", extp->FeatureSupport&64?"supported":"unsupported");
printk(" - Page-mode read: %s\n", extp->FeatureSupport&128?"supported":"unsupported");
printk(" - Synchronous read: %s\n", extp->FeatureSupport&256?"supported":"unsupported");
- for (i=9; i<32; i++) {
- if (extp->FeatureSupport & (1<<i))
+ for (i = 9; i < 32; i++) {
+ if (extp->FeatureSupport & (1 << i))
printk(" - Unknown Bit %X: supported\n", i);
}
printk(" Supported functions after Suspend: %2.2X\n", extp->SuspendCmdSupport);
printk(" - Program after Erase Suspend: %s\n", extp->SuspendCmdSupport&1?"supported":"unsupported");
- for (i=1; i<8; i++) {
- if (extp->SuspendCmdSupport & (1<<i))
+ for (i = 1; i < 8; i++) {
+ if (extp->SuspendCmdSupport & (1 << i))
printk(" - Unknown Bit %X: supported\n", i);
}
printk(" Block Status Register Mask: %4.4X\n", extp->BlkStatusRegMask);
printk(" - Lock Bit Active: %s\n", extp->BlkStatusRegMask&1?"yes":"no");
printk(" - Valid Bit Active: %s\n", extp->BlkStatusRegMask&2?"yes":"no");
- for (i=2; i<16; i++) {
- if (extp->BlkStatusRegMask & (1<<i))
- printk(" - Unknown Bit %X Active: yes\n",i);
+ for (i = 2; i < 16; i++) {
+ if (extp->BlkStatusRegMask & (1 << i))
+ printk(" - Unknown Bit %X Active: yes\n", i);
}
printk(" Vcc Logic Supply Optimum Program/Erase Voltage: %d.%d V\n",
@@ -121,7 +121,7 @@ struct mtd_info *cfi_cmdset_0020(struct map_info *map, int primary)
* routine faked a CFI structure. So we read the feature
* table from it.
*/
- __u16 adr = primary?cfi->cfiq->P_ADR:cfi->cfiq->A_ADR;
+ __u16 adr = primary ? cfi->cfiq->P_ADR : cfi->cfiq->A_ADR;
struct cfi_pri_intelext *extp;
extp = (struct cfi_pri_intelext*)cfi_read_pri(map, adr, sizeof(*extp), "ST Microelectronics");
@@ -151,7 +151,7 @@ struct mtd_info *cfi_cmdset_0020(struct map_info *map, int primary)
cfi->cmdset_priv = extp;
}
- for (i=0; i< cfi->numchips; i++) {
+ for (i = 0; i < cfi->numchips; i++) {
cfi->chips[i].word_write_time = 128;
cfi->chips[i].buffer_write_time = 128;
cfi->chips[i].erase_time = 1024;
@@ -168,8 +168,8 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
struct cfi_private *cfi = map->fldrv_priv;
struct mtd_info *mtd;
unsigned long offset = 0;
- int i,j;
- unsigned long devsize = (1<<cfi->cfiq->DevSize) * cfi->interleave;
+ int i, j;
+ unsigned long devsize = (1 << cfi->cfiq->DevSize) * cfi->interleave;
mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
//printk(KERN_DEBUG "number of CFI chips: %d\n", cfi->numchips);
@@ -187,7 +187,7 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
if (!mtd->eraseregions)
goto free_mtd;
- for (i=0; i<cfi->cfiq->NumEraseRegions; i++) {
+ for (i = 0; i < cfi->cfiq->NumEraseRegions; i++) {
unsigned long ernum, ersize;
ersize = ((cfi->cfiq->EraseRegionInfo[i] >> 8) & ~0xff) * cfi->interleave;
ernum = (cfi->cfiq->EraseRegionInfo[i] & 0xffff) + 1;
@@ -195,10 +195,13 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
if (mtd->erasesize < ersize) {
mtd->erasesize = ersize;
}
- for (j=0; j<cfi->numchips; j++) {
- mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].offset = (j*devsize)+offset;
- mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].erasesize = ersize;
- mtd->eraseregions[(j*cfi->cfiq->NumEraseRegions)+i].numblocks = ernum;
+ for (j = 0; j < cfi->numchips; j++) {
+ unsigned int const x = j * cfi->cfiq->NumEraseRegions
+ + i;
+
+ mtd->eraseregions[x].offset = j * devsize + offset;
+ mtd->eraseregions[x].erasesize = ersize;
+ mtd->eraseregions[x].numblocks = ernum;
}
offset += (ersize * ernum);
}
@@ -210,7 +213,7 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
goto free_mtd;
}
- for (i=0; i<mtd->numeraseregions;i++){
+ for (i = 0; i < mtd->numeraseregions; i++) {
printk(KERN_DEBUG "%d: offset=0x%llx,size=0x%x,blocks=%d\n",
i, (unsigned long long)mtd->eraseregions[i].offset,
mtd->eraseregions[i].erasesize,
@@ -395,8 +398,8 @@ static int cfi_staa_read (struct mtd_info *mtd, loff_t from, size_t len, size_t
if (chipnum >= cfi->numchips)
break;
- if ((len + ofs -1) >> cfi->chipshift)
- thislen = (1<<cfi->chipshift) - ofs;
+ if ((len + ofs - 1) >> cfi->chipshift)
+ thislen = (1 << cfi->chipshift) - ofs;
else
thislen = len;
@@ -676,7 +679,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
if (!buffer)
return -ENOMEM;
- for (i=0; i<count; i++) {
+ for (i = 0; i < count; i++) {
size_t elem_len = vecs[i].iov_len;
void *elem_base = vecs[i].iov_base;
if (!elem_len) /* FIXME: Might be unnecessary. Check that */
@@ -844,8 +847,9 @@ static inline int do_erase_oneblock(struct map_info *map, struct flchip *chip, u
unsigned char chipstatus = status.x[0];
if (!map_word_equal(map, status, CMD(chipstatus))) {
int i, w;
- for (w=0; w<map_words(map); w++) {
- for (i = 0; i<cfi_interleave(cfi); i++) {
+
+ for (w = 0; w < map_words(map); w++) {
+ for (i = 0; i < cfi_interleave(cfi); i++) {
chipstatus |= status.x[w] >> (cfi->device_type * 8);
}
}
@@ -925,7 +929,8 @@ static int cfi_staa_erase_varsize(struct mtd_info *mtd,
* with the erase region at that address.
*/
- while (i<mtd->numeraseregions && (instr->addr + instr->len) >= regions[i].offset)
+ while (i < mtd->numeraseregions
+ && (instr->addr + instr->len) >= regions[i].offset)
i++;
/* As before, drop back one to point at the region in which
@@ -933,16 +938,15 @@ static int cfi_staa_erase_varsize(struct mtd_info *mtd,
*/
i--;
- if ((instr->addr + instr->len) & (regions[i].erasesize-1))
+ if ((instr->addr + instr->len) & (regions[i].erasesize - 1))
return -EINVAL;
chipnum = instr->addr >> cfi->chipshift;
adr = instr->addr - (chipnum << cfi->chipshift);
len = instr->len;
+ i = first;
- i=first;
-
- while(len) {
+ while (len) {
ret = do_erase_oneblock(map, &cfi->chips[chipnum], adr);
if (ret)
@@ -951,7 +955,10 @@ static int cfi_staa_erase_varsize(struct mtd_info *mtd,
adr += regions[i].erasesize;
len -= regions[i].erasesize;
- if (adr % (1<< cfi->chipshift) = (((unsigned long)regions[i].offset + (regions[i].erasesize * regions[i].numblocks)) %( 1<< cfi->chipshift)))
+ if (adr % (1 << cfi->chipshift)
+ = (((unsigned long)regions[i].offset
+ + (regions[i].erasesize * regions[i].numblocks))
+ % (1 << cfi->chipshift)))
i++;
if (adr >> cfi->chipshift) {
@@ -978,13 +985,13 @@ static void cfi_staa_sync (struct mtd_info *mtd)
int ret = 0;
DECLARE_WAITQUEUE(wait, current);
- for (i=0; !ret && i<cfi->numchips; i++) {
+ for (i = 0; !ret && i < cfi->numchips; i++) {
chip = &cfi->chips[i];
retry:
mutex_lock(&chip->mutex);
- switch(chip->state) {
+ switch (chip->state) {
case FL_READY:
case FL_STATUS:
case FL_CFI_QUERY:
@@ -1014,7 +1021,7 @@ static void cfi_staa_sync (struct mtd_info *mtd)
/* Unlock the chips again */
- for (i--; i >=0; i--) {
+ for (i--; i >= 0; i--) {
chip = &cfi->chips[i];
mutex_lock(&chip->mutex);
@@ -1092,7 +1099,7 @@ static inline int do_lock_oneblock(struct map_info *map, struct flchip *chip, un
/* FIXME. Use a timer to check this, and return immediately. */
/* Once the state machine's known to be working I'll do that */
- timeo = jiffies + (HZ*2);
+ timeo = jiffies + HZ * 2;
for (;;) {
status = map_read(map, adr);
@@ -1135,17 +1142,18 @@ static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
if (ofs & (mtd->erasesize - 1))
return -EINVAL;
- if (len & (mtd->erasesize -1))
+ if (len & (mtd->erasesize - 1))
return -EINVAL;
chipnum = ofs >> cfi->chipshift;
adr = ofs - (chipnum << cfi->chipshift);
- while(len) {
+ while (len) {
#ifdef DEBUG_LOCK_BITS
cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL);
- printk("before lock: block status register is %x\n",cfi_read_query(map, adr+(2*ofs_factor)));
+ printk("before lock: block status register is %x\n",
+ cfi_read_query(map, adr + 2 * ofs_factor));
cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL);
#endif
@@ -1153,7 +1161,8 @@ static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
#ifdef DEBUG_LOCK_BITS
cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL);
- printk("after lock: block status register is %x\n",cfi_read_query(map, adr+(2*ofs_factor)));
+ printk("after lock: block status register is %x\n",
+ cfi_read_query(map, adr + 2 * ofs_factor));
cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL);
#endif
@@ -1238,7 +1247,7 @@ static inline int do_unlock_oneblock(struct map_info *map, struct flchip *chip,
/* FIXME. Use a timer to check this, and return immediately. */
/* Once the state machine's known to be working I'll do that */
- timeo = jiffies + (HZ*2);
+ timeo = jiffies + HZ * 2;
for (;;) {
status = map_read(map, adr);
@@ -1288,7 +1297,9 @@ static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL);
while (temp_len) {
- printk("before unlock %x: block status register is %x\n",temp_adr,cfi_read_query(map, temp_adr+(2*ofs_factor)));
+ printk("before unlock %x: block status register is %x\n",
+ temp_adr,
+ cfi_read_query(map, temp_adr + 2 * ofs_factor));
temp_adr += mtd->erasesize;
temp_len -= mtd->erasesize;
}
@@ -1300,7 +1311,8 @@ static int cfi_staa_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
#ifdef DEBUG_LOCK_BITS
cfi_send_gen_cmd(0x90, 0x55, 0, map, cfi, cfi->device_type, NULL);
- printk("after unlock: block status register is %x\n",cfi_read_query(map, adr+(2*ofs_factor)));
+ printk("after unlock: block status register is %x\n",
+ cfi_read_query(map, adr + 2 * ofs_factor));
cfi_send_gen_cmd(0xff, 0x55, 0, map, cfi, cfi->device_type, NULL);
#endif
@@ -1315,12 +1327,12 @@ static int cfi_staa_suspend(struct mtd_info *mtd)
struct flchip *chip;
int ret = 0;
- for (i=0; !ret && i<cfi->numchips; i++) {
+ for (i = 0; !ret && i < cfi->numchips; i++) {
chip = &cfi->chips[i];
mutex_lock(&chip->mutex);
- switch(chip->state) {
+ switch (chip->state) {
case FL_READY:
case FL_STATUS:
case FL_CFI_QUERY:
@@ -1344,7 +1356,7 @@ static int cfi_staa_suspend(struct mtd_info *mtd)
/* Unlock the chips again */
if (ret) {
- for (i--; i >=0; i--) {
+ for (i--; i >= 0; i--) {
chip = &cfi->chips[i];
mutex_lock(&chip->mutex);
@@ -1370,8 +1382,7 @@ static void cfi_staa_resume(struct mtd_info *mtd)
int i;
struct flchip *chip;
- for (i=0; i<cfi->numchips; i++) {
-
+ for (i = 0; i < cfi->numchips; i++) {
chip = &cfi->chips[i];
mutex_lock(&chip->mutex);
--
2.11.0
next prev parent reply other threads:[~2017-01-11 20:55 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-11 20:34 [PATCH 00/18] MTD-CFI: Fine-tuning for several function implementations SF Markus Elfring
2017-01-11 20:35 ` [PATCH 01/18] mtd-cfi_cmdset_0001: Use kmalloc_array() in cfi_intelext_partition_fixup() SF Markus Elfring
2017-01-11 21:59 ` Marek Vasut
2017-01-11 20:37 ` [PATCH 02/18] mtd-cfi_cmdset_0001: Improve another size determination in cfi_intelext_partition_fixu SF Markus Elfring
2017-01-11 21:57 ` [PATCH 02/18] mtd-cfi_cmdset_0001: Improve another size determination in cfi_intelext_partition_ Marek Vasut
2017-01-11 20:38 ` [PATCH 03/18] mtd-cfi_cmdset_0001: Add some spaces for better code readability SF Markus Elfring
2017-01-12 9:19 ` Dan Carpenter
2017-01-11 20:39 ` [PATCH 04/18] mtd-cfi_cmdset_0001: Delete an unnecessary variable initialisation in do_write_oneword SF Markus Elfring
2017-01-11 20:40 ` [PATCH 05/18] mtd-cfi_cmdset_0001: Use common error handling code in do_write_oneword() SF Markus Elfring
2017-01-11 20:41 ` [PATCH 06/18] mtd-cfi_cmdset_0001: Use kcalloc() in cfi_intelext_setup() SF Markus Elfring
2017-01-11 20:42 ` [PATCH 07/18] mtd-cfi_cmdset_0001: One function call and an unnecessary check less in cfi_intelext_s SF Markus Elfring
2017-01-11 20:43 ` [PATCH 08/18] mtd-cfi_cmdset_0001: Rename a jump label in cfi_intelext_setup() SF Markus Elfring
2017-01-11 20:44 ` [PATCH 09/18] mtd-cfi_cmdset_0002: Use kmalloc_array() in cfi_amdstd_setup() SF Markus Elfring
2017-01-11 20:45 ` [PATCH 10/18] mtd-cfi_cmdset_0002: One function call less in cfi_amdstd_setup() after error detectio SF Markus Elfring
2017-01-11 20:46 ` [PATCH 11/18] mtd-cfi_cmdset_0002: Rename a jump label in cfi_amdstd_setup() SF Markus Elfring
2017-01-11 20:47 ` [PATCH 12/18] mtd-cfi_cmdset_0002: Add some spaces for better code readability SF Markus Elfring
2017-01-11 20:48 ` [PATCH 13/18] mtd-cfi_cmdset_0002: Delete an unnecessary variable initialisation in do_write_oneword SF Markus Elfring
2017-01-11 20:49 ` [PATCH 14/18] mtd-cfi_cmdset_0002: Use common error handling code in do_write_oneword() SF Markus Elfring
2017-01-11 20:50 ` [PATCH 15/18] mtd-cfi_cmdset_0002: Use kcalloc() in cfi_ppb_unlock() SF Markus Elfring
2017-01-11 20:51 ` [PATCH 16/18] mtd-cfi_cmdset_0020: Use kmalloc_array() in cfi_staa_setup() SF Markus Elfring
2017-01-11 20:52 ` [PATCH 17/18] mtd-cfi_cmdset_0020: Use common error handling code " SF Markus Elfring
2017-01-11 20:55 ` SF Markus Elfring [this message]
2017-01-12 9:27 ` [PATCH 18/18] mtd-cfi_cmdset_0020: Add some spaces for better code readability Dan Carpenter
2017-01-11 21:56 ` [PATCH 00/18] MTD-CFI: Fine-tuning for several function implementations Boris Brezillon
2017-01-11 21:58 ` Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0e5ee358-fb62-5d0b-81cf-d73a1a47f6d4@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@atmel.com \
--cc=dvlasenk@redhat.com \
--cc=dwmw2@infradead.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox