diff options
author | Bastian Hecht <hechtb@googlemail.com> | 2012-10-19 06:15:34 -0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | 2012-11-15 08:37:50 -0500 |
commit | e8a9d8f31c592eea89f1b0d3fd425e7a96944e88 (patch) | |
tree | 704a94cb7e7a5ab31e57779c7b719ffc88e1bdda /drivers/mtd/nand | |
parent | 5de0b52ea8f8f5149502867acff2efb5efaf1fc2 (diff) |
mtd: sh_flctl: Minor cleanups
Some small fixes to avoid sparse and smatch complain. Other cosmetic fixes
as well.
- Change of the type of the member index in struct sh_flctl from signed
to unsigned. We use index by addressing array members, so unsigned is more
concise here. Adapt functions relying on sh_flctl::index.
- Remove a blurring cast in write_fiforeg().
- Apply consistent naming scheme when refering to the data buffer.
- Shorten some unnecessarily verbose functions.
- Remove spaces at start of lines.
Signed-off-by: Bastian Hecht <hechtb@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r-- | drivers/mtd/nand/sh_flctl.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/drivers/mtd/nand/sh_flctl.c b/drivers/mtd/nand/sh_flctl.c index 4fbfe96e37a1..78d18c0f132f 100644 --- a/drivers/mtd/nand/sh_flctl.c +++ b/drivers/mtd/nand/sh_flctl.c | |||
@@ -225,7 +225,7 @@ static enum flctl_ecc_res_t wait_recfifo_ready | |||
225 | 225 | ||
226 | for (i = 0; i < 3; i++) { | 226 | for (i = 0; i < 3; i++) { |
227 | uint8_t org; | 227 | uint8_t org; |
228 | int index; | 228 | unsigned int index; |
229 | 229 | ||
230 | data = readl(ecc_reg[i]); | 230 | data = readl(ecc_reg[i]); |
231 | 231 | ||
@@ -305,28 +305,29 @@ static enum flctl_ecc_res_t read_ecfiforeg | |||
305 | return res; | 305 | return res; |
306 | } | 306 | } |
307 | 307 | ||
308 | static void write_fiforeg(struct sh_flctl *flctl, int rlen, int offset) | 308 | static void write_fiforeg(struct sh_flctl *flctl, int rlen, |
309 | unsigned int offset) | ||
309 | { | 310 | { |
310 | int i, len_4align; | 311 | int i, len_4align; |
311 | unsigned long *data = (unsigned long *)&flctl->done_buff[offset]; | 312 | unsigned long *buf = (unsigned long *)&flctl->done_buff[offset]; |
312 | void *fifo_addr = (void *)FLDTFIFO(flctl); | ||
313 | 313 | ||
314 | len_4align = (rlen + 3) / 4; | 314 | len_4align = (rlen + 3) / 4; |
315 | for (i = 0; i < len_4align; i++) { | 315 | for (i = 0; i < len_4align; i++) { |
316 | wait_wfifo_ready(flctl); | 316 | wait_wfifo_ready(flctl); |
317 | writel(cpu_to_be32(data[i]), fifo_addr); | 317 | writel(cpu_to_be32(buf[i]), FLDTFIFO(flctl)); |
318 | } | 318 | } |
319 | } | 319 | } |
320 | 320 | ||
321 | static void write_ec_fiforeg(struct sh_flctl *flctl, int rlen, int offset) | 321 | static void write_ec_fiforeg(struct sh_flctl *flctl, int rlen, |
322 | unsigned int offset) | ||
322 | { | 323 | { |
323 | int i, len_4align; | 324 | int i, len_4align; |
324 | unsigned long *data = (unsigned long *)&flctl->done_buff[offset]; | 325 | unsigned long *buf = (unsigned long *)&flctl->done_buff[offset]; |
325 | 326 | ||
326 | len_4align = (rlen + 3) / 4; | 327 | len_4align = (rlen + 3) / 4; |
327 | for (i = 0; i < len_4align; i++) { | 328 | for (i = 0; i < len_4align; i++) { |
328 | wait_wecfifo_ready(flctl); | 329 | wait_wecfifo_ready(flctl); |
329 | writel(cpu_to_be32(data[i]), FLECFIFO(flctl)); | 330 | writel(cpu_to_be32(buf[i]), FLECFIFO(flctl)); |
330 | } | 331 | } |
331 | } | 332 | } |
332 | 333 | ||
@@ -748,41 +749,35 @@ static void flctl_select_chip(struct mtd_info *mtd, int chipnr) | |||
748 | static void flctl_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) | 749 | static void flctl_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) |
749 | { | 750 | { |
750 | struct sh_flctl *flctl = mtd_to_flctl(mtd); | 751 | struct sh_flctl *flctl = mtd_to_flctl(mtd); |
751 | int index = flctl->index; | ||
752 | 752 | ||
753 | memcpy(&flctl->done_buff[index], buf, len); | 753 | memcpy(&flctl->done_buff[flctl->index], buf, len); |
754 | flctl->index += len; | 754 | flctl->index += len; |
755 | } | 755 | } |
756 | 756 | ||
757 | static uint8_t flctl_read_byte(struct mtd_info *mtd) | 757 | static uint8_t flctl_read_byte(struct mtd_info *mtd) |
758 | { | 758 | { |
759 | struct sh_flctl *flctl = mtd_to_flctl(mtd); | 759 | struct sh_flctl *flctl = mtd_to_flctl(mtd); |
760 | int index = flctl->index; | ||
761 | uint8_t data; | 760 | uint8_t data; |
762 | 761 | ||
763 | data = flctl->done_buff[index]; | 762 | data = flctl->done_buff[flctl->index]; |
764 | flctl->index++; | 763 | flctl->index++; |
765 | return data; | 764 | return data; |
766 | } | 765 | } |
767 | 766 | ||
768 | static uint16_t flctl_read_word(struct mtd_info *mtd) | 767 | static uint16_t flctl_read_word(struct mtd_info *mtd) |
769 | { | 768 | { |
770 | struct sh_flctl *flctl = mtd_to_flctl(mtd); | 769 | struct sh_flctl *flctl = mtd_to_flctl(mtd); |
771 | int index = flctl->index; | 770 | uint16_t *buf = (uint16_t *)&flctl->done_buff[flctl->index]; |
772 | uint16_t data; | ||
773 | uint16_t *buf = (uint16_t *)&flctl->done_buff[index]; | ||
774 | 771 | ||
775 | data = *buf; | 772 | flctl->index += 2; |
776 | flctl->index += 2; | 773 | return *buf; |
777 | return data; | ||
778 | } | 774 | } |
779 | 775 | ||
780 | static void flctl_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) | 776 | static void flctl_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) |
781 | { | 777 | { |
782 | struct sh_flctl *flctl = mtd_to_flctl(mtd); | 778 | struct sh_flctl *flctl = mtd_to_flctl(mtd); |
783 | int index = flctl->index; | ||
784 | 779 | ||
785 | memcpy(buf, &flctl->done_buff[index], len); | 780 | memcpy(buf, &flctl->done_buff[flctl->index], len); |
786 | flctl->index += len; | 781 | flctl->index += len; |
787 | } | 782 | } |
788 | 783 | ||