mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: mfe@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 4/6] usb: otg: maintain list of USB OTG controllers
Date: Wed, 28 Feb 2024 17:05:16 +0100	[thread overview]
Message-ID: <20240228160518.1589193-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240228160518.1589193-1-a.fatoum@pengutronix.de>

We register devices for OTG controllers only to associate a .mode device
parameter with them. Follow-up commits will need to refer to previously
registered OTG controllers, so let's register a bus type for them and
use it to maintain a list of controllers.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/usb/otg/otgdev.c | 11 +++++++++++
 include/linux/usb/usb.h  |  2 ++
 2 files changed, 13 insertions(+)

diff --git a/drivers/usb/otg/otgdev.c b/drivers/usb/otg/otgdev.c
index d0a1cecc85cf..e035c988af2d 100644
--- a/drivers/usb/otg/otgdev.c
+++ b/drivers/usb/otg/otgdev.c
@@ -63,6 +63,10 @@ static struct device otg_device = {
 	.id = DEVICE_ID_SINGLE,
 };
 
+struct bus_type otg_bus_type = {
+	.name = "usbotg" /* "otg" is already taken for the alias */
+};
+
 int usb_register_otg_device(struct device *parent,
 			    int (*set_mode)(void *ctx, enum usb_dr_mode mode), void *ctx)
 {
@@ -72,6 +76,7 @@ int usb_register_otg_device(struct device *parent,
 	otg = xzalloc(sizeof(*otg));
 	otg->dev.priv = otg;
 	otg->dev.parent = parent;
+	otg->dev.bus = &otg_bus_type;
 	otg->dev.id = DEVICE_ID_DYNAMIC;
 	dev_set_name(&otg->dev, "otg");
 
@@ -90,3 +95,9 @@ int usb_register_otg_device(struct device *parent,
 
 	return register_otg_device(&otg->dev, otg);
 }
+
+static int otg_bus_init(void)
+{
+	return bus_register(&otg_bus_type);
+}
+pure_initcall(otg_bus_init);
diff --git a/include/linux/usb/usb.h b/include/linux/usb/usb.h
index ffeceec88f9e..a611d19b4a17 100644
--- a/include/linux/usb/usb.h
+++ b/include/linux/usb/usb.h
@@ -480,6 +480,8 @@ enum usb_device_speed of_usb_get_maximum_speed(struct device_node *np,
 int usb_register_otg_device(struct device *parent,
 			    int (*set_mode)(void *ctx, enum usb_dr_mode mode), void *ctx);
 
+extern struct bus_type otg_bus_type;
+
 extern struct list_head usb_device_list;
 
 bool usb_hub_is_root_hub(struct usb_device *hdev);
-- 
2.39.2




  parent reply	other threads:[~2024-02-28 16:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28 16:05 [PATCH 1/6] driver: make struct bus_type::match optional Ahmad Fatoum
2024-02-28 16:05 ` [PATCH 2/6] driver: make struct bus_type::probe optional Ahmad Fatoum
2024-02-28 16:05 ` [PATCH 3/6] treewide: remove bus probe functions that just call driver probe Ahmad Fatoum
2024-02-28 16:05 ` Ahmad Fatoum [this message]
2024-02-28 16:05 ` [PATCH 5/6] usb: otg: turn global otg device into device alias Ahmad Fatoum
2024-02-28 16:05 ` [PATCH 6/6] usb: print number of skipped OTG controllers when scanning Ahmad Fatoum
2024-02-29  8:10 ` [PATCH 1/6] driver: make struct bus_type::match optional 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=20240228160518.1589193-4-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=mfe@pengutronix.de \
    /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