@@ -392,9 +392,7 @@ static int rtc_stm32_init(const struct device *dev)
392
392
static int rtc_stm32_set_time (const struct device * dev , const struct rtc_time * timeptr )
393
393
{
394
394
struct rtc_stm32_data * data = dev -> data ;
395
-
396
395
uint32_t real_year = timeptr -> tm_year + TM_YEAR_REF ;
397
-
398
396
int err = 0 ;
399
397
400
398
if (real_year < RTC_YEAR_REF ) {
@@ -423,11 +421,8 @@ static int rtc_stm32_set_time(const struct device *dev, const struct rtc_time *t
423
421
ErrorStatus status = LL_RTC_EnterInitMode (RTC );
424
422
425
423
if (status != SUCCESS ) {
426
- #if RTC_STM32_BACKUP_DOMAIN_WRITE_PROTECTION
427
- LL_PWR_DisableBkUpAccess ();
428
- #endif /* RTC_STM32_BACKUP_DOMAIN_WRITE_PROTECTION */
429
- k_mutex_unlock (& data -> lock );
430
- return - EIO ;
424
+ err = - EIO ;
425
+ goto protect_unlock_return ;
431
426
}
432
427
433
428
LL_RTC_DATE_SetYear (RTC , bin2bcd (real_year - RTC_YEAR_REF ));
@@ -442,13 +437,13 @@ static int rtc_stm32_set_time(const struct device *dev, const struct rtc_time *t
442
437
LL_RTC_DATE_SetWeekDay (RTC , timeptr -> tm_wday );
443
438
}
444
439
445
-
446
440
LL_RTC_TIME_SetHour (RTC , bin2bcd (timeptr -> tm_hour ));
447
441
LL_RTC_TIME_SetMinute (RTC , bin2bcd (timeptr -> tm_min ));
448
442
LL_RTC_TIME_SetSecond (RTC , bin2bcd (timeptr -> tm_sec ));
449
443
450
444
LL_RTC_DisableInitMode (RTC );
451
445
446
+ protect_unlock_return :
452
447
LL_RTC_EnableWriteProtection (RTC );
453
448
454
449
#if RTC_STM32_BACKUP_DOMAIN_WRITE_PROTECTION
0 commit comments