diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2008-09-01 07:46:50 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-09-03 09:53:45 -0400 |
commit | dc8cfa55da8c21e0b3290c29677a9d05c0a3e595 (patch) | |
tree | a4c8bedad12a15d1e7c9fcfc99f873280ca644b4 /drivers/net/sfc/falcon_xmac.c | |
parent | cc12dac2e512c2b6185ed91899e09e9910630315 (diff) |
sfc: Use explicit bool for boolean variables, parameters and return values
Replace (cond ? 1 : 0) with cond or !!cond as appropriate, and
(cond ? 0 : 1) with !cond.
Remove some redundant boolean temporaries.
Rename one field that looks like a flag but isn't.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/sfc/falcon_xmac.c')
-rw-r--r-- | drivers/net/sfc/falcon_xmac.c | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/drivers/net/sfc/falcon_xmac.c b/drivers/net/sfc/falcon_xmac.c index ab114b4c3426..be5a86f0e5cf 100644 --- a/drivers/net/sfc/falcon_xmac.c +++ b/drivers/net/sfc/falcon_xmac.c | |||
@@ -70,7 +70,7 @@ static int falcon_reset_xmac(struct efx_nic *efx) | |||
70 | } | 70 | } |
71 | 71 | ||
72 | /* This often fails when DSP is disabled, ignore it */ | 72 | /* This often fails when DSP is disabled, ignore it */ |
73 | if (sfe4001_phy_flash_cfg != 0) | 73 | if (sfe4001_phy_flash_cfg) |
74 | return 0; | 74 | return 0; |
75 | 75 | ||
76 | EFX_ERR(efx, "timed out waiting for XMAC core reset\n"); | 76 | EFX_ERR(efx, "timed out waiting for XMAC core reset\n"); |
@@ -217,12 +217,12 @@ int falcon_reset_xaui(struct efx_nic *efx) | |||
217 | return rc; | 217 | return rc; |
218 | } | 218 | } |
219 | 219 | ||
220 | static int falcon_xgmii_status(struct efx_nic *efx) | 220 | static bool falcon_xgmii_status(struct efx_nic *efx) |
221 | { | 221 | { |
222 | efx_dword_t reg; | 222 | efx_dword_t reg; |
223 | 223 | ||
224 | if (falcon_rev(efx) < FALCON_REV_B0) | 224 | if (falcon_rev(efx) < FALCON_REV_B0) |
225 | return 1; | 225 | return true; |
226 | 226 | ||
227 | /* The ISR latches, so clear it and re-read */ | 227 | /* The ISR latches, so clear it and re-read */ |
228 | falcon_xmac_readl(efx, ®, XM_MGT_INT_REG_MAC_B0); | 228 | falcon_xmac_readl(efx, ®, XM_MGT_INT_REG_MAC_B0); |
@@ -231,13 +231,13 @@ static int falcon_xgmii_status(struct efx_nic *efx) | |||
231 | if (EFX_DWORD_FIELD(reg, XM_LCLFLT) || | 231 | if (EFX_DWORD_FIELD(reg, XM_LCLFLT) || |
232 | EFX_DWORD_FIELD(reg, XM_RMTFLT)) { | 232 | EFX_DWORD_FIELD(reg, XM_RMTFLT)) { |
233 | EFX_INFO(efx, "MGT_INT: "EFX_DWORD_FMT"\n", EFX_DWORD_VAL(reg)); | 233 | EFX_INFO(efx, "MGT_INT: "EFX_DWORD_FMT"\n", EFX_DWORD_VAL(reg)); |
234 | return 0; | 234 | return false; |
235 | } | 235 | } |
236 | 236 | ||
237 | return 1; | 237 | return true; |
238 | } | 238 | } |
239 | 239 | ||
240 | static void falcon_mask_status_intr(struct efx_nic *efx, int enable) | 240 | static void falcon_mask_status_intr(struct efx_nic *efx, bool enable) |
241 | { | 241 | { |
242 | efx_dword_t reg; | 242 | efx_dword_t reg; |
243 | 243 | ||
@@ -274,7 +274,7 @@ int falcon_init_xmac(struct efx_nic *efx) | |||
274 | if (rc) | 274 | if (rc) |
275 | goto fail2; | 275 | goto fail2; |
276 | 276 | ||
277 | falcon_mask_status_intr(efx, 1); | 277 | falcon_mask_status_intr(efx, true); |
278 | return 0; | 278 | return 0; |
279 | 279 | ||
280 | fail2: | 280 | fail2: |
@@ -283,13 +283,14 @@ int falcon_init_xmac(struct efx_nic *efx) | |||
283 | return rc; | 283 | return rc; |
284 | } | 284 | } |
285 | 285 | ||
286 | int falcon_xaui_link_ok(struct efx_nic *efx) | 286 | bool falcon_xaui_link_ok(struct efx_nic *efx) |
287 | { | 287 | { |
288 | efx_dword_t reg; | 288 | efx_dword_t reg; |
289 | int align_done, sync_status, link_ok = 0; | 289 | bool align_done, link_ok = false; |
290 | int sync_status; | ||
290 | 291 | ||
291 | if (LOOPBACK_INTERNAL(efx)) | 292 | if (LOOPBACK_INTERNAL(efx)) |
292 | return 1; | 293 | return true; |
293 | 294 | ||
294 | /* Read link status */ | 295 | /* Read link status */ |
295 | falcon_xmac_readl(efx, ®, XX_CORE_STAT_REG_MAC); | 296 | falcon_xmac_readl(efx, ®, XX_CORE_STAT_REG_MAC); |
@@ -297,7 +298,7 @@ int falcon_xaui_link_ok(struct efx_nic *efx) | |||
297 | align_done = EFX_DWORD_FIELD(reg, XX_ALIGN_DONE); | 298 | align_done = EFX_DWORD_FIELD(reg, XX_ALIGN_DONE); |
298 | sync_status = EFX_DWORD_FIELD(reg, XX_SYNC_STAT); | 299 | sync_status = EFX_DWORD_FIELD(reg, XX_SYNC_STAT); |
299 | if (align_done && (sync_status == XX_SYNC_STAT_DECODE_SYNCED)) | 300 | if (align_done && (sync_status == XX_SYNC_STAT_DECODE_SYNCED)) |
300 | link_ok = 1; | 301 | link_ok = true; |
301 | 302 | ||
302 | /* Clear link status ready for next read */ | 303 | /* Clear link status ready for next read */ |
303 | EFX_SET_DWORD_FIELD(reg, XX_COMMA_DET, XX_COMMA_DET_RESET); | 304 | EFX_SET_DWORD_FIELD(reg, XX_COMMA_DET, XX_COMMA_DET_RESET); |
@@ -309,8 +310,7 @@ int falcon_xaui_link_ok(struct efx_nic *efx) | |||
309 | * (error conditions from the wire side propoagate back through | 310 | * (error conditions from the wire side propoagate back through |
310 | * the phy to the xaui side). */ | 311 | * the phy to the xaui side). */ |
311 | if (efx->link_up && link_ok) { | 312 | if (efx->link_up && link_ok) { |
312 | int has_phyxs = efx->phy_op->mmds & (1 << MDIO_MMD_PHYXS); | 313 | if (efx->phy_op->mmds & (1 << MDIO_MMD_PHYXS)) |
313 | if (has_phyxs) | ||
314 | link_ok = mdio_clause45_phyxgxs_lane_sync(efx); | 314 | link_ok = mdio_clause45_phyxgxs_lane_sync(efx); |
315 | } | 315 | } |
316 | 316 | ||
@@ -326,7 +326,7 @@ static void falcon_reconfigure_xmac_core(struct efx_nic *efx) | |||
326 | { | 326 | { |
327 | unsigned int max_frame_len; | 327 | unsigned int max_frame_len; |
328 | efx_dword_t reg; | 328 | efx_dword_t reg; |
329 | int rx_fc = (efx->flow_control & EFX_FC_RX) ? 1 : 0; | 329 | bool rx_fc = !!(efx->flow_control & EFX_FC_RX); |
330 | 330 | ||
331 | /* Configure MAC - cut-thru mode is hard wired on */ | 331 | /* Configure MAC - cut-thru mode is hard wired on */ |
332 | EFX_POPULATE_DWORD_3(reg, | 332 | EFX_POPULATE_DWORD_3(reg, |
@@ -365,7 +365,7 @@ static void falcon_reconfigure_xmac_core(struct efx_nic *efx) | |||
365 | 365 | ||
366 | EFX_POPULATE_DWORD_2(reg, | 366 | EFX_POPULATE_DWORD_2(reg, |
367 | XM_PAUSE_TIME, 0xfffe, /* MAX PAUSE TIME */ | 367 | XM_PAUSE_TIME, 0xfffe, /* MAX PAUSE TIME */ |
368 | XM_DIS_FCNTL, rx_fc ? 0 : 1); | 368 | XM_DIS_FCNTL, !rx_fc); |
369 | falcon_xmac_writel(efx, ®, XM_FC_REG_MAC); | 369 | falcon_xmac_writel(efx, ®, XM_FC_REG_MAC); |
370 | 370 | ||
371 | /* Set MAC address */ | 371 | /* Set MAC address */ |
@@ -384,16 +384,15 @@ static void falcon_reconfigure_xmac_core(struct efx_nic *efx) | |||
384 | static void falcon_reconfigure_xgxs_core(struct efx_nic *efx) | 384 | static void falcon_reconfigure_xgxs_core(struct efx_nic *efx) |
385 | { | 385 | { |
386 | efx_dword_t reg; | 386 | efx_dword_t reg; |
387 | int xgxs_loopback = (efx->loopback_mode == LOOPBACK_XGXS) ? 1 : 0; | 387 | bool xgxs_loopback = (efx->loopback_mode == LOOPBACK_XGXS); |
388 | int xaui_loopback = (efx->loopback_mode == LOOPBACK_XAUI) ? 1 : 0; | 388 | bool xaui_loopback = (efx->loopback_mode == LOOPBACK_XAUI); |
389 | int xgmii_loopback = | 389 | bool xgmii_loopback = (efx->loopback_mode == LOOPBACK_XGMII); |
390 | (efx->loopback_mode == LOOPBACK_XGMII) ? 1 : 0; | ||
391 | 390 | ||
392 | /* XGXS block is flaky and will need to be reset if moving | 391 | /* XGXS block is flaky and will need to be reset if moving |
393 | * into our out of XGMII, XGXS or XAUI loopbacks. */ | 392 | * into our out of XGMII, XGXS or XAUI loopbacks. */ |
394 | if (EFX_WORKAROUND_5147(efx)) { | 393 | if (EFX_WORKAROUND_5147(efx)) { |
395 | int old_xgmii_loopback, old_xgxs_loopback, old_xaui_loopback; | 394 | bool old_xgmii_loopback, old_xgxs_loopback, old_xaui_loopback; |
396 | int reset_xgxs; | 395 | bool reset_xgxs; |
397 | 396 | ||
398 | falcon_xmac_readl(efx, ®, XX_CORE_STAT_REG_MAC); | 397 | falcon_xmac_readl(efx, ®, XX_CORE_STAT_REG_MAC); |
399 | old_xgxs_loopback = EFX_DWORD_FIELD(reg, XX_XGXS_LB_EN); | 398 | old_xgxs_loopback = EFX_DWORD_FIELD(reg, XX_XGXS_LB_EN); |
@@ -438,7 +437,7 @@ static void falcon_reconfigure_xgxs_core(struct efx_nic *efx) | |||
438 | 437 | ||
439 | /* Try and bring the Falcon side of the Falcon-Phy XAUI link fails | 438 | /* Try and bring the Falcon side of the Falcon-Phy XAUI link fails |
440 | * to come back up. Bash it until it comes back up */ | 439 | * to come back up. Bash it until it comes back up */ |
441 | static int falcon_check_xaui_link_up(struct efx_nic *efx) | 440 | static bool falcon_check_xaui_link_up(struct efx_nic *efx) |
442 | { | 441 | { |
443 | int max_tries, tries; | 442 | int max_tries, tries; |
444 | tries = EFX_WORKAROUND_5147(efx) ? 5 : 1; | 443 | tries = EFX_WORKAROUND_5147(efx) ? 5 : 1; |
@@ -446,11 +445,11 @@ static int falcon_check_xaui_link_up(struct efx_nic *efx) | |||
446 | 445 | ||
447 | if ((efx->loopback_mode == LOOPBACK_NETWORK) || | 446 | if ((efx->loopback_mode == LOOPBACK_NETWORK) || |
448 | (efx->phy_type == PHY_TYPE_NONE)) | 447 | (efx->phy_type == PHY_TYPE_NONE)) |
449 | return 0; | 448 | return false; |
450 | 449 | ||
451 | while (tries) { | 450 | while (tries) { |
452 | if (falcon_xaui_link_ok(efx)) | 451 | if (falcon_xaui_link_ok(efx)) |
453 | return 1; | 452 | return true; |
454 | 453 | ||
455 | EFX_LOG(efx, "%s Clobbering XAUI (%d tries left).\n", | 454 | EFX_LOG(efx, "%s Clobbering XAUI (%d tries left).\n", |
456 | __func__, tries); | 455 | __func__, tries); |
@@ -461,14 +460,14 @@ static int falcon_check_xaui_link_up(struct efx_nic *efx) | |||
461 | 460 | ||
462 | EFX_LOG(efx, "Failed to bring XAUI link back up in %d tries!\n", | 461 | EFX_LOG(efx, "Failed to bring XAUI link back up in %d tries!\n", |
463 | max_tries); | 462 | max_tries); |
464 | return 0; | 463 | return false; |
465 | } | 464 | } |
466 | 465 | ||
467 | void falcon_reconfigure_xmac(struct efx_nic *efx) | 466 | void falcon_reconfigure_xmac(struct efx_nic *efx) |
468 | { | 467 | { |
469 | int xaui_link_ok; | 468 | bool xaui_link_ok; |
470 | 469 | ||
471 | falcon_mask_status_intr(efx, 0); | 470 | falcon_mask_status_intr(efx, false); |
472 | 471 | ||
473 | falcon_deconfigure_mac_wrapper(efx); | 472 | falcon_deconfigure_mac_wrapper(efx); |
474 | 473 | ||
@@ -484,7 +483,7 @@ void falcon_reconfigure_xmac(struct efx_nic *efx) | |||
484 | xaui_link_ok = falcon_check_xaui_link_up(efx); | 483 | xaui_link_ok = falcon_check_xaui_link_up(efx); |
485 | 484 | ||
486 | if (xaui_link_ok && efx->link_up) | 485 | if (xaui_link_ok && efx->link_up) |
487 | falcon_mask_status_intr(efx, 1); | 486 | falcon_mask_status_intr(efx, true); |
488 | } | 487 | } |
489 | 488 | ||
490 | void falcon_fini_xmac(struct efx_nic *efx) | 489 | void falcon_fini_xmac(struct efx_nic *efx) |
@@ -563,14 +562,14 @@ void falcon_update_stats_xmac(struct efx_nic *efx) | |||
563 | 562 | ||
564 | int falcon_check_xmac(struct efx_nic *efx) | 563 | int falcon_check_xmac(struct efx_nic *efx) |
565 | { | 564 | { |
566 | unsigned xaui_link_ok; | 565 | bool xaui_link_ok; |
567 | int rc; | 566 | int rc; |
568 | 567 | ||
569 | if ((efx->loopback_mode == LOOPBACK_NETWORK) || | 568 | if ((efx->loopback_mode == LOOPBACK_NETWORK) || |
570 | (efx->phy_type == PHY_TYPE_NONE)) | 569 | (efx->phy_type == PHY_TYPE_NONE)) |
571 | return 0; | 570 | return 0; |
572 | 571 | ||
573 | falcon_mask_status_intr(efx, 0); | 572 | falcon_mask_status_intr(efx, false); |
574 | xaui_link_ok = falcon_xaui_link_ok(efx); | 573 | xaui_link_ok = falcon_xaui_link_ok(efx); |
575 | 574 | ||
576 | if (EFX_WORKAROUND_5147(efx) && !xaui_link_ok) | 575 | if (EFX_WORKAROUND_5147(efx) && !xaui_link_ok) |
@@ -581,7 +580,7 @@ int falcon_check_xmac(struct efx_nic *efx) | |||
581 | 580 | ||
582 | /* Unmask interrupt if everything was (and still is) ok */ | 581 | /* Unmask interrupt if everything was (and still is) ok */ |
583 | if (xaui_link_ok && efx->link_up) | 582 | if (xaui_link_ok && efx->link_up) |
584 | falcon_mask_status_intr(efx, 1); | 583 | falcon_mask_status_intr(efx, true); |
585 | 584 | ||
586 | return rc; | 585 | return rc; |
587 | } | 586 | } |
@@ -622,7 +621,7 @@ int falcon_xmac_set_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd) | |||
622 | 621 | ||
623 | int falcon_xmac_set_pause(struct efx_nic *efx, enum efx_fc_type flow_control) | 622 | int falcon_xmac_set_pause(struct efx_nic *efx, enum efx_fc_type flow_control) |
624 | { | 623 | { |
625 | int reset; | 624 | bool reset; |
626 | 625 | ||
627 | if (flow_control & EFX_FC_AUTO) { | 626 | if (flow_control & EFX_FC_AUTO) { |
628 | EFX_LOG(efx, "10G does not support flow control " | 627 | EFX_LOG(efx, "10G does not support flow control " |