/* We always take the 'filp->f_lock', in since fasync_lock needs to be irq-safe.  */
static int fasync_remove_entry(struct file *filp, struct fasync_struct **fapp)
/* We always take the 'filp->f_lock', in since fasync_lock needs to be irq-safe.  */
static int fasync_remove_entry(struct file *filp, struct fasync_struct **fapp)
{
	struct fasync_struct *fa, **fp;
	int result = 0;
	spin_lock(&filp->f_lock);
	write_lock_irq(&fasync_lock);
	for (fp = fapp; (fa = *fp) != NULL; fp = &fa->fa_next) {
		if (fa->fa_file != filp)
			continue;
		*fp = fa->fa_next;
		kmem_cache_free(fasync_cache, fa);
		filp->f_flags &= ~FASYNC;
		result = 1;
		break;
	}
	write_unlock_irq(&fasync_lock);
	spin_unlock(&filp->f_lock);
	return result;
}