diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2009-08-27 03:35:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-31 00:51:37 -0400 |
commit | 54b15983840c9eb264e41f3b14af398a72ebd426 (patch) | |
tree | ea3dd07e03c0bb74a53b93837e7246149d7e57b4 /drivers | |
parent | ed24157ede901608e00f28b4897398a373e1e926 (diff) |
ucc_geth: Factor out MAC initialization steps into a call
This patch factors out MAC initialization into ucc_geth_init_mac()
function that we'll use for suspend/resume.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ucc_geth.c | 87 |
1 files changed, 52 insertions, 35 deletions
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c index 52a6750b8201..e474e57d96fd 100644 --- a/drivers/net/ucc_geth.c +++ b/drivers/net/ucc_geth.c | |||
@@ -3429,46 +3429,25 @@ static int ucc_geth_set_mac_addr(struct net_device *dev, void *p) | |||
3429 | return 0; | 3429 | return 0; |
3430 | } | 3430 | } |
3431 | 3431 | ||
3432 | /* Called when something needs to use the ethernet device */ | 3432 | static int ucc_geth_init_mac(struct ucc_geth_private *ugeth) |
3433 | /* Returns 0 for success. */ | ||
3434 | static int ucc_geth_open(struct net_device *dev) | ||
3435 | { | 3433 | { |
3436 | struct ucc_geth_private *ugeth = netdev_priv(dev); | 3434 | struct net_device *dev = ugeth->ndev; |
3437 | int err; | 3435 | int err; |
3438 | 3436 | ||
3439 | ugeth_vdbg("%s: IN", __func__); | ||
3440 | |||
3441 | /* Test station address */ | ||
3442 | if (dev->dev_addr[0] & ENET_GROUP_ADDR) { | ||
3443 | if (netif_msg_ifup(ugeth)) | ||
3444 | ugeth_err("%s: Multicast address used for station address" | ||
3445 | " - is this what you wanted?", __func__); | ||
3446 | return -EINVAL; | ||
3447 | } | ||
3448 | |||
3449 | err = init_phy(dev); | ||
3450 | if (err) { | ||
3451 | if (netif_msg_ifup(ugeth)) | ||
3452 | ugeth_err("%s: Cannot initialize PHY, aborting.", | ||
3453 | dev->name); | ||
3454 | return err; | ||
3455 | } | ||
3456 | |||
3457 | err = ucc_struct_init(ugeth); | 3437 | err = ucc_struct_init(ugeth); |
3458 | if (err) { | 3438 | if (err) { |
3459 | if (netif_msg_ifup(ugeth)) | 3439 | if (netif_msg_ifup(ugeth)) |
3460 | ugeth_err("%s: Cannot configure internal struct, aborting.", dev->name); | 3440 | ugeth_err("%s: Cannot configure internal struct, " |
3461 | goto out_err_stop; | 3441 | "aborting.", dev->name); |
3442 | goto err; | ||
3462 | } | 3443 | } |
3463 | 3444 | ||
3464 | napi_enable(&ugeth->napi); | ||
3465 | |||
3466 | err = ucc_geth_startup(ugeth); | 3445 | err = ucc_geth_startup(ugeth); |
3467 | if (err) { | 3446 | if (err) { |
3468 | if (netif_msg_ifup(ugeth)) | 3447 | if (netif_msg_ifup(ugeth)) |
3469 | ugeth_err("%s: Cannot configure net device, aborting.", | 3448 | ugeth_err("%s: Cannot configure net device, aborting.", |
3470 | dev->name); | 3449 | dev->name); |
3471 | goto out_err; | 3450 | goto err; |
3472 | } | 3451 | } |
3473 | 3452 | ||
3474 | err = adjust_enet_interface(ugeth); | 3453 | err = adjust_enet_interface(ugeth); |
@@ -3476,7 +3455,7 @@ static int ucc_geth_open(struct net_device *dev) | |||
3476 | if (netif_msg_ifup(ugeth)) | 3455 | if (netif_msg_ifup(ugeth)) |
3477 | ugeth_err("%s: Cannot configure net device, aborting.", | 3456 | ugeth_err("%s: Cannot configure net device, aborting.", |
3478 | dev->name); | 3457 | dev->name); |
3479 | goto out_err; | 3458 | goto err; |
3480 | } | 3459 | } |
3481 | 3460 | ||
3482 | /* Set MACSTNADDR1, MACSTNADDR2 */ | 3461 | /* Set MACSTNADDR1, MACSTNADDR2 */ |
@@ -3490,13 +3469,51 @@ static int ucc_geth_open(struct net_device *dev) | |||
3490 | &ugeth->ug_regs->macstnaddr1, | 3469 | &ugeth->ug_regs->macstnaddr1, |
3491 | &ugeth->ug_regs->macstnaddr2); | 3470 | &ugeth->ug_regs->macstnaddr2); |
3492 | 3471 | ||
3493 | phy_start(ugeth->phydev); | ||
3494 | |||
3495 | err = ugeth_enable(ugeth, COMM_DIR_RX_AND_TX); | 3472 | err = ugeth_enable(ugeth, COMM_DIR_RX_AND_TX); |
3496 | if (err) { | 3473 | if (err) { |
3497 | if (netif_msg_ifup(ugeth)) | 3474 | if (netif_msg_ifup(ugeth)) |
3498 | ugeth_err("%s: Cannot enable net device, aborting.", dev->name); | 3475 | ugeth_err("%s: Cannot enable net device, aborting.", dev->name); |
3499 | goto out_err; | 3476 | goto err; |
3477 | } | ||
3478 | |||
3479 | return 0; | ||
3480 | err: | ||
3481 | ucc_geth_stop(ugeth); | ||
3482 | return err; | ||
3483 | } | ||
3484 | |||
3485 | /* Called when something needs to use the ethernet device */ | ||
3486 | /* Returns 0 for success. */ | ||
3487 | static int ucc_geth_open(struct net_device *dev) | ||
3488 | { | ||
3489 | struct ucc_geth_private *ugeth = netdev_priv(dev); | ||
3490 | int err; | ||
3491 | |||
3492 | ugeth_vdbg("%s: IN", __func__); | ||
3493 | |||
3494 | /* Test station address */ | ||
3495 | if (dev->dev_addr[0] & ENET_GROUP_ADDR) { | ||
3496 | if (netif_msg_ifup(ugeth)) | ||
3497 | ugeth_err("%s: Multicast address used for station " | ||
3498 | "address - is this what you wanted?", | ||
3499 | __func__); | ||
3500 | return -EINVAL; | ||
3501 | } | ||
3502 | |||
3503 | err = init_phy(dev); | ||
3504 | if (err) { | ||
3505 | if (netif_msg_ifup(ugeth)) | ||
3506 | ugeth_err("%s: Cannot initialize PHY, aborting.", | ||
3507 | dev->name); | ||
3508 | return err; | ||
3509 | } | ||
3510 | |||
3511 | err = ucc_geth_init_mac(ugeth); | ||
3512 | if (err) { | ||
3513 | if (netif_msg_ifup(ugeth)) | ||
3514 | ugeth_err("%s: Cannot initialize MAC, aborting.", | ||
3515 | dev->name); | ||
3516 | goto err; | ||
3500 | } | 3517 | } |
3501 | 3518 | ||
3502 | err = request_irq(ugeth->ug_info->uf_info.irq, ucc_geth_irq_handler, | 3519 | err = request_irq(ugeth->ug_info->uf_info.irq, ucc_geth_irq_handler, |
@@ -3505,16 +3522,16 @@ static int ucc_geth_open(struct net_device *dev) | |||
3505 | if (netif_msg_ifup(ugeth)) | 3522 | if (netif_msg_ifup(ugeth)) |
3506 | ugeth_err("%s: Cannot get IRQ for net device, aborting.", | 3523 | ugeth_err("%s: Cannot get IRQ for net device, aborting.", |
3507 | dev->name); | 3524 | dev->name); |
3508 | goto out_err; | 3525 | goto err; |
3509 | } | 3526 | } |
3510 | 3527 | ||
3528 | phy_start(ugeth->phydev); | ||
3529 | napi_enable(&ugeth->napi); | ||
3511 | netif_start_queue(dev); | 3530 | netif_start_queue(dev); |
3512 | 3531 | ||
3513 | return err; | 3532 | return err; |
3514 | 3533 | ||
3515 | out_err: | 3534 | err: |
3516 | napi_disable(&ugeth->napi); | ||
3517 | out_err_stop: | ||
3518 | ucc_geth_stop(ugeth); | 3535 | ucc_geth_stop(ugeth); |
3519 | return err; | 3536 | return err; |
3520 | } | 3537 | } |