* Calmed down the FreeBSD drivers even more - compat_{read|write}() no longer
print anything. * Added (commented out) debug output to compat_control(). * Renamed variables "len" to "length" where possible. * Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22818 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
1662c6dfc9
commit
b7d3b2fe8f
|
@ -177,16 +177,16 @@ compat_free(void *cookie)
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
compat_read(void *cookie, off_t position, void *buf, size_t *numBytes)
|
compat_read(void *cookie, off_t position, void *buffer, size_t *numBytes)
|
||||||
{
|
{
|
||||||
struct network_device *dev = cookie;
|
struct network_device *dev = cookie;
|
||||||
uint32 semFlags = B_CAN_INTERRUPT;
|
uint32 semFlags = B_CAN_INTERRUPT;
|
||||||
status_t status;
|
status_t status;
|
||||||
struct mbuf *mb;
|
struct mbuf *mb;
|
||||||
size_t len;
|
size_t length;
|
||||||
|
|
||||||
device_printf(DEVNET(dev), "compat_read(%lld, %p, [%lu])\n", position, buf,
|
//device_printf(DEVNET(dev), "compat_read(%lld, %p, [%lu])\n", position,
|
||||||
*numBytes);
|
// buffer, *numBytes);
|
||||||
|
|
||||||
if (DEVNET(dev)->flags & DEVICE_CLOSED)
|
if (DEVNET(dev)->flags & DEVICE_CLOSED)
|
||||||
return B_INTERRUPTED;
|
return B_INTERRUPTED;
|
||||||
|
@ -208,7 +208,7 @@ compat_read(void *cookie, off_t position, void *buf, size_t *numBytes)
|
||||||
IF_DEQUEUE(&dev->receive_queue, mb);
|
IF_DEQUEUE(&dev->receive_queue, mb);
|
||||||
} while (mb == NULL);
|
} while (mb == NULL);
|
||||||
|
|
||||||
len = min_c(max_c((size_t)mb->m_len, 0), *numBytes);
|
length = min_c(max_c((size_t)mb->m_len, 0), *numBytes);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
mb = m_defrag(mb, 0);
|
mb = m_defrag(mb, 0);
|
||||||
|
@ -218,8 +218,8 @@ compat_read(void *cookie, off_t position, void *buf, size_t *numBytes)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
memcpy(buf, mtod(mb, const void *), len);
|
memcpy(buffer, mtod(mb, const void *), length);
|
||||||
*numBytes = len;
|
*numBytes = length;
|
||||||
|
|
||||||
m_freem(mb);
|
m_freem(mb);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
@ -233,8 +233,8 @@ compat_write(void *cookie, off_t position, const void *buffer,
|
||||||
struct network_device *dev = cookie;
|
struct network_device *dev = cookie;
|
||||||
struct mbuf *mb;
|
struct mbuf *mb;
|
||||||
|
|
||||||
device_printf(DEVNET(dev), "compat_write(%lld, %p, [%lu])\n", position,
|
//device_printf(DEVNET(dev), "compat_write(%lld, %p, [%lu])\n", position,
|
||||||
buffer, *numBytes);
|
// buffer, *numBytes);
|
||||||
|
|
||||||
mb = m_getcl(0, MT_DATA, M_PKTHDR);
|
mb = m_getcl(0, MT_DATA, M_PKTHDR);
|
||||||
if (mb == NULL)
|
if (mb == NULL)
|
||||||
|
@ -250,11 +250,14 @@ compat_write(void *cookie, off_t position, const void *buffer,
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
compat_control(void *cookie, uint32 op, void *arg, size_t len)
|
compat_control(void *cookie, uint32 op, void *arg, size_t length)
|
||||||
{
|
{
|
||||||
struct network_device *dev = cookie;
|
struct network_device *dev = cookie;
|
||||||
struct ifnet *ifp = dev->ifp;
|
struct ifnet *ifp = dev->ifp;
|
||||||
|
|
||||||
|
//device_printf(DEVNET(dev), "compat_control(op %lu, %p, [%lu])\n", op,
|
||||||
|
// arg, length);
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case ETHER_INIT:
|
case ETHER_INIT:
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
@ -265,7 +268,7 @@ compat_control(void *cookie, uint32 op, void *arg, size_t len)
|
||||||
case ETHER_NONBLOCK:
|
case ETHER_NONBLOCK:
|
||||||
{
|
{
|
||||||
int32 value;
|
int32 value;
|
||||||
if (len < 4)
|
if (length < 4)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
if (user_memcpy(&value, arg, sizeof(int32)) < B_OK)
|
if (user_memcpy(&value, arg, sizeof(int32)) < B_OK)
|
||||||
return B_BAD_ADDRESS;
|
return B_BAD_ADDRESS;
|
||||||
|
@ -279,7 +282,7 @@ compat_control(void *cookie, uint32 op, void *arg, size_t len)
|
||||||
case ETHER_SETPROMISC:
|
case ETHER_SETPROMISC:
|
||||||
{
|
{
|
||||||
int32 value;
|
int32 value;
|
||||||
if (len < 4)
|
if (length < 4)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
if (user_memcpy(&value, arg, sizeof(int32)) < B_OK)
|
if (user_memcpy(&value, arg, sizeof(int32)) < B_OK)
|
||||||
return B_BAD_ADDRESS;
|
return B_BAD_ADDRESS;
|
||||||
|
@ -293,7 +296,7 @@ compat_control(void *cookie, uint32 op, void *arg, size_t len)
|
||||||
case ETHER_GETFRAMESIZE:
|
case ETHER_GETFRAMESIZE:
|
||||||
{
|
{
|
||||||
uint32 frame_size;
|
uint32 frame_size;
|
||||||
if (len < 4)
|
if (length < 4)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
frame_size = dev->ifp->if_mtu + ETHER_HDR_LEN;
|
frame_size = dev->ifp->if_mtu + ETHER_HDR_LEN;
|
||||||
return user_memcpy(arg, &frame_size, 4);
|
return user_memcpy(arg, &frame_size, 4);
|
||||||
|
@ -313,7 +316,7 @@ compat_control(void *cookie, uint32 op, void *arg, size_t len)
|
||||||
|
|
||||||
if (op == ETHER_ADDMULTI)
|
if (op == ETHER_ADDMULTI)
|
||||||
return if_addmulti(ifp, (struct sockaddr *)&address, NULL);
|
return if_addmulti(ifp, (struct sockaddr *)&address, NULL);
|
||||||
else
|
|
||||||
return if_delmulti(ifp, (struct sockaddr *)&address);
|
return if_delmulti(ifp, (struct sockaddr *)&address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,7 +326,7 @@ compat_control(void *cookie, uint32 op, void *arg, size_t len)
|
||||||
ether_link_state_t state;
|
ether_link_state_t state;
|
||||||
status_t status;
|
status_t status;
|
||||||
|
|
||||||
if (len < sizeof(ether_link_state_t))
|
if (length < sizeof(ether_link_state_t))
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
|
|
||||||
memset(&mediareq, 0, sizeof(mediareq));
|
memset(&mediareq, 0, sizeof(mediareq));
|
||||||
|
|
Loading…
Reference in New Issue