Skip to content

Dev rewrite#7

Merged
ZR233 merged 8 commits into
mainfrom
dev-rewrite
Jun 24, 2025
Merged

Dev rewrite#7
ZR233 merged 8 commits into
mainfrom
dev-rewrite

Conversation

@ZR233
Copy link
Copy Markdown
Member

@ZR233 ZR233 commented Jun 24, 2025

This pull request introduces several changes to improve the modularity and functionality of the rdrive project. Key updates include refactoring the driver interface, enhancing the PlatformDevice abstraction, and restructuring dependencies for better organization. Additionally, redundant code has been removed, and new utility methods have been added to streamline device management.

Refactoring and Enhancements to Driver Interface:

  • interface/rdif-base/src/lib.rs: Replaced the Any trait with AsAny in DriverGeneric for better type safety and flexibility. Removed the lock module as it is no longer required.
  • examples/enumerate/src/main.rs: Updated DriverGeneric implementations to align with the new PlatformDevice abstraction, simplifying the probe logic and enhancing device registration. [1] [2]
  • examples/enumerate/src/timer.rs: Refactored probe logic to use PlatformDevice for device registration and interaction with parent devices.

Dependency Restructuring:

  • Cargo.toml and interface/rdif-base/Cargo.toml: Updated dependencies to include local paths for rdif-* modules, facilitating better modularity and local development workflows. [1] [2]
  • rdrive/Cargo.toml: Reorganized dependencies to use local paths for rdif-* modules and added enum_dispatch for improved driver management.

Codebase Simplification:

  • rdrive/src/descriptor.rs: Added a utility method device_id to simplify access to the DeviceId field in Descriptor. Renamed the file from device/descriptor.rs to descriptor.rs for better organization.
  • examples/enumerate/src/clk.rs: Simplified probe logic to use PlatformDevice for device registration, removing redundant code. [1] [2]

Removal of Redundant Code:

  • interface/rdif-base/src/lock.rs: Removed the lock module, which included Lock and LockGuard implementations, as it is no longer required in the updated design.

Macro Improvements:

  • rdrive-macros/src/lib.rs: Simplified macro logic by using pattern matching with let bindings, improving readability and maintainability.

ZR233 added 8 commits June 23, 2025 09:49
- Updated the `rdrive::init` function to accept a `Platform` enum instead of `DriverInfoKind`.
- Refactored the `Manager` struct to use a `DeviceContainer` for managing devices.
- Introduced a new `Descriptor` struct for device metadata.
- Implemented a `DeviceOwner` struct to manage device ownership and locking.
- Enhanced the `DeviceContainer` with methods for inserting and retrieving devices.
- Updated the probing system to work with the new `PlatformDevice` struct.
- Simplified the FDT probing logic and improved error handling.
- Added tests for device management and probing functionality.
@ZR233 ZR233 requested a review from Copilot June 24, 2025 07:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request refactors and enhances the driver interface of the rdrive project by updating the probing and registration mechanisms, restructuring dependencies for improved modularity, and cleaning up redundant code. Key changes include:

  • Replacing the Any trait with AsAny in driver interfaces and refactoring EnumSystem into a trait using enum_dispatch.
  • Introducing a new PlatformDevice abstraction to streamline device registration.
  • Removing redundant code and updating dependency paths to support local module development.

Reviewed Changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
rdrive/src/probe/mod.rs Refactored EnumSystem and updated to use a new ToProbeFunc type.
rdrive/src/probe/fdt/mod.rs Renamed ProbeFunc to System and adjusted trait implementations.
rdrive/src/descriptor.rs Changed device_id accessibility; added an accessor method.
examples/enumerate/src/uart.rs & timer.rs Updated probe signatures and switched from get_dev! to get.
rdrive/src/manager.rs, lock.rs, lib.rs, others Various dependency restructuring, codebase simplifications and macro improvements.
Comments suppressed due to low confidence (3)

rdrive/src/probe/mod.rs:39

  • The return type of to_unprobed changed from producing a ProbedDevice to a ToProbeFunc. Please ensure that all caller code is updated accordingly and that this change is clearly documented as part of the API design.
    ) -> Result<Option<ToProbeFunc>, ProbeError>;

rdrive/src/descriptor.rs:13

  • Changing device_id from a public to a crate-private field may affect external consumers. Consider documenting the rationale and ensuring the new device_id() accessor method provides equivalent functionality.
    pub(crate) device_id: DeviceId,

examples/enumerate/src/main.rs:125

  • The use of a macro-generated method like register_intc() can obscure its behavior. Consider adding documentation or inline comments to explain how these methods are generated and their expected behavior.
    plat_dev.register_intc(IrqTest {});

Comment thread examples/enumerate/src/uart.rs
@ZR233 ZR233 merged commit 05512e5 into main Jun 24, 2025
@ZR233 ZR233 deleted the dev-rewrite branch June 24, 2025 07:19
@ZR233 ZR233 mentioned this pull request Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants