mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: [PATCH 2/3] phy: put phy devices in class
Date: Fri, 25 Oct 2024 10:49:00 +0200	[thread overview]
Message-ID: <20241025-phy-class-v1-2-24bf51365a08@pengutronix.de> (raw)
In-Reply-To: <20241025-phy-class-v1-0-24bf51365a08@pengutronix.de>

Collect all phy devices in their own class. Let's us list the phy
devices in the class command and gives us an iterator over phy devices
for free.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/phy/phy-core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
index c289e75c78..cd9b59f1fd 100644
--- a/drivers/phy/phy-core.c
+++ b/drivers/phy/phy-core.c
@@ -16,6 +16,10 @@
 static LIST_HEAD(phy_provider_list);
 static int phy_ida;
 
+#define for_each_phy(p) list_for_each_entry(p, &phy_class.devices, dev.class_list)
+
+DEFINE_DEV_CLASS(phy_class, "phy");
+
 /**
  * phy_create() - create a new phy
  * @dev: device that is creating the new phy
@@ -40,7 +44,6 @@ struct phy *phy_create(struct device *dev, struct device_node *node,
 
 	id = phy_ida++;
 
-	dev_set_name(&phy->dev, "phy");
 	phy->dev.id = id;
 	phy->dev.parent = dev;
 	phy->dev.of_node = node ?: dev->of_node;
@@ -57,7 +60,7 @@ struct phy *phy_create(struct device *dev, struct device_node *node,
 		phy->pwr = NULL;
 	}
 
-	ret = register_device(&phy->dev);
+	ret = class_register_device(&phy_class, &phy->dev, "phy");
 	if (ret)
 		goto free_ida;
 

-- 
2.39.5




  parent reply	other threads:[~2024-10-25  8:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-25  8:48 [PATCH 0/3] phy: some updates Sascha Hauer
2024-10-25  8:48 ` [PATCH 1/3] phy: make of_phandle_args constant Sascha Hauer
2024-10-25  8:49 ` Sascha Hauer [this message]
2024-10-25  8:49 ` [PATCH 3/3] phy: add of_phy_simple_xlate() Sascha Hauer
2024-10-28 12:12 ` [PATCH 0/3] phy: some updates Sascha Hauer

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=20241025-phy-class-v1-2-24bf51365a08@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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