Esempio n. 1
0
int
VDev::close(file_t *filep)
{
	PX4_DEBUG("VDev::close");
	int ret = PX4_OK;

	lock();

	if (_open_count > 0) {
		/* decrement the open count */
		_open_count--;

		/* callback cannot decline the close */
		if (_open_count == 0) {
			ret = close_last(filep);
		}

	} else {
		ret = -EBADF;
	}

	unlock();

	return ret;
}
Esempio n. 2
0
int
CDev::close(struct file *filp)
{
	int ret = OK;

	lock();

	if (_open_count > 0) {
		/* decrement the open count */
		_open_count--;

		/* callback cannot decline the close */
		if (_open_count == 0)
			ret = close_last(filp);

	} else {
		ret = -EBADF;
	}

	unlock();

	return ret;
}