Skip to content

Commit c2bcb5b

Browse files
niedzwiecki-dawidkartben
authored andcommitted
drivers: flash: stm32: rename CR lock functions
Rename *write_protection functions to *cr_lock, because it is not enabling real write protection. It only blocks changing register by software accidentally. Signed-off-by: Dawid Niedzwiecki <[email protected]>
1 parent a887fe1 commit c2bcb5b

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

drivers/flash/flash_stm32.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static const struct flash_parameters flash_stm32_parameters = {
4242
#endif
4343
};
4444

45-
static int flash_stm32_write_protection(const struct device *dev, bool enable);
45+
static int flash_stm32_cr_lock(const struct device *dev, bool enable);
4646

4747
bool __weak flash_stm32_valid_range(const struct device *dev, off_t offset,
4848
uint32_t len, bool write)
@@ -175,14 +175,14 @@ static int flash_stm32_erase(const struct device *dev, off_t offset,
175175

176176
LOG_DBG("Erase offset: %ld, len: %zu", (long int) offset, len);
177177

178-
rc = flash_stm32_write_protection(dev, false);
178+
rc = flash_stm32_cr_lock(dev, false);
179179
if (rc == 0) {
180180
rc = flash_stm32_block_erase_loop(dev, offset, len);
181181
}
182182

183183
flash_stm32_flush_caches(dev, offset, len);
184184

185-
int rc2 = flash_stm32_write_protection(dev, true);
185+
int rc2 = flash_stm32_cr_lock(dev, true);
186186

187187
if (!rc) {
188188
rc = rc2;
@@ -212,12 +212,12 @@ static int flash_stm32_write(const struct device *dev, off_t offset,
212212

213213
LOG_DBG("Write offset: %ld, len: %zu", (long int) offset, len);
214214

215-
rc = flash_stm32_write_protection(dev, false);
215+
rc = flash_stm32_cr_lock(dev, false);
216216
if (rc == 0) {
217217
rc = flash_stm32_write_range(dev, offset, data, len);
218218
}
219219

220-
int rc2 = flash_stm32_write_protection(dev, true);
220+
int rc2 = flash_stm32_cr_lock(dev, true);
221221

222222
if (!rc) {
223223
rc = rc2;
@@ -228,7 +228,7 @@ static int flash_stm32_write(const struct device *dev, off_t offset,
228228
return rc;
229229
}
230230

231-
static int flash_stm32_write_protection(const struct device *dev, bool enable)
231+
static int flash_stm32_cr_lock(const struct device *dev, bool enable)
232232
{
233233
FLASH_TypeDef *regs = FLASH_STM32_REGS(dev);
234234

@@ -304,7 +304,7 @@ int flash_stm32_option_bytes_lock(const struct device *dev, bool enable)
304304

305305
/* Unlock CR/PECR/NSCR register if needed. */
306306
if (!enable) {
307-
rc = flash_stm32_write_protection(dev, false);
307+
rc = flash_stm32_cr_lock(dev, false);
308308
if (rc) {
309309
return rc;
310310
}
@@ -347,7 +347,7 @@ int flash_stm32_option_bytes_lock(const struct device *dev, bool enable)
347347
#endif
348348
/* Lock CR/PECR/NSCR register if needed. */
349349
if (enable) {
350-
rc = flash_stm32_write_protection(dev, true);
350+
rc = flash_stm32_cr_lock(dev, true);
351351
if (rc) {
352352
return rc;
353353
}

drivers/flash/flash_stm32h7x.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ int flash_stm32_write_range(const struct device *dev, unsigned int offset, const
671671
return rc;
672672
}
673673

674-
static int flash_stm32h7_write_protection(const struct device *dev, bool enable)
674+
static int flash_stm32h7_cr_lock(const struct device *dev, bool enable)
675675
{
676676
FLASH_TypeDef *regs = FLASH_STM32_REGS(dev);
677677

@@ -750,7 +750,7 @@ static int flash_stm32h7_erase(const struct device *dev, off_t offset, size_t le
750750

751751
LOG_DBG("Erase offset: %ld, len: %zu", (long)offset, len);
752752

753-
rc = flash_stm32h7_write_protection(dev, false);
753+
rc = flash_stm32h7_cr_lock(dev, false);
754754
if (rc) {
755755
goto done;
756756
}
@@ -766,7 +766,7 @@ static int flash_stm32h7_erase(const struct device *dev, off_t offset, size_t le
766766
}
767767
#endif /* CONFIG_CPU_CORTEX_M7 */
768768
done:
769-
rc2 = flash_stm32h7_write_protection(dev, true);
769+
rc2 = flash_stm32h7_cr_lock(dev, true);
770770

771771
if (!rc) {
772772
rc = rc2;
@@ -794,12 +794,12 @@ static int flash_stm32h7_write(const struct device *dev, off_t offset, const voi
794794

795795
LOG_DBG("Write offset: %ld, len: %zu", (long)offset, len);
796796

797-
rc = flash_stm32h7_write_protection(dev, false);
797+
rc = flash_stm32h7_cr_lock(dev, false);
798798
if (!rc) {
799799
rc = flash_stm32_write_range(dev, offset, data, len);
800800
}
801801

802-
int rc2 = flash_stm32h7_write_protection(dev, true);
802+
int rc2 = flash_stm32h7_cr_lock(dev, true);
803803

804804
if (!rc) {
805805
rc = rc2;

0 commit comments

Comments
 (0)