/* =====================rsz_release=========================== The Function is used to release the number of resources occupied by the channel */ static int rsz_release(struct inode *inode, struct file *filp) { struct imp_logical_channel *rsz_conf_chan = (struct imp_logical_channel *)filp->private_data; /* Lock the channel */ mutex_lock(&(rsz_conf_chan->lock)); /* It will free all the input and output buffers */ imp_common_free_buffers(rsz_device, rsz_conf_chan); if (rsz_conf_chan->config_state == STATE_CONFIGURED) { if (!rsz_conf_chan->chained) { imp_hw_if->dealloc_config_block(rsz_device, rsz_conf_chan->config); } kfree(rsz_conf_chan->user_config); } mutex_unlock(&(rsz_conf_chan->lock)); mutex_lock(&rsz_dev.lock); rsz_dev.users--; kfree(filp->private_data); filp->private_data = NULL; mutex_unlock(&rsz_dev.lock); return 0; } /* End of function resizer_release */
int previewer_release(struct inode *inode, struct file *filp) { /* get the configuratin from private_date member of file */ struct prev_fh *fh; struct imp_logical_channel *chan; struct prev_device *device = &prevdevice; unsigned int state; unsigned int mode; dev_dbg(prev_dev, __func__ "E\n"); mutex_lock(&device->lock); fh = (struct prev_fh *)filp->private_data; chan = fh->chan; /* if hw is busy in continuous mode, and this is primary user, we can not close the device */ state = imp_hw_if->get_hw_state(); mode = imp_hw_if->get_preview_oper_mode(); if ((device->users != 1) && (fh->primary_user)) { dev_err(prev_dev, "Close other instances before" " this primary user instance\n"); mutex_unlock(&device->lock); return -EBUSY; } device->users--; if (fh->primary_user) { /* call free_buffers to free memory allocated to buffers */ imp_common_free_buffers(prev_dev, chan); chan->primary_user = 0; if (chan->config_state == STATE_CONFIGURED) kfree(chan->user_config); } kfree(filp->private_data); /* Assign null to private_data member of file and params member of device */ filp->private_data = NULL; mutex_unlock(&device->lock); dev_dbg(prev_dev, __func__ "L\n"); return 0; }