Skip to content

Commit 52f45b9

Browse files
niedzwiecki-dawidkartben
authored andcommitted
drivers: flash: stm32h7: change return value of write_opt
Change the return value of the write_opt function. If returns 0 if a change of option bytes was not needed. It gives callers of the function an information a commit of the option bytes is needed. Signed-off-by: Dawid Niedzwiecki <[email protected]>
1 parent 435b6f6 commit 52f45b9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/flash/flash_stm32h7x.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ static __unused int commit_optb(const struct device *dev)
8181
return 0;
8282
}
8383

84+
/* Returns negative value on error, 0 if a change was not need, 1 if a change has been made. */
8485
static __unused int write_opt(const struct device *dev, uint32_t mask, uint32_t value,
8586
uintptr_t cur, bool commit)
8687
{
@@ -101,6 +102,7 @@ static __unused int write_opt(const struct device *dev, uint32_t mask, uint32_t
101102
}
102103

103104
if ((sys_read32(cur) & mask) == value) {
105+
/* A change not needed, return 0. */
104106
return 0;
105107
}
106108

@@ -110,9 +112,13 @@ static __unused int write_opt(const struct device *dev, uint32_t mask, uint32_t
110112
/* Make sure previous write is completed before committing option bytes. */
111113
barrier_dsync_fence_full();
112114
rc = commit_optb(dev);
115+
if (rc < 0) {
116+
return rc;
117+
}
113118
}
114119

115-
return rc;
120+
/* A change has been made, return 1. */
121+
return 1;
116122
}
117123

118124
static __unused int write_optsr(const struct device *dev, uint32_t mask, uint32_t value)

0 commit comments

Comments
 (0)