Skip to content

lib: clock: return SUCCESS when the operation is a no-op#91

Merged
pathakraul merged 2 commits into
riscv-software-src:mainfrom
ch-perry:fix-clock-already
Jun 25, 2026
Merged

lib: clock: return SUCCESS when the operation is a no-op#91
pathakraul merged 2 commits into
riscv-software-src:mainfrom
ch-perry:fix-clock-already

Conversation

@ch-perry

Copy link
Copy Markdown
Contributor

First commit fixes a bug.

Second commit is a drive-by refactor.

ch-perry added 2 commits May 26, 2026 07:45
Change the return value from ERR_ALREADY to SUCCESS for 3 cases in the
clock service:
 * Setting the same rate on a clock
 * Disabling a disabled clock
 * Enabling an enabled clock

This fixes a problem when enabling clocks already enabled by a prior
boot stage with Linux (as Linux does not retrieve the current state
before enabling a clock, resulting in ERR_ALREADY if the clock was
already enabled).

Fixes: b153230 ("lib: Implement clock infra and clock service group")
Signed-off-by: Charles Perry <charles.perry@microchip.com>
There's no need for a special case for clocks with no child in the disable
path and no parent in the enable path. Since childs/parents must be
checked/enabled before taking care of the clock of interest in any case,
some code duplication and a goto can be eliminated.

Signed-off-by: Charles Perry <charles.perry@microchip.com>
@pathakraul

Copy link
Copy Markdown
Collaborator

Looks good to me

@pathakraul pathakraul merged commit 5f43c12 into riscv-software-src:main Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants