aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/ucc_geth.c87
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 */ 3432static int ucc_geth_init_mac(struct ucc_geth_private *ugeth)
3433/* Returns 0 for success. */
3434static 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;
3480err:
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. */
3487static 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
3515out_err: 3534err:
3516 napi_disable(&ugeth->napi);
3517out_err_stop:
3518 ucc_geth_stop(ugeth); 3535 ucc_geth_stop(ugeth);
3519 return err; 3536 return err;
3520} 3537}