mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Stefano Manni <stefano.manni@gmail.com>, barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] imx-bbu-nand-fcb: do not use hardcoded devicefile
Date: Fri, 21 Feb 2025 18:33:04 +0100	[thread overview]
Message-ID: <06d40295-264c-4119-a201-f6e045def59d@pengutronix.de> (raw)
In-Reply-To: <20250221180109.14129-1-stefano.manni@gmail.com>

Hello Stefano,

On 21.02.25 19:01, Stefano Manni wrote:
> Device file was hardcoded to "nand0.barebox".
> This patch harmonize the signature of
> 
> imx6_bbu_nand_register_handler()
> imx7_bbu_nand_register_handler()
> imx28_bbu_nand_register_handler()
> 
> with the other bbu register functions in order to take
> the devicefile as parameter.

Is this this the sole motivation behind the patch or do you
intend to actually make use of the ability of varying
the devicefile?

Thanks,
Ahmad

> 
> Signed-off-by: Stefano Manni <stefano.manni@gmail.com>
> ---
>  common/imx-bbu-nand-fcb.c | 23 ++++++++++++++++-------
>  include/bbu.h             | 18 ++++++++++++------
>  2 files changed, 28 insertions(+), 13 deletions(-)
> 
> diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c
> index d0261140cf..0d17a7bf6a 100644
> --- a/common/imx-bbu-nand-fcb.c
> +++ b/common/imx-bbu-nand-fcb.c
> @@ -1219,6 +1219,7 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *dat
>  	int used = 0;
>  	int fw_orig_len = 0;
>  	int used_refresh = 0, unused_refresh = 0;
> +	const char *devname = handler->devicefile;
>  
>  	if (data->image) {
>  		filetype = file_detect_type(data->image, data->len);
> @@ -1230,7 +1231,12 @@ static int imx_bbu_nand_update(struct bbu_handler *handler, struct bbu_data *dat
>  			return -EINVAL;
>  	}
>  
> -	bcb_cdev = cdev_by_name(handler->devicefile);
> +	/* Support both boot /dev/nand0.barebox and boot nand0.barebox */
> +	devname += str_has_prefix(devname, "/dev/");
> +
> +	device_detect_by_name(devname);
> +
> +	bcb_cdev = cdev_by_name(devname);
>  	if (!bcb_cdev) {
>  		pr_err("%s: No FCB device!\n", __func__);
>  		return -ENODEV;
> @@ -1432,7 +1438,8 @@ static void imx6_fcb_create(struct imx_nand_fcb_bbu_handler *imx_handler,
>  	fcb->MetadataBytes = 10;
>  }
>  
> -int imx6_bbu_nand_register_handler(const char *name, unsigned long flags)
> +int imx6_bbu_nand_register_handler(const char *name,
> +		const char *devicefile, unsigned long flags)
>  {
>  	struct imx_nand_fcb_bbu_handler *imx_handler;
>  	struct bbu_handler *handler;
> @@ -1451,7 +1458,7 @@ int imx6_bbu_nand_register_handler(const char *name, unsigned long flags)
>  	}
>  
>  	handler = &imx_handler->handler;
> -	handler->devicefile = "nand0.barebox";
> +	handler->devicefile = devicefile;
>  	handler->name = name;
>  	handler->flags = flags | BBU_HANDLER_CAN_REFRESH;
>  	handler->handler = imx_bbu_nand_update;
> @@ -1526,7 +1533,8 @@ static void imx28_fcb_create(struct imx_nand_fcb_bbu_handler *imx_handler,
>  	fcb->EraseThreshold = readl(bch_regs + BCH_MODE);
>  }
>  
> -int imx28_bbu_nand_register_handler(const char *name, unsigned long flags)
> +int imx28_bbu_nand_register_handler(const char *name,
> +		const char *devicefile, unsigned long flags)
>  {
>  	struct imx_nand_fcb_bbu_handler *imx_handler;
>  	struct bbu_handler *handler;
> @@ -1540,7 +1548,7 @@ int imx28_bbu_nand_register_handler(const char *name, unsigned long flags)
>  	imx_handler->filetype = filetype_mxs_bootstream;
>  
>  	handler = &imx_handler->handler;
> -	handler->devicefile = "nand0.barebox";
> +	handler->devicefile = devicefile;
>  	handler->name = name;
>  	handler->flags = flags | BBU_HANDLER_CAN_REFRESH;
>  	handler->handler = imx_bbu_nand_update;
> @@ -1599,7 +1607,8 @@ static int imx7_fcb_write(struct mtd_info *mtd, int block, struct fcb_block *fcb
>  	return mxs_nand_write_fcb_bch62(block, fcb, sizeof(*fcb));
>  }
>  
> -int imx7_bbu_nand_register_handler(const char *name, unsigned long flags)
> +int imx7_bbu_nand_register_handler(const char *name
> +	   const char *devicefile, unsigned long flags)
>  {
>  	struct imx_nand_fcb_bbu_handler *imx_handler;
>  	struct bbu_handler *handler;
> @@ -1612,7 +1621,7 @@ int imx7_bbu_nand_register_handler(const char *name, unsigned long flags)
>  	imx_handler->filetype = filetype_arm_barebox;
>  
>  	handler = &imx_handler->handler;
> -	handler->devicefile = "nand0.barebox";
> +	handler->devicefile = devicefile;
>  	handler->name = name;
>  	handler->flags = flags | BBU_HANDLER_CAN_REFRESH;
>  	handler->handler = imx_bbu_nand_update;
> diff --git a/include/bbu.h b/include/bbu.h
> index 5105d2ac70..087d3ee827 100644
> --- a/include/bbu.h
> +++ b/include/bbu.h
> @@ -98,19 +98,25 @@ static inline int bbu_mmcboot_register_handler(const char *name,
>  #endif
>  
>  #if defined(CONFIG_BAREBOX_UPDATE_IMX_NAND_FCB)
> -int imx6_bbu_nand_register_handler(const char *name, unsigned long flags);
> -int imx7_bbu_nand_register_handler(const char *name, unsigned long flags);
> -int imx28_bbu_nand_register_handler(const char *name, unsigned long flags);
> +int imx6_bbu_nand_register_handler(const char *name, const char *devicefile, unsigned long flags);
> +int imx7_bbu_nand_register_handler(const char *name, const char *devicefile, unsigned long flags);
> +int imx28_bbu_nand_register_handler(const char *name, const char *devicefile, unsigned long flags);
>  #else
> -static inline int imx6_bbu_nand_register_handler(const char *name, unsigned long flags)
> +static inline int imx6_bbu_nand_register_handler(const char *name,
> +					       const char *devicefile,
> +					       unsigned long flags)
>  {
>  	return -ENOSYS;
>  }
> -static inline int imx7_bbu_nand_register_handler(const char *name, unsigned long flags)
> +static inline int imx7_bbu_nand_register_handler(const char *name,
> +					       const char *devicefile,
> +					       unsigned long flags)
>  {
>  	return -ENOSYS;
>  }
> -static inline int imx28_bbu_nand_register_handler(const char *name, unsigned long flags)
> +static inline int imx28_bbu_nand_register_handler(const char *name,
> +					       const char *devicefile,
> +					       unsigned long flags)
>  {
>  	return -ENOSYS;
>  }


-- 
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 |



  reply	other threads:[~2025-02-21 18:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-21 18:01 Stefano Manni
2025-02-21 17:33 ` Ahmad Fatoum [this message]
2025-02-21 18:01 ` [PATCH 2/2] ARM: boards: fix nand bbu_handler device paths Stefano Manni
  -- strict thread matches above, loose matches on Subject: below --
2025-02-20 17:39 [PATCH 1/2] imx-bbu-nand-fcb: do not use hardcoded devicefile Stefano Manni
2025-02-21 10:38 ` Sascha Hauer
2025-02-21 17:47   ` Stefano Manni

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=06d40295-264c-4119-a201-f6e045def59d@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=stefano.manni@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