-
Notifications
You must be signed in to change notification settings - Fork 655
examples/mtdpart:Register MTD devices using the mtd_register method #3130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
35c3954
to
1229352
Compare
please fix:
|
sure, working on this now |
06705ab
to
1c2b33e
Compare
done |
still have ci error, please run checkpatch.sh before you update patch. @jingfei195887 |
1c2b33e
to
babf87b
Compare
1. Due to the automatic wrapping of MTD devices during the open() process, the legacy registration methods ftl_initialize() and bchdev_register() are no longer required for MTD device registration. The new method is now changed to register_mtddriver 2. Some code for space release and deregistration has been added, and certain error handling methods have been updated.
babf87b
to
27ba699
Compare
@@ -204,7 +194,9 @@ int main(int argc, FAR char *argv[]) | |||
if (ret < 0) | |||
{ | |||
ferr("ERROR: mtd->ioctl failed: %d\n", ret); | |||
exit(3); | |||
unregister_mtddriver("/dev/mtd0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to the end and add label err_mtd
@@ -317,8 +294,9 @@ int main(int argc, FAR char *argv[]) | |||
if (nbytes < 0) | |||
{ | |||
printf("ERROR: write to /dev/mtd0 failed: %d\n", errno); | |||
fflush(stdout); | |||
exit(9); | |||
close(fd); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move close to the end and add label err_fd
fflush(stdout); | ||
exit(1); | ||
status = 1; | ||
goto errout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goto errout; | |
goto err; |
@@ -133,8 +133,7 @@ int main(int argc, FAR char *argv[]) | |||
FAR struct mtd_dev_s *part[CONFIG_EXAMPLES_MTDPART_NPARTITIONS + 1]; | |||
FAR struct mtd_geometry_s geo; | |||
FAR uint32_t *buffer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need zero
printf("ERROR: error status %d\n", status); | ||
} | ||
|
||
if (buffer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the check
|
||
if (status) | ||
{ | ||
printf("ERROR: error status %d\n", status); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the unnecessary log
free(buffer); | ||
} | ||
|
||
if (master) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need zero at line 132, please fix ALL warning before submit your change.
fflush(stdout); | ||
exit(7); | ||
status = 6; | ||
goto errout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goto err_buf
exit(3); | ||
printf("ERROR: register_mtddriver /dev/mtd0 failed: %d\n", ret); | ||
status = 2; | ||
goto errout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goto err_mtd
Summary
Due to the automatic wrapping of MTD devices during the open() process, the legacy registration methods ftl_initialize() and bchdev_register() are no longer required for MTD device registration. The new method is now changed to register_mtddriver
Some code for space release and deregistration has been added, and certain error handling methods have been updated.
Test
Run the
examples/mtdpart
in sim:nsh for test an test is passed