Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 167710
b: refs/heads/master
c: 160d0fa
h: refs/heads/master
v: v3
  • Loading branch information
Ben Dooks authored and David S. Miller committed Oct 21, 2009
1 parent a6cce00 commit c00e6b6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 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: 57dada6819160eb08f2945fb847045f173d3218d
refs/heads/master: 160d0fadaf7ce20e5bad26c8a955504b93c6a5ba
37 changes: 33 additions & 4 deletions trunk/drivers/net/ks8851.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,36 @@ static void ks8851_wrreg16(struct ks8851_net *ks, unsigned reg, unsigned val)
ks_err(ks, "spi_sync() failed\n");
}

/**
* ks8851_wrreg8 - write 8bit register value to chip
* @ks: The chip state
* @reg: The register address
* @val: The value to write
*
* Issue a write to put the value @val into the register specified in @reg.
*/
static void ks8851_wrreg8(struct ks8851_net *ks, unsigned reg, unsigned val)
{
struct spi_transfer *xfer = &ks->spi_xfer1;
struct spi_message *msg = &ks->spi_msg1;
__le16 txb[2];
int ret;
int bit;

bit = 1 << (reg & 3);

txb[0] = cpu_to_le16(MK_OP(bit, reg) | KS_SPIOP_WR);
txb[1] = val;

xfer->tx_buf = txb;
xfer->rx_buf = NULL;
xfer->len = 3;

ret = spi_sync(ks->spidev, msg);
if (ret < 0)
ks_err(ks, "spi_sync() failed\n");
}

/**
* ks8851_rx_1msg - select whether to use one or two messages for spi read
* @ks: The device structure
Expand Down Expand Up @@ -322,13 +352,12 @@ static void ks8851_soft_reset(struct ks8851_net *ks, unsigned op)
static int ks8851_write_mac_addr(struct net_device *dev)
{
struct ks8851_net *ks = netdev_priv(dev);
u16 *mcp = (u16 *)dev->dev_addr;
int i;

mutex_lock(&ks->lock);

ks8851_wrreg16(ks, KS_MARL, mcp[0]);
ks8851_wrreg16(ks, KS_MARM, mcp[1]);
ks8851_wrreg16(ks, KS_MARH, mcp[2]);
for (i = 0; i < ETH_ALEN; i++)
ks8851_wrreg8(ks, KS_MAR(i), dev->dev_addr[i]);

mutex_unlock(&ks->lock);

Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/net/ks8851.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define CCR_32PIN (1 << 0)

/* MAC address registers */
#define KS_MAR(_m) 0x15 - (_m)
#define KS_MARL 0x10
#define KS_MARM 0x12
#define KS_MARH 0x14
Expand Down

0 comments on commit c00e6b6

Please sign in to comment.