aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorPavel Roskin <proski@gnu.org>2006-04-07 04:10:39 -0400
committerJohn W. Linville <linville@tuxdriver.com>2006-04-24 16:15:50 -0400
commit6b61626290900f12b7f3978f57f329da6811fb59 (patch)
tree2e1d9518d786bbca0e87ffec3f42a6f5794fe384 /drivers/net/wireless
parentb34b867e944628418d587367276c9a82e03aba8c (diff)
[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: Pavel Roskin <proski@gnu.org> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/hermes.c17
-rw-r--r--drivers/net/wireless/hermes.h7
-rw-r--r--drivers/net/wireless/spectrum_cs.c7
3 files changed, 16 insertions, 15 deletions
diff --git a/drivers/net/wireless/hermes.c b/drivers/net/wireless/hermes.c
index 456d934caad8..be24f01ea469 100644
--- a/drivers/net/wireless/hermes.c
+++ b/drivers/net/wireless/hermes.c
@@ -400,8 +400,7 @@ int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
400} 400}
401 401
402/* Write a block of data to the chip's buffer, via the 402/* Write a block of data to the chip's buffer, via the
403 * BAP. Synchronization/serialization is the caller's problem. len 403 * BAP. Synchronization/serialization is the caller's problem.
404 * must be even.
405 * 404 *
406 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware 405 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
407 */ 406 */
@@ -411,7 +410,7 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
411 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 410 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
412 int err = 0; 411 int err = 0;
413 412
414 if ( (len < 0) || (len % 2) ) 413 if (len < 0)
415 return -EINVAL; 414 return -EINVAL;
416 415
417 err = hermes_bap_seek(hw, bap, id, offset); 416 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 goto out; 418 goto out;
420 419
421 /* Actually do the transfer */ 420 /* Actually do the transfer */
422 hermes_write_words(hw, dreg, buf, len/2); 421 hermes_write_bytes(hw, dreg, buf, len);
423 422
424 out: 423 out:
425 return err; 424 return err;
@@ -427,7 +426,7 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
427 426
428/* Write a block of data to the chip's buffer with padding if 427/* Write a block of data to the chip's buffer with padding if
429 * neccessary, via the BAP. Synchronization/serialization is the 428 * neccessary, via the BAP. Synchronization/serialization is the
430 * caller's problem. len must be even. 429 * caller's problem.
431 * 430 *
432 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware 431 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
433 */ 432 */
@@ -437,7 +436,7 @@ int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, unsigned data_
437 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 436 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
438 int err = 0; 437 int err = 0;
439 438
440 if (len < 0 || len % 2 || data_len > len) 439 if (len < 0 || data_len > len)
441 return -EINVAL; 440 return -EINVAL;
442 441
443 err = hermes_bap_seek(hw, bap, id, offset); 442 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 goto out; 444 goto out;
446 445
447 /* Transfer all the complete words of data */ 446 /* Transfer all the complete words of data */
448 hermes_write_words(hw, dreg, buf, data_len/2); 447 hermes_write_bytes(hw, dreg, buf, data_len);
449 /* If there is an odd byte left over pad and transfer it */ 448 /* If there is an odd byte left over pad and transfer it */
450 if (data_len & 1) { 449 if (data_len & 1) {
451 u8 end[2]; 450 u8 end[2];
452 end[1] = 0; 451 end[1] = 0;
453 end[0] = ((unsigned char *)buf)[data_len - 1]; 452 end[0] = ((unsigned char *)buf)[data_len - 1];
454 hermes_write_words(hw, dreg, end, 1); 453 hermes_write_bytes(hw, dreg, end, 2);
455 data_len ++; 454 data_len ++;
456 } 455 }
457 /* Now send zeros for the padding */ 456 /* Now send zeros for the padding */
@@ -534,7 +533,7 @@ int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,
534 533
535 count = length - 1; 534 count = length - 1;
536 535
537 hermes_write_words(hw, dreg, value, count); 536 hermes_write_bytes(hw, dreg, value, count << 1);
538 537
539 err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS | HERMES_CMD_WRITE, 538 err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS | HERMES_CMD_WRITE,
540 rid, NULL); 539 rid, NULL);
diff --git a/drivers/net/wireless/hermes.h b/drivers/net/wireless/hermes.h
index 34ccba2d4354..e1b279e1bf32 100644
--- a/drivers/net/wireless/hermes.h
+++ b/drivers/net/wireless/hermes.h
@@ -408,10 +408,13 @@ static inline void hermes_read_words(struct hermes *hw, int off, void *buf, unsi
408 ioread16_rep(hw->iobase + off, buf, count); 408 ioread16_rep(hw->iobase + off, buf, count);
409} 409}
410 410
411static inline void hermes_write_words(struct hermes *hw, int off, const void *buf, unsigned count) 411static inline void hermes_write_bytes(struct hermes *hw, int off,
412 const char *buf, unsigned count)
412{ 413{
413 off = off << hw->reg_spacing; 414 off = off << hw->reg_spacing;
414 iowrite16_rep(hw->iobase + off, buf, count); 415 iowrite16_rep(hw->iobase + off, buf, count >> 1);
416 if (unlikely(count & 1))
417 iowrite8(buf[count - 1], hw->iobase + off);
415} 418}
416 419
417static inline void hermes_clear_words(struct hermes *hw, int off, unsigned count) 420static inline void hermes_clear_words(struct hermes *hw, int off, unsigned count)
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index 511bc59f1574..aeb38d938832 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -343,8 +343,7 @@ spectrum_plug_pdi(hermes_t *hw, struct pdr *first_pdr, struct pdi *pdi)
343 343
344 /* do the actual plugging */ 344 /* do the actual plugging */
345 spectrum_aux_setaddr(hw, pdr_addr(pdr)); 345 spectrum_aux_setaddr(hw, pdr_addr(pdr));
346 hermes_write_words(hw, HERMES_AUXDATA, pdi->data, 346 hermes_write_bytes(hw, HERMES_AUXDATA, pdi->data, pdi_len(pdi));
347 pdi_len(pdi) / 2);
348 347
349 return 0; 348 return 0;
350} 349}
@@ -424,8 +423,8 @@ spectrum_load_blocks(hermes_t *hw, const struct dblock *first_block)
424 423
425 while (dblock_addr(blk) != BLOCK_END) { 424 while (dblock_addr(blk) != BLOCK_END) {
426 spectrum_aux_setaddr(hw, blkaddr); 425 spectrum_aux_setaddr(hw, blkaddr);
427 hermes_write_words(hw, HERMES_AUXDATA, blk->data, 426 hermes_write_bytes(hw, HERMES_AUXDATA, blk->data,
428 blklen / 2); 427 blklen);
429 428
430 blk = (struct dblock *) &blk->data[blklen]; 429 blk = (struct dblock *) &blk->data[blklen];
431 blkaddr = dblock_addr(blk); 430 blkaddr = dblock_addr(blk);