aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/hermes.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/hermes.c')
-rw-r--r--drivers/net/wireless/hermes.c66
1 files changed, 4 insertions, 62 deletions
diff --git a/drivers/net/wireless/hermes.c b/drivers/net/wireless/hermes.c
index 346c6febb033..2aa2f389c0d5 100644
--- a/drivers/net/wireless/hermes.c
+++ b/drivers/net/wireless/hermes.c
@@ -121,12 +121,6 @@ void hermes_struct_init(hermes_t *hw, void __iomem *address, int reg_spacing)
121 hw->iobase = address; 121 hw->iobase = address;
122 hw->reg_spacing = reg_spacing; 122 hw->reg_spacing = reg_spacing;
123 hw->inten = 0x0; 123 hw->inten = 0x0;
124
125#ifdef HERMES_DEBUG_BUFFER
126 hw->dbufp = 0;
127 memset(&hw->dbuf, 0xff, sizeof(hw->dbuf));
128 memset(&hw->profile, 0, sizeof(hw->profile));
129#endif
130} 124}
131 125
132int hermes_init(hermes_t *hw) 126int hermes_init(hermes_t *hw)
@@ -347,19 +341,6 @@ static int hermes_bap_seek(hermes_t *hw, int bap, u16 id, u16 offset)
347 reg = hermes_read_reg(hw, oreg); 341 reg = hermes_read_reg(hw, oreg);
348 } 342 }
349 343
350#ifdef HERMES_DEBUG_BUFFER
351 hw->profile[HERMES_BAP_BUSY_TIMEOUT - k]++;
352
353 if (k < HERMES_BAP_BUSY_TIMEOUT) {
354 struct hermes_debug_entry *e =
355 &hw->dbuf[(hw->dbufp++) % HERMES_DEBUG_BUFSIZE];
356 e->bap = bap;
357 e->id = id;
358 e->offset = offset;
359 e->cycles = HERMES_BAP_BUSY_TIMEOUT - k;
360 }
361#endif
362
363 if (reg & HERMES_OFFSET_BUSY) 344 if (reg & HERMES_OFFSET_BUSY)
364 return -ETIMEDOUT; 345 return -ETIMEDOUT;
365 346
@@ -419,8 +400,7 @@ int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
419} 400}
420 401
421/* 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
422 * BAP. Synchronization/serialization is the caller's problem. len 403 * BAP. Synchronization/serialization is the caller's problem.
423 * must be even.
424 * 404 *
425 * 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
426 */ 406 */
@@ -430,7 +410,7 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
430 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 410 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
431 int err = 0; 411 int err = 0;
432 412
433 if ( (len < 0) || (len % 2) ) 413 if (len < 0)
434 return -EINVAL; 414 return -EINVAL;
435 415
436 err = hermes_bap_seek(hw, bap, id, offset); 416 err = hermes_bap_seek(hw, bap, id, offset);
@@ -438,49 +418,12 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
438 goto out; 418 goto out;
439 419
440 /* Actually do the transfer */ 420 /* Actually do the transfer */
441 hermes_write_words(hw, dreg, buf, len/2); 421 hermes_write_bytes(hw, dreg, buf, len);
442 422
443 out: 423 out:
444 return err; 424 return err;
445} 425}
446 426
447/* Write a block of data to the chip's buffer with padding if
448 * neccessary, via the BAP. Synchronization/serialization is the
449 * caller's problem. len must be even.
450 *
451 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
452 */
453int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, unsigned data_len, int len,
454 u16 id, u16 offset)
455{
456 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
457 int err = 0;
458
459 if (len < 0 || len % 2 || data_len > len)
460 return -EINVAL;
461
462 err = hermes_bap_seek(hw, bap, id, offset);
463 if (err)
464 goto out;
465
466 /* Transfer all the complete words of data */
467 hermes_write_words(hw, dreg, buf, data_len/2);
468 /* If there is an odd byte left over pad and transfer it */
469 if (data_len & 1) {
470 u8 end[2];
471 end[1] = 0;
472 end[0] = ((unsigned char *)buf)[data_len - 1];
473 hermes_write_words(hw, dreg, end, 1);
474 data_len ++;
475 }
476 /* Now send zeros for the padding */
477 if (data_len < len)
478 hermes_clear_words(hw, dreg, (len - data_len) / 2);
479 /* Complete */
480 out:
481 return err;
482}
483
484/* Read a Length-Type-Value record from the card. 427/* Read a Length-Type-Value record from the card.
485 * 428 *
486 * If length is NULL, we ignore the length read from the card, and 429 * If length is NULL, we ignore the length read from the card, and
@@ -553,7 +496,7 @@ int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,
553 496
554 count = length - 1; 497 count = length - 1;
555 498
556 hermes_write_words(hw, dreg, value, count); 499 hermes_write_bytes(hw, dreg, value, count << 1);
557 500
558 err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS | HERMES_CMD_WRITE, 501 err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS | HERMES_CMD_WRITE,
559 rid, NULL); 502 rid, NULL);
@@ -568,7 +511,6 @@ EXPORT_SYMBOL(hermes_allocate);
568 511
569EXPORT_SYMBOL(hermes_bap_pread); 512EXPORT_SYMBOL(hermes_bap_pread);
570EXPORT_SYMBOL(hermes_bap_pwrite); 513EXPORT_SYMBOL(hermes_bap_pwrite);
571EXPORT_SYMBOL(hermes_bap_pwrite_pad);
572EXPORT_SYMBOL(hermes_read_ltv); 514EXPORT_SYMBOL(hermes_read_ltv);
573EXPORT_SYMBOL(hermes_write_ltv); 515EXPORT_SYMBOL(hermes_write_ltv);
574 516