RE: [PATCH net-next-2.6 12/12] qlcnic: convert to set_phys_id
From: Sucheta Chakraborty <hidden>
Date: 2011-04-06 12:57:35
quoted hunk
- if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) { - dev_down = 1; - if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) - return -EIO; - - ret = qlcnic_diag_alloc_res(dev, QLCNIC_LED_TEST); + switch (state) { + case ETHTOOL_ID_ACTIVE: + if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) { + if (test_and_set_bit(__QLCNIC_RESETTING, &adapter-quoted
state))+ return -EIO; + + ret = qlcnic_diag_alloc_res(dev, QLCNIC_LED_TEST); + if (ret) { + clear_bit(__QLCNIC_RESETTING, &adapter->state); + return ret; + } + } + + ret = adapter->nic_ops->config_led(adapter, 1, 0xf); if (ret) { - clear_bit(__QLCNIC_RESETTING, &adapter->state); - return ret; + dev_err(&adapter->pdev->dev, + "Failed to set LED blink state.\n"); + break; } - } - - ret = adapter->nic_ops->config_led(adapter, 1, 0xf); - if (ret) { - dev_err(&adapter->pdev->dev, - "Failed to set LED blink state.\n"); - goto done; - } + return 0; - msleep_interruptible(val * 1000); + case ETHTOOL_ID_INACTIVE: + ret = adapter->nic_ops->config_led(adapter, 0, 0xf); + if (ret) + dev_err(&adapter->pdev->dev, + "Failed to reset LED blink state.\n"); + break; - ret = adapter->nic_ops->config_led(adapter, 0, 0xf); - if (ret) { - dev_err(&adapter->pdev->dev, - "Failed to reset LED blink state.\n"); - goto done; + default: + return -EINVAL; } -done: - if (dev_down) { + if (!netif_running(dev)) { qlcnic_diag_free_res(dev, max_sds_rings); clear_bit(__QLCNIC_RESETTING, &adapter->state); }
netif_running() check will not work here because interface can be brought down when LED test is ACTIVE. This may result in freeing resources unnecessarily. You can have a bit flag in adapter->state to track resources allocation (qlcnic_diag_alloc_res()). Thanks, Sucheta. This message and any attached documents contain information from QLogic Corporation or its wholly-owned subsidiaries that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.