diff mbox series

[RESEND] spl: spl_fit: add weak prototype for fpga_load

Message ID 20230619102839.277902-1-eugen.hristev@collabora.com
State Superseded
Delegated to: Michal Simek
Headers show
Series [RESEND] spl: spl_fit: add weak prototype for fpga_load | expand

Commit Message

Eugen Hristev June 19, 2023, 10:28 a.m. UTC
In case OPTIMIZE_DEBUG is set, unused code will not be optimized out, hence
the reference to fpga_load will be compiled.
if DM_FPGA and SPL_FPGA are not set, the build will fail with :

aarch64-none-linux-gnu-ld.bfd: common/spl/spl_fit.o: in function `spl_fit_upload_fpga':
u-boot/common/spl/spl_fit.c:595: undefined reference to `fpga_load'

By adding a weak prototype, build is successful.

Signed-off-by: Eugen Hristev <eugen.hristev@collabora.com>
---
 common/spl/spl_fit.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Simon Glass June 19, 2023, 12:37 p.m. UTC | #1
Hi Eugen,

On Mon, 19 Jun 2023 at 11:29, Eugen Hristev <eugen.hristev@collabora.com> wrote:
>
> In case OPTIMIZE_DEBUG is set, unused code will not be optimized out, hence
> the reference to fpga_load will be compiled.
> if DM_FPGA and SPL_FPGA are not set, the build will fail with :
>
> aarch64-none-linux-gnu-ld.bfd: common/spl/spl_fit.o: in function `spl_fit_upload_fpga':
> u-boot/common/spl/spl_fit.c:595: undefined reference to `fpga_load'
>
> By adding a weak prototype, build is successful.
>
> Signed-off-by: Eugen Hristev <eugen.hristev@collabora.com>
> ---
>  common/spl/spl_fit.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
> index c51482b3b659..ca2e337b1ec4 100644
> --- a/common/spl/spl_fit.c
> +++ b/common/spl/spl_fit.c
> @@ -570,6 +570,12 @@ static void warn_deprecated(const char *msg)
>         printf("\tSee doc/uImage.FIT/source_file_format.txt\n");
>  }
>
> +__weak int fpga_load(int devnum, const void *buf, size_t bsize,
> +                    bitstream_type bstype, int flags)
> +{
> +       return 0;
> +}
> +
>  static int spl_fit_upload_fpga(struct spl_fit_info *ctx, int node,
>                                struct spl_image_info *fpga_image)
>  {
> --
> 2.34.1
>

I'm not sure what to do with this. Perhaps the least worst is to put
your weak function behind an '#ifdef OPTIMIZE_DEBUG'? Or would it work
to create a static inline in the header for this case? Putting #ifdefs
in the header files is more acceptable.

Regards,
Simon
diff mbox series

Patch

diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index c51482b3b659..ca2e337b1ec4 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -570,6 +570,12 @@  static void warn_deprecated(const char *msg)
 	printf("\tSee doc/uImage.FIT/source_file_format.txt\n");
 }
 
+__weak int fpga_load(int devnum, const void *buf, size_t bsize,
+		     bitstream_type bstype, int flags)
+{
+	return 0;
+}
+
 static int spl_fit_upload_fpga(struct spl_fit_info *ctx, int node,
 			       struct spl_image_info *fpga_image)
 {