hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/s390/net/qeth_l2_sys.c
....@@ -18,12 +18,10 @@
1818 int rc = 0;
1919 char *word;
2020
21
- if (!card)
22
- return -EINVAL;
23
-
24
- if (qeth_l2_vnicc_is_in_use(card))
21
+ if (!qeth_bridgeport_allowed(card))
2522 return sprintf(buf, "n/a (VNIC characteristics)\n");
2623
24
+ mutex_lock(&card->sbp_lock);
2725 if (qeth_card_hw_is_reachable(card) &&
2826 card->options.sbp.supported_funcs)
2927 rc = qeth_bridgeport_query_ports(card,
....@@ -57,6 +55,7 @@
5755 else
5856 rc = sprintf(buf, "%s\n", word);
5957 }
58
+ mutex_unlock(&card->sbp_lock);
6059
6160 return rc;
6261 }
....@@ -66,7 +65,7 @@
6665 {
6766 struct qeth_card *card = dev_get_drvdata(dev);
6867
69
- if (qeth_l2_vnicc_is_in_use(card))
68
+ if (!qeth_bridgeport_allowed(card))
7069 return sprintf(buf, "n/a (VNIC characteristics)\n");
7170
7271 return qeth_bridge_port_role_state_show(dev, attr, buf, 0);
....@@ -79,8 +78,6 @@
7978 int rc = 0;
8079 enum qeth_sbp_roles role;
8180
82
- if (!card)
83
- return -EINVAL;
8481 if (sysfs_streq(buf, "primary"))
8582 role = QETH_SBP_ROLE_PRIMARY;
8683 else if (sysfs_streq(buf, "secondary"))
....@@ -91,8 +88,9 @@
9188 return -EINVAL;
9289
9390 mutex_lock(&card->conf_mutex);
91
+ mutex_lock(&card->sbp_lock);
9492
95
- if (qeth_l2_vnicc_is_in_use(card))
93
+ if (!qeth_bridgeport_allowed(card))
9694 rc = -EBUSY;
9795 else if (card->options.sbp.reflect_promisc)
9896 /* Forbid direct manipulation */
....@@ -104,6 +102,7 @@
104102 } else
105103 card->options.sbp.role = role;
106104
105
+ mutex_unlock(&card->sbp_lock);
107106 mutex_unlock(&card->conf_mutex);
108107
109108 return rc ? rc : count;
....@@ -117,7 +116,7 @@
117116 {
118117 struct qeth_card *card = dev_get_drvdata(dev);
119118
120
- if (qeth_l2_vnicc_is_in_use(card))
119
+ if (!qeth_bridgeport_allowed(card))
121120 return sprintf(buf, "n/a (VNIC characteristics)\n");
122121
123122 return qeth_bridge_port_role_state_show(dev, attr, buf, 1);
....@@ -132,10 +131,7 @@
132131 struct qeth_card *card = dev_get_drvdata(dev);
133132 int enabled;
134133
135
- if (!card)
136
- return -EINVAL;
137
-
138
- if (qeth_l2_vnicc_is_in_use(card))
134
+ if (!qeth_bridgeport_allowed(card))
139135 return sprintf(buf, "n/a (VNIC characteristics)\n");
140136
141137 enabled = card->options.sbp.hostnotification;
....@@ -150,24 +146,24 @@
150146 bool enable;
151147 int rc;
152148
153
- if (!card)
154
- return -EINVAL;
155
-
156149 rc = kstrtobool(buf, &enable);
157150 if (rc)
158151 return rc;
159152
160153 mutex_lock(&card->conf_mutex);
154
+ mutex_lock(&card->sbp_lock);
161155
162
- if (qeth_l2_vnicc_is_in_use(card))
156
+ if (!qeth_bridgeport_allowed(card))
163157 rc = -EBUSY;
164158 else if (qeth_card_hw_is_reachable(card)) {
165159 rc = qeth_bridgeport_an_set(card, enable);
160
+ /* sbp_lock ensures ordering vs notifications-stopped events */
166161 if (!rc)
167162 card->options.sbp.hostnotification = enable;
168163 } else
169164 card->options.sbp.hostnotification = enable;
170165
166
+ mutex_unlock(&card->sbp_lock);
171167 mutex_unlock(&card->conf_mutex);
172168
173169 return rc ? rc : count;
....@@ -183,10 +179,7 @@
183179 struct qeth_card *card = dev_get_drvdata(dev);
184180 char *state;
185181
186
- if (!card)
187
- return -EINVAL;
188
-
189
- if (qeth_l2_vnicc_is_in_use(card))
182
+ if (!qeth_bridgeport_allowed(card))
190183 return sprintf(buf, "n/a (VNIC characteristics)\n");
191184
192185 if (card->options.sbp.reflect_promisc) {
....@@ -207,9 +200,6 @@
207200 int enable, primary;
208201 int rc = 0;
209202
210
- if (!card)
211
- return -EINVAL;
212
-
213203 if (sysfs_streq(buf, "none")) {
214204 enable = 0;
215205 primary = 0;
....@@ -223,8 +213,9 @@
223213 return -EINVAL;
224214
225215 mutex_lock(&card->conf_mutex);
216
+ mutex_lock(&card->sbp_lock);
226217
227
- if (qeth_l2_vnicc_is_in_use(card))
218
+ if (!qeth_bridgeport_allowed(card))
228219 rc = -EBUSY;
229220 else if (card->options.sbp.role != QETH_SBP_ROLE_NONE)
230221 rc = -EPERM;
....@@ -234,6 +225,7 @@
234225 rc = 0;
235226 }
236227
228
+ mutex_unlock(&card->sbp_lock);
237229 mutex_unlock(&card->conf_mutex);
238230
239231 return rc ? rc : count;
....@@ -254,35 +246,6 @@
254246 static struct attribute_group qeth_l2_bridgeport_attr_group = {
255247 .attrs = qeth_l2_bridgeport_attrs,
256248 };
257
-
258
-/**
259
- * qeth_l2_setup_bridgeport_attrs() - set/restore attrs when turning online.
260
- * @card: qeth_card structure pointer
261
- *
262
- * Note: this function is called with conf_mutex held by the caller
263
- */
264
-void qeth_l2_setup_bridgeport_attrs(struct qeth_card *card)
265
-{
266
- int rc;
267
-
268
- if (!card)
269
- return;
270
- if (!card->options.sbp.supported_funcs)
271
- return;
272
- if (card->options.sbp.role != QETH_SBP_ROLE_NONE) {
273
- /* Conditional to avoid spurious error messages */
274
- qeth_bridgeport_setrole(card, card->options.sbp.role);
275
- /* Let the callback function refresh the stored role value. */
276
- qeth_bridgeport_query_ports(card,
277
- &card->options.sbp.role, NULL);
278
- }
279
- if (card->options.sbp.hostnotification) {
280
- rc = qeth_bridgeport_an_set(card, 1);
281
- if (rc)
282
- card->options.sbp.hostnotification = 0;
283
- } else
284
- qeth_bridgeport_an_set(card, 0);
285
-}
286249
287250 /* VNIC CHARS support */
288251
....@@ -315,9 +278,6 @@
315278 u32 timeout;
316279 int rc;
317280
318
- if (!card)
319
- return -EINVAL;
320
-
321281 rc = qeth_l2_vnicc_get_timeout(card, &timeout);
322282 if (rc == -EBUSY)
323283 return sprintf(buf, "n/a (BridgePort)\n");
....@@ -334,9 +294,6 @@
334294 struct qeth_card *card = dev_get_drvdata(dev);
335295 u32 timeout;
336296 int rc;
337
-
338
- if (!card)
339
- return -EINVAL;
340297
341298 rc = kstrtou32(buf, 10, &timeout);
342299 if (rc)
....@@ -357,9 +314,6 @@
357314 u32 vnicc;
358315 int rc;
359316
360
- if (!card)
361
- return -EINVAL;
362
-
363317 vnicc = qeth_l2_vnicc_sysfs_attr_to_char(attr->attr.name);
364318 rc = qeth_l2_vnicc_get_state(card, vnicc, &state);
365319
....@@ -379,9 +333,6 @@
379333 bool state;
380334 u32 vnicc;
381335 int rc;
382
-
383
- if (!card)
384
- return -EINVAL;
385336
386337 if (kstrtobool(buf, &state))
387338 return -EINVAL;