Skip to content

Commit

Permalink
esp-storage: Fix pointer mutability
Browse files Browse the repository at this point in the history
  • Loading branch information
DBLouis committed Aug 14, 2024
1 parent 460eaa2 commit 2737b4f
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions esp-storage/src/esp32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ pub struct EspRomSpiflashChipT {

#[inline(never)]
#[link_section = ".rwtext"]
pub(crate) fn esp_rom_spiflash_read(src_addr: u32, data: *const u32, len: u32) -> i32 {
pub(crate) fn esp_rom_spiflash_read(src_addr: u32, data: *mut u32, len: u32) -> i32 {
maybe_with_critical_section(|| {
spiflash_wait_for_ready();
unsafe {
let esp_rom_spiflash_read: unsafe extern "C" fn(u32, *const u32, u32) -> i32 =
let esp_rom_spiflash_read: unsafe extern "C" fn(u32, *mut u32, u32) -> i32 =
core::mem::transmute(ESP_ROM_SPIFLASH_READ);
esp_rom_spiflash_read(src_addr, data, len)
}
Expand Down
4 changes: 2 additions & 2 deletions esp-storage/src/esp32c2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const ESP_ROM_SPIFLASH_UNLOCK: u32 = 0x40000140;
const ESP_ROM_SPIFLASH_ERASE_SECTOR: u32 = 0x40000130;
const ESP_ROM_SPIFLASH_WRITE: u32 = 0x40000138;

pub(crate) fn esp_rom_spiflash_read(src_addr: u32, data: *const u32, len: u32) -> i32 {
pub(crate) fn esp_rom_spiflash_read(src_addr: u32, data: *mut u32, len: u32) -> i32 {
maybe_with_critical_section(|| unsafe {
let esp_rom_spiflash_read: unsafe extern "C" fn(u32, *const u32, u32) -> i32 =
let esp_rom_spiflash_read: unsafe extern "C" fn(u32, *mut u32, u32) -> i32 =
core::mem::transmute(ESP_ROM_SPIFLASH_READ);
esp_rom_spiflash_read(src_addr, data, len)
})
Expand Down
4 changes: 2 additions & 2 deletions esp-storage/src/esp32c3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const ESP_ROM_SPIFLASH_UNLOCK: u32 = 0x40000140;
const ESP_ROM_SPIFLASH_ERASE_SECTOR: u32 = 0x40000128;
const ESP_ROM_SPIFLASH_WRITE: u32 = 0x4000012c;

pub(crate) fn esp_rom_spiflash_read(src_addr: u32, data: *const u32, len: u32) -> i32 {
pub(crate) fn esp_rom_spiflash_read(src_addr: u32, data: *mut u32, len: u32) -> i32 {
maybe_with_critical_section(|| unsafe {
let esp_rom_spiflash_read: unsafe extern "C" fn(u32, *const u32, u32) -> i32 =
let esp_rom_spiflash_read: unsafe extern "C" fn(u32, *mut u32, u32) -> i32 =
core::mem::transmute(ESP_ROM_SPIFLASH_READ);
esp_rom_spiflash_read(src_addr, data, len)
})
Expand Down
4 changes: 2 additions & 2 deletions esp-storage/src/esp32c6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const ESP_ROM_SPIFLASH_UNLOCK: u32 = 0x40000154;
const ESP_ROM_SPIFLASH_ERASE_SECTOR: u32 = 0x40000144;
const ESP_ROM_SPIFLASH_WRITE: u32 = 0x4000014c;

pub(crate) fn esp_rom_spiflash_read(src_addr: u32, data: *const u32, len: u32) -> i32 {
pub(crate) fn esp_rom_spiflash_read(src_addr: u32, data: *mut u32, len: u32) -> i32 {
maybe_with_critical_section(|| unsafe {
let esp_rom_spiflash_read: unsafe extern "C" fn(u32, *const u32, u32) -> i32 =
let esp_rom_spiflash_read: unsafe extern "C" fn(u32, *mut u32, u32) -> i32 =
core::mem::transmute(ESP_ROM_SPIFLASH_READ);
esp_rom_spiflash_read(src_addr, data, len)
})
Expand Down
4 changes: 2 additions & 2 deletions esp-storage/src/esp32h2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const ESP_ROM_SPIFLASH_UNLOCK: u32 = 0x40000130;
const ESP_ROM_SPIFLASH_ERASE_SECTOR: u32 = 0x40000120;
const ESP_ROM_SPIFLASH_WRITE: u32 = 0x40000128;

pub(crate) fn esp_rom_spiflash_read(src_addr: u32, data: *const u32, len: u32) -> i32 {
pub(crate) fn esp_rom_spiflash_read(src_addr: u32, data: *mut u32, len: u32) -> i32 {
maybe_with_critical_section(|| unsafe {
let esp_rom_spiflash_read: unsafe extern "C" fn(u32, *const u32, u32) -> i32 =
let esp_rom_spiflash_read: unsafe extern "C" fn(u32, *mut u32, u32) -> i32 =
core::mem::transmute(ESP_ROM_SPIFLASH_READ);
esp_rom_spiflash_read(src_addr, data, len)
})
Expand Down
4 changes: 2 additions & 2 deletions esp-storage/src/esp32s2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const ESP_ROM_SPIFLASH_UNLOCK: u32 = 0x40016e88;
const ESP_ROM_SPIFLASH_ERASE_SECTOR: u32 = 0x4001716c;
const ESP_ROM_SPIFLASH_WRITE: u32 = 0x400171cc;

pub(crate) fn esp_rom_spiflash_read(src_addr: u32, data: *const u32, len: u32) -> i32 {
pub(crate) fn esp_rom_spiflash_read(src_addr: u32, data: *mut u32, len: u32) -> i32 {
maybe_with_critical_section(|| unsafe {
let esp_rom_spiflash_read: unsafe extern "C" fn(u32, *const u32, u32) -> i32 =
let esp_rom_spiflash_read: unsafe extern "C" fn(u32, *mut u32, u32) -> i32 =
core::mem::transmute(ESP_ROM_SPIFLASH_READ);
esp_rom_spiflash_read(src_addr, data, len)
})
Expand Down
4 changes: 2 additions & 2 deletions esp-storage/src/esp32s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const ESP_ROM_SPIFLASH_WRITE: u32 = 0x40000a14;

#[inline(always)]
#[link_section = ".rwtext"]
pub(crate) fn esp_rom_spiflash_read(src_addr: u32, data: *const u32, len: u32) -> i32 {
pub(crate) fn esp_rom_spiflash_read(src_addr: u32, data: *mut u32, len: u32) -> i32 {
maybe_with_critical_section(|| unsafe {
let esp_rom_spiflash_read: unsafe extern "C" fn(u32, *const u32, u32) -> i32 =
let esp_rom_spiflash_read: unsafe extern "C" fn(u32, *mut u32, u32) -> i32 =
core::mem::transmute(ESP_ROM_SPIFLASH_READ);
esp_rom_spiflash_read(src_addr, data, len)
})
Expand Down

0 comments on commit 2737b4f

Please sign in to comment.