On Mon, Jul 06, 2020 at 12:35:30AM +0200, Ahmad Fatoum wrote: > > > On 7/5/20 8:42 PM, Sascha Hauer wrote: > > On Wed, Jul 01, 2020 at 11:11:13AM +0200, Ahmad Fatoum wrote: > >> +static void at91_fat_start_image(struct pbl_bio *bio, > >> + void *buf, unsigned int len, > >> + u32 r4) > >> +{ > >> + void __noreturn (*bb)(void); > >> + int ret; > >> + > >> + ret = pbl_fat_load(bio, "barebox.bin", buf, len); > >> + if (ret < 0) { > >> + pr_err("pbl_fat_load: error %d\n", ret); > >> + return; > >> + } > >> + > >> + bb = buf; > >> + > >> + sync_caches_for_execution(); > >> + > >> + xload_bb(bb, r4); > >> +} > >> + > >> +static const struct sdhci_instance { > >> + void __iomem *base; > >> + unsigned id; > >> + u8 periph; > >> + s8 pins[15]; > >> +} sdhci_instances[] = { > >> + [0] = { SAMA5D2_BASE_SDHC0, SAMA5D2_ID_SDMMC0, AT91_MUX_PERIPH_A, > >> + { 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 13, 10, 11, 12, -1 } }, > >> + [1] = { SAMA5D2_BASE_SDHC1, SAMA5D2_ID_SDMMC1, AT91_MUX_PERIPH_E, > >> + { 18, 19, 20, 21, 22, 28, 30, -1 } }, > >> +}; > > > > Can we use C99 initializer here please? > > Can do > > > > >> + > >> +/** > >> + * sama5d2_sdhci_start_image - Load and start an image from FAT-formatted SDHCI > >> + * @r4: value of r4 passed by BootROM > >> + * > >> + * Return: If successul, this function does not return. A negative error > > > > s/successul/successful/ > > > >> + * code is returned when this function fails. > > > > This is not true, the function panics on error. > > It did when I first wrote the comment :D. > Will reply with a fixup. > > > > >> + */ > >> +void __noreturn sama5d2_sdhci_start_image(u32 r4) > >> +{ > >> + void *buf = (void *)SAMA5_DDRCS; > >> + const struct sdhci_instance *instance; > >> + struct pbl_bio bio; > >> + const s8 *pin; > >> + int ret; > >> + > >> + instance = &sdhci_instances[!!sama5_bootsource_instance(r4)]; > > > > Why "!!"? sama5_bootsource_instance() should return exactly 0 or 1 here. > > SAMA5_BOOTSOURCE_INSTANCE is GENMASK(7, 4). While it should only be 0 or 1 > on the sama5d2, better be on the safe side and force it to either 0 or 1. "safe" would be to only accept 0 and 1 and refuse other values. Interpreting everything != 0 as 1 is IMO not safe. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox