Skip to content

Commit

Permalink
Merge #31
Browse files Browse the repository at this point in the history
31: Several updates r=ryankurte a=eldruin

- Update dependencies
- Update MSRV due to dependencies
- Add common traits to public structures
- Small warning fixes
- Several fixes to the CI
- Update README badge

Co-authored-by: Diego Barrios Romero <[email protected]>
  • Loading branch information
bors[bot] and eldruin authored Sep 19, 2021
2 parents cbbec45 + dd6db08 commit ee960c5
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 31 deletions.
12 changes: 6 additions & 6 deletions .github/bors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ block_labels = ["needs-decision"]
delete_merged_branches = true
required_approvals = 1
status = [
"ci-linux (stable, x86_64-unknown-linux-gnu)",
"ci-linux (stable, x86_64-unknown-linux-musl)",
"ci-linux (beta, x86_64-unknown-linux-gnu)",
"ci-linux (beta, x86_64-unknown-linux-musl)",
"ci-linux (1.40.0, x86_64-unknown-linux-gnu)",
"ci-linux (1.40.0, x86_64-unknown-linux-musl)",
"CI (stable, x86_64-unknown-linux-gnu)",
"CI (stable, x86_64-unknown-linux-musl)",
"CI (beta, x86_64-unknown-linux-gnu)",
"CI (beta, x86_64-unknown-linux-musl)",
"CI (1.46.0, x86_64-unknown-linux-gnu)",
"CI (1.46.0, x86_64-unknown-linux-musl)",
]
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ name: Continuous integration

jobs:
ci-linux:
name: CI
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental || false }}
strategy:
matrix:
# All published crates must build on stable.
rust: [stable, beta, 1.40.0]
rust: [stable, beta, 1.46.0]

# The default target we're compiling on and for.
TARGET: [x86_64-unknown-linux-gnu, x86_64-unknown-linux-musl]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
toolchain: 1.55.0
override: true
components: clippy
- uses: actions-rs/clippy-check@v1
Expand Down
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

## Not yet released

- Nix bumped to 0.20
- Minimum supported rust version is now 1.40.0
[Full Changelog](https://github.com/rust-embedded/rust-spidev/compare/0.4.1...HEAD)

- Added `Debug` implementation for `Spidev`
- Added `Debug`, `Default`, `Copy` and `PartialEq` implementations for `SpidevOptions`
- Nix bumped to 0.22
- bitflags updated to 1.3
- Minimum supported rust version is now 1.46.0

## 0.4.1 / 2021-02-21

Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ half-duplex SPI access, and full-duplex SPI access.

[dependencies]
libc = "0.2"
bitflags = "1.0"
nix = "0.20"
bitflags = "1.3"
nix = "0.22"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Rust Spidev

[![Build Status](https://travis-ci.org/rust-embedded/rust-spidev.svg?branch=master)](https://travis-ci.org/rust-embedded/rust-spidev)
[![Build Status](https://github.com/rust-embedded/rust-spidev/workflows/CI/badge.svg)](https://github.com/rust-embedded/rust-spidev/actions)
[![Version](https://img.shields.io/crates/v/spidev.svg)](https://crates.io/crates/spidev)
[![License](https://img.shields.io/crates/l/spidev.svg)](https://github.com/rust-embedded/rust-spidev/blob/master/README.md#license)

Expand Down Expand Up @@ -76,7 +76,7 @@ The following features are implemented and planned for the library:

## Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.40 and up. It *might*
This crate is guaranteed to compile on stable Rust 1.46 and up. It *might*
compile with older versions but that may change in any new patch release.

## Cross Compiling
Expand Down
12 changes: 4 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ bitflags! {
}

/// Provide high-level access to Linux Spidev Driver
#[derive(Debug)]
pub struct Spidev {
devfile: File,
}
Expand All @@ -128,7 +129,7 @@ pub struct Spidev {
/// Options that are not configured with one of the builder
/// functions will not be modified in the kernel when
/// `configure` is called.
#[derive(Clone)]
#[derive(Debug, Default, Clone, Copy, PartialEq)]
pub struct SpidevOptions {
pub bits_per_word: Option<u8>,
pub max_speed_hz: Option<u32>,
Expand All @@ -139,12 +140,7 @@ pub struct SpidevOptions {
impl SpidevOptions {
/// Create a new, empty set of options
pub fn new() -> SpidevOptions {
SpidevOptions {
bits_per_word: None,
max_speed_hz: None,
lsb_first: None,
spi_mode: None,
}
SpidevOptions::default()
}

/// The number of bits in each SPI transfer word
Expand Down Expand Up @@ -193,7 +189,7 @@ impl SpidevOptions {

/// Finalize and build the SpidevOptions
pub fn build(&self) -> Self {
self.clone()
*self
}
}

Expand Down
11 changes: 2 additions & 9 deletions src/spidevioctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,10 @@ use std::io;
use std::marker::PhantomData;
use std::os::unix::prelude::*;

fn from_nix_error(err: ::nix::Error) -> io::Error {
io::Error::from_raw_os_error(
err.as_errno()
.unwrap_or_else(|| nix::errno::Errno::UnknownErrno) as i32,
)
}

fn from_nix_result<T>(res: ::nix::Result<T>) -> io::Result<T> {
match res {
Ok(r) => Ok(r),
Err(err) => Err(from_nix_error(err)),
Err(err) => Err(err.into()),
}
}

Expand Down Expand Up @@ -116,7 +109,7 @@ impl<'a, 'b> spi_ioc_transfer<'a, 'b> {
mod ioctl {
use super::*;

const SPI_IOC_MAGIC: u8 = 'k' as u8;
const SPI_IOC_MAGIC: u8 = b'k';
const SPI_IOC_NR_TRANSFER: u8 = 0;
const SPI_IOC_NR_MODE: u8 = 1;
const SPI_IOC_NR_LSB_FIRST: u8 = 2;
Expand Down

0 comments on commit ee960c5

Please sign in to comment.