]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.34/scsi-fcoe-make-use-of-fip_mode-enum-complete.patch
Linux 4.14.111
[thirdparty/kernel/stable-queue.git] / releases / 4.19.34 / scsi-fcoe-make-use-of-fip_mode-enum-complete.patch
1 From 99460d063fad72490b9627be2d36e5e2280575fa Mon Sep 17 00:00:00 2001
2 From: Sedat Dilek <sedat.dilek@gmail.com>
3 Date: Fri, 15 Feb 2019 13:19:20 +0100
4 Subject: scsi: fcoe: make use of fip_mode enum complete
5
6 [ Upstream commit 8beb90aaf334a6efa3e924339926b5f93a234dbb ]
7
8 commit 1917d42d14b7 ("fcoe: use enum for fip_mode") introduces a separate
9 enum for the fip_mode that shall be used during initialisation handling
10 until it is passed to fcoe_ctrl_link_up to set the initial fip_state. That
11 change was incomplete and gcc quietly converted in various places between
12 the fip_mode and the fip_state enum values with implicit enum conversions,
13 which fortunately cannot cause any issues in the actual code's execution.
14
15 clang however warns about these implicit enum conversions in the scsi
16 drivers. This commit consolidates the use of the two enums, guided by
17 clang's enum-conversion warnings.
18
19 This commit now completes the use of the fip_mode: It expects and uses
20 fip_mode in {bnx2fc,fcoe}_interface_create and fcoe_ctlr_init, and it calls
21 fcoe_ctrl_set_set() with the correct values in fcoe_ctlr_link_up(). It
22 also breaks the association between FIP_MODE_AUTO and FIP_ST_AUTO to
23 indicate these two enums are distinct.
24
25 Link: https://github.com/ClangBuiltLinux/linux/issues/151
26 Fixes: 1917d42d14b7 ("fcoe: use enum for fip_mode")
27 Reported-by: Dmitry Golovin <dima@golovin.in>
28 Original-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
29 CC: Lukas Bulwahn <lukas.bulwahn@gmail.com>
30 CC: Nick Desaulniers <ndesaulniers@google.com>
31 CC: Nathan Chancellor <natechancellor@gmail.com>
32 Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
33 Tested-by: Nathan Chancellor <natechancellor@gmail.com>
34 Suggested-by: Johannes Thumshirn <jthumshirn@suse.de>
35 Signed-off-by: Sedat Dilek <sedat.dilek@gmail.com>
36 Signed-off-by: Hannes Reinecke <hare@suse.com>
37 Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
38 Signed-off-by: Sasha Levin <sashal@kernel.org>
39 ---
40 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 2 +-
41 drivers/scsi/fcoe/fcoe.c | 2 +-
42 drivers/scsi/fcoe/fcoe_ctlr.c | 7 +++++--
43 drivers/scsi/fcoe/fcoe_transport.c | 2 +-
44 drivers/scsi/qedf/qedf_main.c | 2 +-
45 include/scsi/libfcoe.h | 4 ++--
46 6 files changed, 11 insertions(+), 8 deletions(-)
47
48 diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
49 index 3f97ec4aac4b..780651c4fc0c 100644
50 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
51 +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
52 @@ -1445,7 +1445,7 @@ bind_err:
53 static struct bnx2fc_interface *
54 bnx2fc_interface_create(struct bnx2fc_hba *hba,
55 struct net_device *netdev,
56 - enum fip_state fip_mode)
57 + enum fip_mode fip_mode)
58 {
59 struct fcoe_ctlr_device *ctlr_dev;
60 struct bnx2fc_interface *interface;
61 diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
62 index f46b312d04bc..6768b2e8148a 100644
63 --- a/drivers/scsi/fcoe/fcoe.c
64 +++ b/drivers/scsi/fcoe/fcoe.c
65 @@ -390,7 +390,7 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe,
66 * Returns: pointer to a struct fcoe_interface or NULL on error
67 */
68 static struct fcoe_interface *fcoe_interface_create(struct net_device *netdev,
69 - enum fip_state fip_mode)
70 + enum fip_mode fip_mode)
71 {
72 struct fcoe_ctlr_device *ctlr_dev;
73 struct fcoe_ctlr *ctlr;
74 diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
75 index 54da3166da8d..7dc4ffa24430 100644
76 --- a/drivers/scsi/fcoe/fcoe_ctlr.c
77 +++ b/drivers/scsi/fcoe/fcoe_ctlr.c
78 @@ -147,7 +147,7 @@ static void fcoe_ctlr_map_dest(struct fcoe_ctlr *fip)
79 * fcoe_ctlr_init() - Initialize the FCoE Controller instance
80 * @fip: The FCoE controller to initialize
81 */
82 -void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_state mode)
83 +void fcoe_ctlr_init(struct fcoe_ctlr *fip, enum fip_mode mode)
84 {
85 fcoe_ctlr_set_state(fip, FIP_ST_LINK_WAIT);
86 fip->mode = mode;
87 @@ -454,7 +454,10 @@ void fcoe_ctlr_link_up(struct fcoe_ctlr *fip)
88 mutex_unlock(&fip->ctlr_mutex);
89 fc_linkup(fip->lp);
90 } else if (fip->state == FIP_ST_LINK_WAIT) {
91 - fcoe_ctlr_set_state(fip, fip->mode);
92 + if (fip->mode == FIP_MODE_NON_FIP)
93 + fcoe_ctlr_set_state(fip, FIP_ST_NON_FIP);
94 + else
95 + fcoe_ctlr_set_state(fip, FIP_ST_AUTO);
96 switch (fip->mode) {
97 default:
98 LIBFCOE_FIP_DBG(fip, "invalid mode %d\n", fip->mode);
99 diff --git a/drivers/scsi/fcoe/fcoe_transport.c b/drivers/scsi/fcoe/fcoe_transport.c
100 index f4909cd206d3..f15d5e1d56b1 100644
101 --- a/drivers/scsi/fcoe/fcoe_transport.c
102 +++ b/drivers/scsi/fcoe/fcoe_transport.c
103 @@ -873,7 +873,7 @@ static int fcoe_transport_create(const char *buffer,
104 int rc = -ENODEV;
105 struct net_device *netdev = NULL;
106 struct fcoe_transport *ft = NULL;
107 - enum fip_state fip_mode = (enum fip_state)(long)kp->arg;
108 + enum fip_mode fip_mode = (enum fip_mode)kp->arg;
109
110 mutex_lock(&ft_mutex);
111
112 diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
113 index 0a5dd5595dd3..cd61905ca2f5 100644
114 --- a/drivers/scsi/qedf/qedf_main.c
115 +++ b/drivers/scsi/qedf/qedf_main.c
116 @@ -1418,7 +1418,7 @@ static struct libfc_function_template qedf_lport_template = {
117
118 static void qedf_fcoe_ctlr_setup(struct qedf_ctx *qedf)
119 {
120 - fcoe_ctlr_init(&qedf->ctlr, FIP_ST_AUTO);
121 + fcoe_ctlr_init(&qedf->ctlr, FIP_MODE_AUTO);
122
123 qedf->ctlr.send = qedf_fip_send;
124 qedf->ctlr.get_src_addr = qedf_get_src_mac;
125 diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
126 index cb8a273732cf..bb8092fa1e36 100644
127 --- a/include/scsi/libfcoe.h
128 +++ b/include/scsi/libfcoe.h
129 @@ -79,7 +79,7 @@ enum fip_state {
130 * It must not change after fcoe_ctlr_init() sets it.
131 */
132 enum fip_mode {
133 - FIP_MODE_AUTO = FIP_ST_AUTO,
134 + FIP_MODE_AUTO,
135 FIP_MODE_NON_FIP,
136 FIP_MODE_FABRIC,
137 FIP_MODE_VN2VN,
138 @@ -250,7 +250,7 @@ struct fcoe_rport {
139 };
140
141 /* FIP API functions */
142 -void fcoe_ctlr_init(struct fcoe_ctlr *, enum fip_state);
143 +void fcoe_ctlr_init(struct fcoe_ctlr *, enum fip_mode);
144 void fcoe_ctlr_destroy(struct fcoe_ctlr *);
145 void fcoe_ctlr_link_up(struct fcoe_ctlr *);
146 int fcoe_ctlr_link_down(struct fcoe_ctlr *);
147 --
148 2.19.1
149