diff options
author | Brian Norris <computersforpeace@gmail.com> | 2017-08-04 21:42:37 -0400 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2017-08-04 21:42:37 -0400 |
commit | 33983675fbd5b2447430c3dd4c205e879576b475 (patch) | |
tree | 2ec4301c1ebba4793f8c29a505a01f09630e7b3d | |
parent | 5771a8c08880cdca3bfb4a3fc6d309d6bba20877 (diff) | |
parent | ee02f73e04c0e690600f621a3a1d2245834af7fe (diff) |
Merge tag 'nand/fixes-for-4.13-rc4' of git://git.infradead.org/l2-mtd into MTD
"""
This PR contains both core and drivers fixes for 4.13.
Core fixes:
- Fix data interface setup for ONFI NANDs that do not support the SET
FEATURES command
- Fix a kernel doc header
- Fix potential integer overflow when retrieving timing information
from the parameter page
- Fix wrong OOB layout for small page NANDs
Driver fixes:
- Fix potential division-by-zero bug
- Fix backward compat with old atmel-nand DT bindings
- Fix ->setup_data_interface() in the atmel NAND driver
"""
-rw-r--r-- | drivers/mtd/nand/atmel/nand-controller.c | 2 | ||||
-rw-r--r-- | drivers/mtd/nand/atmel/pmecc.c | 21 | ||||
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 13 | ||||
-rw-r--r-- | drivers/mtd/nand/nand_timings.c | 6 | ||||
-rw-r--r-- | drivers/mtd/nand/sunxi_nand.c | 4 | ||||
-rw-r--r-- | include/linux/mtd/nand.h | 6 |
6 files changed, 27 insertions, 25 deletions
diff --git a/drivers/mtd/nand/atmel/nand-controller.c b/drivers/mtd/nand/atmel/nand-controller.c index d922a88e407f..2c8baa0c2c4e 100644 --- a/drivers/mtd/nand/atmel/nand-controller.c +++ b/drivers/mtd/nand/atmel/nand-controller.c | |||
@@ -1201,7 +1201,7 @@ static int atmel_smc_nand_prepare_smcconf(struct atmel_nand *nand, | |||
1201 | * tRC < 30ns implies EDO mode. This controller does not support this | 1201 | * tRC < 30ns implies EDO mode. This controller does not support this |
1202 | * mode. | 1202 | * mode. |
1203 | */ | 1203 | */ |
1204 | if (conf->timings.sdr.tRC_min < 30) | 1204 | if (conf->timings.sdr.tRC_min < 30000) |
1205 | return -ENOTSUPP; | 1205 | return -ENOTSUPP; |
1206 | 1206 | ||
1207 | atmel_smc_cs_conf_init(smcconf); | 1207 | atmel_smc_cs_conf_init(smcconf); |
diff --git a/drivers/mtd/nand/atmel/pmecc.c b/drivers/mtd/nand/atmel/pmecc.c index 55a8ee5306ea..8c210a5776bc 100644 --- a/drivers/mtd/nand/atmel/pmecc.c +++ b/drivers/mtd/nand/atmel/pmecc.c | |||
@@ -945,6 +945,7 @@ struct atmel_pmecc *devm_atmel_pmecc_get(struct device *userdev) | |||
945 | */ | 945 | */ |
946 | struct platform_device *pdev = to_platform_device(userdev); | 946 | struct platform_device *pdev = to_platform_device(userdev); |
947 | const struct atmel_pmecc_caps *caps; | 947 | const struct atmel_pmecc_caps *caps; |
948 | const struct of_device_id *match; | ||
948 | 949 | ||
949 | /* No PMECC engine available. */ | 950 | /* No PMECC engine available. */ |
950 | if (!of_property_read_bool(userdev->of_node, | 951 | if (!of_property_read_bool(userdev->of_node, |
@@ -953,21 +954,11 @@ struct atmel_pmecc *devm_atmel_pmecc_get(struct device *userdev) | |||
953 | 954 | ||
954 | caps = &at91sam9g45_caps; | 955 | caps = &at91sam9g45_caps; |
955 | 956 | ||
956 | /* | 957 | /* Find the caps associated to the NAND dev node. */ |
957 | * Try to find the NFC subnode and extract the associated caps | 958 | match = of_match_node(atmel_pmecc_legacy_match, |
958 | * from there. | 959 | userdev->of_node); |
959 | */ | 960 | if (match && match->data) |
960 | np = of_find_compatible_node(userdev->of_node, NULL, | 961 | caps = match->data; |
961 | "atmel,sama5d3-nfc"); | ||
962 | if (np) { | ||
963 | const struct of_device_id *match; | ||
964 | |||
965 | match = of_match_node(atmel_pmecc_legacy_match, np); | ||
966 | if (match && match->data) | ||
967 | caps = match->data; | ||
968 | |||
969 | of_node_put(np); | ||
970 | } | ||
971 | 962 | ||
972 | pmecc = atmel_pmecc_create(pdev, caps, 1, 2); | 963 | pmecc = atmel_pmecc_create(pdev, caps, 1, 2); |
973 | } | 964 | } |
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 5fa5ddc94834..c6c18b82f8f4 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -65,8 +65,14 @@ static int nand_ooblayout_ecc_sp(struct mtd_info *mtd, int section, | |||
65 | 65 | ||
66 | if (!section) { | 66 | if (!section) { |
67 | oobregion->offset = 0; | 67 | oobregion->offset = 0; |
68 | oobregion->length = 4; | 68 | if (mtd->oobsize == 16) |
69 | oobregion->length = 4; | ||
70 | else | ||
71 | oobregion->length = 3; | ||
69 | } else { | 72 | } else { |
73 | if (mtd->oobsize == 8) | ||
74 | return -ERANGE; | ||
75 | |||
70 | oobregion->offset = 6; | 76 | oobregion->offset = 6; |
71 | oobregion->length = ecc->total - 4; | 77 | oobregion->length = ecc->total - 4; |
72 | } | 78 | } |
@@ -1125,7 +1131,9 @@ static int nand_setup_data_interface(struct nand_chip *chip, int chipnr) | |||
1125 | * Ensure the timing mode has been changed on the chip side | 1131 | * Ensure the timing mode has been changed on the chip side |
1126 | * before changing timings on the controller side. | 1132 | * before changing timings on the controller side. |
1127 | */ | 1133 | */ |
1128 | if (chip->onfi_version) { | 1134 | if (chip->onfi_version && |
1135 | (le16_to_cpu(chip->onfi_params.opt_cmd) & | ||
1136 | ONFI_OPT_CMD_SET_GET_FEATURES)) { | ||
1129 | u8 tmode_param[ONFI_SUBFEATURE_PARAM_LEN] = { | 1137 | u8 tmode_param[ONFI_SUBFEATURE_PARAM_LEN] = { |
1130 | chip->onfi_timing_mode_default, | 1138 | chip->onfi_timing_mode_default, |
1131 | }; | 1139 | }; |
@@ -2741,7 +2749,6 @@ static int nand_write_page_syndrome(struct mtd_info *mtd, | |||
2741 | * @buf: the data to write | 2749 | * @buf: the data to write |
2742 | * @oob_required: must write chip->oob_poi to OOB | 2750 | * @oob_required: must write chip->oob_poi to OOB |
2743 | * @page: page number to write | 2751 | * @page: page number to write |
2744 | * @cached: cached programming | ||
2745 | * @raw: use _raw version of write_page | 2752 | * @raw: use _raw version of write_page |
2746 | */ | 2753 | */ |
2747 | static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, | 2754 | static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, |
diff --git a/drivers/mtd/nand/nand_timings.c b/drivers/mtd/nand/nand_timings.c index f06312df3669..7e36d7d13c26 100644 --- a/drivers/mtd/nand/nand_timings.c +++ b/drivers/mtd/nand/nand_timings.c | |||
@@ -311,9 +311,9 @@ int onfi_init_data_interface(struct nand_chip *chip, | |||
311 | struct nand_sdr_timings *timings = &iface->timings.sdr; | 311 | struct nand_sdr_timings *timings = &iface->timings.sdr; |
312 | 312 | ||
313 | /* microseconds -> picoseconds */ | 313 | /* microseconds -> picoseconds */ |
314 | timings->tPROG_max = 1000000UL * le16_to_cpu(params->t_prog); | 314 | timings->tPROG_max = 1000000ULL * le16_to_cpu(params->t_prog); |
315 | timings->tBERS_max = 1000000UL * le16_to_cpu(params->t_bers); | 315 | timings->tBERS_max = 1000000ULL * le16_to_cpu(params->t_bers); |
316 | timings->tR_max = 1000000UL * le16_to_cpu(params->t_r); | 316 | timings->tR_max = 1000000ULL * le16_to_cpu(params->t_r); |
317 | 317 | ||
318 | /* nanoseconds -> picoseconds */ | 318 | /* nanoseconds -> picoseconds */ |
319 | timings->tCCS_min = 1000UL * le16_to_cpu(params->t_ccs); | 319 | timings->tCCS_min = 1000UL * le16_to_cpu(params->t_ccs); |
diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c index d0b6f8f9f297..6abd142b1324 100644 --- a/drivers/mtd/nand/sunxi_nand.c +++ b/drivers/mtd/nand/sunxi_nand.c | |||
@@ -1728,6 +1728,10 @@ static int sunxi_nfc_setup_data_interface(struct mtd_info *mtd, int csline, | |||
1728 | */ | 1728 | */ |
1729 | chip->clk_rate = NSEC_PER_SEC / min_clk_period; | 1729 | chip->clk_rate = NSEC_PER_SEC / min_clk_period; |
1730 | real_clk_rate = clk_round_rate(nfc->mod_clk, chip->clk_rate); | 1730 | real_clk_rate = clk_round_rate(nfc->mod_clk, chip->clk_rate); |
1731 | if (real_clk_rate <= 0) { | ||
1732 | dev_err(nfc->dev, "Unable to round clk %lu\n", chip->clk_rate); | ||
1733 | return -EINVAL; | ||
1734 | } | ||
1731 | 1735 | ||
1732 | /* | 1736 | /* |
1733 | * ONFI specification 3.1, paragraph 4.15.2 dictates that EDO data | 1737 | * ONFI specification 3.1, paragraph 4.15.2 dictates that EDO data |
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 892148c448cc..5216d2eb2289 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
@@ -681,10 +681,10 @@ struct nand_buffers { | |||
681 | * @tWW_min: WP# transition to WE# low | 681 | * @tWW_min: WP# transition to WE# low |
682 | */ | 682 | */ |
683 | struct nand_sdr_timings { | 683 | struct nand_sdr_timings { |
684 | u32 tBERS_max; | 684 | u64 tBERS_max; |
685 | u32 tCCS_min; | 685 | u32 tCCS_min; |
686 | u32 tPROG_max; | 686 | u64 tPROG_max; |
687 | u32 tR_max; | 687 | u64 tR_max; |
688 | u32 tALH_min; | 688 | u32 tALH_min; |
689 | u32 tADL_min; | 689 | u32 tADL_min; |
690 | u32 tALS_min; | 690 | u32 tALS_min; |