Commit 6b616262 authored by Pavel Roskin's avatar Pavel Roskin Committed by John W. Linville

[PATCH] orinoco replace hermes_write_words() with hermes_write_bytes()

The new function can write an odd number of bytes, thus making padding
unnecessary.
Signed-off-by: default avatarPavel Roskin <proski@gnu.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent b34b867e
...@@ -400,8 +400,7 @@ int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len, ...@@ -400,8 +400,7 @@ int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
} }
/* Write a block of data to the chip's buffer, via the /* Write a block of data to the chip's buffer, via the
* BAP. Synchronization/serialization is the caller's problem. len * BAP. Synchronization/serialization is the caller's problem.
* must be even.
* *
* Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
*/ */
...@@ -411,7 +410,7 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len, ...@@ -411,7 +410,7 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
int err = 0; int err = 0;
if ( (len < 0) || (len % 2) ) if (len < 0)
return -EINVAL; return -EINVAL;
err = hermes_bap_seek(hw, bap, id, offset); err = hermes_bap_seek(hw, bap, id, offset);
...@@ -419,7 +418,7 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len, ...@@ -419,7 +418,7 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
goto out; goto out;
/* Actually do the transfer */ /* Actually do the transfer */
hermes_write_words(hw, dreg, buf, len/2); hermes_write_bytes(hw, dreg, buf, len);
out: out:
return err; return err;
...@@ -427,7 +426,7 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len, ...@@ -427,7 +426,7 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
/* Write a block of data to the chip's buffer with padding if /* Write a block of data to the chip's buffer with padding if
* neccessary, via the BAP. Synchronization/serialization is the * neccessary, via the BAP. Synchronization/serialization is the
* caller's problem. len must be even. * caller's problem.
* *
* Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
*/ */
...@@ -437,7 +436,7 @@ int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, unsigned data_ ...@@ -437,7 +436,7 @@ int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, unsigned data_
int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
int err = 0; int err = 0;
if (len < 0 || len % 2 || data_len > len) if (len < 0 || data_len > len)
return -EINVAL; return -EINVAL;
err = hermes_bap_seek(hw, bap, id, offset); err = hermes_bap_seek(hw, bap, id, offset);
...@@ -445,13 +444,13 @@ int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, unsigned data_ ...@@ -445,13 +444,13 @@ int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, unsigned data_
goto out; goto out;
/* Transfer all the complete words of data */ /* Transfer all the complete words of data */
hermes_write_words(hw, dreg, buf, data_len/2); hermes_write_bytes(hw, dreg, buf, data_len);
/* If there is an odd byte left over pad and transfer it */ /* If there is an odd byte left over pad and transfer it */
if (data_len & 1) { if (data_len & 1) {
u8 end[2]; u8 end[2];
end[1] = 0; end[1] = 0;
end[0] = ((unsigned char *)buf)[data_len - 1]; end[0] = ((unsigned char *)buf)[data_len - 1];
hermes_write_words(hw, dreg, end, 1); hermes_write_bytes(hw, dreg, end, 2);
data_len ++; data_len ++;
} }
/* Now send zeros for the padding */ /* Now send zeros for the padding */
...@@ -534,7 +533,7 @@ int hermes_write_ltv(hermes_t *hw, int bap, u16 rid, ...@@ -534,7 +533,7 @@ int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,
count = length - 1; count = length - 1;
hermes_write_words(hw, dreg, value, count); hermes_write_bytes(hw, dreg, value, count << 1);
err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS | HERMES_CMD_WRITE, err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS | HERMES_CMD_WRITE,
rid, NULL); rid, NULL);
......
...@@ -408,10 +408,13 @@ static inline void hermes_read_words(struct hermes *hw, int off, void *buf, unsi ...@@ -408,10 +408,13 @@ static inline void hermes_read_words(struct hermes *hw, int off, void *buf, unsi
ioread16_rep(hw->iobase + off, buf, count); ioread16_rep(hw->iobase + off, buf, count);
} }
static inline void hermes_write_words(struct hermes *hw, int off, const void *buf, unsigned count) static inline void hermes_write_bytes(struct hermes *hw, int off,
const char *buf, unsigned count)
{ {
off = off << hw->reg_spacing; off = off << hw->reg_spacing;
iowrite16_rep(hw->iobase + off, buf, count); iowrite16_rep(hw->iobase + off, buf, count >> 1);
if (unlikely(count & 1))
iowrite8(buf[count - 1], hw->iobase + off);
} }
static inline void hermes_clear_words(struct hermes *hw, int off, unsigned count) static inline void hermes_clear_words(struct hermes *hw, int off, unsigned count)
......
...@@ -343,8 +343,7 @@ spectrum_plug_pdi(hermes_t *hw, struct pdr *first_pdr, struct pdi *pdi) ...@@ -343,8 +343,7 @@ spectrum_plug_pdi(hermes_t *hw, struct pdr *first_pdr, struct pdi *pdi)
/* do the actual plugging */ /* do the actual plugging */
spectrum_aux_setaddr(hw, pdr_addr(pdr)); spectrum_aux_setaddr(hw, pdr_addr(pdr));
hermes_write_words(hw, HERMES_AUXDATA, pdi->data, hermes_write_bytes(hw, HERMES_AUXDATA, pdi->data, pdi_len(pdi));
pdi_len(pdi) / 2);
return 0; return 0;
} }
...@@ -424,8 +423,8 @@ spectrum_load_blocks(hermes_t *hw, const struct dblock *first_block) ...@@ -424,8 +423,8 @@ spectrum_load_blocks(hermes_t *hw, const struct dblock *first_block)
while (dblock_addr(blk) != BLOCK_END) { while (dblock_addr(blk) != BLOCK_END) {
spectrum_aux_setaddr(hw, blkaddr); spectrum_aux_setaddr(hw, blkaddr);
hermes_write_words(hw, HERMES_AUXDATA, blk->data, hermes_write_bytes(hw, HERMES_AUXDATA, blk->data,
blklen / 2); blklen);
blk = (struct dblock *) &blk->data[blklen]; blk = (struct dblock *) &blk->data[blklen];
blkaddr = dblock_addr(blk); blkaddr = dblock_addr(blk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment