From: Luca Ellero Date: Thu, 10 Jul 2014 09:03:57 +0000 (+0200) Subject: staging: ced1401: fix ced_wait_event() X-Git-Tag: firefly_0821_release~176^2~3491^2~986 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3fe68ea0f6ca0411a634658eb18e3ce322b4dae1;p=firefly-linux-kernel-4.4.55.git staging: ced1401: fix ced_wait_event() Rename camel case arguments and locals in function ced_wait_event() Signed-off-by: Luca Ellero Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/ced1401/ced_ioc.c b/drivers/staging/ced1401/ced_ioc.c index f00aff6d3818..707f8fa68ce1 100644 --- a/drivers/staging/ced1401/ced_ioc.c +++ b/drivers/staging/ced1401/ced_ioc.c @@ -863,45 +863,51 @@ int ced_set_event(struct ced_data *ced, struct transfer_event __user *ute) ** of times that a block met the event condition since we last cleared it or ** 0 if timed out, or -ve error (bad area or not set, or signal). ****************************************************************************/ -int ced_wait_event(struct ced_data *ced, int nArea, int msTimeOut) +int ced_wait_event(struct ced_data *ced, int area, int time_out) { - int iReturn; - if ((unsigned)nArea >= MAX_TRANSAREAS) + int ret; + if ((unsigned)area >= MAX_TRANSAREAS) return U14ERR_BADAREA; else { - int iWait; - struct transarea *pTA = &ced->trans_def[nArea]; - msTimeOut = (msTimeOut * HZ + 999) / 1000; /* convert timeout to jiffies */ + int wait; + struct transarea *ta = &ced->trans_def[area]; - /* We cannot wait holding the mutex, but we check the flags while holding */ - /* it. This may well be pointless as another thread could get in between */ - /* releasing it and the wait call. However, this would have to clear the */ - /* iWakeUp flag. However, the !pTA-bUsed may help us in this case. */ - mutex_lock(&ced->io_mutex); /* make sure we have no competitor */ - if (!pTA->used || !pTA->event_sz) /* check something to wait for... */ + /* convert timeout to jiffies */ + time_out = (time_out * HZ + 999) / 1000; + + /* We cannot wait holding the mutex, but we check the flags */ + /* while holding it. This may well be pointless as another */ + /* thread could get in between releasing it and the wait */ + /* call. However, this would have to clear the wake_up flag. */ + /* However, the !ta->used may help us in this case. */ + + /* make sure we have no competitor */ + mutex_lock(&ced->io_mutex); + if (!ta->used || !ta->event_sz) /* check something to */ + /* wait for... */ return U14ERR_NOTSET; /* ...else we do nothing */ mutex_unlock(&ced->io_mutex); - if (msTimeOut) - iWait = - wait_event_interruptible_timeout(pTA->event, - pTA->wake_up - || !pTA->used, - msTimeOut); + if (time_out) + wait = wait_event_interruptible_timeout(ta->event, + ta->wake_up || + !ta->used, + time_out); else - iWait = - wait_event_interruptible(pTA->event, pTA->wake_up - || !pTA->used); - if (iWait) - iReturn = -ERESTARTSYS; /* oops - we have had a SIGNAL */ + wait = wait_event_interruptible(ta->event, + ta->wake_up || + !ta->used); + + if (wait) + ret = -ERESTARTSYS; /* oops - we have had a SIGNAL */ else - iReturn = pTA->wake_up; /* else the wakeup count */ + ret = ta->wake_up; /* else the wakeup count */ spin_lock_irq(&ced->staged_lock); - pTA->wake_up = 0; /* clear the flag */ + ta->wake_up = 0; /* clear the flag */ spin_unlock_irq(&ced->staged_lock); } - return iReturn; + return ret; } /**************************************************************************** diff --git a/drivers/staging/ced1401/usb1401.h b/drivers/staging/ced1401/usb1401.h index d18755b2390d..ac4062bde410 100644 --- a/drivers/staging/ced1401/usb1401.h +++ b/drivers/staging/ced1401/usb1401.h @@ -253,6 +253,6 @@ extern int ced_dbg_stop_loop(struct ced_data *ced); extern int ced_set_circular(struct ced_data *ced, struct transfer_area_desc __user *pTD); extern int ced_get_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB); extern int ced_free_circ_block(struct ced_data *ced, TCIRCBLOCK __user *pCB); -extern int ced_wait_event(struct ced_data *ced, int nArea, int msTimeOut); extern int ced_test_event(struct ced_data *ced, int nArea); +extern int ced_wait_event(struct ced_data *ced, int area, int time_out); #endif