-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers: rtc: rtc_ll_stm32: replace k_mutex with k_spinlock #85943
drivers: rtc: rtc_ll_stm32: replace k_mutex with k_spinlock #85943
Conversation
|
||
LOG_DBG("Setting clock"); | ||
|
||
k_spinlock_key_t key = k_spin_lock(&data->lock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid functional changes, the following should be used instead:
k_spinlock_key_t key = k_spin_lock(&data->lock); | |
k_spinlock_key_t key; | |
int err = k_spin_trylock(&data->lock, &key); | |
if (err < 0) { | |
return err; | |
} |
cc @erwango for whether the functional change is OK or not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference. These set_time
functions use k_spin_lock
:
- rtc_sam0_set_time
- rtc_numaker_set_time
- rtc_mc146818_set_time
- ifx_cat1_rtc_set_time
- ambiq_rtc_set_time
- rtc_rpi_pico_set_time
- ds1307_set_time
k_spin_trylock
is not used by any rtc driver atm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@erwango any chance you got time to give this a look?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's a good response here.
I agree you @mathieuchopstm, you're changing the dynamic here, but drivers behaves today differently from the other drivers indeed, so we can't argue about we'll fail on the API contract.
I'm fine with keeping this change and if some applications have trouble with that, let's say that we're moving to the general API consensus.
if (err) { | ||
return err; | ||
} | ||
k_spinlock_key_t key = k_spin_lock(&data->lock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark here
a8ffec3
to
2b3a885
Compare
@jeppenodgaard Rebase required |
71c679d
to
29adf2f
Compare
This allows using this RTC driver from contexts where `k_mutex` use is not allowed. Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
Lock just before and just after accessing functions that modifies register values. Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
29adf2f
to
e073fa9
Compare
This allows using this RTC driver from contexts where
k_mutex
use is not allowed.Rework
rtc_stm32_set_time
to lock just before and just after accessing functions that modifies register values.