From patchwork Tue Mar 31 08:27:25 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 25356 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id E0838DDEE1 for ; Tue, 31 Mar 2009 19:27:49 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753837AbZCaI1e (ORCPT ); Tue, 31 Mar 2009 04:27:34 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753594AbZCaI1d (ORCPT ); Tue, 31 Mar 2009 04:27:33 -0400 Received: from wa-out-1112.google.com ([209.85.146.182]:47063 "EHLO wa-out-1112.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753532AbZCaI13 (ORCPT ); Tue, 31 Mar 2009 04:27:29 -0400 Received: by wa-out-1112.google.com with SMTP id j5so1584813wah.21 for ; Tue, 31 Mar 2009 01:27:27 -0700 (PDT) Received: by 10.114.127.1 with SMTP id z1mr4240108wac.3.1238488047529; Tue, 31 Mar 2009 01:27:27 -0700 (PDT) Received: from trillian.cg.shawcable.net (S01060016b61d1226.cg.shawcable.net [68.146.92.145]) by mx.google.com with ESMTPS id n9sm5356449wag.11.2009.03.31.01.27.26 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 31 Mar 2009 01:27:26 -0700 (PDT) Received: from localhost.localdomain (trillian [127.0.0.1]) by trillian.cg.shawcable.net (Postfix) with ESMTP id 46F5CC8085; Tue, 31 Mar 2009 02:27:25 -0600 (MDT) From: Grant Likely Subject: [PATCH 08/14] net: rework fsl_pq_mdio driver to use of_mdio infrastructure To: netdev@vger.kernel.org, linuxppc-dev@ozlabs.org Cc: olof@lixom.net, afleming@freescale.com, galak@kernel.crashing.org, Anton Vorontsov , Joakim Tjernlund Date: Tue, 31 Mar 2009 02:27:25 -0600 Message-ID: <20090331082725.1427.76321.stgit@localhost.localdomain> In-Reply-To: <20090331075537.1427.7819.stgit@localhost.localdomain> References: <20090331075537.1427.7819.stgit@localhost.localdomain> User-Agent: StGIT/0.14.2 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Grant Likely This patch simplifies the driver by making use of more common code. Signed-off-by: Grant Likely --- drivers/net/fsl_pq_mdio.c | 53 +++------------------------------------------ 1 files changed, 4 insertions(+), 49 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/fsl_pq_mdio.c b/drivers/net/fsl_pq_mdio.c index b3079a5..83a98f4 100644 --- a/drivers/net/fsl_pq_mdio.c +++ b/drivers/net/fsl_pq_mdio.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -154,44 +155,6 @@ static int fsl_pq_mdio_reset(struct mii_bus *bus) return 0; } -/* Allocate an array which provides irq #s for each PHY on the given bus */ -static int *create_irq_map(struct device_node *np) -{ - int *irqs; - int i; - struct device_node *child = NULL; - - irqs = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL); - - if (!irqs) - return NULL; - - for (i = 0; i < PHY_MAX_ADDR; i++) - irqs[i] = PHY_POLL; - - while ((child = of_get_next_child(np, child)) != NULL) { - int irq = irq_of_parse_and_map(child, 0); - const u32 *id; - - if (irq == NO_IRQ) - continue; - - id = of_get_property(child, "reg", NULL); - - if (!id) - continue; - - if (*id < PHY_MAX_ADDR && *id >= 0) - irqs[*id] = irq; - else - printk(KERN_WARNING "%s: " - "%d is not a valid PHY address\n", - np->full_name, *id); - } - - return irqs; -} - void fsl_pq_mdio_bus_name(char *name, struct device_node *np) { const u32 *addr; @@ -314,7 +277,7 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev, new_bus->priv = (void __force *)regs; - new_bus->irq = create_irq_map(np); + new_bus->irq = kcalloc(PHY_MAX_ADDR, sizeof(int), GFP_KERNEL); if (NULL == new_bus->irq) { err = -ENOMEM; @@ -383,16 +346,8 @@ static int fsl_pq_mdio_probe(struct of_device *ofdev, out_be32(tbipa, tbiaddr); - /* - * The TBIPHY-only buses will find PHYs at every address, - * so we mask them all but the TBI - */ - if (!of_device_is_compatible(np, "fsl,gianfar-mdio")) - new_bus->phy_mask = ~(1 << tbiaddr); - - err = mdiobus_register(new_bus); - - if (err) { + err = of_mdiobus_register(new_bus, np); + if (err != 0) { printk (KERN_ERR "%s: Cannot register as MDIO bus\n", new_bus->name); goto err_free_irqs;