/* Unlike mutex_trylock, this function can be used from interrupt context, and the semaphore can be released by any task or interrupt.  */
int down_trylock(struct semaphore *sem)
/* Unlike mutex_trylock, this function can be used from interrupt context, and the semaphore can be released by any task or interrupt.  */
int down_trylock(struct semaphore *sem)
{
	unsigned long flags;
	int count;
	spin_lock_irqsave(&sem->lock, flags);
	count = sem->count - 1;
	if (likely(count >= 0))
		sem->count = count;
	spin_unlock_irqrestore(&sem->lock, flags);
	return (count < 0);
}