Dev rewrite#7
Merged
Merged
Conversation
- 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.
There was a problem hiding this comment.
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 {});
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several changes to improve the modularity and functionality of the
rdriveproject. Key updates include refactoring the driver interface, enhancing thePlatformDeviceabstraction, 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 theAnytrait withAsAnyinDriverGenericfor better type safety and flexibility. Removed thelockmodule as it is no longer required.examples/enumerate/src/main.rs: UpdatedDriverGenericimplementations to align with the newPlatformDeviceabstraction, simplifying the probe logic and enhancing device registration. [1] [2]examples/enumerate/src/timer.rs: Refactoredprobelogic to usePlatformDevicefor device registration and interaction with parent devices.Dependency Restructuring:
Cargo.tomlandinterface/rdif-base/Cargo.toml: Updated dependencies to include local paths forrdif-*modules, facilitating better modularity and local development workflows. [1] [2]rdrive/Cargo.toml: Reorganized dependencies to use local paths forrdif-*modules and addedenum_dispatchfor improved driver management.Codebase Simplification:
rdrive/src/descriptor.rs: Added a utility methoddevice_idto simplify access to theDeviceIdfield inDescriptor. Renamed the file fromdevice/descriptor.rstodescriptor.rsfor better organization.examples/enumerate/src/clk.rs: Simplifiedprobelogic to usePlatformDevicefor device registration, removing redundant code. [1] [2]Removal of Redundant Code:
interface/rdif-base/src/lock.rs: Removed thelockmodule, which includedLockandLockGuardimplementations, as it is no longer required in the updated design.Macro Improvements:
rdrive-macros/src/lib.rs: Simplified macro logic by using pattern matching withletbindings, improving readability and maintainability.