linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antoine Tenart <antoine.tenart@bootlin.com>
To: davem@davemloft.net, andrew@lunn.ch, f.fainelli@gmail.com,
	hkallweit1@gmail.com, richardcochran@gmail.com,
	alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	thomas.petazzoni@bootlin.com, allan.nielsen@microchip.com,
	foss@0leil.net, antoine.tenart@bootlin.com
Subject: [PATCH net-next 1/8] net: phy: add support for a common probe between shared PHYs
Date: Wed, 27 May 2020 18:41:51 +0200	[thread overview]
Message-ID: <20200527164158.313025-2-antoine.tenart@bootlin.com> (raw)
In-Reply-To: <20200527164158.313025-1-antoine.tenart@bootlin.com>

Shared PHYs (PHYs in the same hardware package) may have shared
registers and their drivers would usually need to share information.
There is currently a way to have a shared (part of the) init, by using
phy_package_init_once(). This patch extends the logic to share parts of
the probe to allow sharing the initialization of locks or resources
retrieval.

Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
---
 include/linux/phy.h | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/include/linux/phy.h b/include/linux/phy.h
index 8c05d0fb5c00..058219b6441f 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -244,7 +244,8 @@ struct phy_package_shared {
 };
 
 /* used as bit number in atomic bitops */
-#define PHY_SHARED_F_INIT_DONE 0
+#define PHY_SHARED_F_INIT_DONE  0
+#define PHY_SHARED_F_PROBE_DONE 1
 
 /*
  * The Bus class for PHYs.  Devices which provide access to
@@ -1554,14 +1555,25 @@ static inline int __phy_package_write(struct phy_device *phydev,
 	return __mdiobus_write(phydev->mdio.bus, shared->addr, regnum, val);
 }
 
-static inline bool phy_package_init_once(struct phy_device *phydev)
+static inline 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(PHY_SHARED_F_INIT_DONE, &shared->flags);
+	return !test_and_set_bit(b, &shared->flags);
+}
+
+static inline bool phy_package_init_once(struct phy_device *phydev)
+{
+	return __phy_package_set_once(phydev, PHY_SHARED_F_INIT_DONE);
+}
+
+static inline bool phy_package_probe_once(struct phy_device *phydev)
+{
+	return __phy_package_set_once(phydev, PHY_SHARED_F_PROBE_DONE);
 }
 
 extern struct bus_type mdio_bus_type;
-- 
2.26.2


  reply	other threads:[~2020-05-27 16:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27 16:41 [PATCH net-next 0/8] net: phy: mscc: PHC and timestamping support Antoine Tenart
2020-05-27 16:41 ` Antoine Tenart [this message]
2020-05-27 16:41 ` [PATCH net-next 2/8] net: phy: mscc: fix copyright and author information in MACsec Antoine Tenart
2020-05-27 16:41 ` [PATCH net-next 3/8] net: phy: mscc: remove the TR CLK disable magic value Antoine Tenart
2020-05-27 16:41 ` [PATCH net-next 4/8] net: phy: mscc: take into account the 1588 block in MACsec init Antoine Tenart
2020-05-27 16:41 ` [PATCH net-next 5/8] net: phy: mscc: 1588 block initialization Antoine Tenart
2020-05-27 17:35   ` Jakub Kicinski
2020-05-28  6:57     ` Antoine Tenart
2020-05-27 22:04   ` kbuild test robot
2020-05-27 16:41 ` [PATCH net-next 6/8] net: phy: mscc: timestamping and PHC support Antoine Tenart
2020-05-28 14:34   ` Richard Cochran
2020-05-28 15:23     ` Antoine Tenart
2020-05-27 16:41 ` [PATCH net-next 7/8] dt-bindings: net: phy: vsc8531: document the load/save GPIO Antoine Tenart
2020-05-27 16:41 ` [PATCH net-next 8/8] MIPS: dts: ocelot: describe " Antoine Tenart

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=20200527164158.313025-2-antoine.tenart@bootlin.com \
    --to=antoine.tenart@bootlin.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=allan.nielsen@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=foss@0leil.net \
    --cc=hkallweit1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=thomas.petazzoni@bootlin.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).