Skip to content

Commit 8beb90a

Browse files
dileksmartinkpetersen
authored andcommitted
scsi: fcoe: make use of fip_mode enum complete
commit 1917d42 ("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: ClangBuiltLinux#151 Fixes: 1917d42 ("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>
1 parent bcf3b67 commit 8beb90a

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

drivers/scsi/bnx2fc/bnx2fc_fcoe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ static struct bnx2fc_hba *bnx2fc_hba_create(struct cnic_dev *cnic)
14381438
static struct bnx2fc_interface *
14391439
bnx2fc_interface_create(struct bnx2fc_hba *hba,
14401440
struct net_device *netdev,
1441-
enum fip_state fip_mode)
1441+
enum fip_mode fip_mode)
14421442
{
14431443
struct fcoe_ctlr_device *ctlr_dev;
14441444
struct bnx2fc_interface *interface;

drivers/scsi/fcoe/fcoe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe,
389389
* Returns: pointer to a struct fcoe_interface or NULL on error
390390
*/
391391
static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev,
392-
enum fip_state fip_mode)
392+
enum fip_mode fip_mode)
393393
{
394394
struct fcoe_ctlr_device *ctlr_dev;
395395
struct fcoe_ctlr *ctlr;

drivers/scsi/fcoe/fcoe_ctlr.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static void fcoe_ctlr_map_dest(struct fcoe_ctlr *fip)
147147
* fcoe_ctlr_init() - Initialize the FCoE Controller instance
148148
* @fip: The FCoE controller to initialize
149149
*/
150-
void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state mode)
150+
void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_mode mode)
151151
{
152152
fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT);
153153
fip->mode = mode;
@@ -454,7 +454,10 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *fip)
454454
mutex_unlock(&fip->ctlr_mutex);
455455
fc_linkup(fip->lp);
456456
} else if (fip->state == FIP_ST_LINK_WAIT) {
457-
fcoe_ctlr_set_state(fip, fip->mode);
457+
if (fip->mode == FIP_MODE_NON_FIP)
458+
fcoe_ctlr_set_state(fip, FIP_ST_NON_FIP);
459+
else
460+
fcoe_ctlr_set_state(fip, FIP_ST_AUTO);
458461
switch (fip->mode) {
459462
default:
460463
LIBFCOE_FIP_DBG(fip, "invalid mode %d\n", fip->mode);

drivers/scsi/fcoe/fcoe_transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ static int fcoe_transport_create(const char *buffer,
872872
int rc = -ENODEV;
873873
struct net_device *netdev = NULL;
874874
struct fcoe_transport *ft = NULL;
875-
enum fip_state fip_mode = (enum fip_state)(long)kp->arg;
875+
enum fip_mode fip_mode = (enum fip_mode)kp->arg;
876876

877877
mutex_lock(&ft_mutex);
878878

drivers/scsi/qedf/qedf_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ static struct libfc_function_template qedf_lport_template = {
14171417

14181418
static void qedf_fcoe_ctlr_setup(struct qedf_ctx *qedf)
14191419
{
1420-
fcoe_ctlr_init(&qedf->ctlr, FIP_ST_AUTO);
1420+
fcoe_ctlr_init(&qedf->ctlr, FIP_MODE_AUTO);
14211421

14221422
qedf->ctlr.send = qedf_fip_send;
14231423
qedf->ctlr.get_src_addr = qedf_get_src_mac;

include/scsi/libfcoe.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ enum fip_state {
7979
* It must not change after fcoe_ctlr_init() sets it.
8080
*/
8181
enum fip_mode {
82-
FIP_MODE_AUTO = FIP_ST_AUTO,
82+
FIP_MODE_AUTO,
8383
FIP_MODE_NON_FIP,
8484
FIP_MODE_FABRIC,
8585
FIP_MODE_VN2VN,
@@ -250,7 +250,7 @@ struct fcoe_rport {
250250
};
251251

252252
/* FIP API functions */
253-
void fcoe_ctlr_init(struct fcoe_ctlr *, enum fip_state);
253+
void fcoe_ctlr_init(struct fcoe_ctlr *, enum fip_mode);
254254
void fcoe_ctlr_destroy(struct fcoe_ctlr *);
255255
void fcoe_ctlr_link_up(struct fcoe_ctlr *);
256256
int fcoe_ctlr_link_down(struct fcoe_ctlr *);

0 commit comments

Comments
 (0)