Skip to content

Commit 4bc491a

Browse files
authored
Merge pull request #12598 from rajkan01/mutex_lock_remove_return
Change Mutex lock and unlock APIs return value to void
2 parents da9f85b + 2f4cf1a commit 4bc491a

File tree

3 files changed

+28
-86
lines changed

3 files changed

+28
-86
lines changed

rtos/Mutex.h

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,9 @@ class Mutex : private mbed::NonCopyable<Mutex> {
8484
/**
8585
Wait until a Mutex becomes available.
8686
87-
@return status code that indicates the execution status of the function:
88-
@a osOK the mutex has been obtained.
89-
9087
@note You cannot call this function from ISR context.
91-
@note This function treats RTOS errors as fatal system errors, so it can only return osOK.
92-
Use of the return value is deprecated, as the return is expected to become void in the future.
9388
*/
94-
#if MBED_CONF_RTOS_PRESENT
95-
osStatus lock();
96-
#else
97-
void lock(); // Value return backwards compatibility not required for non-RTOS
98-
#endif
89+
void lock();
9990

10091
/** Try to lock the mutex, and return immediately
10192
@return true if the mutex was acquired, false otherwise.
@@ -132,18 +123,9 @@ class Mutex : private mbed::NonCopyable<Mutex> {
132123
/**
133124
Unlock the mutex that has previously been locked by the same thread
134125
135-
@return status code that indicates the execution status of the function:
136-
@a osOK the mutex has been released.
137-
138126
@note You cannot call this function from ISR context.
139-
@note This function treats RTOS errors as fatal system errors, so it can only return osOK.
140-
Use of the return value is deprecated, as the return is expected to become void in the future.
141127
*/
142-
#if MBED_CONF_RTOS_PRESENT
143-
osStatus unlock();
144-
#else
145-
void unlock(); // Value return backwards compatibility not required for non-RTOS
146-
#endif
128+
void unlock();
147129

148130
/** Get the owner the this mutex
149131
@return the current owner of this mutex.

rtos/source/Mutex.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void Mutex::constructor(const char *name)
5757
MBED_ASSERT(_id || mbed_get_error_in_progress());
5858
}
5959

60-
osStatus Mutex::lock(void)
60+
void Mutex::lock(void)
6161
{
6262
osStatus status = osMutexAcquire(_id, osWaitForever);
6363
if (osOK == status) {
@@ -67,8 +67,6 @@ osStatus Mutex::lock(void)
6767
if (status != osOK && !mbed_get_error_in_progress()) {
6868
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_MUTEX_LOCK_FAILED), "Mutex lock failed", status);
6969
}
70-
71-
return osOK;
7270
}
7371

7472
bool Mutex::trylock()
@@ -109,7 +107,7 @@ bool Mutex::trylock_until(uint64_t millisec)
109107
}
110108
}
111109

112-
osStatus Mutex::unlock()
110+
void Mutex::unlock()
113111
{
114112
osStatus status = osMutexRelease(_id);
115113
if (osOK == status) {
@@ -119,8 +117,6 @@ osStatus Mutex::unlock()
119117
if (status != osOK && !mbed_get_error_in_progress()) {
120118
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_MUTEX_UNLOCK_FAILED), "Mutex unlock failed", status);
121119
}
122-
123-
return status;
124120
}
125121

126122
osThreadId Mutex::get_owner()

targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F439xI/TARGET_MODULE_UBLOX_ODIN_W2/sdk/ublox-odin-w2-drivers/OdinWiFiInterface.cpp

Lines changed: 24 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,13 @@ nsapi_error_t OdinWiFiInterface::set_credentials(const char *ssid, const char *p
231231
return NSAPI_ERROR_PARAMETER;
232232
}
233233

234-
osStatus res = _mutex.lock();
235-
MBED_ASSERT(res == osOK);
234+
_mutex.lock();
236235

237236
strncpy(_sta.ssid, ssid, cbWLAN_SSID_MAX_LENGTH);
238237
strncpy(_sta.passwd, pass, cbWLAN_MAX_PASSPHRASE_LENGTH);
239238
_sta.security = security;
240239

241-
res = _mutex.unlock();
242-
MBED_ASSERT(res == osOK);
240+
_mutex.unlock();
243241

244242
return NSAPI_ERROR_OK;
245243
}
@@ -275,26 +273,18 @@ nsapi_error_t OdinWiFiInterface::set_channel(uint8_t channel)
275273
return NSAPI_ERROR_PARAMETER;
276274
}
277275

278-
osStatus res = _mutex.lock();
279-
MBED_ASSERT(res == osOK);
280-
276+
_mutex.lock();
281277
_sta.channel = channel;
282-
283-
res = _mutex.unlock();
284-
MBED_ASSERT(res == osOK);
278+
_mutex.unlock();
285279

286280
return NSAPI_ERROR_OK;
287281
}
288282

289283
nsapi_error_t OdinWiFiInterface::set_timeout(int ms)
290284
{
291-
osStatus res = _mutex.lock();
292-
MBED_ASSERT(res == osOK);
293-
285+
_mutex.lock();
294286
_sta.timeout_ms = ms;
295-
296-
res = _mutex.unlock();
297-
MBED_ASSERT(res == osOK);
287+
_mutex.unlock();
298288

299289
return NSAPI_ERROR_OK;
300290
}
@@ -560,8 +550,7 @@ nsapi_error_t OdinWiFiInterface::set_ap_network(const char *ip_address, const ch
560550
{
561551
nsapi_error_t result = NSAPI_ERROR_PARAMETER;
562552

563-
osStatus res = _mutex.lock();
564-
MBED_ASSERT(res == osOK);
553+
_mutex.lock();
565554

566555
if ((ip_address != NULL) && (netmask != NULL) && (gateway != NULL))
567556
{
@@ -583,8 +572,7 @@ nsapi_error_t OdinWiFiInterface::set_ap_network(const char *ip_address, const ch
583572
result = NSAPI_ERROR_OK;
584573
}
585574

586-
res = _mutex.unlock();
587-
MBED_ASSERT(res == osOK);
575+
_mutex.unlock();
588576

589577
return result;
590578
}
@@ -593,28 +581,22 @@ nsapi_error_t OdinWiFiInterface::set_ap_network(const char *ip_address, const ch
593581
nsapi_error_t OdinWiFiInterface::set_ap_credentials(const char *ssid, const char *pass,
594582
nsapi_security_t security)
595583
{
596-
osStatus res = _mutex.lock();
597-
MBED_ASSERT(res == osOK);
584+
_mutex.lock();
598585

599586
_ap.ssid = ssid;
600587
_ap.passwd = pass;
601588
_ap.security = security;
602589

603-
res = _mutex.unlock();
604-
MBED_ASSERT(res == osOK);
590+
_mutex.unlock();
605591

606592
return NSAPI_ERROR_OK;
607593
}
608594

609595
nsapi_error_t OdinWiFiInterface::set_ap_channel(uint8_t channel)
610596
{
611-
osStatus res = _mutex.lock();
612-
MBED_ASSERT(res == osOK);
613-
597+
_mutex.lock();
614598
_ap.channel = channel;
615-
616-
res = _mutex.unlock();
617-
MBED_ASSERT(res == osOK);
599+
_mutex.unlock();
618600

619601
return NSAPI_ERROR_OK;
620602
}
@@ -623,13 +605,9 @@ int OdinWiFiInterface::get_ap_connection_count()
623605
{
624606
int cnt;
625607

626-
osStatus res = _mutex.lock();
627-
MBED_ASSERT(res == osOK);
628-
608+
_mutex.lock();
629609
cnt = _ap.cnt_connected;
630-
631-
res = _mutex.unlock();
632-
MBED_ASSERT(res == osOK);
610+
_mutex.unlock();
633611

634612
return cnt;
635613
}
@@ -641,13 +619,9 @@ int OdinWiFiInterface::get_ap_max_connection_count()
641619

642620
nsapi_error_t OdinWiFiInterface::set_ap_dhcp(bool dhcp)
643621
{
644-
osStatus res = _mutex.lock();
645-
MBED_ASSERT(res == osOK);
646-
622+
_mutex.lock();
647623
_ap.use_dhcp = dhcp;
648-
649-
res = _mutex.unlock();
650-
MBED_ASSERT(res == osOK);
624+
_mutex.unlock();
651625

652626
return NSAPI_ERROR_OK;
653627
}
@@ -739,13 +713,9 @@ nsapi_error_t OdinWiFiInterface::ap_stop()
739713

740714
nsapi_error_t OdinWiFiInterface::set_ap_beacon_interval(uint16_t interval)
741715
{
742-
osStatus res = _mutex.lock();
743-
MBED_ASSERT(res == osOK);
744-
716+
_mutex.lock();
745717
_ap.beacon_interval = interval;
746-
747-
res = _mutex.unlock();
748-
MBED_ASSERT(res == osOK);
718+
_mutex.unlock();
749719

750720
return NSAPI_ERROR_OK;
751721
}
@@ -860,8 +830,7 @@ void OdinWiFiInterface::handle_in_msg(void)
860830
struct odin_wifi_msg_s *msg = (odin_wifi_msg_s*)evt.value.p;
861831
MBED_ASSERT(msg != 0);
862832

863-
osStatus res = _mutex.lock();
864-
MBED_ASSERT(res == osOK);
833+
_mutex.lock();
865834

866835
switch(msg->type) {
867836
case ODIN_WIFI_MSG_USER_CONNECT:
@@ -949,8 +918,7 @@ void OdinWiFiInterface::handle_in_msg(void)
949918
break;
950919
}
951920

952-
res = _mutex.unlock();
953-
MBED_ASSERT(res == osOK);
921+
_mutex.unlock();
954922

955923
if(msg != 0) {
956924
_msg_pool->free(msg);
@@ -1530,8 +1498,7 @@ void OdinWiFiInterface::handle_wlan_status_ap_down()
15301498

15311499
void OdinWiFiInterface::init(bool debug = false)
15321500
{
1533-
osStatus res = _mutex.lock();
1534-
MBED_ASSERT(res == osOK);
1501+
_mutex.lock();
15351502

15361503
// Initialise internal variables
15371504
_state = S_NOT_INITIALISED;
@@ -1595,8 +1562,7 @@ void OdinWiFiInterface::init(bool debug = false)
15951562

15961563
_thread.start(callback(wlan_callb_s::odin_thread_fcn, this));
15971564

1598-
res = _mutex.unlock();
1599-
MBED_ASSERT(res == osOK);
1565+
_mutex.unlock();
16001566
}
16011567

16021568
void OdinWiFiInterface::send_user_response_msg(unsigned int type, nsapi_error_t error_code)
@@ -1817,14 +1783,12 @@ void OdinWiFiInterface::wlan_scan_indication(cbWLAN_ScanIndicationInfo *scan_inf
18171783
MBED_ASSERT(ok == osOK);
18181784
}
18191785
else {
1820-
osStatus res = _mutex.lock();
1821-
MBED_ASSERT(res == osOK);
1786+
_mutex.lock();
18221787

18231788
// Add scan result to scan_list
18241789
update_scan_list(scan_info);
18251790

1826-
res = _mutex.unlock();
1827-
MBED_ASSERT(res == osOK);
1791+
_mutex.unlock();
18281792
}
18291793
}
18301794
else {

0 commit comments

Comments
 (0)