Commit 956c5fe8 authored by Margit Schubert-While's avatar Margit Schubert-While Committed by Linus Torvalds

[PATCH] prism54 Code cleanup

(Patches submitted by Denis Vlasenko)
There are neither functionality changes nor bug fixes.

* 2004-08-14 Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua>
* Move assignment out of if()
* Remove trailing space from printk
* Eliminate not needed local 'u32 reg'
* Add a comment about undoc bits
* Add #define VEC_SIZE, use it as appropriate
* Add some printks to reset error code path (our
* current area of trouble)
* Make printk text less confusing
* Some not needed NULL assignments removed
* mgt_commit_list(): tell which oid has failed
parent f56f31ef
...@@ -133,8 +133,8 @@ isl38xx_trigger_device(int asleep, void *device_base) ...@@ -133,8 +133,8 @@ isl38xx_trigger_device(int asleep, void *device_base)
readl(device_base + ISL38XX_CTRL_STAT_REG)); readl(device_base + ISL38XX_CTRL_STAT_REG));
udelay(ISL38XX_WRITEIO_DELAY); udelay(ISL38XX_WRITEIO_DELAY);
if (reg = readl(device_base + ISL38XX_INT_IDENT_REG), reg = readl(device_base + ISL38XX_INT_IDENT_REG);
reg == 0xabadface) { if (reg == 0xabadface) {
#if VERBOSE > SHOW_ERROR_MESSAGES #if VERBOSE > SHOW_ERROR_MESSAGES
do_gettimeofday(&current_time); do_gettimeofday(&current_time);
DEBUG(SHOW_TRACING, DEBUG(SHOW_TRACING,
...@@ -192,10 +192,8 @@ isl38xx_trigger_device(int asleep, void *device_base) ...@@ -192,10 +192,8 @@ isl38xx_trigger_device(int asleep, void *device_base)
void void
isl38xx_interface_reset(void *device_base, dma_addr_t host_address) isl38xx_interface_reset(void *device_base, dma_addr_t host_address)
{ {
u32 reg;
#if VERBOSE > SHOW_ERROR_MESSAGES #if VERBOSE > SHOW_ERROR_MESSAGES
DEBUG(SHOW_FUNCTION_CALLS, "isl38xx_interface_reset \n"); DEBUG(SHOW_FUNCTION_CALLS, "isl38xx_interface_reset\n");
#endif #endif
/* load the address of the control block in the device */ /* load the address of the control block in the device */
...@@ -203,8 +201,7 @@ isl38xx_interface_reset(void *device_base, dma_addr_t host_address) ...@@ -203,8 +201,7 @@ isl38xx_interface_reset(void *device_base, dma_addr_t host_address)
udelay(ISL38XX_WRITEIO_DELAY); udelay(ISL38XX_WRITEIO_DELAY);
/* set the reset bit in the Device Interrupt Register */ /* set the reset bit in the Device Interrupt Register */
isl38xx_w32_flush(device_base, ISL38XX_DEV_INT_RESET, isl38xx_w32_flush(device_base, ISL38XX_DEV_INT_RESET, ISL38XX_DEV_INT_REG);
ISL38XX_DEV_INT_REG);
udelay(ISL38XX_WRITEIO_DELAY); udelay(ISL38XX_WRITEIO_DELAY);
/* enable the interrupt for detecting initialization */ /* enable the interrupt for detecting initialization */
...@@ -212,9 +209,7 @@ isl38xx_interface_reset(void *device_base, dma_addr_t host_address) ...@@ -212,9 +209,7 @@ isl38xx_interface_reset(void *device_base, dma_addr_t host_address)
/* Note: Do not enable other interrupts here. We want the /* Note: Do not enable other interrupts here. We want the
* device to have come up first 100% before allowing any other * device to have come up first 100% before allowing any other
* interrupts. */ * interrupts. */
reg = ISL38XX_INT_IDENT_INIT; isl38xx_w32_flush(device_base, ISL38XX_INT_IDENT_INIT, ISL38XX_INT_EN_REG);
isl38xx_w32_flush(device_base, reg, ISL38XX_INT_EN_REG);
udelay(ISL38XX_WRITEIO_DELAY); /* allow complete full reset */ udelay(ISL38XX_WRITEIO_DELAY); /* allow complete full reset */
} }
......
...@@ -95,6 +95,10 @@ isl38xx_w32_flush(void *base, u32 val, unsigned long offset) ...@@ -95,6 +95,10 @@ isl38xx_w32_flush(void *base, u32 val, unsigned long offset)
#define ISL38XX_INT_SOURCES 0x001E #define ISL38XX_INT_SOURCES 0x001E
/* Control/Status register bits */ /* Control/Status register bits */
/* Looks like there are other meaningful bits
0x20004400 seen in normal operation,
0x200044db at 'timeout waiting for mgmt response'
*/
#define ISL38XX_CTRL_STAT_SLEEPMODE 0x00000200 #define ISL38XX_CTRL_STAT_SLEEPMODE 0x00000200
#define ISL38XX_CTRL_STAT_CLKRUN 0x00800000 #define ISL38XX_CTRL_STAT_CLKRUN 0x00800000
#define ISL38XX_CTRL_STAT_RESET 0x10000000 #define ISL38XX_CTRL_STAT_RESET 0x10000000
......
...@@ -1947,7 +1947,7 @@ prism54_debug_get_oid(struct net_device *ndev, struct iw_request_info *info, ...@@ -1947,7 +1947,7 @@ prism54_debug_get_oid(struct net_device *ndev, struct iw_request_info *info,
struct iw_point *data, char *extra) struct iw_point *data, char *extra)
{ {
islpci_private *priv = netdev_priv(ndev); islpci_private *priv = netdev_priv(ndev);
struct islpci_mgmtframe *response = NULL; struct islpci_mgmtframe *response;
int ret = -EIO; int ret = -EIO;
printk("%s: get_oid 0x%08X\n", ndev->name, priv->priv_oid); printk("%s: get_oid 0x%08X\n", ndev->name, priv->priv_oid);
...@@ -1983,7 +1983,7 @@ prism54_debug_set_oid(struct net_device *ndev, struct iw_request_info *info, ...@@ -1983,7 +1983,7 @@ prism54_debug_set_oid(struct net_device *ndev, struct iw_request_info *info,
struct iw_point *data, char *extra) struct iw_point *data, char *extra)
{ {
islpci_private *priv = netdev_priv(ndev); islpci_private *priv = netdev_priv(ndev);
struct islpci_mgmtframe *response = NULL; struct islpci_mgmtframe *response;
int ret = 0, response_op = PIMFOR_OP_ERROR; int ret = 0, response_op = PIMFOR_OP_ERROR;
printk("%s: set_oid 0x%08X\tlen: %d\n", ndev->name, priv->priv_oid, printk("%s: set_oid 0x%08X\tlen: %d\n", ndev->name, priv->priv_oid,
......
...@@ -375,8 +375,6 @@ islpci_open(struct net_device *ndev) ...@@ -375,8 +375,6 @@ islpci_open(struct net_device *ndev)
u32 rc; u32 rc;
islpci_private *priv = netdev_priv(ndev); islpci_private *priv = netdev_priv(ndev);
printk(KERN_DEBUG "%s: islpci_open()\n", ndev->name);
/* reset data structures, upload firmware and reset device */ /* reset data structures, upload firmware and reset device */
rc = islpci_reset(priv,1); rc = islpci_reset(priv,1);
if (rc) { if (rc) {
...@@ -462,8 +460,7 @@ islpci_upload_fw(islpci_private *priv) ...@@ -462,8 +460,7 @@ islpci_upload_fw(islpci_private *priv)
return rc; return rc;
} }
printk(KERN_DEBUG printk(KERN_DEBUG "%s: firmware upload complete\n",
"%s: firmware uploaded done, now triggering reset...\n",
priv->ndev->name); priv->ndev->name);
islpci_set_state(priv, PRV_STATE_POSTBOOT); islpci_set_state(priv, PRV_STATE_POSTBOOT);
...@@ -499,15 +496,16 @@ islpci_reset_if(islpci_private *priv) ...@@ -499,15 +496,16 @@ islpci_reset_if(islpci_private *priv)
/* If we're here it's because our IRQ hasn't yet gone through. /* If we're here it's because our IRQ hasn't yet gone through.
* Retry a bit more... * Retry a bit more...
*/ */
printk(KERN_ERR "%s: device soft reset timed out\n", printk(KERN_ERR "%s: reset problem: no 'reset complete' IRQ seen\n",
priv->ndev->name); priv->ndev->name);
} }
finish_wait(&priv->reset_done, &wait); finish_wait(&priv->reset_done, &wait);
if(result) if (result) {
printk(KERN_ERR "%s: islpci_reset_if: failure\n", priv->ndev->name);
return result; return result;
}
islpci_set_state(priv, PRV_STATE_INIT); islpci_set_state(priv, PRV_STATE_INIT);
...@@ -524,6 +522,7 @@ islpci_reset_if(islpci_private *priv) ...@@ -524,6 +522,7 @@ islpci_reset_if(islpci_private *priv)
islpci_set_state(priv, PRV_STATE_READY); islpci_set_state(priv, PRV_STATE_READY);
printk(KERN_DEBUG "%s: interface reset complete\n", priv->ndev->name);
return 0; return 0;
} }
...@@ -584,18 +583,18 @@ islpci_reset(islpci_private *priv, int reload_firmware) ...@@ -584,18 +583,18 @@ islpci_reset(islpci_private *priv, int reload_firmware)
/* now that the data structures are cleaned up, upload /* now that the data structures are cleaned up, upload
* firmware and reset interface */ * firmware and reset interface */
rc = islpci_upload_fw(priv); rc = islpci_upload_fw(priv);
if (rc) if (rc) {
printk(KERN_ERR "%s: islpci_reset: failure\n",
priv->ndev->name);
return rc; return rc;
}
} }
/* finally reset interface */ /* finally reset interface */
rc = islpci_reset_if(priv); rc = islpci_reset_if(priv);
if (!rc) /* If successful */ if (rc)
return rc; printk(KERN_ERR "prism54: Your card/socket may be faulty, or IRQ line too busy :(\n");
printk(KERN_DEBUG "prism54: Your card/socket may be faulty, or IRQ line too busy :(\n");
return rc; return rc;
} }
struct net_device_stats * struct net_device_stats *
...@@ -604,7 +603,7 @@ islpci_statistics(struct net_device *ndev) ...@@ -604,7 +603,7 @@ islpci_statistics(struct net_device *ndev)
islpci_private *priv = netdev_priv(ndev); islpci_private *priv = netdev_priv(ndev);
#if VERBOSE > SHOW_ERROR_MESSAGES #if VERBOSE > SHOW_ERROR_MESSAGES
DEBUG(SHOW_FUNCTION_CALLS, "islpci_statistics \n"); DEBUG(SHOW_FUNCTION_CALLS, "islpci_statistics\n");
#endif #endif
return &priv->statistics; return &priv->statistics;
......
...@@ -508,11 +508,12 @@ islpci_eth_tx_timeout(struct net_device *ndev) ...@@ -508,11 +508,12 @@ islpci_eth_tx_timeout(struct net_device *ndev)
/* increment the transmit error counter */ /* increment the transmit error counter */
statistics->tx_errors++; statistics->tx_errors++;
printk(KERN_WARNING "%s: tx_timeout", ndev->name);
if (!priv->reset_task_pending) { if (!priv->reset_task_pending) {
priv->reset_task_pending = 1; priv->reset_task_pending = 1;
printk(", scheduling a reset");
netif_stop_queue(ndev); netif_stop_queue(ndev);
schedule_work(&priv->reset_task); schedule_work(&priv->reset_task);
} }
printk("\n");
return;
} }
...@@ -555,15 +555,18 @@ mgt_commit_list(islpci_private *priv, enum oid_num_t *l, int n) ...@@ -555,15 +555,18 @@ mgt_commit_list(islpci_private *priv, enum oid_num_t *l, int n)
u32 oid = t->oid; u32 oid = t->oid;
BUG_ON(data == NULL); BUG_ON(data == NULL);
while (j <= t->range) { while (j <= t->range) {
response = NULL; int r = islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET,
ret |= islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET,
oid, data, t->size, oid, data, t->size,
&response); &response);
if (response) { if (response) {
ret |= (response->header->operation == r |= (response->header->operation == PIMFOR_OP_ERROR);
PIMFOR_OP_ERROR);
islpci_mgt_release(response); islpci_mgt_release(response);
} }
if (r)
printk(KERN_ERR "%s: mgt_commit_list: failure. "
"oid=%08x err=%d\n",
priv->ndev->name, oid, r);
ret |= r;
j++; j++;
oid++; oid++;
data += t->size; data += t->size;
...@@ -624,7 +627,7 @@ static enum oid_num_t commit_part2[] = { ...@@ -624,7 +627,7 @@ static enum oid_num_t commit_part2[] = {
static int static int
mgt_update_addr(islpci_private *priv) mgt_update_addr(islpci_private *priv)
{ {
struct islpci_mgmtframe *res = NULL; struct islpci_mgmtframe *res;
int ret; int ret;
ret = islpci_mgt_transaction(priv->ndev, PIMFOR_OP_GET, ret = islpci_mgt_transaction(priv->ndev, PIMFOR_OP_GET,
...@@ -638,9 +641,13 @@ mgt_update_addr(islpci_private *priv) ...@@ -638,9 +641,13 @@ mgt_update_addr(islpci_private *priv)
if (res) if (res)
islpci_mgt_release(res); islpci_mgt_release(res);
if (ret)
printk(KERN_ERR "%s: mgt_update_addr: failure\n", priv->ndev->name);
return ret; return ret;
} }
#define VEC_SIZE(a) (sizeof(a)/sizeof(a[0]))
void void
mgt_commit(islpci_private *priv) mgt_commit(islpci_private *priv)
{ {
...@@ -650,14 +657,10 @@ mgt_commit(islpci_private *priv) ...@@ -650,14 +657,10 @@ mgt_commit(islpci_private *priv)
if (islpci_get_state(priv) < PRV_STATE_INIT) if (islpci_get_state(priv) < PRV_STATE_INIT)
return; return;
rvalue = mgt_commit_list(priv, commit_part1, rvalue = mgt_commit_list(priv, commit_part1, VEC_SIZE(commit_part1));
sizeof (commit_part1) /
sizeof (commit_part1[0]));
if (priv->iw_mode != IW_MODE_MONITOR) if (priv->iw_mode != IW_MODE_MONITOR)
rvalue |= mgt_commit_list(priv, commit_part2, rvalue |= mgt_commit_list(priv, commit_part2, VEC_SIZE(commit_part2));
sizeof (commit_part2) /
sizeof (commit_part2[0]));
u = OID_INL_MODE; u = OID_INL_MODE;
rvalue |= mgt_commit_list(priv, &u, 1); rvalue |= mgt_commit_list(priv, &u, 1);
...@@ -666,8 +669,7 @@ mgt_commit(islpci_private *priv) ...@@ -666,8 +669,7 @@ mgt_commit(islpci_private *priv)
if (rvalue) { if (rvalue) {
/* some request have failed. The device might be in an /* some request have failed. The device might be in an
incoherent state. We should reset it ! */ incoherent state. We should reset it ! */
printk(KERN_DEBUG "%s: mgt_commit has failed. Restart the " printk(KERN_DEBUG "%s: mgt_commit: failure\n", priv->ndev->name);
"device \n", priv->ndev->name);
} }
} }
......
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