Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 10946
b: refs/heads/master
c: 2c36ed2
h: refs/heads/master
v: v3
  • Loading branch information
Alan Cox authored and Jeff Garzik committed Oct 28, 2005
1 parent 9a83d4d commit fb01cc1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 63f57fb69b017230c77c40f1713e40885ae6d159
refs/heads/master: 2c36ed22c6f64de94c6c3b7258dd7285bb093401
38 changes: 38 additions & 0 deletions trunk/drivers/net/wireless/hermes.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,43 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, unsigned len,
return err;
}

/* Write a block of data to the chip's buffer with padding if
* neccessary, via the BAP. Synchronization/serialization is the
* caller's problem. len must be even.
*
* Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
*/
int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, unsigned data_len, unsigned len,
u16 id, u16 offset)
{
int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
int err = 0;

if (len < 0 || len % 2 || data_len > len)
return -EINVAL;

err = hermes_bap_seek(hw, bap, id, offset);
if (err)
goto out;

/* Transfer all the complete words of data */
hermes_write_words(hw, dreg, buf, data_len/2);
/* If there is an odd byte left over pad and transfer it */
if (data_len & 1) {
u8 end[2];
end[1] = 0;
end[0] = ((unsigned char *)buf)[data_len - 1];
hermes_write_words(hw, dreg, end, 1);
data_len ++;
}
/* Now send zeros for the padding */
if (data_len < len)
hermes_clear_words(hw, dreg, (len - data_len) / 2);
/* Complete */
out:
return err;
}

/* Read a Length-Type-Value record from the card.
*
* If length is NULL, we ignore the length read from the card, and
Expand Down Expand Up @@ -531,6 +568,7 @@ EXPORT_SYMBOL(hermes_allocate);

EXPORT_SYMBOL(hermes_bap_pread);
EXPORT_SYMBOL(hermes_bap_pwrite);
EXPORT_SYMBOL(hermes_bap_pwrite_pad);
EXPORT_SYMBOL(hermes_read_ltv);
EXPORT_SYMBOL(hermes_write_ltv);

Expand Down
2 changes: 2 additions & 0 deletions trunk/drivers/net/wireless/hermes.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ int hermes_bap_pread(hermes_t *hw, int bap, void *buf, unsigned len,
u16 id, u16 offset);
int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, unsigned len,
u16 id, u16 offset);
int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf,
unsigned data_len, unsigned len, u16 id, u16 offset);
int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned buflen,
u16 *length, void *buf);
int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,
Expand Down
11 changes: 9 additions & 2 deletions trunk/drivers/net/wireless/orinoco.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,14 +542,21 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
stats->tx_errors++;
goto fail;
}
/* Actual xfer length - allow for padding */
len = ALIGN(data_len, 2);
if (len < ETH_ZLEN - ETH_HLEN)
len = ETH_ZLEN - ETH_HLEN;
} else { /* IEEE 802.3 frame */
data_len = len + ETH_HLEN;
data_off = HERMES_802_3_OFFSET;
p = skb->data;
/* Actual xfer length - round up for odd length packets */
len = ALIGN(data_len, 2);
if (len < ETH_ZLEN)
len = ETH_ZLEN;
}

/* Round up for odd length packets */
err = hermes_bap_pwrite(hw, USER_BAP, p, ALIGN(data_len, 2),
err = hermes_bap_pwrite_pad(hw, USER_BAP, p, data_len, len,
txfid, data_off);
if (err) {
printk(KERN_ERR "%s: Error %d writing packet to BAP\n",
Expand Down

0 comments on commit fb01cc1

Please sign in to comment.