From: Stefano Manni <stefano.manni@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 1/2] imx-bbu-nand-fcb: do not use hardcoded devicefile
Date: Thu, 20 Feb 2025 18:39:55 +0100 [thread overview]
Message-ID: <J2TZRS.AUAITN7RW0RJ1@gmail.com> (raw)
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.
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;
}
--
2.25.1
next reply other threads:[~2025-02-20 16:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 17:39 Stefano Manni [this message]
2025-02-21 10:38 ` Sascha Hauer
2025-02-21 17:47 ` Stefano Manni
2025-02-21 18:01 Stefano Manni
2025-02-21 17:33 ` Ahmad Fatoum
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=J2TZRS.AUAITN7RW0RJ1@gmail.com \
--to=stefano.manni@gmail.com \
--cc=barebox@lists.infradead.org \
/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