From: Grant Likely <grant.likely@secretlab.ca>
To: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Cc: Andy Fleming <afleming@freescale.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
David Miller <davem@davemloft.net>,
linuxppc-dev@ozlabs.org,
linuxppc-dev-bounces+joakim.tjernlund=transmode.se@ozlabs.org,
netdev@vger.kernel.org
Subject: Re: [PATCH v3 09/13] net: Rework ucc_geth driver to use of_mdio infrastructure
Date: Mon, 27 Apr 2009 09:36:07 -0600 [thread overview]
Message-ID: <fa686aa40904270836v352b7d24sb5798ca95d71ccd@mail.gmail.com> (raw)
In-Reply-To: <OFD90DF3E8.3B40B9BF-ONC12575A4.0030C830-C12575A4.00317AE2@transmode.se>
On Sun, Apr 26, 2009 at 3:00 AM, Joakim Tjernlund
<Joakim.Tjernlund@transmode.se> wrote:
> Change in fixed link case, see inline.
>
>>
>> From: Grant Likely <grant.likely@secretlab.ca>
>>
>> This patch simplifies the driver by making use of more common code.
>>
>> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
>> Acked-by: Andy Fleming <afleming@freescale.com>
>> ---
>>
>> drivers/net/ucc_geth.c | 47
> ++++++++++++-----------------------------------
>> drivers/net/ucc_geth.h | 2 +-
>> 2 files changed, 13 insertions(+), 36 deletions(-)
>>
>>
>> diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
>> index d3f39e8..195b490 100644
>> --- a/drivers/net/ucc_geth.c
>> +++ b/drivers/net/ucc_geth.c
>> @@ -27,6 +27,7 @@
>> #include <linux/mii.h>
>> #include <linux/phy.h>
>> #include <linux/workqueue.h>
>> +#include <linux/of_mdio.h>
>> #include <linux/of_platform.h>
>>
>> #include <asm/uaccess.h>
>> @@ -1542,12 +1543,14 @@ static int init_phy(struct net_device *dev)
>> priv->oldspeed = 0;
>> priv->oldduplex = -1;
>>
>> - phydev = phy_connect(dev, ug_info->phy_bus_id, &adjust_link, 0,
>> - priv->phy_interface);
>> + if (!ug_info->phy_node)
>> + return 0;
>>
>> - if (IS_ERR(phydev)) {
>> + phydev = of_phy_connect(dev, ug_info->phy_node, &adjust_link, 0,
>> + priv->phy_interface);
>> + if (!phydev) {
>> printk("%s: Could not attach to PHY\n", dev->name);
>> - return PTR_ERR(phydev);
>> + return -ENODEV;
>> }
>>
>> phydev->supported &= (ADVERTISED_10baseT_Half |
>> @@ -3519,14 +3522,12 @@ static int ucc_geth_probe(struct of_device*
> ofdev, const struct of_device_id *ma
>> {
>> struct device *device = &ofdev->dev;
>> struct device_node *np = ofdev->node;
>> - struct device_node *mdio;
>> struct net_device *dev = NULL;
>> struct ucc_geth_private *ugeth = NULL;
>> struct ucc_geth_info *ug_info;
>> struct resource res;
>> struct device_node *phy;
>> int err, ucc_num, max_speed = 0;
>> - const phandle *ph;
>> const u32 *fixed_link;
>> const unsigned int *prop;
>> const char *sprop;
>> @@ -3626,45 +3627,21 @@ static int ucc_geth_probe(struct of_device*
> ofdev, const struct of_device_id *ma
>> ug_info->uf_info.irq = irq_of_parse_and_map(np, 0);
>> fixed_link = of_get_property(np, "fixed-link", NULL);
>> if (fixed_link) {
>> - snprintf(ug_info->phy_bus_id, sizeof(ug_info->phy_bus_id),
>> - PHY_ID_FMT, "0", fixed_link[0]);
>> phy = NULL;
>
> phy assigned to NULL ...
>
>> } else {
>> - char bus_name[MII_BUS_ID_SIZE];
>> -
>> - ph = of_get_property(np, "phy-handle", NULL);
>> - phy = of_find_node_by_phandle(*ph);
>> -
>> + phy = of_parse_phandle(np, "phy-handle", 0);
>> if (phy == NULL)
>> return -ENODEV;
>> -
>> - /* set the PHY address */
>> - prop = of_get_property(phy, "reg", NULL);
>> - if (prop == NULL)
>> - return -1;
>> -
>> - /* Set the bus id */
>> - mdio = of_get_parent(phy);
>> -
>> - if (mdio == NULL)
>> - return -ENODEV;
>> -
>> - err = of_address_to_resource(mdio, 0, &res);
>> -
>> - if (err) {
>> - of_node_put(mdio);
>> - return err;
>> - }
>> - fsl_pq_mdio_bus_name(bus_name, mdio);
>> - of_node_put(mdio);
>> - snprintf(ug_info->phy_bus_id, sizeof(ug_info->phy_bus_id),
>> - "%s:%02x", bus_name, *prop);
>> }
>> + ug_info->phy_node = phy;
>>
>> /* get the phy interface type, or default to MII */
>> prop = of_get_property(np, "phy-connection-type", NULL);
>> if (!prop) {
>> /* handle interface property present in old trees */
>> + if (!phy)
>> + return -ENODEV;
>
> .. here an error is returned. Is this intentional?
Yes, I did that intentionally because it looked like a bug to me
because of_get_property() is passed the phy value. However, I suppose
that if phy is null then of_get_property will just return NULL, so I
think I made a mistake. I'll post a patch to remove these two lines.
g.
>
>> +
>> prop = of_get_property(phy, "interface", NULL);
>> if (prop != NULL) {
>> phy_interface = enet_to_phy_interface[*prop];
>> diff --git a/drivers/net/ucc_geth.h b/drivers/net/ucc_geth.h
>> index 2f8ee7c..bc31975 100644
>> --- a/drivers/net/ucc_geth.h
>> +++ b/drivers/net/ucc_geth.h
>> @@ -1100,7 +1100,7 @@ struct ucc_geth_info {
>> u32 eventRegMask;
>> u16 pausePeriod;
>> u16 extensionField;
>> - char phy_bus_id[BUS_ID_SIZE];
>> + struct device_node *phy_node;
>> u8 weightfactor[NUM_TX_QUEUES];
>> u8 interruptcoalescingmaxvalue[NUM_RX_QUEUES];
>> u8 l2qt[UCC_GETH_VLAN_PRIORITY_MAX];
>>
>> _______________________________________________
>> Linuxppc-dev mailing list
>> Linuxppc-dev@ozlabs.org
>> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>>
>>
>
>
--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
next prev parent reply other threads:[~2009-04-27 15:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-25 22:52 [PATCH 00/13] OF device tree handling of PHY drivers Grant Likely
2009-04-25 22:52 ` [PATCH v3 01/13] of: add of_parse_phandle() helper for parsing phandle properties Grant Likely
2009-04-25 22:52 ` [PATCH v3 02/13] phylib: rework to prepare for OF registration of PHYs Grant Likely
2009-04-25 22:52 ` [PATCH v3 03/13] phylib: add *_direct() variants of phy_connect and phy_attach functions Grant Likely
2009-04-25 22:52 ` [PATCH v3 04/13] openfirmware: Add OF phylib support code Grant Likely
2009-04-25 22:53 ` [PATCH v3 05/13] net: Rework mpc5200 fec driver to use of_mdio infrastructure Grant Likely
2009-04-25 22:53 ` [PATCH v3 06/13] net: rework fsl_pq_mdio " Grant Likely
2009-04-25 22:53 ` [PATCH v3 07/13] net: Rework gianfar " Grant Likely
2009-04-25 22:53 ` [PATCH v3 08/13] net: Rework pasemi_mac " Grant Likely
2009-04-25 22:53 ` [PATCH v3 09/13] net: Rework ucc_geth " Grant Likely
2009-04-26 9:00 ` Joakim Tjernlund
2009-04-27 15:36 ` Grant Likely [this message]
2009-04-25 22:53 ` [PATCH v3 10/13] powerpc/82xx: Rework Embedded Planet ep8248e platform to use of_mdio Grant Likely
2009-04-25 22:53 ` [PATCH v3 11/13] net: Rework fs_enet driver to use of_mdio infrastructure Grant Likely
2009-04-25 22:53 ` [PATCH v3 12/13] net: add Xilinx ll_temac device driver Grant Likely
2009-04-25 22:53 ` [PATCH v3 13/13] net: fix fsl_pq_mdio driver to use module_init() Grant Likely
2009-04-27 9:54 ` [PATCH 00/13] OF device tree handling of PHY drivers David Miller
2009-04-27 13:07 ` Grant Likely
2009-04-27 17:17 ` Grant Likely
2009-05-04 23:14 ` Scott Wood
2009-05-05 1:55 ` Grant Likely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fa686aa40904270836v352b7d24sb5798ca95d71ccd@mail.gmail.com \
--to=grant.likely@secretlab.ca \
--cc=Joakim.Tjernlund@transmode.se \
--cc=afleming@freescale.com \
--cc=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=linuxppc-dev-bounces+joakim.tjernlund=transmode.se@ozlabs.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).