diff options
author | Brian Norris <computersforpeace@gmail.com> | 2011-09-07 16:13:35 -0400 |
---|---|---|
committer | Artem Bityutskiy <artem.bityutskiy@intel.com> | 2011-09-11 10:16:03 -0400 |
commit | b61bf5bbf619fc66ca866a27038da0b91cafb92d (patch) | |
tree | f3830c3c3f898259e7a5c948af0195761ed06092 /drivers/mtd | |
parent | c5e8ef9c21a492f1e0436b350bbc3e916f93e506 (diff) |
mtd: nand: remove gotos in `check_create()'
This is a second step in restructuring `check_create()'. When we don't
rely on goto statements for our main functionality, the code will become
a little easier to manipulate.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/nand/nand_bbt.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index 42b523a84fc6..7dbfce4a1a5b 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c | |||
@@ -875,7 +875,7 @@ static inline int nand_memory_bbt(struct mtd_info *mtd, struct nand_bbt_descr *b | |||
875 | */ | 875 | */ |
876 | static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd) | 876 | static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr *bd) |
877 | { | 877 | { |
878 | int i, chips, writeops, chipsel, res; | 878 | int i, chips, writeops, create, chipsel, res; |
879 | struct nand_chip *this = mtd->priv; | 879 | struct nand_chip *this = mtd->priv; |
880 | struct nand_bbt_descr *td = this->bbt_td; | 880 | struct nand_bbt_descr *td = this->bbt_td; |
881 | struct nand_bbt_descr *md = this->bbt_md; | 881 | struct nand_bbt_descr *md = this->bbt_md; |
@@ -889,6 +889,7 @@ static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc | |||
889 | 889 | ||
890 | for (i = 0; i < chips; i++) { | 890 | for (i = 0; i < chips; i++) { |
891 | writeops = 0; | 891 | writeops = 0; |
892 | create = 0; | ||
892 | rd = NULL; | 893 | rd = NULL; |
893 | rd2 = NULL; | 894 | rd2 = NULL; |
894 | /* Per chip or per device? */ | 895 | /* Per chip or per device? */ |
@@ -896,8 +897,8 @@ static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc | |||
896 | /* Mirrored table available? */ | 897 | /* Mirrored table available? */ |
897 | if (md) { | 898 | if (md) { |
898 | if (td->pages[i] == -1 && md->pages[i] == -1) { | 899 | if (td->pages[i] == -1 && md->pages[i] == -1) { |
900 | create = 1; | ||
899 | writeops = 0x03; | 901 | writeops = 0x03; |
900 | goto create; | ||
901 | } else if (td->pages[i] == -1) { | 902 | } else if (td->pages[i] == -1) { |
902 | rd = md; | 903 | rd = md; |
903 | td->version[i] = md->version[i]; | 904 | td->version[i] = md->version[i]; |
@@ -921,25 +922,27 @@ static int check_create(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_desc | |||
921 | } | 922 | } |
922 | } else { | 923 | } else { |
923 | if (td->pages[i] == -1) { | 924 | if (td->pages[i] == -1) { |
925 | create = 1; | ||
924 | writeops = 0x01; | 926 | writeops = 0x01; |
925 | goto create; | 927 | } else { |
928 | rd = td; | ||
926 | } | 929 | } |
927 | rd = td; | ||
928 | } | 930 | } |
929 | goto writecheck; | ||
930 | create: | ||
931 | /* Create the bad block table by scanning the device? */ | ||
932 | if (!(td->options & NAND_BBT_CREATE)) | ||
933 | continue; | ||
934 | 931 | ||
935 | /* Create the table in memory by scanning the chip(s) */ | 932 | if (create) { |
936 | if (!(this->bbt_options & NAND_BBT_CREATE_EMPTY)) | 933 | /* Create the bad block table by scanning the device? */ |
937 | create_bbt(mtd, buf, bd, chipsel); | 934 | if (!(td->options & NAND_BBT_CREATE)) |
935 | continue; | ||
936 | |||
937 | /* Create the table in memory by scanning the chip(s) */ | ||
938 | if (!(this->bbt_options & NAND_BBT_CREATE_EMPTY)) | ||
939 | create_bbt(mtd, buf, bd, chipsel); | ||
940 | |||
941 | td->version[i] = 1; | ||
942 | if (md) | ||
943 | md->version[i] = 1; | ||
944 | } | ||
938 | 945 | ||
939 | td->version[i] = 1; | ||
940 | if (md) | ||
941 | md->version[i] = 1; | ||
942 | writecheck: | ||
943 | /* Read back first? */ | 946 | /* Read back first? */ |
944 | if (rd) | 947 | if (rd) |
945 | read_abs_bbt(mtd, buf, rd, chipsel); | 948 | read_abs_bbt(mtd, buf, rd, chipsel); |