Commit bd0fa860 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-phy-remove-fixed_phy_add-and-first-its-users'

Heiner Kallweit says:

====================
net: phy: remove fixed_phy_add and first its users

fixed_phy_add() has a number of problems/disadvantages:
- It uses phy address 0 w/o checking whether a fixed phy with this
  address exists already.
- A subsequent call to fixed_phy_register() would also use phy address 0,
  because fixed_phy_add() doesn't mark it as used.
- fixed_phy_add() is used from platform code, therefore requires that
  fixed phy code is built-in.

fixed_phy_add() has only two users
- coldfire/5272, using fec
- bcm47xx, using b44

So migrate fec and b44 to use fixed_phy_register_100fd(), afterwards
remove usage of fixed_phy_add() from the two platforms, and eventually
remove fixed_phy_add().
====================

Link: https://patch.msgid.link/0285fcb0-0fb5-4f6f-823c-7b6e85e28ba3@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 907c46ae 5de9ea1c
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
#include <linux/init.h>
#include <linux/io.h>
#include <linux/phy.h>
#include <linux/phy_fixed.h>
#include <asm/machdep.h>
#include <asm/coldfire.h>
#include <asm/mcfsim.h>
@@ -103,23 +102,9 @@ void __init config_BSP(char *commandp, int size)

/***************************************************************************/

/*
 * Some 5272 based boards have the FEC ethernet directly connected to
 * an ethernet switch. In this case we need to use the fixed phy type,
 * and we need to declare it early in boot.
 */
static const struct fixed_phy_status nettel_fixed_phy_status __initconst = {
	.link	= 1,
	.speed	= 100,
	.duplex	= 0,
};

/***************************************************************************/

static int __init init_BSP(void)
{
	m5272_uarts_init();
	fixed_phy_add(&nettel_fixed_phy_status);
	clkdev_add_table(m5272_clk_lookup, ARRAY_SIZE(m5272_clk_lookup));
	return 0;
}
+0 −7
Original line number Diff line number Diff line
@@ -256,12 +256,6 @@ static int __init bcm47xx_cpu_fixes(void)
}
arch_initcall(bcm47xx_cpu_fixes);

static const struct fixed_phy_status bcm47xx_fixed_phy_status __initconst = {
	.link	= 1,
	.speed	= SPEED_100,
	.duplex	= DUPLEX_FULL,
};

static int __init bcm47xx_register_bus_complete(void)
{
	switch (bcm47xx_bus_type) {
@@ -282,7 +276,6 @@ static int __init bcm47xx_register_bus_complete(void)
	bcm47xx_leds_register();
	bcm47xx_workarounds();

	fixed_phy_add(&bcm47xx_fixed_phy_status);
	return 0;
}
device_initcall(bcm47xx_register_bus_complete);
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ config B44
	select SSB
	select MII
	select PHYLIB
	select FIXED_PHY if BCM47XX
	help
	  If you have a network (Ethernet) controller of this type, say Y
	  or M here.
+20 −17
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <linux/ssb/ssb.h>
#include <linux/slab.h>
#include <linux/phy.h>
#include <linux/phy_fixed.h>

#include <linux/uaccess.h>
#include <asm/io.h>
@@ -2233,7 +2234,6 @@ static int b44_register_phy_one(struct b44 *bp)
	struct mii_bus *mii_bus;
	struct ssb_device *sdev = bp->sdev;
	struct phy_device *phydev;
	char bus_id[MII_BUS_ID_SIZE + 3];
	struct ssb_sprom *sprom = &sdev->bus->sprom;
	int err;

@@ -2260,27 +2260,26 @@ static int b44_register_phy_one(struct b44 *bp)
		goto err_out_mdiobus;
	}

	if (!mdiobus_is_registered_device(bp->mii_bus, bp->phy_addr) &&
	    (sprom->boardflags_lo & (B44_BOARDFLAG_ROBO | B44_BOARDFLAG_ADM))) {

	phydev = mdiobus_get_phy(bp->mii_bus, bp->phy_addr);
	if (!phydev &&
	    sprom->boardflags_lo & (B44_BOARDFLAG_ROBO | B44_BOARDFLAG_ADM)) {
		dev_info(sdev->dev,
			 "could not find PHY at %i, use fixed one\n",
			 bp->phy_addr);

		bp->phy_addr = 0;
		snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, "fixed-0",
			 bp->phy_addr);
	} else {
		snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, mii_bus->id,
			 bp->phy_addr);
		phydev = fixed_phy_register_100fd();
		if (!IS_ERR(phydev))
			bp->phy_addr = phydev->mdio.addr;
	}

	phydev = phy_connect(bp->dev, bus_id, &b44_adjust_link,
	if (IS_ERR_OR_NULL(phydev))
		err = -ENODEV;
	else
		err = phy_connect_direct(bp->dev, phydev, &b44_adjust_link,
					 PHY_INTERFACE_MODE_MII);
	if (IS_ERR(phydev)) {
	if (err) {
		dev_err(sdev->dev, "could not attach PHY at %i\n",
			bp->phy_addr);
		err = PTR_ERR(phydev);
		goto err_out_mdiobus_unregister;
	}

@@ -2293,7 +2292,6 @@ static int b44_register_phy_one(struct b44 *bp)
	linkmode_copy(phydev->advertising, phydev->supported);

	bp->old_link = 0;
	bp->phy_addr = phydev->mdio.addr;

	phy_attached_info(phydev);

@@ -2311,10 +2309,15 @@ static int b44_register_phy_one(struct b44 *bp)

static void b44_unregister_phy_one(struct b44 *bp)
{
	struct net_device *dev = bp->dev;
	struct mii_bus *mii_bus = bp->mii_bus;
	struct net_device *dev = bp->dev;
	struct phy_device *phydev;

	phydev = dev->phydev;

	phy_disconnect(dev->phydev);
	phy_disconnect(phydev);
	if (phy_is_pseudo_fixed_link(phydev))
		fixed_phy_unregister(phydev);
	mdiobus_unregister(mii_bus);
	mdiobus_free(mii_bus);
}
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ config FEC
	depends on PTP_1588_CLOCK_OPTIONAL
	select CRC32
	select PHYLIB
	select FIXED_PHY if M5272
	select PAGE_POOL
	imply PAGE_POOL_STATS
	imply NET_SELFTESTS
Loading