rrunner: use offsetof() instead of homegrown insanity
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Jeff Garzik <jeff@garzik.org>
This commit is contained in:
parent
95e0918dbb
commit
cf96237837
|
@ -294,7 +294,6 @@ static int rr_reset(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct rr_private *rrpriv;
|
struct rr_private *rrpriv;
|
||||||
struct rr_regs __iomem *regs;
|
struct rr_regs __iomem *regs;
|
||||||
struct eeprom *hw = NULL;
|
|
||||||
u32 start_pc;
|
u32 start_pc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -381,7 +380,8 @@ static int rr_reset(struct net_device *dev)
|
||||||
writel(RBURST_64|WBURST_64, ®s->PciState);
|
writel(RBURST_64|WBURST_64, ®s->PciState);
|
||||||
wmb();
|
wmb();
|
||||||
|
|
||||||
start_pc = rr_read_eeprom_word(rrpriv, &hw->rncd_info.FwStart);
|
start_pc = rr_read_eeprom_word(rrpriv,
|
||||||
|
offsetof(struct eeprom, rncd_info.FwStart));
|
||||||
|
|
||||||
#if (DEBUG > 1)
|
#if (DEBUG > 1)
|
||||||
printk("%s: Executing firmware at address 0x%06x\n",
|
printk("%s: Executing firmware at address 0x%06x\n",
|
||||||
|
@ -438,12 +438,12 @@ static unsigned int rr_read_eeprom(struct rr_private *rrpriv,
|
||||||
* it to our CPU byte-order.
|
* it to our CPU byte-order.
|
||||||
*/
|
*/
|
||||||
static u32 rr_read_eeprom_word(struct rr_private *rrpriv,
|
static u32 rr_read_eeprom_word(struct rr_private *rrpriv,
|
||||||
void * offset)
|
size_t offset)
|
||||||
{
|
{
|
||||||
u32 word;
|
__be32 word;
|
||||||
|
|
||||||
if ((rr_read_eeprom(rrpriv, (unsigned long)offset,
|
if ((rr_read_eeprom(rrpriv, offset,
|
||||||
(char *)&word, 4) == 4))
|
(unsigned char *)&word, 4) == 4))
|
||||||
return be32_to_cpu(word);
|
return be32_to_cpu(word);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -510,7 +510,6 @@ static int __devinit rr_init(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct rr_private *rrpriv;
|
struct rr_private *rrpriv;
|
||||||
struct rr_regs __iomem *regs;
|
struct rr_regs __iomem *regs;
|
||||||
struct eeprom *hw = NULL;
|
|
||||||
u32 sram_size, rev;
|
u32 sram_size, rev;
|
||||||
DECLARE_MAC_BUF(mac);
|
DECLARE_MAC_BUF(mac);
|
||||||
|
|
||||||
|
@ -545,14 +544,14 @@ static int __devinit rr_init(struct net_device *dev)
|
||||||
* other method I've seen. -VAL
|
* other method I've seen. -VAL
|
||||||
*/
|
*/
|
||||||
|
|
||||||
*(u16 *)(dev->dev_addr) =
|
*(__be16 *)(dev->dev_addr) =
|
||||||
htons(rr_read_eeprom_word(rrpriv, &hw->manf.BoardULA));
|
htons(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA)));
|
||||||
*(u32 *)(dev->dev_addr+2) =
|
*(__be32 *)(dev->dev_addr+2) =
|
||||||
htonl(rr_read_eeprom_word(rrpriv, &hw->manf.BoardULA[4]));
|
htonl(rr_read_eeprom_word(rrpriv, offsetof(struct eeprom, manf.BoardULA[4])));
|
||||||
|
|
||||||
printk(" MAC: %s\n", print_mac(mac, dev->dev_addr));
|
printk(" MAC: %s\n", print_mac(mac, dev->dev_addr));
|
||||||
|
|
||||||
sram_size = rr_read_eeprom_word(rrpriv, (void *)8);
|
sram_size = rr_read_eeprom_word(rrpriv, 8);
|
||||||
printk(" SRAM size 0x%06x\n", sram_size);
|
printk(" SRAM size 0x%06x\n", sram_size);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1477,11 +1476,10 @@ static int rr_load_firmware(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct rr_private *rrpriv;
|
struct rr_private *rrpriv;
|
||||||
struct rr_regs __iomem *regs;
|
struct rr_regs __iomem *regs;
|
||||||
unsigned long eptr, segptr;
|
size_t eptr, segptr;
|
||||||
int i, j;
|
int i, j;
|
||||||
u32 localctrl, sptr, len, tmp;
|
u32 localctrl, sptr, len, tmp;
|
||||||
u32 p2len, p2size, nr_seg, revision, io, sram_size;
|
u32 p2len, p2size, nr_seg, revision, io, sram_size;
|
||||||
struct eeprom *hw = NULL;
|
|
||||||
|
|
||||||
rrpriv = netdev_priv(dev);
|
rrpriv = netdev_priv(dev);
|
||||||
regs = rrpriv->regs;
|
regs = rrpriv->regs;
|
||||||
|
@ -1509,7 +1507,7 @@ static int rr_load_firmware(struct net_device *dev)
|
||||||
*/
|
*/
|
||||||
io = readl(®s->ExtIo);
|
io = readl(®s->ExtIo);
|
||||||
writel(0, ®s->ExtIo);
|
writel(0, ®s->ExtIo);
|
||||||
sram_size = rr_read_eeprom_word(rrpriv, (void *)8);
|
sram_size = rr_read_eeprom_word(rrpriv, 8);
|
||||||
|
|
||||||
for (i = 200; i < sram_size / 4; i++){
|
for (i = 200; i < sram_size / 4; i++){
|
||||||
writel(i * 4, ®s->WinBase);
|
writel(i * 4, ®s->WinBase);
|
||||||
|
@ -1520,13 +1518,13 @@ static int rr_load_firmware(struct net_device *dev)
|
||||||
writel(io, ®s->ExtIo);
|
writel(io, ®s->ExtIo);
|
||||||
mb();
|
mb();
|
||||||
|
|
||||||
eptr = (unsigned long)rr_read_eeprom_word(rrpriv,
|
eptr = rr_read_eeprom_word(rrpriv,
|
||||||
&hw->rncd_info.AddrRunCodeSegs);
|
offsetof(struct eeprom, rncd_info.AddrRunCodeSegs));
|
||||||
eptr = ((eptr & 0x1fffff) >> 3);
|
eptr = ((eptr & 0x1fffff) >> 3);
|
||||||
|
|
||||||
p2len = rr_read_eeprom_word(rrpriv, (void *)(0x83*4));
|
p2len = rr_read_eeprom_word(rrpriv, 0x83*4);
|
||||||
p2len = (p2len << 2);
|
p2len = (p2len << 2);
|
||||||
p2size = rr_read_eeprom_word(rrpriv, (void *)(0x84*4));
|
p2size = rr_read_eeprom_word(rrpriv, 0x84*4);
|
||||||
p2size = ((p2size & 0x1fffff) >> 3);
|
p2size = ((p2size & 0x1fffff) >> 3);
|
||||||
|
|
||||||
if ((eptr < p2size) || (eptr > (p2size + p2len))){
|
if ((eptr < p2size) || (eptr > (p2size + p2len))){
|
||||||
|
@ -1534,7 +1532,8 @@ static int rr_load_firmware(struct net_device *dev)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
revision = rr_read_eeprom_word(rrpriv, &hw->manf.HeaderFmt);
|
revision = rr_read_eeprom_word(rrpriv,
|
||||||
|
offsetof(struct eeprom, manf.HeaderFmt));
|
||||||
|
|
||||||
if (revision != 1){
|
if (revision != 1){
|
||||||
printk("%s: invalid firmware format (%i)\n",
|
printk("%s: invalid firmware format (%i)\n",
|
||||||
|
@ -1542,18 +1541,18 @@ static int rr_load_firmware(struct net_device *dev)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
nr_seg = rr_read_eeprom_word(rrpriv, (void *)eptr);
|
nr_seg = rr_read_eeprom_word(rrpriv, eptr);
|
||||||
eptr +=4;
|
eptr +=4;
|
||||||
#if (DEBUG > 1)
|
#if (DEBUG > 1)
|
||||||
printk("%s: nr_seg %i\n", dev->name, nr_seg);
|
printk("%s: nr_seg %i\n", dev->name, nr_seg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (i = 0; i < nr_seg; i++){
|
for (i = 0; i < nr_seg; i++){
|
||||||
sptr = rr_read_eeprom_word(rrpriv, (void *)eptr);
|
sptr = rr_read_eeprom_word(rrpriv, eptr);
|
||||||
eptr += 4;
|
eptr += 4;
|
||||||
len = rr_read_eeprom_word(rrpriv, (void *)eptr);
|
len = rr_read_eeprom_word(rrpriv, eptr);
|
||||||
eptr += 4;
|
eptr += 4;
|
||||||
segptr = (unsigned long)rr_read_eeprom_word(rrpriv, (void *)eptr);
|
segptr = rr_read_eeprom_word(rrpriv, eptr);
|
||||||
segptr = ((segptr & 0x1fffff) >> 3);
|
segptr = ((segptr & 0x1fffff) >> 3);
|
||||||
eptr += 4;
|
eptr += 4;
|
||||||
#if (DEBUG > 1)
|
#if (DEBUG > 1)
|
||||||
|
@ -1561,7 +1560,7 @@ static int rr_load_firmware(struct net_device *dev)
|
||||||
dev->name, i, sptr, len, segptr);
|
dev->name, i, sptr, len, segptr);
|
||||||
#endif
|
#endif
|
||||||
for (j = 0; j < len; j++){
|
for (j = 0; j < len; j++){
|
||||||
tmp = rr_read_eeprom_word(rrpriv, (void *)segptr);
|
tmp = rr_read_eeprom_word(rrpriv, segptr);
|
||||||
writel(sptr, ®s->WinBase);
|
writel(sptr, ®s->WinBase);
|
||||||
mb();
|
mb();
|
||||||
writel(tmp, ®s->WinData);
|
writel(tmp, ®s->WinData);
|
||||||
|
|
|
@ -838,7 +838,7 @@ static unsigned int rr_read_eeprom(struct rr_private *rrpriv,
|
||||||
unsigned long offset,
|
unsigned long offset,
|
||||||
unsigned char *buf,
|
unsigned char *buf,
|
||||||
unsigned long length);
|
unsigned long length);
|
||||||
static u32 rr_read_eeprom_word(struct rr_private *rrpriv, void * offset);
|
static u32 rr_read_eeprom_word(struct rr_private *rrpriv, size_t offset);
|
||||||
static int rr_load_firmware(struct net_device *dev);
|
static int rr_load_firmware(struct net_device *dev);
|
||||||
static inline void rr_raz_tx(struct rr_private *, struct net_device *);
|
static inline void rr_raz_tx(struct rr_private *, struct net_device *);
|
||||||
static inline void rr_raz_rx(struct rr_private *, struct net_device *);
|
static inline void rr_raz_rx(struct rr_private *, struct net_device *);
|
||||||
|
|
Loading…
Reference in New Issue