[PATCH] qede: Don't implicitly cast enumerated types in __qede_probe

From: Nathan Chancellor
Date: Thu Jan 24 2019 - 11:27:18 EST


Clang warns:

drivers/net/ethernet/qlogic/qede/qede_main.c:1183:29: warning: implicit
conversion from enumeration type 'enum qede_rdma_probe_mode' to
different enumeration type 'enum qede_rdma_remove_mode'
[-Wenum-conversion]
qede_rdma_dev_remove(edev, QEDE_RDMA_PROBE_MODE(mode));
~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/qlogic/qede/qede_main.c:1074:33: note: expanded
from macro 'QEDE_RDMA_PROBE_MODE'
((mode) == QEDE_PROBE_NORMAL ? QEDE_RDMA_PROBE_NORMAL \
^~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/qlogic/qede/qede_main.c:1183:29: warning: implicit
conversion from enumeration type 'enum qede_rdma_probe_mode' to
different enumeration type 'enum qede_rdma_remove_mode'
[-Wenum-conversion]
qede_rdma_dev_remove(edev, QEDE_RDMA_PROBE_MODE(mode));
~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/qlogic/qede/qede_main.c:1075:12: note: expanded
from macro 'QEDE_RDMA_PROBE_MODE'
: QEDE_RDMA_PROBE_RECOVERY)
^~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.

qede_rdma_dev_remove expects an value from enumerated type
qede_rdma_remove_mode. Hoist the definitions of qede_remove_mode
and QEDE_RDMA_REMOVE_MODE up above __qede_probe so they can be
used there, eliminating this warning.

Fixes: 278396de78a9 ("qede: Error recovery process")
Signed-off-by: Nathan Chancellor <natechancellor@xxxxxxxxx>
---
drivers/net/ethernet/qlogic/qede/qede_main.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c
index de955f2b2980..06bdba90d521 100644
--- a/drivers/net/ethernet/qlogic/qede/qede_main.c
+++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
@@ -1074,6 +1074,15 @@ enum qede_probe_mode {
((mode) == QEDE_PROBE_NORMAL ? QEDE_RDMA_PROBE_NORMAL \
: QEDE_RDMA_PROBE_RECOVERY)

+enum qede_remove_mode {
+ QEDE_REMOVE_NORMAL,
+ QEDE_REMOVE_RECOVERY,
+};
+
+#define QEDE_RDMA_REMOVE_MODE(mode) \
+ ((mode) == QEDE_REMOVE_NORMAL ? QEDE_RDMA_REMOVE_NORMAL \
+ : QEDE_RDMA_REMOVE_RECOVERY)
+
static int __qede_probe(struct pci_dev *pdev, u32 dp_module, u8 dp_level,
bool is_vf, enum qede_probe_mode mode)
{
@@ -1180,7 +1189,7 @@ static int __qede_probe(struct pci_dev *pdev, u32 dp_module, u8 dp_level,
return 0;

err4:
- qede_rdma_dev_remove(edev, QEDE_RDMA_PROBE_MODE(mode));
+ qede_rdma_dev_remove(edev, QEDE_RDMA_REMOVE_MODE(mode));
err3:
free_netdev(edev->ndev);
err2:
@@ -1214,15 +1223,6 @@ static int qede_probe(struct pci_dev *pdev, const struct pci_device_id *id)
QEDE_PROBE_NORMAL);
}

-enum qede_remove_mode {
- QEDE_REMOVE_NORMAL,
- QEDE_REMOVE_RECOVERY,
-};
-
-#define QEDE_RDMA_REMOVE_MODE(mode) \
- ((mode) == QEDE_REMOVE_NORMAL ? QEDE_RDMA_REMOVE_NORMAL \
- : QEDE_RDMA_REMOVE_RECOVERY)
-
static void __qede_remove(struct pci_dev *pdev, enum qede_remove_mode mode)
{
struct net_device *ndev = pci_get_drvdata(pdev);
--
2.20.1