Commit a0ba2c5d authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] via-velocity warning fixes

With CONFIG_PM=n various functions (such as velocity_set_wol) are unused
and we get warnings and unused code.

Fix that up by moving the functions so they fall inside the callers's #ifdef
CONFIG_PM.

Remove now-unneeded forward declarations.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
parent 32b4ee1d
......@@ -255,9 +255,6 @@ static void enable_flow_control_ability(struct velocity_info *vptr);
static void enable_mii_autopoll(struct mac_regs * regs);
static int velocity_mii_read(struct mac_regs *, u8 byIdx, u16 * pdata);
static int velocity_mii_write(struct mac_regs *, u8 byMiiAddr, u16 data);
static int velocity_set_wol(struct velocity_info *vptr);
static void velocity_save_context(struct velocity_info *vptr, struct velocity_context *context);
static void velocity_restore_context(struct velocity_info *vptr, struct velocity_context *context);
static u32 mii_check_media_mode(struct mac_regs * regs);
static u32 check_connection_type(struct mac_regs * regs);
static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status);
......@@ -3085,89 +3082,6 @@ static void velocity_restore_context(struct velocity_info *vptr, struct velocity
}
static int velocity_suspend(struct pci_dev *pdev, u32 state)
{
struct velocity_info *vptr = pci_get_drvdata(pdev);
unsigned long flags;
if(!netif_running(vptr->dev))
return 0;
netif_device_detach(vptr->dev);
spin_lock_irqsave(&vptr->lock, flags);
pci_save_state(pdev, vptr->pci_state);
#ifdef ETHTOOL_GWOL
if (vptr->flags & VELOCITY_FLAGS_WOL_ENABLED) {
velocity_get_ip(vptr);
velocity_save_context(vptr, &vptr->context);
velocity_shutdown(vptr);
velocity_set_wol(vptr);
pci_enable_wake(pdev, 3, 1);
pci_set_power_state(pdev, 3);
} else {
velocity_save_context(vptr, &vptr->context);
velocity_shutdown(vptr);
pci_disable_device(pdev);
pci_set_power_state(pdev, state);
}
#else
pci_set_power_state(pdev, state);
#endif
spin_unlock_irqrestore(&vptr->lock, flags);
return 0;
}
static int velocity_resume(struct pci_dev *pdev)
{
struct velocity_info *vptr = pci_get_drvdata(pdev);
unsigned long flags;
int i;
if(!netif_running(vptr->dev))
return 0;
pci_set_power_state(pdev, 0);
pci_enable_wake(pdev, 0, 0);
pci_restore_state(pdev, vptr->pci_state);
mac_wol_reset(vptr->mac_regs);
spin_lock_irqsave(&vptr->lock, flags);
velocity_restore_context(vptr, &vptr->context);
velocity_init_registers(vptr, VELOCITY_INIT_WOL);
mac_disable_int(vptr->mac_regs);
velocity_tx_srv(vptr, 0);
for (i = 0; i < vptr->num_txq; i++) {
if (vptr->td_used[i]) {
mac_tx_queue_wake(vptr->mac_regs, i);
}
}
mac_enable_int(vptr->mac_regs);
spin_unlock_irqrestore(&vptr->lock, flags);
netif_device_attach(vptr->dev);
return 0;
}
static int velocity_netdev_event(struct notifier_block *nb, unsigned long notification, void *ptr)
{
struct in_ifaddr *ifa = (struct in_ifaddr *) ptr;
struct net_device *dev;
struct velocity_info *vptr;
if (ifa) {
dev = ifa->ifa_dev->dev;
vptr = dev->priv;
velocity_get_ip(vptr);
}
return NOTIFY_DONE;
}
#endif
/*
* Purpose: Functions to set WOL.
*/
......@@ -3207,22 +3121,16 @@ const static unsigned short crc16_tab[256] = {
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
};
static u32 mask_pattern[2][4] = {
{0x00203000, 0x000003C0, 0x00000000, 0x0000000}, /* ARP */
{0xfffff000, 0xffffffff, 0xffffffff, 0x000ffff} /* Magic Packet */
};
/**
* ether_crc16 - compute ethernet CRC
* @len: buffer length
* @cp: buffer
* @crc16: initial CRC
*
* Compute a CRC value for a block of data.
* Compute a CRC value for a block of data.
* FIXME: can we use generic functions ?
*/
static u16 ether_crc16(int len, u8 * cp, u16 crc16)
{
while (len--)
......@@ -3236,7 +3144,7 @@ static u16 ether_crc16(int len, u8 * cp, u16 crc16)
*
* Reverse the order of a 16bit value and return the reversed bits
*/
static u16 bit_reverse(u16 data)
{
u32 new = 0x00000000;
......@@ -3259,7 +3167,7 @@ static u16 bit_reverse(u16 data)
* Compute the wake on lan crc hashes for the packet header
* we are interested in.
*/
u16 wol_calc_crc(int size, u8 * pattern, u8 *mask_pattern)
{
u16 crc = 0xFFFF;
......@@ -3296,13 +3204,18 @@ u16 wol_calc_crc(int size, u8 * pattern, u8 *mask_pattern)
*
* FIXME: check static buffer is safe here
*/
static int velocity_set_wol(struct velocity_info *vptr)
{
struct mac_regs * regs = vptr->mac_regs;
static u8 buf[256];
int i;
static u32 mask_pattern[2][4] = {
{0x00203000, 0x000003C0, 0x00000000, 0x0000000}, /* ARP */
{0xfffff000, 0xffffffff, 0xffffffff, 0x000ffff} /* Magic Packet */
};
writew(0xFFFF, &regs->WOLCRClr);
writeb(WOLCFG_SAB | WOLCFG_SAM, &regs->WOLCFGSet);
writew(WOLCR_MAGIC_EN, &regs->WOLCRSet);
......@@ -3329,7 +3242,8 @@ static int velocity_set_wol(struct velocity_info *vptr)
memcpy(arp->ar_tip, vptr->ip_addr, 4);
crc = wol_calc_crc((sizeof(struct arp_packet) + 7) / 8, buf, (u8 *) & mask_pattern[0][0]);
crc = wol_calc_crc((sizeof(struct arp_packet) + 7) / 8, buf,
(u8 *) & mask_pattern[0][0]);
writew(crc, &regs->PatternCRC[0]);
writew(WOLCR_ARP_EN, &regs->WOLCRSet);
......@@ -3368,3 +3282,85 @@ static int velocity_set_wol(struct velocity_info *vptr)
return 0;
}
static int velocity_suspend(struct pci_dev *pdev, u32 state)
{
struct velocity_info *vptr = pci_get_drvdata(pdev);
unsigned long flags;
if(!netif_running(vptr->dev))
return 0;
netif_device_detach(vptr->dev);
spin_lock_irqsave(&vptr->lock, flags);
pci_save_state(pdev, vptr->pci_state);
#ifdef ETHTOOL_GWOL
if (vptr->flags & VELOCITY_FLAGS_WOL_ENABLED) {
velocity_get_ip(vptr);
velocity_save_context(vptr, &vptr->context);
velocity_shutdown(vptr);
velocity_set_wol(vptr);
pci_enable_wake(pdev, 3, 1);
pci_set_power_state(pdev, 3);
} else {
velocity_save_context(vptr, &vptr->context);
velocity_shutdown(vptr);
pci_disable_device(pdev);
pci_set_power_state(pdev, state);
}
#else
pci_set_power_state(pdev, state);
#endif
spin_unlock_irqrestore(&vptr->lock, flags);
return 0;
}
static int velocity_resume(struct pci_dev *pdev)
{
struct velocity_info *vptr = pci_get_drvdata(pdev);
unsigned long flags;
int i;
if(!netif_running(vptr->dev))
return 0;
pci_set_power_state(pdev, 0);
pci_enable_wake(pdev, 0, 0);
pci_restore_state(pdev, vptr->pci_state);
mac_wol_reset(vptr->mac_regs);
spin_lock_irqsave(&vptr->lock, flags);
velocity_restore_context(vptr, &vptr->context);
velocity_init_registers(vptr, VELOCITY_INIT_WOL);
mac_disable_int(vptr->mac_regs);
velocity_tx_srv(vptr, 0);
for (i = 0; i < vptr->num_txq; i++) {
if (vptr->td_used[i]) {
mac_tx_queue_wake(vptr->mac_regs, i);
}
}
mac_enable_int(vptr->mac_regs);
spin_unlock_irqrestore(&vptr->lock, flags);
netif_device_attach(vptr->dev);
return 0;
}
static int velocity_netdev_event(struct notifier_block *nb, unsigned long notification, void *ptr)
{
struct in_ifaddr *ifa = (struct in_ifaddr *) ptr;
struct net_device *dev;
struct velocity_info *vptr;
if (ifa) {
dev = ifa->ifa_dev->dev;
vptr = dev->priv;
velocity_get_ip(vptr);
}
return NOTIFY_DONE;
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment