The I2cAdapterTrait was introduced because of a need to test the i2c
implementation without having access to a physical device on the host
running the tests. This abstraction though still made the tests pretty
hard to write, so it is now replaced by another abstractions: I2cDevice.
This abstraction is written working backwards from what we DO NOT have
access to on the host where we want to run the tests. This is the i2c
device. So, this abstraction is just abstracting the way all the ioctl
calls that need to be handled by an i2c device. This way, we can test
all the other wrappers that are implemented in this crate.
The abstraction is implemented for a physical device to keep backwards
compatibility with existing code.
This abstraction still needs improvements such as marking the functions
as unsafe. For now the tests are commented out because they need to be
re-written with this abstraction. Since we still have refactoring work
to do (i.e. separate the parsing from the device operation), writing
tests is postponed so that it does not involve duplicated work.
Signed-off-by: Andreea Florescu <fandree@amazon.com>
This function does not need to be in the trait. Having it as a public
function also makes the code hard to use because the return of the
`is_smbus` function is only valid after an initial call to `get_func`.
To get rid of this behavior, we can make the `get_func` a private
function in the `I2cAdapter` implementation, and call this function on
`new`.
The function was renamed to `read_func` to make the name more "mutable"
compatible (the function needs a mutable reference, but it was called
`get`; get functions don't typically need mutable references).
Signed-off-by: Andreea Florescu <fandree@amazon.com>
We've typically separated imports in 3 categories:
- Rust standard library
- external crates
- project internal imports (such as imports from user defined modules)
Signed-off-by: Andreea Florescu <fandree@amazon.com>
This is a first change in a series meant for moving all the parsing of
strings in a single place, with the goal of separating parsing from the
device operation. This helps with separating concerns, mocking, and
writing unit tests.
Signed-off-by: Andreea Florescu <fandree@amazon.com>
This still doesn't emulate the descriptors and descriptor chains over
the vrings. That will be added later.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Remove the incorrect file dependabot.yaml and edit the correct one to
allow crate updates on weekly basis.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
To avoid breaking the crate with a newer version of the
vhost-user-backend crate, fix the dependency to a known good version of
the crate.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
vhost-user-backend repository received few updates recently, which
caused this one to break.
Update the code here to fix the breakage.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reduce the test coverage score as the files apart from i2c.rs are
mostly boilerplate code and it is difficult to test them as well as it
may not be worth it.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This patch implements the low level I2C helpers responsible for
transferring data and parsing the adapters and their clients.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This adds the boilerplate code and its dependencies to get the basic
structure for the i2c crate.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This converts the Cargo.toml to a virtual manifest, removes the
src/lib.rs file and adds basic workspace for i2c backend device.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>