mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
drivers/input: rm sched_[un]lock
We use enter_critical_section to protect the read and write of priv structures, sched_lock is mainly used to prevent active context switching caused by nxsem_post. We do not actively switch contexts when reading and writing priv structures, so sched_lock can be removed. Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
@@ -331,7 +331,6 @@ static int tsc2007_waitsample(FAR struct tsc2007_dev_s *priv,
|
||||
* from getting control while we muck with the semaphores.
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
flags = enter_critical_section();
|
||||
|
||||
/* Now release the semaphore that manages mutually exclusive access to
|
||||
@@ -374,14 +373,6 @@ errout:
|
||||
*/
|
||||
|
||||
leave_critical_section(flags);
|
||||
|
||||
/* Restore pre-emption. We might get suspended here but that is okay
|
||||
* because we already have our sample. Note: this means that if there
|
||||
* were two threads reading from the TSC2007 for some reason, the data
|
||||
* might be read out of order.
|
||||
*/
|
||||
|
||||
sched_unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -541,6 +532,10 @@ static void tsc2007_worker(FAR void *arg)
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
/* Get exclusive access to the driver data structure */
|
||||
|
||||
nxmutex_lock(&priv->devlock);
|
||||
|
||||
/* Get a pointer the callbacks for convenience (and so the code is not so
|
||||
* ugly).
|
||||
*/
|
||||
@@ -715,6 +710,7 @@ static void tsc2007_worker(FAR void *arg)
|
||||
|
||||
errout:
|
||||
config->enable(config, true);
|
||||
nxmutex_unlock(&priv->devlock);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user