From: Andrew Lunn <andrew@lunn.ch>
To: Raghuram Chary J <raghuramchary.jallipalli@microchip.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org,
unglinuxdriver@microchip.com, woojung.huh@microchip.com
Subject: Re: [PATCH net-next] lan78xx: Lan7801 Support for Fixed PHY
Date: Mon, 23 Apr 2018 14:42:03 +0200 [thread overview]
Message-ID: <20180423124203.GC25919@lunn.ch> (raw)
In-Reply-To: <20180423044630.2672-1-raghuramchary.jallipalli@microchip.com>
> #define DRIVER_AUTHOR "WOOJUNG HUH <woojung.huh@microchip.com>"
> #define DRIVER_DESC "LAN78XX USB 3.0 Gigabit Ethernet Devices"
> #define DRIVER_NAME "lan78xx"
> -#define DRIVER_VERSION "1.0.6"
> +#define DRIVER_VERSION "1.0.7"
Hi Raghuram
Driver version strings a pretty pointless. You might want to remove
it.
>
> #define TX_TIMEOUT_JIFFIES (5 * HZ)
> #define THROTTLE_JIFFIES (HZ / 8)
> @@ -426,6 +426,7 @@ struct lan78xx_net {
> struct statstage stats;
>
> struct irq_domain_data domain_data;
> + struct phy_device *fixedphy;
> };
>
> /* define external phy id */
> @@ -2062,11 +2063,39 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)
> int ret;
> u32 mii_adv;
> struct phy_device *phydev;
> + struct fixed_phy_status fphy_status = {
> + .link = 1,
> + .speed = SPEED_1000,
> + .duplex = DUPLEX_FULL,
> + };
>
> phydev = phy_find_first(dev->mdiobus);
> if (!phydev) {
> - netdev_err(dev->net, "no PHY found\n");
> - return -EIO;
> + if (dev->chipid == ID_REV_CHIP_ID_7801_) {
> + u32 buf;
> +
> + netdev_info(dev->net, "PHY Not Found!! Registering Fixed PHY\n");
> + phydev = fixed_phy_register(PHY_POLL, &fphy_status, -1,
> + NULL);
> + if (IS_ERR(phydev)) {
> + netdev_err(dev->net, "No PHY/fixed_PHY found\n");
> + return -ENODEV;
> + }
> + netdev_info(dev->net, "Registered FIXED PHY\n");
There are too many detdev_info() messages here. Maybe make them both
netdev_dbg().
> + dev->interface = PHY_INTERFACE_MODE_RGMII;
> + dev->fixedphy = phydev;
You can use
if (!phy_is_pseudo_fixed_link(phydev))
to determine is a PHY is a fixed phy. I think you can then do without
dev->fixedphy.
> + ret = lan78xx_write_reg(dev, MAC_RGMII_ID,
> + MAC_RGMII_ID_TXC_DELAY_EN_);
> + ret = lan78xx_write_reg(dev, RGMII_TX_BYP_DLL, 0x3D00);
> + ret = lan78xx_read_reg(dev, HW_CFG, &buf);
> + buf |= HW_CFG_CLK125_EN_;
> + buf |= HW_CFG_REFCLK25_EN_;
> + ret = lan78xx_write_reg(dev, HW_CFG, buf);
> + goto phyinit;
Please don't use a goto like this. Maybe turn this into a switch statement?
> + } else {
> + netdev_err(dev->net, "no PHY found\n");
> + return -EIO;
> + }
> }
>
> if ((dev->chipid == ID_REV_CHIP_ID_7800_) ||
> @@ -2105,6 +2134,7 @@ static int lan78xx_phy_init(struct lan78xx_net *dev)
> goto error;
Please take a look at what happens at error: It does not look
correct. Probably now is a good time to refactor the whole of lan78xx_phy_init()
Andrew
next prev parent reply other threads:[~2018-04-23 12:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-23 4:46 [PATCH net-next] lan78xx: Lan7801 Support for Fixed PHY Raghuram Chary J
2018-04-23 12:42 ` Andrew Lunn [this message]
2018-04-25 5:21 ` RaghuramChary.Jallipalli
2018-04-25 12:39 ` Andrew Lunn
2018-04-25 17:04 ` RaghuramChary.Jallipalli
2018-04-25 17:36 ` Florian Fainelli
2018-04-25 19:05 ` RaghuramChary.Jallipalli
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=20180423124203.GC25919@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=raghuramchary.jallipalli@microchip.com \
--cc=unglinuxdriver@microchip.com \
--cc=woojung.huh@microchip.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.