Skip to content
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

[bsp/allwinner] feat: porting to RT_USING_DEVICE_OPS #9142

Merged
merged 3 commits into from
Jul 9, 2024

Conversation

polarvid
Copy link
Contributor

@polarvid polarvid commented Jul 6, 2024

拉取/合并请求描述:(PR description)

[

为什么提交这份PR (why to submit this PR)

This patch ports the codebase to use the RT_USING_DEVICE_OPS structure, which is required by v5.1.0 Smart kernel, improves modularity and makes it easier to manage device operations by consolidating them into a single structure, enhancing maintainability and future scalability.

你的解决方案是什么 (what is your solution)

Changes:

  • Added RT_USING_DEVICE_OPS conditionals to partition.c and drv_sdmmc.c.
  • Defined rt_device_ops structures for partition and sdmmc drivers.
  • Updated device initialization to use the ops structure if defined.
  • Replaced direct function calls with rt_dev_control, rt_dev_read, and rt_dev_write macros where applicable.
  • Removed redundant us_delay function from os.c.

请提供验证的bsp和config (provide the config and bsp)

  • BSP: allwinner d1s
  • .config:
  • action:

]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 代码是高质量的 Code in this PR is of high quality
  • 已经使用formatting 等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification

@polarvid
Copy link
Contributor Author

polarvid commented Jul 6, 2024

@ylyamin you could check the PR message or the commit log for details 😉

This patch ports the codebase to use the RT_USING_DEVICE_OPS structure,
which is required by v5.1.0 Smart kernel, improves modularity and makes
it easier to manage device operations by consolidating them into a
single structure, enhancing maintainability and future scalability.

Changes:
- Added RT_USING_DEVICE_OPS conditionals to partition.c and drv_sdmmc.c.
- Defined rt_device_ops structures for partition and sdmmc drivers.
- Updated device initialization to use the ops structure if defined.
- Replaced direct function calls with rt_dev_control, rt_dev_read, and
  rt_dev_write macros where applicable.
- Removed redundant us_delay function from os.c.

Signed-off-by: Shell <smokewood@qq.com>
@polarvid polarvid marked this pull request as ready for review July 6, 2024 08:52
@@ -27,4 +27,18 @@ struct dev_sdmmc
void sd_mmc1_init(void);
void sd_mmc1_deinit(void);

#ifdef RT_USING_DEVICE_OPS
#define rt_dev_has_control(dev) (dev)->ops->control
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些使用rt_device_* API是否更合适些?

Copy link
Contributor Author

@polarvid polarvid Jul 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rt_device API 有特殊的操作协议 (open, init),但是 allwinner HAL 实现 API 没有遵循这种协议。这就导致对接后驱动工作异常(驱动内部直接 read 没有 open,无法通过引用计数检查。也可以理解为驱动内部是通过 dev-ops 调内部 API 的,因此不遵循外部操作协议)。

因此建议是建个 issue,后续工作中继续推进驱动的 API 对接问题。本 PR 还是保留宏的形式。

@Rbb666 Rbb666 added the BSP label Jul 7, 2024
@polarvid polarvid added the Status: waiting for test Waiting test for this PR. label Jul 7, 2024
@polarvid polarvid removed the Status: waiting for test Waiting test for this PR. label Jul 8, 2024
@polarvid
Copy link
Contributor Author

polarvid commented Jul 8, 2024

tested with commit c7e1982 on 柿饼 M7

image

image

@BernardXiong BernardXiong merged commit b733966 into RT-Thread:master Jul 9, 2024
43 checks passed
messigogogo pushed a commit to messigogogo/rt-thread that referenced this pull request Jul 22, 2024
* [bsp/allwinner] feat: porting to RT_USING_DEVICE_OPS

This patch ports the codebase to use the RT_USING_DEVICE_OPS structure,
which is required by v5.1.0 Smart kernel, improves modularity and makes
it easier to manage device operations by consolidating them into a
single structure, enhancing maintainability and future scalability.

Changes:
- Added RT_USING_DEVICE_OPS conditionals to partition.c and drv_sdmmc.c.
- Defined rt_device_ops structures for partition and sdmmc drivers.
- Updated device initialization to use the ops structure if defined.
- Replaced direct function calls with rt_dev_control, rt_dev_read, and
  rt_dev_write macros where applicable.
- Removed redundant us_delay function from os.c.

Signed-off-by: Shell <smokewood@qq.com>

* feat: update configuration

* feat: fixup compiler warning

---------

Signed-off-by: Shell <smokewood@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants