storage: implement driver for grlib nandfctrl2#643
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new driver for the GRLIB NANDFCTRL2, significantly expanding the system's storage capabilities by enabling support for NAND flash devices. The implementation provides a robust MTD interface for interacting with the flash, including low-level DMA operations, ECC handling, and bad block management. A comprehensive test suite is also included to ensure the driver's reliability and correctness. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new GRLIB NANDFCTRL2 flash controller driver, device interface, and server, along with a dedicated test program. The review highlights several areas for improvement, including a critical bug in flashsrv.c where partition paths are hardcoded to mtd0, which will cause issues with multiple dies. Additionally, there are suggestions to refactor duplicated error handling and resource cleanup code in flashdev.c and flashdrv.c using goto statements for improved readability and maintainability. The review also points out the use of a magic number for interrupt enabling in flashdrv.c that should be replaced with a more descriptive constant, and a type correctness issue in flashsrv.c where strtol is used instead of strtoul for parsing an unsigned integer.
| } | ||
|
|
||
|
|
||
| int flashdev_init(storage_t *strg, unsigned int target) |
There was a problem hiding this comment.
The error handling in this function has a lot of duplicated code for cleaning up allocated resources. This can be made much cleaner and less error-prone by using goto statements for a centralized cleanup path. This is a common and accepted pattern in C for resource management.
For example:
int flashdev_init(storage_t *strg, unsigned int target)
{
int err = -ENOMEM;
strg->dev = malloc(sizeof(storage_dev_t));
if (strg->dev == NULL) {
return err;
}
strg->dev->ctx = malloc(sizeof(storage_devCtx_t));
if (strg->dev->ctx == NULL) {
goto err_dev;
}
/* ... other allocations ... */
return 0;
/* ... cleanup labels ... */
err_ctx:
free(strg->dev->ctx);
err_dev:
free(strg->dev);
strg->dev = NULL;
return err;
}| } | ||
|
|
||
|
|
||
| int flashdrv_init(void) |
There was a problem hiding this comment.
YT: CSAT-158
5da07a1 to
18745d2
Compare
YT: CSAT-158
Description
Motivation and Context
Types of changes
How Has This Been Tested?
riscv64-gr765-vcu118Checklist:
Special treatment