mirror of https://github.com/xemu-project/xemu.git
trivial: etraxfs_eth: Eliminate checkpatch errors
This is a trivial patch to harmonize the coding style on hw/etraxfs_eth.c. This is in preparation to split off the bitbang mdio code into a separate file. Cc: Peter Maydell <peter.maydell@linaro.org> Cc: Paul Brook <paul@codesourcery.com> Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com> Cc: Anthony Liguori <aliguori@us.ibm.com> Cc: Andreas Färber <afaerber@suse.de> Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
This commit is contained in:
parent
177f7fc688
commit
9fc7577af5
|
@ -47,8 +47,7 @@ struct qemu_phy
|
|||
int link;
|
||||
|
||||
unsigned int (*read)(struct qemu_phy *phy, unsigned int req);
|
||||
void (*write)(struct qemu_phy *phy, unsigned int req,
|
||||
unsigned int data);
|
||||
void (*write)(struct qemu_phy *phy, unsigned int req, unsigned int data);
|
||||
};
|
||||
|
||||
static unsigned int tdk_read(struct qemu_phy *phy, unsigned int req)
|
||||
|
@ -60,8 +59,9 @@ static unsigned int tdk_read(struct qemu_phy *phy, unsigned int req)
|
|||
|
||||
switch (regnum) {
|
||||
case 1:
|
||||
if (!phy->link)
|
||||
if (!phy->link) {
|
||||
break;
|
||||
}
|
||||
/* MR1. */
|
||||
/* Speeds and modes. */
|
||||
r |= (1 << 13) | (1 << 14);
|
||||
|
@ -86,8 +86,9 @@ static unsigned int tdk_read(struct qemu_phy *phy, unsigned int req)
|
|||
int duplex = 0;
|
||||
int speed_100 = 0;
|
||||
|
||||
if (!phy->link)
|
||||
if (!phy->link) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* Are we advertising 100 half or 100 duplex ? */
|
||||
speed_100 = !!(phy->regs[4] & ADVERTISE_100HALF);
|
||||
|
@ -183,10 +184,11 @@ static void mdio_read_req(struct qemu_mdio *bus)
|
|||
struct qemu_phy *phy;
|
||||
|
||||
phy = bus->devs[bus->addr];
|
||||
if (phy && phy->read)
|
||||
if (phy && phy->read) {
|
||||
bus->data = phy->read(phy, bus->req);
|
||||
else
|
||||
} else {
|
||||
bus->data = 0xffff;
|
||||
}
|
||||
}
|
||||
|
||||
static void mdio_write_req(struct qemu_mdio *bus)
|
||||
|
@ -194,8 +196,9 @@ static void mdio_write_req(struct qemu_mdio *bus)
|
|||
struct qemu_phy *phy;
|
||||
|
||||
phy = bus->devs[bus->addr];
|
||||
if (phy && phy->write)
|
||||
if (phy && phy->write) {
|
||||
phy->write(phy, bus->req, bus->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void mdio_cycle(struct qemu_mdio *bus)
|
||||
|
@ -205,11 +208,11 @@ static void mdio_cycle(struct qemu_mdio *bus)
|
|||
D(printf("mdc=%d mdio=%d state=%d cnt=%d drv=%d\n",
|
||||
bus->mdc, bus->mdio, bus->state, bus->cnt, bus->drive));
|
||||
#if 0
|
||||
if (bus->mdc)
|
||||
if (bus->mdc) {
|
||||
printf("%d", bus->mdio);
|
||||
}
|
||||
#endif
|
||||
switch (bus->state)
|
||||
{
|
||||
switch (bus->state) {
|
||||
case PREAMBLE:
|
||||
if (bus->mdc) {
|
||||
if (bus->cnt >= (32 * 2) && !bus->mdio) {
|
||||
|
@ -221,8 +224,9 @@ static void mdio_cycle(struct qemu_mdio *bus)
|
|||
break;
|
||||
case SOF:
|
||||
if (bus->mdc) {
|
||||
if (bus->mdio != 1)
|
||||
if (bus->mdio != 1) {
|
||||
printf("WARNING: no SOF\n");
|
||||
}
|
||||
if (bus->cnt == 1*2) {
|
||||
bus->cnt = 0;
|
||||
bus->opc = 0;
|
||||
|
@ -290,8 +294,9 @@ static void mdio_cycle(struct qemu_mdio *bus)
|
|||
if (bus->cnt == 16 * 2) {
|
||||
bus->cnt = 0;
|
||||
bus->state = PREAMBLE;
|
||||
if (!bus->drive)
|
||||
if (!bus->drive) {
|
||||
mdio_write_req(bus);
|
||||
}
|
||||
bus->drive = 0;
|
||||
}
|
||||
}
|
||||
|
@ -357,18 +362,19 @@ static void eth_validate_duplex(struct fs_eth *eth)
|
|||
phy_duplex = !!(phy->read(phy, 18) & (1 << 11));
|
||||
mac_duplex = !!(eth->regs[RW_REC_CTRL] & 128);
|
||||
|
||||
if (mac_duplex != phy_duplex)
|
||||
if (mac_duplex != phy_duplex) {
|
||||
new_mm = 1;
|
||||
}
|
||||
|
||||
if (eth->regs[RW_GEN_CTRL] & 1) {
|
||||
if (new_mm != eth->duplex_mismatch) {
|
||||
if (new_mm)
|
||||
printf("HW: WARNING "
|
||||
"ETH duplex mismatch MAC=%d PHY=%d\n",
|
||||
if (new_mm) {
|
||||
printf("HW: WARNING ETH duplex mismatch MAC=%d PHY=%d\n",
|
||||
mac_duplex, phy_duplex);
|
||||
else
|
||||
} else {
|
||||
printf("HW: ETH duplex ok.\n");
|
||||
}
|
||||
}
|
||||
eth->duplex_mismatch = new_mm;
|
||||
}
|
||||
}
|
||||
|
@ -387,7 +393,7 @@ eth_read(void *opaque, hwaddr addr, unsigned int size)
|
|||
break;
|
||||
default:
|
||||
r = eth->regs[addr];
|
||||
D(printf ("%s %x\n", __func__, addr * 4));
|
||||
D(printf("%s %x\n", __func__, addr * 4));
|
||||
break;
|
||||
}
|
||||
return r;
|
||||
|
@ -401,8 +407,9 @@ static void eth_update_ma(struct fs_eth *eth, int ma)
|
|||
ma &= 1;
|
||||
|
||||
reg = RW_MA0_LO;
|
||||
if (ma)
|
||||
if (ma) {
|
||||
reg = RW_MA1_LO;
|
||||
}
|
||||
|
||||
eth->macaddr[ma][i++] = eth->regs[reg];
|
||||
eth->macaddr[ma][i++] = eth->regs[reg] >> 8;
|
||||
|
@ -425,8 +432,7 @@ eth_write(void *opaque, hwaddr addr,
|
|||
uint32_t value = val64;
|
||||
|
||||
addr >>= 2;
|
||||
switch (addr)
|
||||
{
|
||||
switch (addr) {
|
||||
case RW_MA0_LO:
|
||||
case RW_MA0_HI:
|
||||
eth->regs[addr] = value;
|
||||
|
@ -440,8 +446,9 @@ eth_write(void *opaque, hwaddr addr,
|
|||
|
||||
case RW_MGM_CTRL:
|
||||
/* Attach an MDIO/PHY abstraction. */
|
||||
if (value & 2)
|
||||
if (value & 2) {
|
||||
eth->mdio_bus.mdio = value & 1;
|
||||
}
|
||||
if (eth->mdio_bus.mdc != (value & 4)) {
|
||||
mdio_cycle(ð->mdio_bus);
|
||||
eth_validate_duplex(eth);
|
||||
|
@ -457,8 +464,7 @@ eth_write(void *opaque, hwaddr addr,
|
|||
|
||||
default:
|
||||
eth->regs[addr] = value;
|
||||
D(printf ("%s %x %x\n",
|
||||
__func__, addr, value));
|
||||
D(printf("%s %x %x\n", __func__, addr, value));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -474,8 +480,9 @@ static int eth_match_groupaddr(struct fs_eth *eth, const unsigned char *sa)
|
|||
|
||||
/* First bit on the wire of a MAC address signals multicast or
|
||||
physical address. */
|
||||
if (!m_individual && !(sa[0] & 1))
|
||||
if (!m_individual && !(sa[0] & 1)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Calculate the hash index for the GA registers. */
|
||||
hsh = 0;
|
||||
|
@ -498,10 +505,11 @@ static int eth_match_groupaddr(struct fs_eth *eth, const unsigned char *sa)
|
|||
hsh ^= ((*sa) >> 2) & 0x3f;
|
||||
|
||||
hsh &= 63;
|
||||
if (hsh > 31)
|
||||
if (hsh > 31) {
|
||||
match = eth->regs[RW_GA_HI] & (1 << (hsh - 32));
|
||||
else
|
||||
} else {
|
||||
match = eth->regs[RW_GA_LO] & (1 << hsh);
|
||||
}
|
||||
D(printf("hsh=%x ga=%x.%x mtch=%d\n", hsh,
|
||||
eth->regs[RW_GA_HI], eth->regs[RW_GA_LO], match));
|
||||
return match;
|
||||
|
@ -520,8 +528,9 @@ static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
|
|||
int use_ma1 = eth->regs[RW_REC_CTRL] & 2;
|
||||
int r_bcast = eth->regs[RW_REC_CTRL] & 8;
|
||||
|
||||
if (size < 12)
|
||||
if (size < 12) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
D(printf("%x.%x.%x.%x.%x.%x ma=%d %d bc=%d\n",
|
||||
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
|
||||
|
@ -531,8 +540,9 @@ static ssize_t eth_receive(NetClientState *nc, const uint8_t *buf, size_t size)
|
|||
if ((!use_ma0 || memcmp(buf, eth->macaddr[0], 6))
|
||||
&& (!use_ma1 || memcmp(buf, eth->macaddr[1], 6))
|
||||
&& (!r_bcast || memcmp(buf, sa_bcast, 6))
|
||||
&& !eth_match_groupaddr(eth, buf))
|
||||
&& !eth_match_groupaddr(eth, buf)) {
|
||||
return size;
|
||||
}
|
||||
|
||||
/* FIXME: Find another way to pass on the fake csum. */
|
||||
etraxfs_dmac_input(eth->dma_in, (void *)buf, size + 4, 1);
|
||||
|
|
Loading…
Reference in New Issue