Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 149903
b: refs/heads/master
c: 87cbfd0
h: refs/heads/master
i:
  149901: 0dde808
  149899: 5f1c299
  149895: 1121522
  149887: 90480dc
v: v3
  • Loading branch information
Max Filippov authored and John W. Linville committed Apr 22, 2009
1 parent c197ae1 commit c00ec2e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 28 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: 6a362bb1c9f900f7e6daeee52ff2d538badae49b
refs/heads/master: 87cbfd06889256cac945b37c7f62f4ce7f44b34a
41 changes: 14 additions & 27 deletions trunk/drivers/net/wireless/p54/p54spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,13 @@ static const struct p54spi_spi_reg p54spi_registers_array[] =
static int p54spi_wait_bit(struct p54s_priv *priv, u16 reg, __le32 bits)
{
int i;
__le32 buffer;

for (i = 0; i < 2000; i++) {
p54spi_spi_read(priv, reg, &buffer, sizeof(buffer));
__le32 buffer = p54spi_read32(priv, reg);
if ((buffer & bits) == bits)
return 1;

msleep(1);
msleep(0);
}
return 0;
}
Expand All @@ -185,10 +184,10 @@ static int p54spi_spi_write_dma(struct p54s_priv *priv, __le32 base,
p54spi_write16(priv, SPI_ADRS_DMA_WRITE_CTRL,
cpu_to_le16(SPI_DMA_WRITE_CTRL_ENABLE));

if (p54spi_wait_bit(priv, SPI_ADRS_DMA_WRITE_CTRL,
cpu_to_le32(HOST_ALLOWED)) == 0) {
if (!p54spi_wait_bit(priv, SPI_ADRS_DMA_WRITE_CTRL,
cpu_to_le32(HOST_ALLOWED))) {
dev_err(&priv->spi->dev, "spi_write_dma not allowed "
"to DMA write.");
"to DMA write.\n");
return -EAGAIN;
}

Expand Down Expand Up @@ -330,21 +329,15 @@ static inline void p54spi_int_ack(struct p54s_priv *priv, u32 val)

static void p54spi_wakeup(struct p54s_priv *priv)
{
unsigned long timeout;
u32 ints;

/* wake the chip */
p54spi_write32(priv, SPI_ADRS_ARM_INTERRUPTS,
cpu_to_le32(SPI_TARGET_INT_WAKEUP));

/* And wait for the READY interrupt */
timeout = jiffies + HZ;

ints = p54spi_read32(priv, SPI_ADRS_HOST_INTERRUPTS);
while (!(ints & SPI_HOST_INT_READY)) {
if (time_after(jiffies, timeout))
goto out;
ints = p54spi_read32(priv, SPI_ADRS_HOST_INTERRUPTS);
if (!p54spi_wait_bit(priv, SPI_ADRS_HOST_INTERRUPTS,
cpu_to_le32(SPI_HOST_INT_READY))) {
dev_err(&priv->spi->dev, "INT_READY timeout\n");
goto out;
}

p54spi_int_ack(priv, SPI_HOST_INT_READY);
Expand Down Expand Up @@ -432,25 +425,19 @@ static irqreturn_t p54spi_interrupt(int irq, void *config)
static int p54spi_tx_frame(struct p54s_priv *priv, struct sk_buff *skb)
{
struct p54_hdr *hdr = (struct p54_hdr *) skb->data;
unsigned long timeout;
int ret = 0;
u32 ints;

p54spi_wakeup(priv);

ret = p54spi_spi_write_dma(priv, hdr->req_id, skb->data, skb->len);
if (ret < 0)
goto out;

timeout = jiffies + 2 * HZ;
ints = p54spi_read32(priv, SPI_ADRS_HOST_INTERRUPTS);
while (!(ints & SPI_HOST_INT_WR_READY)) {
if (time_after(jiffies, timeout)) {
dev_err(&priv->spi->dev, "WR_READY timeout\n");
ret = -1;
goto out;
}
ints = p54spi_read32(priv, SPI_ADRS_HOST_INTERRUPTS);
if (!p54spi_wait_bit(priv, SPI_ADRS_HOST_INTERRUPTS,
cpu_to_le32(SPI_HOST_INT_WR_READY))) {
dev_err(&priv->spi->dev, "WR_READY timeout\n");
ret = -1;
goto out;
}

p54spi_int_ack(priv, SPI_HOST_INT_WR_READY);
Expand Down

0 comments on commit c00ec2e

Please sign in to comment.