mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Alexander Shiyan <eagle.alexander923@gmail.com>,
	barebox@lists.infradead.org
Subject: Re: [PATCH] ARM: OMAP: xload: Fix compile without CONFIG_MTD
Date: Thu, 2 Jun 2022 10:07:34 +0200	[thread overview]
Message-ID: <53dfc2e7-7271-e872-dbf9-ffb9ed7e7802@pengutronix.de> (raw)
In-Reply-To: <20220601071452.17033-1-eagle.alexander923@gmail.com>

On 01.06.22 09:14, Alexander Shiyan wrote:
> arm-linux-ld: arch/arm/mach-omap/xload.o: in function read_mtd_barebox':
> /home/ARM/barebox/arch/arm/mach-omap/xload.c:75: undefined reference to mtd_peb_read_file'

Am I missing something or does this patch just change

  if (0) {
    return NULL;
  }

  /* something */;
  return to;

into

  if (0) {
    /* something */
    return to;
  }
  return NULL;


This shouldn't really make a difference. How old is your GCC?

Cheers,
Ahmad

> 
> Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com>
> ---
>  arch/arm/mach-omap/xload.c | 72 ++++++++++++++++++--------------------
>  1 file changed, 34 insertions(+), 38 deletions(-)
> 
> diff --git a/arch/arm/mach-omap/xload.c b/arch/arm/mach-omap/xload.c
> index 6d3704b8cf..78b2221304 100644
> --- a/arch/arm/mach-omap/xload.c
> +++ b/arch/arm/mach-omap/xload.c
> @@ -53,46 +53,44 @@ static void *read_mtd_barebox(const char *part, unsigned int start, unsigned int
>  	struct mtd_info *mtd;
>  	unsigned int ps, pe;
>  
> -	if (!IS_ENABLED(CONFIG_MTD)) {
> -		printf("Cannot load from nand/nor: MTD support is disabled\n");
> -		return NULL;
> -	}
> +	if (IS_ENABLED(CONFIG_MTD)) {
> +		cdev = cdev_open_by_name(part, O_RDONLY);
> +		if (!cdev) {
> +			printf("failed to open partition\n");
> +			return NULL;
> +		}
>  
> -	cdev = cdev_open_by_name(part, O_RDONLY);
> -	if (!cdev) {
> -		printf("failed to open partition\n");
> -		return NULL;
> -	}
> +		mtd = cdev->mtd;
> +		if (!mtd)
> +			return NULL;
>  
> -	mtd = cdev->mtd;
> -	if (!mtd)
> -		return NULL;
> +		if (mtd_mod_by_eb(start, mtd) != 0) {
> +			printf("Start must be eraseblock aligned\n");
> +			return NULL;
> +		}
>  
> -	if (mtd_mod_by_eb(start, mtd) != 0) {
> -		printf("Start must be eraseblock aligned\n");
> -		return NULL;
> -	}
> +		to = xmalloc(size);
>  
> -	to = xmalloc(size);
> +		ps = mtd_div_by_eb(start, mtd);
> +		pe = mtd_div_by_eb(start + size, mtd);
> +		ret = mtd_peb_read_file(mtd, ps, pe, to, size);
> +		if (ret) {
> +			printf("Can't read image from %s: %d\n", part, ret);
> +			goto err;
> +		}
>  
> -	ps = mtd_div_by_eb(start, mtd);
> -	pe = mtd_div_by_eb(start + size, mtd);
> -	ret = mtd_peb_read_file(mtd, ps, pe, to, size);
> -	if (ret) {
> -		printf("Can't read image from %s: %d\n", part, ret);
> -		goto err;
> -	}
> +		size = get_image_size(to);
> +		if (!size) {
> +			printf("failed to get image size\n");
> +			goto err;
> +		}
>  
> -	size = get_image_size(to);
> -	if (!size) {
> -		printf("failed to get image size\n");
> -		goto err;
> -	}
> +		return to;
>  
> -	return to;
> +		err:
> +		free(to);
> +	}
>  
> -err:
> -	free(to);
>  	return NULL;
>  }
>  
> @@ -292,7 +290,7 @@ static void *am33xx_net_boot(void)
>   */
>  static __noreturn int omap_xload(void)
>  {
> -	void *func;
> +	void *func = NULL;
>  
>  	if (!barebox_part)
>  		barebox_part = &default_part;
> @@ -310,10 +308,8 @@ static __noreturn int omap_xload(void)
>  		} else if (IS_ENABLED(CONFIG_FS_OMAP4_USBBOOT)) {
>  			printf("booting from USB\n");
>  			func = omap4_xload_boot_usb();
> -		} else {
> +		} else
>  			printf("booting from USB not enabled\n");
> -			func = NULL;
> -		}
>  		break;
>  	case BOOTSOURCE_NAND:
>  		printf("booting from NAND\n");
> @@ -327,16 +323,16 @@ static __noreturn int omap_xload(void)
>  		if (IS_ENABLED(CONFIG_OMAP_SERIALBOOT)) {
>  			printf("booting from serial\n");
>  			func = omap_serial_boot();
> -			break;
>  		}
> +		break;
>  	case BOOTSOURCE_NET:
>  		if (IS_ENABLED(CONFIG_AM33XX_NET_BOOT)) {
>  			printf("booting from NET\n");
>  			func = am33xx_net_boot();
> -			break;
>  		} else {
>  			printf("booting from network not enabled\n");
>  		}
> +		break;
>  	default:
>  		printf("unknown boot source. Fall back to nand\n");
>  		func = omap_xload_boot_nand(barebox_part);


-- 
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@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  parent reply	other threads:[~2022-06-02  8:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-01  7:14 Alexander Shiyan
2022-06-02  6:55 ` Sascha Hauer
2022-06-02  8:07 ` Ahmad Fatoum [this message]
2022-06-02  8:59   ` Alexander Shiyan
2022-06-02  9:01     ` Ahmad Fatoum
2022-06-02  9:10       ` Alexander Shiyan
2022-06-03  6:56 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53dfc2e7-7271-e872-dbf9-ffb9ed7e7802@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=eagle.alexander923@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox