All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Calvin Johnson <calvin.johnson@oss.nxp.com>
Cc: linux.cj@gmail.com, Jeremy Linton <jeremy.linton@arm.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Cristi Sovaiala <cristian.sovaiala@nxp.com>,
	Florin Laurentiu Chiculita <florinlaurentiu.chiculita@nxp.com>,
	Ioana Ciornei <ioana.ciornei@nxp.com>,
	Madalin Bucur <madalin.bucur@oss.nxp.com>,
	netdev@vger.kernel.org, Laurentiu Tudor <laurentiu.tudor@nxp.com>,
	linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Diana Madalina Craciun <diana.craciun@nxp.com>,
	linux-kernel@vger.kernel.org, Varun Sethi <V.Sethi@nxp.com>,
	Marcin Wojtas <mw@semihalf.com>,
	"Rajesh V . Bikkina" <rajesh.bikkina@nxp.com>,
	Pankaj Bansal <pankaj.bansal@nxp.com>,
	Makarand Pawagi <makarand.pawagi@nxp.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [RFC net-next PATCH v2 1/2] net/fsl: add ACPI support for mdio bus
Date: Sat, 18 Apr 2020 12:41:16 +0100	[thread overview]
Message-ID: <20200418114116.GU25745@shell.armlinux.org.uk> (raw)
In-Reply-To: <20200418105432.11233-2-calvin.johnson@oss.nxp.com>

On Sat, Apr 18, 2020 at 04:24:31PM +0530, Calvin Johnson wrote:
> @@ -241,18 +244,81 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum)
>  	return value;
>  }
>  
> +/* Extract the clause 22 phy ID from the compatible string of the form
> + * ethernet-phy-idAAAA.BBBB

This comment is incorrect.  What about clause 45 PHYs?

> + */
> +static int xgmac_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id)
> +{
> +	const char *cp;
> +	unsigned int upper, lower;
> +	int ret;
> +
> +	ret = fwnode_property_read_string(fwnode, "compatible", &cp);
> +	if (!ret) {
> +		if (sscanf(cp, "ethernet-phy-id%4x.%4x",
> +			   &upper, &lower) == 2) {
> +			*phy_id = ((upper & 0xFFFF) << 16) | (lower & 0xFFFF);
> +			return 0;
> +		}
> +	}
> +	return -EINVAL;
> +}
> +
> +static int xgmac_mdiobus_register_phy(struct mii_bus *bus,
> +				      struct fwnode_handle *child, u32 addr)
> +{
> +	struct phy_device *phy;
> +	bool is_c45 = false;
> +	int rc;
> +	const char *cp;
> +	u32 phy_id;
> +
> +	fwnode_property_read_string(child, "compatible", &cp);
> +	if (!strcmp(cp, "ethernet-phy-ieee802.3-c45"))
> +		is_c45 = true;
> +
> +	if (!is_c45 && !xgmac_get_phy_id(child, &phy_id))
> +		phy = phy_device_create(bus, addr, phy_id, 0, NULL);
> +	else
> +		phy = get_phy_device(bus, addr, is_c45);
> +	if (IS_ERR(phy))
> +		return PTR_ERR(phy);
> +
> +	phy->irq = bus->irq[addr];
> +
> +	/* Associate the fwnode with the device structure so it
> +	 * can be looked up later.
> +	 */
> +	phy->mdio.dev.fwnode = child;
> +
> +	/* All data is now stored in the phy struct, so register it */
> +	rc = phy_device_register(phy);
> +	if (rc) {
> +		phy_device_free(phy);
> +		fwnode_handle_put(child);
> +		return rc;
> +	}
> +
> +	dev_dbg(&bus->dev, "registered phy at address %i\n", addr);
> +
> +	return 0;

You seem to be duplicating the OF implementation in a private driver,
converting it to fwnode.  This is not how we develop the Linux kernel.
We fix subsystem problems by fixing the subsystems, not by throwing
what should be subsystem code into private drivers.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up

WARNING: multiple messages have this Message-ID (diff)
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Calvin Johnson <calvin.johnson@oss.nxp.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"Rajesh V . Bikkina" <rajesh.bikkina@nxp.com>,
	Madalin Bucur <madalin.bucur@oss.nxp.com>,
	netdev@vger.kernel.org, Pankaj Bansal <pankaj.bansal@nxp.com>,
	linux-kernel@vger.kernel.org,
	Jeremy Linton <jeremy.linton@arm.com>,
	Marcin Wojtas <mw@semihalf.com>,
	Diana Madalina Craciun <diana.craciun@nxp.com>,
	linux-acpi@vger.kernel.org,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Cristi Sovaiala <cristian.sovaiala@nxp.com>,
	Varun Sethi <V.Sethi@nxp.com>,
	linux.cj@gmail.com, Ioana Ciornei <ioana.ciornei@nxp.com>,
	Laurentiu Tudor <laurentiu.tudor@nxp.com>,
	Makarand Pawagi <makarand.pawagi@nxp.com>,
	"David S. Miller" <davem@davemloft.net>,
	linux-arm-kernel@lists.infradead.org,
	Florin Laurentiu Chiculita <florinlaurentiu.chiculita@nxp.com>
Subject: Re: [RFC net-next PATCH v2 1/2] net/fsl: add ACPI support for mdio bus
Date: Sat, 18 Apr 2020 12:41:16 +0100	[thread overview]
Message-ID: <20200418114116.GU25745@shell.armlinux.org.uk> (raw)
In-Reply-To: <20200418105432.11233-2-calvin.johnson@oss.nxp.com>

On Sat, Apr 18, 2020 at 04:24:31PM +0530, Calvin Johnson wrote:
> @@ -241,18 +244,81 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum)
>  	return value;
>  }
>  
> +/* Extract the clause 22 phy ID from the compatible string of the form
> + * ethernet-phy-idAAAA.BBBB

This comment is incorrect.  What about clause 45 PHYs?

> + */
> +static int xgmac_get_phy_id(struct fwnode_handle *fwnode, u32 *phy_id)
> +{
> +	const char *cp;
> +	unsigned int upper, lower;
> +	int ret;
> +
> +	ret = fwnode_property_read_string(fwnode, "compatible", &cp);
> +	if (!ret) {
> +		if (sscanf(cp, "ethernet-phy-id%4x.%4x",
> +			   &upper, &lower) == 2) {
> +			*phy_id = ((upper & 0xFFFF) << 16) | (lower & 0xFFFF);
> +			return 0;
> +		}
> +	}
> +	return -EINVAL;
> +}
> +
> +static int xgmac_mdiobus_register_phy(struct mii_bus *bus,
> +				      struct fwnode_handle *child, u32 addr)
> +{
> +	struct phy_device *phy;
> +	bool is_c45 = false;
> +	int rc;
> +	const char *cp;
> +	u32 phy_id;
> +
> +	fwnode_property_read_string(child, "compatible", &cp);
> +	if (!strcmp(cp, "ethernet-phy-ieee802.3-c45"))
> +		is_c45 = true;
> +
> +	if (!is_c45 && !xgmac_get_phy_id(child, &phy_id))
> +		phy = phy_device_create(bus, addr, phy_id, 0, NULL);
> +	else
> +		phy = get_phy_device(bus, addr, is_c45);
> +	if (IS_ERR(phy))
> +		return PTR_ERR(phy);
> +
> +	phy->irq = bus->irq[addr];
> +
> +	/* Associate the fwnode with the device structure so it
> +	 * can be looked up later.
> +	 */
> +	phy->mdio.dev.fwnode = child;
> +
> +	/* All data is now stored in the phy struct, so register it */
> +	rc = phy_device_register(phy);
> +	if (rc) {
> +		phy_device_free(phy);
> +		fwnode_handle_put(child);
> +		return rc;
> +	}
> +
> +	dev_dbg(&bus->dev, "registered phy at address %i\n", addr);
> +
> +	return 0;

You seem to be duplicating the OF implementation in a private driver,
converting it to fwnode.  This is not how we develop the Linux kernel.
We fix subsystem problems by fixing the subsystems, not by throwing
what should be subsystem code into private drivers.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-04-18 11:41 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-18 10:54 [RFC net-next PATCH v2 0/2] ACPI support for xgmac_mdio and dpaa2-mac drivers Calvin Johnson
2020-04-18 10:54 ` Calvin Johnson
2020-04-18 10:54 ` [RFC net-next PATCH v2 1/2] net/fsl: add ACPI support for mdio bus Calvin Johnson
2020-04-18 10:54   ` Calvin Johnson
2020-04-18 11:41   ` Russell King - ARM Linux admin [this message]
2020-04-18 11:41     ` Russell King - ARM Linux admin
2020-04-18 11:50     ` Andy Shevchenko
2020-04-18 11:50       ` Andy Shevchenko
2020-04-18 14:39     ` Andrew Lunn
2020-04-18 14:39       ` Andrew Lunn
2020-04-20 15:42     ` Calvin Johnson
2020-04-20 15:42       ` Calvin Johnson
2020-04-18 14:46   ` Andrew Lunn
2020-04-18 14:46     ` Andrew Lunn
2020-04-20 15:44     ` Calvin Johnson
2020-04-20 15:44       ` Calvin Johnson
2020-04-18 10:54 ` [RFC net-next PATCH v2 2/2] net: dpaa2-mac: Add ACPI support for DPAA2 MAC driver Calvin Johnson
2020-04-18 10:54   ` Calvin Johnson
2020-04-18 11:38   ` Russell King - ARM Linux admin
2020-04-18 11:38     ` Russell King - ARM Linux admin
2020-04-20 13:53     ` Calvin Johnson
2020-04-20 13:53       ` Calvin Johnson
2020-04-18 15:00   ` Andrew Lunn
2020-04-18 15:00     ` Andrew Lunn
2020-04-21 19:30   ` kbuild test robot
2020-04-22  4:15   ` kbuild test robot

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=20200418114116.GU25745@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=V.Sethi@nxp.com \
    --cc=andrew@lunn.ch \
    --cc=andy.shevchenko@gmail.com \
    --cc=calvin.johnson@oss.nxp.com \
    --cc=cristian.sovaiala@nxp.com \
    --cc=davem@davemloft.net \
    --cc=diana.craciun@nxp.com \
    --cc=f.fainelli@gmail.com \
    --cc=florinlaurentiu.chiculita@nxp.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=jeremy.linton@arm.com \
    --cc=laurentiu.tudor@nxp.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux.cj@gmail.com \
    --cc=madalin.bucur@oss.nxp.com \
    --cc=makarand.pawagi@nxp.com \
    --cc=mw@semihalf.com \
    --cc=netdev@vger.kernel.org \
    --cc=pankaj.bansal@nxp.com \
    --cc=rajesh.bikkina@nxp.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.