Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/vchiq/dist/interface/compat Simplify the se...



details:   https://anonhg.NetBSD.org/src/rev/143e0e936ca2
branches:  trunk
changeset: 794867:143e0e936ca2
user:      skrll <skrll%NetBSD.org@localhost>
date:      Thu Mar 27 07:59:17 2014 +0000

description:
Simplify the semaphore code a little

diffstat:

 sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c |  15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)

diffs (58 lines):

diff -r 592194f7cd58 -r 143e0e936ca2 sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c
--- a/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c   Thu Mar 27 07:56:56 2014 +0000
+++ b/sys/external/bsd/vchiq/dist/interface/compat/vchi_bsd.c   Thu Mar 27 07:59:17 2014 +0000
@@ -26,7 +26,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $Id: vchi_bsd.c,v 1.5 2014/03/27 07:56:56 skrll Exp $
+ * $Id: vchi_bsd.c,v 1.6 2014/03/27 07:59:17 skrll Exp $
  */
 
 #include <sys/types.h>
@@ -283,15 +283,12 @@
 int
 down_interruptible(struct semaphore *s)
 {
-       int ret ;
-
-       ret = 0;
 
        mutex_enter(&s->mtx);
 
        while (s->value == 0) {
                s->waiters++;
-               ret = cv_wait_sig(&s->cv, &s->mtx);
+               int ret = cv_wait_sig(&s->cv, &s->mtx);
                s->waiters--;
 
                if (ret == EINTR || ret == ERESTART) {
@@ -309,9 +306,7 @@
 int
 down_trylock(struct semaphore *s)
 {
-       int ret;
-
-       ret = 0;
+       int ret = 1;
 
        mutex_enter(&s->mtx);
 
@@ -319,8 +314,6 @@
                /* Success. */
                s->value--;
                ret = 0;
-       } else {
-               ret = -EAGAIN;
        }
 
        mutex_exit(&s->mtx);
@@ -333,7 +326,7 @@
 {
        mutex_enter(&s->mtx);
        s->value++;
-       if (s->waiters && s->value > 0)
+       if (s->value > 0 && s->waiters)
                cv_signal(&s->cv);
 
        mutex_exit(&s->mtx);



Home | Main Index | Thread Index | Old Index