add: *num_bytes = size;
context: wb840_read(void* cookie, off_t position, void *buf, size_t* num_bytes){	wb_device *device = (wb_device*)cookie;	int16 current;	status_t status;	size_t size;	int32 blockFlag;	uint32 check;		LOG((DEVICE_NAME ": read()\n"));		blockFlag = device->blockFlag;		if (atomic_or(&device->rxLock, 1)) {		*num_bytes = 0;		return B_ERROR;	}			if ((status = acquire_sem_etc(device->rxSem, 1, B_CAN_INTERRUPT | blockFlag, 0)) != B_OK) {		atomic_and(&device->rxLock, 0);		*num_bytes = 0;		return status;	}		current = device->rxCurrent;	check = device->rxDescriptor[current].wb_status;	 	if (check & WB_RXSTAT_OWN) {		LOG(("ERROR: read: buffer %d still in use: %x\n", (int)current, (int)status));		atomic_and(&device->rxLock, 0);		*num_bytes = 0;		return B_BUSY;	}		if (check & (WB_RXSTAT_RXERR | WB_RXSTAT_CRCERR | WB_RXSTAT_RUNT)) {		LOG(("Error read: packet with errors."));		*num_bytes = 0;	} else {		size = WB_RXBYTES(check);		LOG((DEVICE_NAME": received %d bytes\n", (int)size));		if (size > WB_MAX_FRAMELEN || size > *num_bytes) {			LOG(("ERROR: Bad frame size: %d", (int)size));			size = *num_bytes;		}		memcpy(buf, (void *)device->rxBuffer[current], size);	}		device->rxCurrent = (current + 1) & WB_RX_CNT_MASK;	{		cpu_status former;		former = disable_interrupts();		acquire_spinlock(&device->rxSpinlock);		// release buffer to ring		wb_free_rx_descriptor(&device->rxDescriptor[current]);		device->rxFree++;		release_spinlock(&device->rxSpinlock);   		restore_interrupts(former);	}		atomic_and(&device->rxLock, 0);		return B_OK;}