static int mon_text_release(struct inode *inode, struct file *file) { struct mon_reader_text *rp = file->private_data; struct mon_bus *mbus; /* unsigned long flags; */ struct list_head *p; struct mon_event_text *ep; mutex_lock(&mon_lock); mbus = inode->i_private; if (mbus->nreaders <= 0) { printk(KERN_ERR TAG ": consistency error on close\n"); mutex_unlock(&mon_lock); return 0; } mon_reader_del(mbus, &rp->r); /* * In theory, e_list is protected by mbus->lock. However, * after mon_reader_del has finished, the following is the case: * - we are not on reader list anymore, so new events won't be added; * - whole mbus may be dropped if it was orphaned. * So, we better not touch mbus. */ /* spin_lock_irqsave(&mbus->lock, flags); */ while (!list_empty(&rp->e_list)) { p = rp->e_list.next; ep = list_entry(p, struct mon_event_text, e_link); list_del(p); --rp->nevents; kmem_cache_free(rp->e_slab, ep); } /* spin_unlock_irqrestore(&mbus->lock, flags); */ kmem_cache_destroy(rp->e_slab); kfree(rp->printf_buf); kfree(rp); mutex_unlock(&mon_lock); return 0; }
static int mon_text_release(struct inode *inode, struct file *file) { struct mon_reader_text *rp = file->private_data; struct mon_bus *mbus; /* */ struct list_head *p; struct mon_event_text *ep; mutex_lock(&mon_lock); mbus = inode->i_private; if (mbus->nreaders <= 0) { printk(KERN_ERR TAG ": consistency error on close\n"); mutex_unlock(&mon_lock); return 0; } mon_reader_del(mbus, &rp->r); /* */ /* */ while (!list_empty(&rp->e_list)) { p = rp->e_list.next; ep = list_entry(p, struct mon_event_text, e_link); list_del(p); --rp->nevents; kmem_cache_free(rp->e_slab, ep); } /* */ kmem_cache_destroy(rp->e_slab); kfree(rp->printf_buf); kfree(rp); mutex_unlock(&mon_lock); return 0; }