Skip to content

Commit e90dd26

Browse files
mdrustadJeff Kirsher
authored andcommitted
ixgbe: Make return values more direct
Make return values more direct, eliminating some gotos and otherwise unneeded conditionals. This also eliminates some local variables. Also a few minor cleanups in affected code so checkpatch won't complain. Signed-off-by: Mark Rustad <[email protected]> Tested-by: Phil Schmitt <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 9f1fb8a commit e90dd26

File tree

11 files changed

+742
-1010
lines changed

11 files changed

+742
-1010
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c

Lines changed: 43 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw)
122122
{
123123
struct ixgbe_mac_info *mac = &hw->mac;
124124
struct ixgbe_phy_info *phy = &hw->phy;
125-
s32 ret_val = 0;
125+
s32 ret_val;
126126
u16 list_offset, data_offset;
127127

128128
/* Identify the PHY */
@@ -147,28 +147,23 @@ static s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw)
147147

148148
/* Call SFP+ identify routine to get the SFP+ module type */
149149
ret_val = phy->ops.identify_sfp(hw);
150-
if (ret_val != 0)
151-
goto out;
152-
else if (hw->phy.sfp_type == ixgbe_sfp_type_unknown) {
153-
ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED;
154-
goto out;
155-
}
150+
if (ret_val)
151+
return ret_val;
152+
if (hw->phy.sfp_type == ixgbe_sfp_type_unknown)
153+
return IXGBE_ERR_SFP_NOT_SUPPORTED;
156154

157155
/* Check to see if SFP+ module is supported */
158156
ret_val = ixgbe_get_sfp_init_sequence_offsets(hw,
159157
&list_offset,
160158
&data_offset);
161-
if (ret_val != 0) {
162-
ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED;
163-
goto out;
164-
}
159+
if (ret_val)
160+
return IXGBE_ERR_SFP_NOT_SUPPORTED;
165161
break;
166162
default:
167163
break;
168164
}
169165

170-
out:
171-
return ret_val;
166+
return 0;
172167
}
173168

174169
/**
@@ -183,7 +178,7 @@ static s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw)
183178
{
184179
u32 regval;
185180
u32 i;
186-
s32 ret_val = 0;
181+
s32 ret_val;
187182

188183
ret_val = ixgbe_start_hw_generic(hw);
189184

@@ -203,11 +198,13 @@ static s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw)
203198
IXGBE_WRITE_REG(hw, IXGBE_DCA_RXCTRL(i), regval);
204199
}
205200

201+
if (ret_val)
202+
return ret_val;
203+
206204
/* set the completion timeout for interface */
207-
if (ret_val == 0)
208-
ixgbe_set_pcie_completion_timeout(hw);
205+
ixgbe_set_pcie_completion_timeout(hw);
209206

210-
return ret_val;
207+
return 0;
211208
}
212209

213210
/**
@@ -222,7 +219,6 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
222219
ixgbe_link_speed *speed,
223220
bool *autoneg)
224221
{
225-
s32 status = 0;
226222
u32 autoc = 0;
227223

228224
/*
@@ -262,11 +258,10 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
262258
break;
263259

264260
default:
265-
status = IXGBE_ERR_LINK_SETUP;
266-
break;
261+
return IXGBE_ERR_LINK_SETUP;
267262
}
268263

269-
return status;
264+
return 0;
270265
}
271266

272267
/**
@@ -277,14 +272,12 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
277272
**/
278273
static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw)
279274
{
280-
enum ixgbe_media_type media_type;
281-
282275
/* Detect if there is a copper PHY attached. */
283276
switch (hw->phy.type) {
284277
case ixgbe_phy_cu_unknown:
285278
case ixgbe_phy_tn:
286-
media_type = ixgbe_media_type_copper;
287-
goto out;
279+
return ixgbe_media_type_copper;
280+
288281
default:
289282
break;
290283
}
@@ -294,30 +287,27 @@ static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw)
294287
case IXGBE_DEV_ID_82598:
295288
case IXGBE_DEV_ID_82598_BX:
296289
/* Default device ID is mezzanine card KX/KX4 */
297-
media_type = ixgbe_media_type_backplane;
298-
break;
290+
return ixgbe_media_type_backplane;
291+
299292
case IXGBE_DEV_ID_82598AF_DUAL_PORT:
300293
case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
301294
case IXGBE_DEV_ID_82598_DA_DUAL_PORT:
302295
case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM:
303296
case IXGBE_DEV_ID_82598EB_XF_LR:
304297
case IXGBE_DEV_ID_82598EB_SFP_LOM:
305-
media_type = ixgbe_media_type_fiber;
306-
break;
298+
return ixgbe_media_type_fiber;
299+
307300
case IXGBE_DEV_ID_82598EB_CX4:
308301
case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
309-
media_type = ixgbe_media_type_cx4;
310-
break;
302+
return ixgbe_media_type_cx4;
303+
311304
case IXGBE_DEV_ID_82598AT:
312305
case IXGBE_DEV_ID_82598AT2:
313-
media_type = ixgbe_media_type_copper;
314-
break;
306+
return ixgbe_media_type_copper;
307+
315308
default:
316-
media_type = ixgbe_media_type_unknown;
317-
break;
309+
return ixgbe_media_type_unknown;
318310
}
319-
out:
320-
return media_type;
321311
}
322312

323313
/**
@@ -328,7 +318,6 @@ static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw)
328318
**/
329319
static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)
330320
{
331-
s32 ret_val = 0;
332321
u32 fctrl_reg;
333322
u32 rmcs_reg;
334323
u32 reg;
@@ -338,10 +327,8 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)
338327
bool link_up;
339328

340329
/* Validate the water mark configuration */
341-
if (!hw->fc.pause_time) {
342-
ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
343-
goto out;
344-
}
330+
if (!hw->fc.pause_time)
331+
return IXGBE_ERR_INVALID_LINK_SETTINGS;
345332

346333
/* Low water mark of zero causes XOFF floods */
347334
for (i = 0; i < MAX_TRAFFIC_CLASS; i++) {
@@ -350,8 +337,7 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)
350337
if (!hw->fc.low_water[i] ||
351338
hw->fc.low_water[i] >= hw->fc.high_water[i]) {
352339
hw_dbg(hw, "Invalid water mark configuration\n");
353-
ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
354-
goto out;
340+
return IXGBE_ERR_INVALID_LINK_SETTINGS;
355341
}
356342
}
357343
}
@@ -428,8 +414,7 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)
428414
break;
429415
default:
430416
hw_dbg(hw, "Flow control param set incorrectly\n");
431-
ret_val = IXGBE_ERR_CONFIG;
432-
goto out;
417+
return IXGBE_ERR_CONFIG;
433418
}
434419

435420
/* Set 802.3x based flow control settings. */
@@ -460,8 +445,7 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw)
460445
/* Configure flow control refresh threshold value */
461446
IXGBE_WRITE_REG(hw, IXGBE_FCRTV, hw->fc.pause_time / 2);
462447

463-
out:
464-
return ret_val;
448+
return 0;
465449
}
466450

467451
/**
@@ -597,7 +581,7 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
597581
}
598582

599583
if (!*link_up)
600-
goto out;
584+
return 0;
601585
}
602586

603587
links_reg = IXGBE_READ_REG(hw, IXGBE_LINKS);
@@ -628,7 +612,6 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
628612
(ixgbe_validate_link_ready(hw) != 0))
629613
*link_up = false;
630614

631-
out:
632615
return 0;
633616
}
634617

@@ -645,7 +628,6 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw,
645628
bool autoneg_wait_to_complete)
646629
{
647630
bool autoneg = false;
648-
s32 status = 0;
649631
ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;
650632
u32 curr_autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
651633
u32 autoc = curr_autoc;
@@ -656,7 +638,7 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw,
656638
speed &= link_capabilities;
657639

658640
if (speed == IXGBE_LINK_SPEED_UNKNOWN)
659-
status = IXGBE_ERR_LINK_SETUP;
641+
return IXGBE_ERR_LINK_SETUP;
660642

661643
/* Set KX4/KX support according to speed requested */
662644
else if (link_mode == IXGBE_AUTOC_LMS_KX4_AN ||
@@ -670,17 +652,11 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw,
670652
IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
671653
}
672654

673-
if (status == 0) {
674-
/*
675-
* Setup and restart the link based on the new values in
676-
* ixgbe_hw This will write the AUTOC register based on the new
677-
* stored values
678-
*/
679-
status = ixgbe_start_mac_link_82598(hw,
680-
autoneg_wait_to_complete);
681-
}
682-
683-
return status;
655+
/* Setup and restart the link based on the new values in
656+
* ixgbe_hw This will write the AUTOC register based on the new
657+
* stored values
658+
*/
659+
return ixgbe_start_mac_link_82598(hw, autoneg_wait_to_complete);
684660
}
685661

686662

@@ -717,7 +693,7 @@ static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw,
717693
**/
718694
static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
719695
{
720-
s32 status = 0;
696+
s32 status;
721697
s32 phy_status = 0;
722698
u32 ctrl;
723699
u32 gheccr;
@@ -727,8 +703,8 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
727703

728704
/* Call adapter stop to disable tx/rx and clear interrupts */
729705
status = hw->mac.ops.stop_adapter(hw);
730-
if (status != 0)
731-
goto reset_hw_out;
706+
if (status)
707+
return status;
732708

733709
/*
734710
* Power up the Atlas Tx lanes if they are currently powered down.
@@ -770,7 +746,7 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
770746
/* Init PHY and function pointers, perform SFP setup */
771747
phy_status = hw->phy.ops.init(hw);
772748
if (phy_status == IXGBE_ERR_SFP_NOT_SUPPORTED)
773-
goto reset_hw_out;
749+
return phy_status;
774750
if (phy_status == IXGBE_ERR_SFP_NOT_PRESENT)
775751
goto mac_reset_top;
776752

@@ -836,7 +812,6 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
836812
*/
837813
hw->mac.ops.init_rx_addrs(hw);
838814

839-
reset_hw_out:
840815
if (phy_status)
841816
status = phy_status;
842817

0 commit comments

Comments
 (0)