Commit e7f984e9 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Jakub Kicinski
Browse files

net: phy: move PHY package related code from phy.h to phy_package.c



Move PHY package related inline functions from phy.h to phy_package.c.
While doing so remove locked versions phy_package_read() and
phy_package_write() which have no user.

Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Link: https://patch.msgid.link/a4518379-7a5d-45f3-831c-b7fde6512c65@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent e0327e9f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <linux/module.h>
#include <linux/phy.h>

#include "phylib.h"
#include "bcm-phy-lib.h"

/* RDB per-port registers
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#include <linux/of.h>
#include <linux/netdevice.h>
#include <dt-bindings/net/mscc-phy-vsc8531.h>

#include "../phylib.h"
#include "mscc_serdes.h"
#include "mscc.h"

+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
#include <linux/phy.h>
#include <linux/of.h>

#include "phylib.h"
#include "phylib-internal.h"

/**
+61 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
#include <linux/phy.h>

#include "phylib.h"
#include "phylib-internal.h"

struct device_node *phy_package_get_node(struct phy_device *phydev)
{
@@ -20,6 +21,66 @@ void *phy_package_get_priv(struct phy_device *phydev)
}
EXPORT_SYMBOL_GPL(phy_package_get_priv);

int phy_package_address(struct phy_device *phydev, unsigned int addr_offset)
{
	struct phy_package_shared *shared = phydev->shared;
	u8 base_addr = shared->base_addr;

	if (addr_offset >= PHY_MAX_ADDR - base_addr)
		return -EIO;

	/* we know that addr will be in the range 0..31 and thus the
	 * implicit cast to a signed int is not a problem.
	 */
	return base_addr + addr_offset;
}

int __phy_package_read(struct phy_device *phydev, unsigned int addr_offset,
		       u32 regnum)
{
	int addr = phy_package_address(phydev, addr_offset);

	if (addr < 0)
		return addr;

	return __mdiobus_read(phydev->mdio.bus, addr, regnum);
}
EXPORT_SYMBOL_GPL(__phy_package_read);

int __phy_package_write(struct phy_device *phydev, unsigned int addr_offset,
			u32 regnum, u16 val)
{
	int addr = phy_package_address(phydev, addr_offset);

	if (addr < 0)
		return addr;

	return __mdiobus_write(phydev->mdio.bus, addr, regnum, val);
}
EXPORT_SYMBOL_GPL(__phy_package_write);

static bool __phy_package_set_once(struct phy_device *phydev, unsigned int b)
{
	struct phy_package_shared *shared = phydev->shared;

	if (!shared)
		return false;

	return !test_and_set_bit(b, &shared->flags);
}

bool phy_package_init_once(struct phy_device *phydev)
{
	return __phy_package_set_once(phydev, 0);
}
EXPORT_SYMBOL_GPL(phy_package_init_once);

bool phy_package_probe_once(struct phy_device *phydev)
{
	return __phy_package_set_once(phydev, 1);
}
EXPORT_SYMBOL_GPL(phy_package_probe_once);

/**
 * phy_package_join - join a common PHY group
 * @phydev: target phy_device struct
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ void of_set_phy_timing_role(struct phy_device *phydev);
int phy_speed_down_core(struct phy_device *phydev);
void phy_check_downshift(struct phy_device *phydev);

int phy_package_address(struct phy_device *phydev, unsigned int addr_offset);

int genphy_c45_read_eee_adv(struct phy_device *phydev, unsigned long *adv);

#endif /* __PHYLIB_INTERNAL_H */
Loading