Corrected the last commit: we actually use the value of *_length later,
so we shouldn't overwrite it with zero... I must have tested an older version of the driver by accident; now it actually works again under R5. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12475 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -282,7 +282,7 @@ device_open(const char *name, uint32 flags, void **cookie)
|
|||||||
// enable receiver's state machine
|
// enable receiver's state machine
|
||||||
write32(info->registers + SiS900_MAC_COMMAND, SiS900_MAC_CMD_Rx_ENABLE);
|
write32(info->registers + SiS900_MAC_COMMAND, SiS900_MAC_CMD_Rx_ENABLE);
|
||||||
|
|
||||||
// check link mode & add timer
|
// check link mode & add timer (once every second)
|
||||||
sis900_checkMode(info);
|
sis900_checkMode(info);
|
||||||
add_timer(&info->timer, sis900_timer, 1000000LL, B_PERIODIC_TIMER);
|
add_timer(&info->timer, sis900_timer, 1000000LL, B_PERIODIC_TIMER);
|
||||||
|
|
||||||
@@ -414,14 +414,14 @@ device_read(void *data, off_t pos, void *buffer, size_t *_length)
|
|||||||
uint32 check;
|
uint32 check;
|
||||||
int16 current;
|
int16 current;
|
||||||
|
|
||||||
|
if (checkDeviceInfo(info = data) != B_OK) {
|
||||||
#ifndef __HAIKU__
|
#ifndef __HAIKU__
|
||||||
*_length = 0;
|
*_length = 0;
|
||||||
// net_server work-around; it obviously doesn't care about error conditions
|
// net_server work-around; it obviously doesn't care about error conditions
|
||||||
// For Haiku, this can be removed
|
// For Haiku, this can be removed
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (checkDeviceInfo(info = data) != B_OK)
|
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
blockFlag = info->blockFlag;
|
blockFlag = info->blockFlag;
|
||||||
|
|
||||||
@@ -429,13 +429,20 @@ device_read(void *data, off_t pos, void *buffer, size_t *_length)
|
|||||||
info->rxInterruptIndex, info->rxFree, info->rxCurrent, blockFlag));
|
info->rxInterruptIndex, info->rxFree, info->rxCurrent, blockFlag));
|
||||||
|
|
||||||
// read is not reentrant
|
// read is not reentrant
|
||||||
if (atomic_or(&info->rxLock, 1))
|
if (atomic_or(&info->rxLock, 1)) {
|
||||||
|
#ifndef __HAIKU__
|
||||||
|
*_length = 0;
|
||||||
|
#endif
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
// block until data is available (if blocking is allowed)
|
// block until data is available (if blocking is allowed)
|
||||||
if ((status = acquire_sem_etc(info->rxSem, 1, B_CAN_INTERRUPT | blockFlag, 0)) != B_NO_ERROR) {
|
if ((status = acquire_sem_etc(info->rxSem, 1, B_CAN_INTERRUPT | blockFlag, 0)) != B_NO_ERROR) {
|
||||||
TRACE(("cannot acquire read sem: %lx, %s\n", status, strerror(status)));
|
TRACE(("cannot acquire read sem: %lx, %s\n", status, strerror(status)));
|
||||||
atomic_and(&info->rxLock, 0);
|
atomic_and(&info->rxLock, 0);
|
||||||
|
#ifndef __HAIKU__
|
||||||
|
*_length = 0;
|
||||||
|
#endif
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,6 +453,9 @@ device_read(void *data, off_t pos, void *buffer, size_t *_length)
|
|||||||
if (!(check & SiS900_DESCR_OWN)) { // the buffer is still in use!
|
if (!(check & SiS900_DESCR_OWN)) { // the buffer is still in use!
|
||||||
TRACE(("ERROR: read: buffer %d still in use: %lx\n", current, status));
|
TRACE(("ERROR: read: buffer %d still in use: %lx\n", current, status));
|
||||||
atomic_and(&info->rxLock, 0);
|
atomic_and(&info->rxLock, 0);
|
||||||
|
#ifndef __HAIKU__
|
||||||
|
*_length = 0;
|
||||||
|
#endif
|
||||||
return B_BUSY;
|
return B_BUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user