qlcnic: define macro for driver state
authorAmit Kumar Salecha <amit.salecha@qlogic.com>
Thu, 22 Apr 2010 02:51:38 +0000 (02:51 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 22 Apr 2010 22:28:28 +0000 (15:28 -0700)
Defining macro to set and clear driver state.

Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/qlcnic/qlcnic_hdr.h
drivers/net/qlcnic/qlcnic_main.c

index 8285a06eecdbc149990e25de6e291fc960770150..a984cd227582cfc40f533517740e5b10de57b488 100644 (file)
@@ -707,6 +707,12 @@ enum {
 #define QLCNIC_DEV_FAILED              0x6
 #define QLCNIC_DEV_QUISCENT            0x7
 
+#define QLC_DEV_SET_REF_CNT(VAL, FN)           ((VAL) |= (1 << (FN * 4)))
+#define QLC_DEV_CLR_REF_CNT(VAL, FN)           ((VAL) &= ~(1 << (FN * 4)))
+#define QLC_DEV_SET_RST_RDY(VAL, FN)           ((VAL) |= (1 << (FN * 4)))
+#define QLC_DEV_SET_QSCNT_RDY(VAL, FN)         ((VAL) |= (2 << (FN * 4)))
+#define QLC_DEV_CLR_RST_QSCNT(VAL, FN)         ((VAL) &= ~(3 << (FN * 4)))
+
 #define QLCNIC_RCODE_DRIVER_INFO               0x20000000
 #define QLCNIC_RCODE_DRIVER_CAN_RELOAD         0x40000000
 #define QLCNIC_RCODE_FATAL_ERROR               0x80000000
index 06349908092f329f5e651a1e727af114452e05c9..3c8a963f68a907513c5d8a97c7d94cbcf3d2131e 100644 (file)
@@ -1963,9 +1963,9 @@ qlcnic_set_drv_state(struct qlcnic_adapter *adapter, int state)
        val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE);
 
        if (state == QLCNIC_DEV_NEED_RESET)
-               val |= ((u32)0x1 << (adapter->portnum * 4));
+               QLC_DEV_SET_RST_RDY(val, adapter->portnum);
        else if (state == QLCNIC_DEV_NEED_QUISCENT)
-               val |= ((u32)0x1 << ((adapter->portnum * 4) + 1));
+               QLC_DEV_SET_QSCNT_RDY(val, adapter->portnum);
 
        QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val);
 
@@ -1981,7 +1981,7 @@ qlcnic_clr_drv_state(struct qlcnic_adapter *adapter)
                return -EBUSY;
 
        val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE);
-       val &= ~((u32)0x3 << (adapter->portnum * 4));
+       QLC_DEV_CLR_RST_QSCNT(val, adapter->portnum);
        QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val);
 
        qlcnic_api_unlock(adapter);
@@ -1998,14 +1998,14 @@ qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter)
                goto err;
 
        val = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT);
-       val &= ~((u32)0x1 << (adapter->portnum * 4));
+       QLC_DEV_CLR_REF_CNT(val, adapter->portnum);
        QLCWR32(adapter, QLCNIC_CRB_DEV_REF_COUNT, val);
 
        if (!(val & 0x11111111))
                QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_COLD);
 
        val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE);
-       val &= ~((u32)0x3 << (adapter->portnum * 4));
+       QLC_DEV_CLR_RST_QSCNT(val, adapter->portnum);
        QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val);
 
        qlcnic_api_unlock(adapter);
@@ -2036,7 +2036,7 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
 {
        u32 val, prev_state;
        u8 dev_init_timeo = adapter->dev_init_timeo;
-       int portnum = adapter->portnum;
+       u8 portnum = adapter->portnum;
 
        if (test_and_clear_bit(__QLCNIC_START_FW, &adapter->state))
                return 1;
@@ -2045,8 +2045,8 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
                return -1;
 
        val = QLCRD32(adapter, QLCNIC_CRB_DEV_REF_COUNT);
-       if (!(val & ((int)0x1 << (portnum * 4)))) {
-               val |= ((u32)0x1 << (portnum * 4));
+       if (!(val & (1 << (portnum * 4)))) {
+               QLC_DEV_SET_REF_CNT(val, portnum);
                QLCWR32(adapter, QLCNIC_CRB_DEV_REF_COUNT, val);
        }
 
@@ -2065,13 +2065,13 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
 
        case QLCNIC_DEV_NEED_RESET:
                val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE);
-               val |= ((u32)0x1 << (portnum * 4));
+               QLC_DEV_SET_RST_RDY(val, portnum);
                QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val);
                break;
 
        case QLCNIC_DEV_NEED_QUISCENT:
                val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE);
-               val |= ((u32)0x1 << ((portnum * 4) + 1));
+               QLC_DEV_SET_QSCNT_RDY(val, portnum);
                QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val);
                break;
 
@@ -2101,7 +2101,7 @@ qlcnic_can_start_firmware(struct qlcnic_adapter *adapter)
                return -1;
 
        val = QLCRD32(adapter, QLCNIC_CRB_DRV_STATE);
-       val &= ~((u32)0x3 << (portnum * 4));
+       QLC_DEV_CLR_RST_QSCNT(val, portnum);
        QLCWR32(adapter, QLCNIC_CRB_DRV_STATE, val);
 
        qlcnic_api_unlock(adapter);