lib/mutex: return zero on get_ceiling() in non-PP case

This is a simple way to figure out the protocol of a mutex without
crippling the API with trivial accessors people might need twice a
century.
This commit is contained in:
Philippe Gerum 2019-08-24 12:37:06 +02:00
parent bed2532942
commit 672bc22c7c
1 changed files with 5 additions and 4 deletions

View File

@ -385,17 +385,18 @@ int evl_set_mutex_ceiling(struct evl_mutex *mutex,
int evl_get_mutex_ceiling(struct evl_mutex *mutex) int evl_get_mutex_ceiling(struct evl_mutex *mutex)
{ {
if (mutex->magic == __MUTEX_UNINIT_MAGIC) { if (mutex->magic == __MUTEX_UNINIT_MAGIC) {
if (mutex->uninit.monitor != EVL_MONITOR_GATE || if (mutex->uninit.monitor != EVL_MONITOR_GATE)
mutex->uninit.ceiling == 0)
return -EINVAL; return -EINVAL;
return mutex->uninit.ceiling; return mutex->uninit.ceiling;
} }
if (mutex->magic != __MUTEX_ACTIVE_MAGIC || if (mutex->magic != __MUTEX_ACTIVE_MAGIC ||
mutex->active.monitor != EVL_MONITOR_GATE || mutex->active.monitor != EVL_MONITOR_GATE)
mutex->active.protocol != EVL_GATE_PP)
return -EINVAL; return -EINVAL;
if (mutex->active.protocol != EVL_GATE_PP)
return 0;
return mutex->active.state->u.gate.ceiling; return mutex->active.state->u.gate.ceiling;
} }