scsi: fcoe: make use of fip_mode enum complete
authorSedat Dilek <sedat.dilek@gmail.com>
Fri, 15 Feb 2019 12:19:20 +0000 (13:19 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 19 Feb 2019 23:58:38 +0000 (18:58 -0500)
commit 1917d42d14b7 ("fcoe: use enum for fip_mode") introduces a separate
enum for the fip_mode that shall be used during initialisation handling
until it is passed to fcoe_ctrl_link_up to set the initial fip_state.  That
change was incomplete and gcc quietly converted in various places between
the fip_mode and the fip_state enum values with implicit enum conversions,
which fortunately cannot cause any issues in the actual code's execution.

clang however warns about these implicit enum conversions in the scsi
drivers. This commit consolidates the use of the two enums, guided by
clang's enum-conversion warnings.

This commit now completes the use of the fip_mode: It expects and uses
fip_mode in {bnx2fc,fcoe}_interface_create and fcoe_ctlr_init, and it calls
fcoe_ctrl_set_set() with the correct values in fcoe_ctlr_link_up().  It
also breaks the association between FIP_MODE_AUTO and FIP_ST_AUTO to
indicate these two enums are distinct.

Link: https://github.com/ClangBuiltLinux/linux/issues/151
Fixes: 1917d42d14b7 ("fcoe: use enum for fip_mode")
Reported-by: Dmitry Golovin <dima@golovin.in>
Original-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
CC: Lukas Bulwahn <lukas.bulwahn@gmail.com>
CC: Nick Desaulniers <ndesaulniers@google.com>
CC: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Suggested-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
drivers/scsi/fcoe/fcoe.c
drivers/scsi/fcoe/fcoe_ctlr.c
drivers/scsi/fcoe/fcoe_transport.c
drivers/scsi/qedf/qedf_main.c
include/scsi/libfcoe.h

index 2e4e7159ebf9bef875250f4d0aa82367f9aa40ad..a75e74ad1698d758ccad5c0cc584e45aeadbfd53 100644 (file)
@@ -1438,7 +1438,7 @@ bind_err:
 static struct bnx2fc_interface *
 bnx2fc_interface_create(struct bnx2fc_hba *hba,
                        struct net_device *netdev,
-                       enum fip_state fip_mode)
+                       enum fip_mode fip_mode)
 {
        struct fcoe_ctlr_device *ctlr_dev;
        struct bnx2fc_interface *interface;
index cd19be3f3405b4a0098c8ec7611dc197efdc5740..8ba8862d3292ca2d9efac79b505be5a02ee749e8 100644 (file)
@@ -389,7 +389,7 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe,
  * Returns: pointer to a struct fcoe_interface or NULL on error
  */
 static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev,
-                                                   enum fip_state fip_mode)
+                                                   enum fip_mode fip_mode)
 {
        struct fcoe_ctlr_device *ctlr_dev;
        struct fcoe_ctlr *ctlr;
index 54da3166da8d71e207620186d064e1ad6e674886..7dc4ffa244304ada7bab9b8718af9ebc7066d6ab 100644 (file)
@@ -147,7 +147,7 @@ static void fcoe_ctlr_map_dest(struct fcoe_ctlr *fip)
  * fcoe_ctlr_init() - Initialize the FCoE Controller instance
  * @fip: The FCoE controller to initialize
  */
-void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state mode)
+void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_mode mode)
 {
        fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT);
        fip->mode = mode;
@@ -454,7 +454,10 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *fip)
                mutex_unlock(&fip->ctlr_mutex);
                fc_linkup(fip->lp);
        } else if (fip->state == FIP_ST_LINK_WAIT) {
-               fcoe_ctlr_set_state(fip, fip->mode);
+               if (fip->mode == FIP_MODE_NON_FIP)
+                       fcoe_ctlr_set_state(fip, FIP_ST_NON_FIP);
+               else
+                       fcoe_ctlr_set_state(fip, FIP_ST_AUTO);
                switch (fip->mode) {
                default:
                        LIBFCOE_FIP_DBG(fip, "invalid mode %d\n", fip->mode);
index 6d3949b687efdb34b3722458d235337ea5aca1f4..29fe3426f9f29986868d391c273a570129c7a6e9 100644 (file)
@@ -872,7 +872,7 @@ static int fcoe_transport_create(const char *buffer,
        int rc = -ENODEV;
        struct net_device *netdev = NULL;
        struct fcoe_transport *ft = NULL;
-       enum fip_state fip_mode = (enum fip_state)(long)kp->arg;
+       enum fip_mode fip_mode = (enum fip_mode)kp->arg;
 
        mutex_lock(&ft_mutex);
 
index edcaf4b0cb0b716cd54d3868ef6e710c5ccddf4e..d43342b327ac143e39bfff980001a0d3f06dd1ea 100644 (file)
@@ -1417,7 +1417,7 @@ static struct libfc_function_template qedf_lport_template = {
 
 static void qedf_fcoe_ctlr_setup(struct qedf_ctx *qedf)
 {
-       fcoe_ctlr_init(&qedf->ctlr, FIP_ST_AUTO);
+       fcoe_ctlr_init(&qedf->ctlr, FIP_MODE_AUTO);
 
        qedf->ctlr.send = qedf_fip_send;
        qedf->ctlr.get_src_addr = qedf_get_src_mac;
index cb8a273732cf667d47a7f43e5770ada588ce9ab7..bb8092fa1e364114fc60458e86c7bc73f3beeb93 100644 (file)
@@ -79,7 +79,7 @@ enum fip_state {
  * It must not change after fcoe_ctlr_init() sets it.
  */
 enum fip_mode {
-       FIP_MODE_AUTO = FIP_ST_AUTO,
+       FIP_MODE_AUTO,
        FIP_MODE_NON_FIP,
        FIP_MODE_FABRIC,
        FIP_MODE_VN2VN,
@@ -250,7 +250,7 @@ struct fcoe_rport {
 };
 
 /* FIP API functions */
-void fcoe_ctlr_init(struct fcoe_ctlr *, enum fip_state);
+void fcoe_ctlr_init(struct fcoe_ctlr *, enum fip_mode);
 void fcoe_ctlr_destroy(struct fcoe_ctlr *);
 void fcoe_ctlr_link_up(struct fcoe_ctlr *);
 int fcoe_ctlr_link_down(struct fcoe_ctlr *);