-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[component ]add INIT_XXX_EXPORT_ORDER macro #5194
Conversation
没这么随意加代码,加到99的吧 |
希望在4.0.5能有这个功能,同级初始化顺序不可控,一直被吐槽😢 |
范围可以改,如: 0 ~ 15,0 ~ 20,甚至是0~9,都可以. |
这个为啥关闭呀,感觉这种有序初始化的方式,还挺需要的呢 |
先别关,这个一直是个痛点。 |
找不到优雅的写法,也可将此代码独立一个文件 |
/* initialization export order */ | ||
#define _INIT_ORDER_0 "00" | ||
#define _INIT_ORDER_1 "01" | ||
#define _INIT_ORDER_2 "02" | ||
#define _INIT_ORDER_3 "03" | ||
#define _INIT_ORDER_4 "04" | ||
#define _INIT_ORDER_5 "05" | ||
#define _INIT_ORDER_6 "06" | ||
#define _INIT_ORDER_7 "07" | ||
#define _INIT_ORDER_8 "08" | ||
#define _INIT_ORDER_9 "09" |
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.
定义这么多宏定义实在意义不大, 使用的时候直接用字符串就可以了, 例如:
INIT_PREV_EXPORT_ORDER(fn, "3")
至于 default, 个人认为默认0就可以了
#define INIT_ORDER_DEFAULT "00"
或者这样定义, 就不用加双引号:
#define INIT_DEVICE_EXPORT_ORDER(fn, order) INIT_EXPORT(fn, "3." #order)
一点个人看法, 仅供参考,谢谢!
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.
- 定义这么宏就是为了避免出现 10 高于 2 的问题
- 若不定义这些宏,就按你的方案,这样
order
就是开放的。只能人为约定,不能写0 ~ 9,只能写00 ~ 09。也可是其他字符串。这样有潜在风险。(这种方案可授受?) - 至于 default 定义在中间值,就是为了可在默认
INIT_XXX_EXPORT(fn)
的之前或之后运行
这种方案如何?
INIT_BOARD_EXPORT(fn); /* 默认 */
INIT_BOARD_EXPORT_BEFORE(fn,8); /* 在默认之前 */
INIT_BOARD_EXPORT_AFTER(fn,2); /* 在默认之后 */
/* 自定义顺序(10~99) */
#define _INIT_ORDER_88 "88"
INIT_BOARD_EXPORT_AFTER(fn,88);
#define _INIT_ORDER_0 "00"
#define _INIT_ORDER_1 "01"
#define _INIT_ORDER_2 "02"
#define _INIT_ORDER_3 "03"
#define _INIT_ORDER_4 "04"
#define _INIT_ORDER_5 "05"
#define _INIT_ORDER_6 "06"
#define _INIT_ORDER_7 "07"
#define _INIT_ORDER_8 "08"
#define _INIT_ORDER_9 "09"
#define _INIT_ORDER(order) _INIT_ORDER_##order
/* board init routines will be called in board_init() function */
#define INIT_BOARD_EXPORT_BEFORE(fn, order) INIT_EXPORT(fn, "1.0" _INIT_ORDER(order))
#define INIT_BOARD_EXPORT(fn) INIT_EXPORT(fn, "1.100")
#define INIT_BOARD_EXPORT_AFTER(fn, order) INIT_EXPORT(fn, "1.2" _INIT_ORDER(order)) |
奇怪,知道外设初始化过程的依赖关系,为什么就不可以把两个有依赖关系的外设初始化过程放一起?在同一个初始化函数里进行,保证执行过程的正确顺序。 |
如果这样说, |
一个明确的,有限的几个启动阶段,和一个不确定的,没依据的启动编号。两者选哪个? linux 已经放弃了 00-99 的启动编号顺序的方式了,大多发行版改用 systemd 设置启动,不是没有根据的。 我们应该做的可能是出一份使用说明和注意事项,而不是把启动阶段划分扩展到 100 1000 个 |
实现一个 systemd ? 好像挺复杂的. |
没人说在 rtt 上实现 systemd 保持现状就好。用增加编号的办法解决依赖问题,不怎么高明, |
实现一套 systemd ,似乎是个好的方式 😄 |
拉取/合并请求描述:(PR description)
[
组件初始化中的同级初始化顺序一直是个痛点. 如:
本 PR 添加一组INIT_XXX_EXPORT_ORDER 宏,以解决这个问题
10
高于2
的问题]
以下的内容不应该在提交PR时的message修改,修改下述message,PR会被直接关闭。请在提交PR后,浏览器查看PR并对以下检查项逐项check,没问题后逐条在页面上打钩。
The following content must not be changed in the submitted PR message. Otherwise, the PR will be closed immediately. After submitted PR, please use a web browser to visit PR, and check items one by one, and ticked them if no problem.
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0
代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up