Skip to content

Commit dcf4855

Browse files
etienne-lmsnashif
authored andcommitted
drivers: clock_control: fix IN_RANGE() use in stm32 clock drivers
IN_RANGE() macro from zephyr/sys/util.h returns a boolean value so it should be treated as such and not compared to a decimal value. Fix stm32 clock drivers accordingly and simplify places where the value is compared to true. No functional change. Signed-off-by: Etienne Carriere <[email protected]>
1 parent 6c2d354 commit dcf4855

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

drivers/clock_control/clock_stm32_ll_common.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static inline int stm32_clock_control_on(const struct device *dev,
255255

256256
ARG_UNUSED(dev);
257257

258-
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == 0) {
258+
if (!IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) {
259259
/* Attempt to change a wrong periph clock bit */
260260
return -ENOTSUP;
261261
}
@@ -278,7 +278,7 @@ static inline int stm32_clock_control_off(const struct device *dev,
278278

279279
ARG_UNUSED(dev);
280280

281-
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == 0) {
281+
if (!IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) {
282282
/* Attempt to toggle a wrong periph clock bit */
283283
return -ENOTSUP;
284284
}
@@ -498,7 +498,7 @@ static enum clock_control_status stm32_clock_control_get_status(const struct dev
498498

499499
ARG_UNUSED(dev);
500500

501-
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == true) {
501+
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) {
502502
/* Gated clocks */
503503
if ((sys_read32(DT_REG_ADDR(DT_NODELABEL(rcc)) + pclken->bus) & pclken->enr)
504504
== pclken->enr) {

drivers/clock_control/clock_stm32_ll_h5.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static inline int stm32_clock_control_on(const struct device *dev,
152152

153153
ARG_UNUSED(dev);
154154

155-
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == 0) {
155+
if (!IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) {
156156
/* Attempt to toggle a wrong periph clock bit */
157157
return -ENOTSUP;
158158
}
@@ -173,7 +173,7 @@ static inline int stm32_clock_control_off(const struct device *dev,
173173

174174
ARG_UNUSED(dev);
175175

176-
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == 0) {
176+
if (!IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) {
177177
/* Attempt to toggle a wrong periph clock bit */
178178
return -ENOTSUP;
179179
}

drivers/clock_control/clock_stm32_ll_h7.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ static inline int stm32_clock_control_on(const struct device *dev,
390390

391391
ARG_UNUSED(dev);
392392

393-
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == 0) {
393+
if (!IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) {
394394
/* Attempt to toggle a wrong periph clock bit */
395395
return -ENOTSUP;
396396
}
@@ -416,7 +416,7 @@ static inline int stm32_clock_control_off(const struct device *dev,
416416

417417
ARG_UNUSED(dev);
418418

419-
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == 0) {
419+
if (!IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) {
420420
/* Attempt to toggle a wrong periph clock bit */
421421
return -ENOTSUP;
422422
}

drivers/clock_control/clock_stm32_ll_n6.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static inline int stm32_clock_control_on(const struct device *dev,
198198

199199
ARG_UNUSED(dev);
200200

201-
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == 0) {
201+
if (!IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) {
202202
/* Attempt to toggle a wrong periph clock bit */
203203
return -ENOTSUP;
204204
}
@@ -221,7 +221,7 @@ static inline int stm32_clock_control_off(const struct device *dev,
221221

222222
ARG_UNUSED(dev);
223223

224-
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == 0) {
224+
if (!IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) {
225225
/* Attempt to toggle a wrong periph clock bit */
226226
return -ENOTSUP;
227227
}

drivers/clock_control/clock_stm32_ll_u5.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static inline int stm32_clock_control_on(const struct device *dev,
158158

159159
ARG_UNUSED(dev);
160160

161-
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == 0) {
161+
if (!IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) {
162162
/* Attempt to toggle a wrong periph clock bit */
163163
return -ENOTSUP;
164164
}
@@ -179,7 +179,7 @@ static inline int stm32_clock_control_off(const struct device *dev,
179179

180180
ARG_UNUSED(dev);
181181

182-
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == 0) {
182+
if (!IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) {
183183
/* Attempt to toggle a wrong periph clock bit */
184184
return -ENOTSUP;
185185
}
@@ -373,7 +373,7 @@ static enum clock_control_status stm32_clock_control_get_status(const struct dev
373373

374374
ARG_UNUSED(dev);
375375

376-
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == true) {
376+
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) {
377377
/* Gated clocks */
378378
if ((sys_read32(DT_REG_ADDR(DT_NODELABEL(rcc)) + pclken->bus) & pclken->enr)
379379
== pclken->enr) {

drivers/clock_control/clock_stm32_ll_wba.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static inline int stm32_clock_control_on(const struct device *dev,
7070

7171
ARG_UNUSED(dev);
7272

73-
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == 0) {
73+
if (!IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) {
7474
/* Attempt to toggle a wrong periph clock bit */
7575
return -ENOTSUP;
7676
}
@@ -91,7 +91,7 @@ static inline int stm32_clock_control_off(const struct device *dev,
9191

9292
ARG_UNUSED(dev);
9393

94-
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == 0) {
94+
if (!IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) {
9595
/* Attempt to toggle a wrong periph clock bit */
9696
return -ENOTSUP;
9797
}
@@ -287,7 +287,7 @@ static enum clock_control_status stm32_clock_control_get_status(const struct dev
287287

288288
ARG_UNUSED(dev);
289289

290-
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == true) {
290+
if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) {
291291
/* Gated clocks */
292292
if ((sys_read32(DT_REG_ADDR(DT_NODELABEL(rcc)) + pclken->bus) & pclken->enr)
293293
== pclken->enr) {

0 commit comments

Comments
 (0)