From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chee, Tien Fong Date: Mon, 26 Feb 2018 06:20:40 +0000 Subject: [U-Boot] [PATCH v8 4/4] common: Generic firmware loader for file system In-Reply-To: <17cbb393-3661-9735-4261-4c3e25f9237d@denx.de> References: <1517814409-25698-1-git-send-email-tien.fong.chee@intel.com> <1517814409-25698-5-git-send-email-tien.fong.chee@intel.com> <6406826c-2092-a616-1adc-d3c8f735d1a8@denx.de> <1519287480.9210.14.camel@intel.com> <17cbb393-3661-9735-4261-4c3e25f9237d@denx.de> Message-ID: <1519626039.12632.4.camel@intel.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: u-boot@lists.denx.de On Thu, 2018-02-22 at 15:28 +0100, Marek Vasut wrote: > On 02/22/2018 09:18 AM, Chee, Tien Fong wrote: > > > > On Thu, 2018-02-15 at 15:58 +0100, Marek Vasut wrote: > > > > > > On 02/05/2018 08:06 AM, tien.fong.chee at intel.com wrote: > > > > > > > > > > > > From: Tien Fong Chee > > > > > > > > This is file system generic loader which can be used to load > > > > the file image from the storage into target such as memory. > > > > The consumer driver would then use this loader to program > > > > whatever, > > > > ie. the FPGA device. > > > > > > > > Signed-off-by: Tien Fong Chee > > > > Reviewed-by: Lothar Waßmann > > > [...] > > > > > > > > > > > > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#ifdef CONFIG_SPL > > > Are the ifdefs needed ? > > > > > Because spl.h contains some codes have its dependency with SPL. So, > > Tom > > adviced to make this part of code depend on CONFIG_SPL. > > However, only __weak int init_mmc() depend on the codes from spl.h, > > so > > user can override their own init_mmc() if SPL is not used. > You probably dont need those ifdefs around headers. > > > > > > > > > > > > > > +#include > > > > +#endif > > > > +#include > > > > +#ifdef CONFIG_CMD_UBIFS > > > > +#include > > > > +#include > > > > +#endif > > > > +#include > > > > + > > > > +struct firmware_priv { > > > > + const char *name; /* Filename */ > > > > + u32 offset; /* Offset of reading a file > > > > */ > > > > +}; > > > > + > > > > +static struct device_location default_locations[] = { > > > > + { > > > > + .name = "mmc", > > > > + .devpart = "0:1", > > > > + }, > > > > + { > > > > + .name = "usb", > > > > + .devpart = "0:1", > > > > + }, > > > > + { > > > > + .name = "sata", > > > > + .devpart = "0:1", > > > > + }, > > > How can this load from UBI if it's not listed here ? > Well ? > I can add ".name = ubi" and ".devpart = UBI" . > [...] > > > > > > > > > > > > > > +#ifdef CONFIG_SATA > > > > +static int init_storage_sata(void) > > > > +{ > > > > + return sata_probe(0); > > > Shouldn't the sata device number be pulled from devpart in > > > default_locations table ? > > > > > This may need to add the logic for splitting the device number and > > partition into integer from the string. Let me think how to do it, > > may > > be i can leverage existing code. > strtok(), strtol() or something ? > yes, plan to use that. > [...] > > > > > > > > > > > > > > +#ifdef CONFIG_SPL > > > > + spl_mmc_find_device(&mmc, spl_boot_device()); > > > > +#else > > > > + debug("#define CONFIG_SPL is required or overrriding > > > > %s\n", > > > > +       __func__); > > > This can be a compile-time error, maybe ? > > > > > No compile error. When you open the file, "%s\n" is actually same > > line > > with debug("..... . > So what ? This missing macro can be detected at runtime, heck this > code > can even depend on CONFIG_SPL in Kconfig. > Oh...I got you, i thought you means syntax error. So, i would remove it and adding the depend on CONFIG_SPL in Kconfig. > > > > > > > > > > > > > > > > > + return -ENOENT; > > > > +#endif > > > > + > > > > + err = mmc_init(mmc); > > > > + if (err) { > > > > + debug("spl: mmc init failed with error: %d\n", > > > > err); > > > > + return err; > > > > + } > > > > + > > > > + return err; > > > > +} > > > > +#else > > > > +__weak int init_mmc(void) > > > > +{ > > > > + /* Expect somewhere already initialize MMC */ > > > > + return 0; > > > > +} > > > > +#endif > > > [...] >