-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[DM][REGULATOR] Update regulator #11009
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,6 +31,7 @@ static rt_err_t regulator_disable(struct rt_regulator_node *reg_np); | |||||||||||||
|
|
||||||||||||||
| rt_err_t rt_regulator_register(struct rt_regulator_node *reg_np) | ||||||||||||||
| { | ||||||||||||||
| rt_err_t err; | ||||||||||||||
| const struct rt_regulator_param *param; | ||||||||||||||
|
|
||||||||||||||
| if (!reg_np || !reg_np->dev || !reg_np->param || !reg_np->ops) | ||||||||||||||
|
|
@@ -48,6 +49,16 @@ rt_err_t rt_regulator_register(struct rt_regulator_node *reg_np) | |||||||||||||
|
|
||||||||||||||
| reg_np->parent = RT_NULL; | ||||||||||||||
|
|
||||||||||||||
| if ((param->ramp_delay || param->ramp_disable) && | ||||||||||||||
| reg_np->ops->set_ramp_delay) | ||||||||||||||
| { | ||||||||||||||
| if ((err = reg_np->ops->set_ramp_delay(reg_np, param->ramp_delay))) | ||||||||||||||
| { | ||||||||||||||
| LOG_E("Set ramp error = %s\n", rt_strerror(err)); | ||||||||||||||
| return err; | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| #ifdef RT_USING_OFW | ||||||||||||||
| if (reg_np->dev->ofw_node) | ||||||||||||||
| { | ||||||||||||||
|
|
@@ -184,6 +195,40 @@ static rt_uint32_t regulator_get_enable_time(struct rt_regulator_node *reg_np) | |||||||||||||
| return 0; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| static rt_uint32_t regulator_set_voltage_time(struct rt_regulator_node *reg_np, | ||||||||||||||
| int old_uvolt, int new_uvolt) | ||||||||||||||
| { | ||||||||||||||
| unsigned int ramp_delay = 0; | ||||||||||||||
|
|
||||||||||||||
| if (reg_np->param->ramp_delay) | ||||||||||||||
| { | ||||||||||||||
| ramp_delay = reg_np->param->ramp_delay; | ||||||||||||||
| } | ||||||||||||||
| else if (reg_np->param->ramp_delay) | ||||||||||||||
| { | ||||||||||||||
| ramp_delay = reg_np->param->ramp_delay; | ||||||||||||||
|
Comment on lines
+207
to
+209
|
||||||||||||||
| else if (reg_np->param->ramp_delay) | |
| { | |
| ramp_delay = reg_np->param->ramp_delay; | |
| else if (reg_np->ops->get_voltage_time) | |
| { | |
| ramp_delay = reg_np->ops->get_voltage_time(reg_np, old_uvolt, new_uvolt); |
Copilot
AI
Dec 2, 2025
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.
🟠 [Bug/错误]: Missing error code assignment when regulator node is not found
English: When reg_np is NULL (line 642), the function jumps to _end without setting an error code in reg. The removed line at 643 previously set reg = rt_err_ptr(-RT_ENOSYS) to indicate the regulator was not found. Without this assignment, the function returns NULL instead of an error pointer, which breaks the error handling contract where callers expect error pointers (as seen in lines 608, 628, 657).
中文: 当 reg_np 为 NULL(第 642 行)时,函数跳转到 _end 而没有在 reg 中设置错误代码。之前第 643 行的代码设置了 reg = rt_err_ptr(-RT_ENOSYS) 来表示未找到调节器。如果没有这个赋值,函数返回 NULL 而不是错误指针,这破坏了错误处理契约,调用者期望错误指针(如第 608、628、657 行所示)。
Suggested fix/建议修复:
if (!reg_np)
{
reg = rt_err_ptr(-RT_ENOSYS);
goto _end;
}| { | |
| { | |
| reg = rt_err_ptr(-RT_ENOSYS); |
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.
🟢 [Documentation/文档]: Missing unit comments for new settling time fields
English: The new fields
settling_time,settling_time_up, andsettling_time_down(lines 33-35) lack unit specification comments. Following the existing convention in the struct where other time-related fields have "/* In usec /" or "/ In uV/usec */" comments, these new fields should also document their units for consistency and clarity.中文: 新字段
settling_time、settling_time_up和settling_time_down(第 33-35 行)缺少单位说明注释。遵循结构体中现有的约定,其他与时间相关的字段都有 "/* In usec /" 或 "/ In uV/usec */" 注释,这些新字段也应该记录其单位以保持一致性和清晰度。Suggested fix/建议修复: