This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 5a067854c78a3f08c78c097c17622fea23dceb5b Author: wangshaoxin <[email protected]> AuthorDate: Tue Aug 4 21:07:06 2026 +0800 drivers/mtd: fix the build when CONFIG_MTD_BYTE_WRITE is disabled struct mtd_dev_s::write only exists with CONFIG_MTD_BYTE_WRITE, but MTD_WRITE() referenced (d)->write unconditionally, so any caller failed to compile without the option. Return -ENOSYS from MTD_WRITE() in that case, as the other MTD_*() macros do for a missing operation. rpmsgmtd_write_handler() then no longer uses its server variable; mark it UNUSED(). Signed-off-by: wangshaoxin <[email protected]> --- drivers/mtd/rpmsgmtd_server.c | 1 + include/nuttx/mtd/mtd.h | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/rpmsgmtd_server.c b/drivers/mtd/rpmsgmtd_server.c index 9c2bc3886ab..8350cd7eaa4 100644 --- a/drivers/mtd/rpmsgmtd_server.c +++ b/drivers/mtd/rpmsgmtd_server.c @@ -288,6 +288,7 @@ static int rpmsgmtd_write_handler(FAR struct rpmsg_endpoint *ept, rpmsg_send(ept, msg, sizeof(*msg) - 1); } + UNUSED(server); return 0; } diff --git a/include/nuttx/mtd/mtd.h b/include/nuttx/mtd/mtd.h index 64bdbf79095..5a7c81492f8 100644 --- a/include/nuttx/mtd/mtd.h +++ b/include/nuttx/mtd/mtd.h @@ -95,7 +95,11 @@ #define MTD_BREAD(d,s,n,b) ((d)->bread ? (d)->bread(d,s,n,b) : (-ENOSYS)) #define MTD_BWRITE(d,s,n,b)((d)->bwrite ? (d)->bwrite(d,s,n,b) : (-ENOSYS)) #define MTD_READ(d,s,n,b) ((d)->read ? (d)->read(d,s,n,b) : (-ENOSYS)) -#define MTD_WRITE(d,s,n,b) ((d)->write ? (d)->write(d,s,n,b) : (-ENOSYS)) +#ifdef CONFIG_MTD_BYTE_WRITE +# define MTD_WRITE(d,s,n,b) ((d)->write ? (d)->write(d,s,n,b) : (-ENOSYS)) +#else +# define MTD_WRITE(d,s,n,b) (-ENOSYS) +#endif #define MTD_IOCTL(d,c,a) ((d)->ioctl ? (d)->ioctl(d,c,a) : (-ENOSYS)) #ifdef CONFIG_FTL_BBM
