Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-linus-20170807' of git://git.infradead.org/linux-mtd

Pull MTD fixes from Brian Norris:
"I missed getting these out for rc4, but here are some MTD fixes.

Just NAND fixes (in both the core handling, and a few drivers). Notes
stolen from Boris:

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"

* tag 'for-linus-20170807' of git://git.infradead.org/linux-mtd:
mtd: nand: atmel: Fix EDO mode check
mtd: nand: Declare tBERS, tR and tPROG as u64 to avoid integer overflow
mtd: nand: Fix timing setup for NANDs that do not support SET FEATURES
mtd: nand: Fix a docs build warning
mtd: nand: sunxi: fix potential divide-by-zero error
nand: fix wrong default oob layout for small pages using soft ecc
mtd: nand: atmel: Fix DT backward compatibility in pmecc.c

+27 -25
+1 -1
drivers/mtd/nand/atmel/nand-controller.c
··· 1201 1201 * tRC < 30ns implies EDO mode. This controller does not support this 1202 1202 * mode. 1203 1203 */ 1204 - if (conf->timings.sdr.tRC_min < 30) 1204 + if (conf->timings.sdr.tRC_min < 30000) 1205 1205 return -ENOTSUPP; 1206 1206 1207 1207 atmel_smc_cs_conf_init(smcconf);
+6 -15
drivers/mtd/nand/atmel/pmecc.c
··· 945 945 */ 946 946 struct platform_device *pdev = to_platform_device(userdev); 947 947 const struct atmel_pmecc_caps *caps; 948 + const struct of_device_id *match; 948 949 949 950 /* No PMECC engine available. */ 950 951 if (!of_property_read_bool(userdev->of_node, ··· 954 953 955 954 caps = &at91sam9g45_caps; 956 955 957 - /* 958 - * Try to find the NFC subnode and extract the associated caps 959 - * from there. 960 - */ 961 - np = of_find_compatible_node(userdev->of_node, NULL, 962 - "atmel,sama5d3-nfc"); 963 - if (np) { 964 - const struct of_device_id *match; 965 - 966 - match = of_match_node(atmel_pmecc_legacy_match, np); 967 - if (match && match->data) 968 - caps = match->data; 969 - 970 - of_node_put(np); 971 - } 956 + /* Find the caps associated to the NAND dev node. */ 957 + match = of_match_node(atmel_pmecc_legacy_match, 958 + userdev->of_node); 959 + if (match && match->data) 960 + caps = match->data; 972 961 973 962 pmecc = atmel_pmecc_create(pdev, caps, 1, 2); 974 963 }
+10 -3
drivers/mtd/nand/nand_base.c
··· 65 65 66 66 if (!section) { 67 67 oobregion->offset = 0; 68 - oobregion->length = 4; 68 + if (mtd->oobsize == 16) 69 + oobregion->length = 4; 70 + else 71 + oobregion->length = 3; 69 72 } else { 73 + if (mtd->oobsize == 8) 74 + return -ERANGE; 75 + 70 76 oobregion->offset = 6; 71 77 oobregion->length = ecc->total - 4; 72 78 } ··· 1131 1125 * Ensure the timing mode has been changed on the chip side 1132 1126 * before changing timings on the controller side. 1133 1127 */ 1134 - if (chip->onfi_version) { 1128 + if (chip->onfi_version && 1129 + (le16_to_cpu(chip->onfi_params.opt_cmd) & 1130 + ONFI_OPT_CMD_SET_GET_FEATURES)) { 1135 1131 u8 tmode_param[ONFI_SUBFEATURE_PARAM_LEN] = { 1136 1132 chip->onfi_timing_mode_default, 1137 1133 }; ··· 2749 2741 * @buf: the data to write 2750 2742 * @oob_required: must write chip->oob_poi to OOB 2751 2743 * @page: page number to write 2752 - * @cached: cached programming 2753 2744 * @raw: use _raw version of write_page 2754 2745 */ 2755 2746 static int nand_write_page(struct mtd_info *mtd, struct nand_chip *chip,
+3 -3
drivers/mtd/nand/nand_timings.c
··· 311 311 struct nand_sdr_timings *timings = &iface->timings.sdr; 312 312 313 313 /* microseconds -> picoseconds */ 314 - timings->tPROG_max = 1000000UL * le16_to_cpu(params->t_prog); 315 - timings->tBERS_max = 1000000UL * le16_to_cpu(params->t_bers); 316 - timings->tR_max = 1000000UL * le16_to_cpu(params->t_r); 314 + timings->tPROG_max = 1000000ULL * le16_to_cpu(params->t_prog); 315 + timings->tBERS_max = 1000000ULL * le16_to_cpu(params->t_bers); 316 + timings->tR_max = 1000000ULL * le16_to_cpu(params->t_r); 317 317 318 318 /* nanoseconds -> picoseconds */ 319 319 timings->tCCS_min = 1000UL * le16_to_cpu(params->t_ccs);
+4
drivers/mtd/nand/sunxi_nand.c
··· 1728 1728 */ 1729 1729 chip->clk_rate = NSEC_PER_SEC / min_clk_period; 1730 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 1737 * ONFI specification 3.1, paragraph 4.15.2 dictates that EDO data
+3 -3
include/linux/mtd/nand.h
··· 681 681 * @tWW_min: WP# transition to WE# low 682 682 */ 683 683 struct nand_sdr_timings { 684 - u32 tBERS_max; 684 + u64 tBERS_max; 685 685 u32 tCCS_min; 686 - u32 tPROG_max; 687 - u32 tR_max; 686 + u64 tPROG_max; 687 + u64 tR_max; 688 688 u32 tALH_min; 689 689 u32 tADL_min; 690 690 u32 tALS_min;