Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit da4625ac authored by Russell King's avatar Russell King Committed by David S. Miller
Browse files

net: phy: split out PHY speed and duplex string generation



Other code would like to make use of this, so make the speed and duplex
string generation visible, and place it in a separate file.

Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c3ecbe75
Loading
Loading
Loading
Loading
+49 −0
Original line number Original line Diff line number Diff line
@@ -9,6 +9,55 @@
#include <linux/export.h>
#include <linux/export.h>
#include <linux/phy.h>
#include <linux/phy.h>


const char *phy_speed_to_str(int speed)
{
	switch (speed) {
	case SPEED_10:
		return "10Mbps";
	case SPEED_100:
		return "100Mbps";
	case SPEED_1000:
		return "1Gbps";
	case SPEED_2500:
		return "2.5Gbps";
	case SPEED_5000:
		return "5Gbps";
	case SPEED_10000:
		return "10Gbps";
	case SPEED_14000:
		return "14Gbps";
	case SPEED_20000:
		return "20Gbps";
	case SPEED_25000:
		return "25Gbps";
	case SPEED_40000:
		return "40Gbps";
	case SPEED_50000:
		return "50Gbps";
	case SPEED_56000:
		return "56Gbps";
	case SPEED_100000:
		return "100Gbps";
	case SPEED_UNKNOWN:
		return "Unknown";
	default:
		return "Unsupported (update phy-core.c)";
	}
}
EXPORT_SYMBOL_GPL(phy_speed_to_str);

const char *phy_duplex_to_str(unsigned int duplex)
{
	if (duplex == DUPLEX_HALF)
		return "Half";
	if (duplex == DUPLEX_FULL)
		return "Full";
	if (duplex == DUPLEX_UNKNOWN)
		return "Unknown";
	return "Unsupported (update phy-core.c)";
}
EXPORT_SYMBOL_GPL(phy_duplex_to_str);

static void mmd_phy_indirect(struct mii_bus *bus, int phy_addr, int devad,
static void mmd_phy_indirect(struct mii_bus *bus, int phy_addr, int devad,
			     u16 regnum)
			     u16 regnum)
{
{
+1 −37
Original line number Original line Diff line number Diff line
@@ -38,42 +38,6 @@


#include <asm/irq.h>
#include <asm/irq.h>


static const char *phy_speed_to_str(int speed)
{
	switch (speed) {
	case SPEED_10:
		return "10Mbps";
	case SPEED_100:
		return "100Mbps";
	case SPEED_1000:
		return "1Gbps";
	case SPEED_2500:
		return "2.5Gbps";
	case SPEED_5000:
		return "5Gbps";
	case SPEED_10000:
		return "10Gbps";
	case SPEED_14000:
		return "14Gbps";
	case SPEED_20000:
		return "20Gbps";
	case SPEED_25000:
		return "25Gbps";
	case SPEED_40000:
		return "40Gbps";
	case SPEED_50000:
		return "50Gbps";
	case SPEED_56000:
		return "56Gbps";
	case SPEED_100000:
		return "100Gbps";
	case SPEED_UNKNOWN:
		return "Unknown";
	default:
		return "Unsupported (update phy.c)";
	}
}

#define PHY_STATE_STR(_state)			\
#define PHY_STATE_STR(_state)			\
	case PHY_##_state:			\
	case PHY_##_state:			\
		return __stringify(_state);	\
		return __stringify(_state);	\
@@ -109,7 +73,7 @@ void phy_print_status(struct phy_device *phydev)
		netdev_info(phydev->attached_dev,
		netdev_info(phydev->attached_dev,
			"Link is Up - %s/%s - flow control %s\n",
			"Link is Up - %s/%s - flow control %s\n",
			phy_speed_to_str(phydev->speed),
			phy_speed_to_str(phydev->speed),
			DUPLEX_FULL == phydev->duplex ? "Full" : "Half",
			phy_duplex_to_str(phydev->duplex),
			phydev->pause ? "rx/tx" : "off");
			phydev->pause ? "rx/tx" : "off");
	} else	{
	} else	{
		netdev_info(phydev->attached_dev, "Link is Down\n");
		netdev_info(phydev->attached_dev, "Link is Down\n");
+3 −0
Original line number Original line Diff line number Diff line
@@ -667,6 +667,9 @@ struct phy_fixup {
	int (*run)(struct phy_device *phydev);
	int (*run)(struct phy_device *phydev);
};
};


const char *phy_speed_to_str(int speed);
const char *phy_duplex_to_str(unsigned int duplex);

/**
/**
 * phy_read_mmd - Convenience function for reading a register
 * phy_read_mmd - Convenience function for reading a register
 * from an MMD on a given PHY.
 * from an MMD on a given PHY.