From 4809ec4770119878f4141f92fc80654b87c50056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20Dupr=C3=A9=20Bertoni?= Date: Sun, 28 Jul 2024 20:00:00 +0300 Subject: [PATCH] esp-storage: Fix pointer mutability --- esp-storage/src/esp32.rs | 4 ++-- esp-storage/src/esp32c2.rs | 4 ++-- esp-storage/src/esp32c3.rs | 4 ++-- esp-storage/src/esp32c6.rs | 4 ++-- esp-storage/src/esp32h2.rs | 4 ++-- esp-storage/src/esp32s2.rs | 4 ++-- esp-storage/src/esp32s3.rs | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/esp-storage/src/esp32.rs b/esp-storage/src/esp32.rs index 352a983ab6b..f168687409f 100644 --- a/esp-storage/src/esp32.rs +++ b/esp-storage/src/esp32.rs @@ -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) } diff --git a/esp-storage/src/esp32c2.rs b/esp-storage/src/esp32c2.rs index c7c071ee253..cebd21b14dc 100644 --- a/esp-storage/src/esp32c2.rs +++ b/esp-storage/src/esp32c2.rs @@ -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) }) diff --git a/esp-storage/src/esp32c3.rs b/esp-storage/src/esp32c3.rs index 73a2d4c8dc1..715a00ab723 100644 --- a/esp-storage/src/esp32c3.rs +++ b/esp-storage/src/esp32c3.rs @@ -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) }) diff --git a/esp-storage/src/esp32c6.rs b/esp-storage/src/esp32c6.rs index 5255a6370eb..b0835990d07 100644 --- a/esp-storage/src/esp32c6.rs +++ b/esp-storage/src/esp32c6.rs @@ -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) }) diff --git a/esp-storage/src/esp32h2.rs b/esp-storage/src/esp32h2.rs index b7a1641d2b0..8a4dbab3f0b 100644 --- a/esp-storage/src/esp32h2.rs +++ b/esp-storage/src/esp32h2.rs @@ -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) }) diff --git a/esp-storage/src/esp32s2.rs b/esp-storage/src/esp32s2.rs index 2717ae8f26d..ef0f9eb49b7 100644 --- a/esp-storage/src/esp32s2.rs +++ b/esp-storage/src/esp32s2.rs @@ -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) }) diff --git a/esp-storage/src/esp32s3.rs b/esp-storage/src/esp32s3.rs index 37cfbb791f4..954ed2d2b63 100644 --- a/esp-storage/src/esp32s3.rs +++ b/esp-storage/src/esp32s3.rs @@ -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) })