All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org, BALATON Zoltan <balaton@eik.bme.hu>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Huacai Chen" <chenhc@lemote.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	xen-devel@lists.xenproject.org,
	"Yoshinori Sato" <ysato@users.sourceforge.jp>,
	"Paul Durrant" <paul@xen.org>,
	"Magnus Damm" <magnus.damm@gmail.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	"Anthony Perard" <anthony.perard@citrix.com>,
	"Samuel Thibault" <samuel.thibault@ens-lyon.org>,
	"Leif Lindholm" <leif@nuviainc.com>,
	"Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Beniamino Galvani" <b.galvani@gmail.com>,
	"Niek Linnenbank" <nieklinnenbank@gmail.com>,
	qemu-arm@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Richard Henderson" <rth@twiddle.net>,
	"Radoslaw Biernacki" <radoslaw.biernacki@linaro.org>,
	"Igor Mitsyanko" <i.mitsyanko@gmail.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Paul Zimmerman" <pauldzim@gmail.com>,
	qemu-ppc@nongnu.org, "David Gibson" <david@gibson.dropbear.id.au>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH 18/26] hw/usb/bus: Add usb_get_port_path()
Date: Sat,  4 Jul 2020 16:49:35 +0200	[thread overview]
Message-ID: <20200704144943.18292-19-f4bug@amsat.org> (raw)
In-Reply-To: <20200704144943.18292-1-f4bug@amsat.org>

Refactor usb_get_full_dev_path() to take a 'want_full_path'
argument, and add usb_get_port_path() which returns a short
path.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/usb.h | 10 ++++++++++
 hw/usb/bus.c     | 18 +++++++++++++-----
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/include/hw/usb.h b/include/hw/usb.h
index 8c3bc920ff..7ea502d421 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -506,6 +506,16 @@ void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr);
 void usb_unregister_port(USBBus *bus, USBPort *port);
 void usb_claim_port(USBDevice *dev, Error **errp);
 void usb_release_port(USBDevice *dev);
+/**
+ * usb_get_port_path:
+ * @dev: the USB device
+ *
+ * The returned data must be released with g_free()
+ * when no longer required.
+ *
+ * Returns: a dynamically allocated pathname.
+ */
+char *usb_get_port_path(USBDevice *dev);
 void usb_device_attach(USBDevice *dev, Error **errp);
 int usb_device_detach(USBDevice *dev);
 void usb_check_attach(USBDevice *dev, Error **errp);
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index fad8194bf5..518e5b94ed 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -577,12 +577,10 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
                    dev->attached ? ", attached" : "");
 }
 
-static char *usb_get_full_dev_path(DeviceState *qdev)
+static char *usb_get_dev_path(USBDevice *dev, bool want_full_path)
 {
-    USBDevice *dev = USB_DEVICE(qdev);
-
-    if (dev->flags & (1 << USB_DEV_FLAG_FULL_PATH)) {
-        DeviceState *hcd = qdev->parent_bus->parent;
+    if (want_full_path && (dev->flags & (1 << USB_DEV_FLAG_FULL_PATH))) {
+        DeviceState *hcd = DEVICE(dev)->parent_bus->parent;
         char *id = qdev_get_dev_path(hcd);
 
         if (id) {
@@ -594,6 +592,16 @@ static char *usb_get_full_dev_path(DeviceState *qdev)
     return g_strdup(dev->port->path);
 }
 
+static char *usb_get_full_dev_path(DeviceState *qdev)
+{
+    return usb_get_dev_path(USB_DEVICE(qdev), true);
+}
+
+char *usb_get_port_path(USBDevice *dev)
+{
+    return usb_get_dev_path(dev, false);
+}
+
 static char *usb_get_fw_dev_path(DeviceState *qdev)
 {
     USBDevice *dev = USB_DEVICE(qdev);
-- 
2.21.3



WARNING: multiple messages have this Message-ID (diff)
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org, BALATON Zoltan <balaton@eik.bme.hu>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Huacai Chen" <chenhc@lemote.com>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	xen-devel@lists.xenproject.org,
	"Yoshinori Sato" <ysato@users.sourceforge.jp>,
	"Paul Durrant" <paul@xen.org>,
	"Magnus Damm" <magnus.damm@gmail.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Hervé Poussineau" <hpoussin@reactos.org>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Anthony Perard" <anthony.perard@citrix.com>,
	"Samuel Thibault" <samuel.thibault@ens-lyon.org>,
	"Leif Lindholm" <leif@nuviainc.com>,
	"Andrzej Zaborowski" <balrogg@gmail.com>,
	"Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
	"Beniamino Galvani" <b.galvani@gmail.com>,
	"Niek Linnenbank" <nieklinnenbank@gmail.com>,
	qemu-arm@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Richard Henderson" <rth@twiddle.net>,
	"Radoslaw Biernacki" <radoslaw.biernacki@linaro.org>,
	"Igor Mitsyanko" <i.mitsyanko@gmail.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Paul Zimmerman" <pauldzim@gmail.com>,
	qemu-ppc@nongnu.org, "David Gibson" <david@gibson.dropbear.id.au>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH 18/26] hw/usb/bus: Add usb_get_port_path()
Date: Sat,  4 Jul 2020 16:49:35 +0200	[thread overview]
Message-ID: <20200704144943.18292-19-f4bug@amsat.org> (raw)
In-Reply-To: <20200704144943.18292-1-f4bug@amsat.org>

Refactor usb_get_full_dev_path() to take a 'want_full_path'
argument, and add usb_get_port_path() which returns a short
path.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/usb.h | 10 ++++++++++
 hw/usb/bus.c     | 18 +++++++++++++-----
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/include/hw/usb.h b/include/hw/usb.h
index 8c3bc920ff..7ea502d421 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -506,6 +506,16 @@ void usb_port_location(USBPort *downstream, USBPort *upstream, int portnr);
 void usb_unregister_port(USBBus *bus, USBPort *port);
 void usb_claim_port(USBDevice *dev, Error **errp);
 void usb_release_port(USBDevice *dev);
+/**
+ * usb_get_port_path:
+ * @dev: the USB device
+ *
+ * The returned data must be released with g_free()
+ * when no longer required.
+ *
+ * Returns: a dynamically allocated pathname.
+ */
+char *usb_get_port_path(USBDevice *dev);
 void usb_device_attach(USBDevice *dev, Error **errp);
 int usb_device_detach(USBDevice *dev);
 void usb_check_attach(USBDevice *dev, Error **errp);
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index fad8194bf5..518e5b94ed 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -577,12 +577,10 @@ static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent)
                    dev->attached ? ", attached" : "");
 }
 
-static char *usb_get_full_dev_path(DeviceState *qdev)
+static char *usb_get_dev_path(USBDevice *dev, bool want_full_path)
 {
-    USBDevice *dev = USB_DEVICE(qdev);
-
-    if (dev->flags & (1 << USB_DEV_FLAG_FULL_PATH)) {
-        DeviceState *hcd = qdev->parent_bus->parent;
+    if (want_full_path && (dev->flags & (1 << USB_DEV_FLAG_FULL_PATH))) {
+        DeviceState *hcd = DEVICE(dev)->parent_bus->parent;
         char *id = qdev_get_dev_path(hcd);
 
         if (id) {
@@ -594,6 +592,16 @@ static char *usb_get_full_dev_path(DeviceState *qdev)
     return g_strdup(dev->port->path);
 }
 
+static char *usb_get_full_dev_path(DeviceState *qdev)
+{
+    return usb_get_dev_path(USB_DEVICE(qdev), true);
+}
+
+char *usb_get_port_path(USBDevice *dev)
+{
+    return usb_get_dev_path(dev, false);
+}
+
 static char *usb_get_fw_dev_path(DeviceState *qdev)
 {
     USBDevice *dev = USB_DEVICE(qdev);
-- 
2.21.3



  parent reply	other threads:[~2020-07-04 15:02 UTC|newest]

Thread overview: 127+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-04 14:49 [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Philippe Mathieu-Daudé
2020-07-04 14:49 ` Philippe Mathieu-Daudé
2020-07-04 14:49 ` [PATCH 01/26] hw/arm/sbsa-ref: Remove unused 'hw/usb.h' header Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 16:49   ` Alistair Francis
2020-07-06 16:49     ` Alistair Francis
2020-07-04 14:49 ` [PATCH 02/26] hw/ppc/sam460ex: Add missing 'hw/pci/pci.h' header Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-04 16:29   ` BALATON Zoltan
2020-07-06 16:50   ` Alistair Francis
2020-07-06 16:50     ` Alistair Francis
2020-07-04 14:49 ` [PATCH 03/26] hw/usb: Remove unused VM_USB_HUB_SIZE definition Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 16:51   ` Alistair Francis
2020-07-06 16:51     ` Alistair Francis
2020-07-04 14:49 ` [PATCH 04/26] hw/usb: Reduce 'exec/memory.h' inclusion Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 16:52   ` Alistair Francis
2020-07-06 16:52     ` Alistair Francis
2020-07-04 14:49 ` [PATCH 05/26] hw/usb/desc: Add missing header Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 16:55   ` Alistair Francis
2020-07-06 16:55     ` Alistair Francis
2020-07-04 14:49 ` [PATCH 06/26] hw/usb/hcd-dwc2: Remove unnecessary includes Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 16:54   ` Alistair Francis
2020-07-06 16:54     ` Alistair Francis
2020-07-06 23:28   ` Paul Zimmerman
2020-07-06 23:28     ` Paul Zimmerman
2020-07-04 14:49 ` [PATCH 07/26] hw/usb/hcd-dwc2: Restrict some headers to source Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 16:54   ` Alistair Francis
2020-07-06 16:54     ` Alistair Francis
2020-07-06 23:27   ` Paul Zimmerman
2020-07-06 23:27     ` Paul Zimmerman
2020-07-04 14:49 ` [PATCH 08/26] hw/usb/hcd-dwc2: Restrict 'dwc2-regs.h' scope Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 16:47   ` Alistair Francis
2020-07-06 16:47     ` Alistair Francis
2020-07-06 23:29   ` Paul Zimmerman
2020-07-06 23:29     ` Paul Zimmerman
2020-07-04 14:49 ` [PATCH 09/26] hw/usb/hcd-ehci: Remove unnecessary include Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 16:56   ` Alistair Francis
2020-07-06 16:56     ` Alistair Francis
2020-07-04 14:49 ` [PATCH 10/26] hw/usb/hcd-ehci: Move few definitions from header to source Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 17:00   ` Alistair Francis
2020-07-06 17:00     ` Alistair Francis
2020-07-04 14:49 ` [PATCH 11/26] hw/usb/hcd-xhci: Add missing header Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 16:57   ` Alistair Francis
2020-07-06 16:57     ` Alistair Francis
2020-07-04 14:49 ` [PATCH 12/26] hw/usb/hcd-musb: Restrict header scope Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 16:58   ` Alistair Francis
2020-07-06 16:58     ` Alistair Francis
2020-07-04 14:49 ` [PATCH 13/26] hw/usb/desc: Reduce some declarations scope Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 17:00   ` Alistair Francis
2020-07-06 17:00     ` Alistair Francis
2020-07-04 14:49 ` [PATCH 14/26] hw/usb/quirks: Rename included source with '.inc.c' suffix Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 17:02   ` Alistair Francis
2020-07-06 17:02     ` Alistair Francis
2020-07-04 14:49 ` [PATCH 15/26] hw/usb: Add new 'usb-quirks.h' local header Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 17:45   ` Alistair Francis
2020-07-06 17:45     ` Alistair Francis
2020-07-04 14:49 ` [PATCH 16/26] hw/usb/bus: Simplify usb_get_dev_path() Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 17:46   ` Alistair Francis
2020-07-06 17:46     ` Alistair Francis
2020-07-04 14:49 ` [PATCH 17/26] hw/usb/bus: Rename usb_get_dev_path() as usb_get_full_dev_path() Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-06 17:46   ` Alistair Francis
2020-07-06 17:46     ` Alistair Francis
2020-07-04 14:49 ` Philippe Mathieu-Daudé [this message]
2020-07-04 14:49   ` [PATCH 18/26] hw/usb/bus: Add usb_get_port_path() Philippe Mathieu-Daudé
2020-07-07  0:07   ` Alistair Francis
2020-07-07  0:07     ` Alistair Francis
2020-07-04 14:49 ` [PATCH 19/26] hw/ppc/spapr: Use usb_get_port_path() Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-07  0:07   ` Alistair Francis
2020-07-07  0:07     ` Alistair Francis
2020-07-04 14:49 ` [PATCH 20/26] hw/usb: Introduce "hw/usb/usb.h" public API Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-04 14:49 ` [PATCH 21/26] hw/usb: Move internal API to local 'usb-internal.h' header Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-04 14:49 ` [PATCH 22/26] hw/usb/usb-hcd: Use OHCI type definitions Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-04 17:13   ` BALATON Zoltan
2020-07-04 17:13     ` BALATON Zoltan
2020-07-04 18:09     ` Philippe Mathieu-Daudé
2020-07-04 18:09       ` Philippe Mathieu-Daudé
2020-07-05 19:55   ` Niek Linnenbank
2020-07-05 19:55     ` Niek Linnenbank
2020-07-04 14:49 ` [PATCH 23/26] hw/usb/usb-hcd: Use EHCI " Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-04 17:15   ` BALATON Zoltan
2020-07-04 17:15     ` BALATON Zoltan
2020-07-05  9:26     ` Philippe Mathieu-Daudé
2020-07-05  9:26       ` Philippe Mathieu-Daudé
2020-07-04 14:49 ` [PATCH 24/26] hw/usb/usb-hcd: Use UHCI " Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-04 17:17   ` BALATON Zoltan
2020-07-04 17:17     ` BALATON Zoltan
2020-07-04 18:12     ` Philippe Mathieu-Daudé
2020-07-04 18:12       ` Philippe Mathieu-Daudé
2020-07-04 19:44       ` BALATON Zoltan
2020-07-04 19:44         ` BALATON Zoltan
2020-07-04 19:49         ` Philippe Mathieu-Daudé
2020-07-04 19:49           ` Philippe Mathieu-Daudé
2020-07-05  5:37         ` Paolo Bonzini
2020-07-05  5:37           ` Paolo Bonzini
2020-07-04 14:49 ` [PATCH 25/26] hw/usb/usb-hcd: Use XHCI " Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-04 17:19   ` BALATON Zoltan
2020-07-04 17:19     ` BALATON Zoltan
2020-07-04 18:07     ` Philippe Mathieu-Daudé
2020-07-04 18:07       ` Philippe Mathieu-Daudé
2020-07-04 14:49 ` [PATCH 26/26] MAINTAINERS: Cover dwc-hsotg (dwc2) USB host controller emulation Philippe Mathieu-Daudé
2020-07-04 14:49   ` Philippe Mathieu-Daudé
2020-07-04 16:25   ` Paul Zimmerman
2020-07-04 16:25     ` Paul Zimmerman
2020-07-13  9:46 ` [PATCH 00/26] hw/usb: Give it love, reduce 'hw/usb.h' inclusion out of hw/usb/ Gerd Hoffmann
2020-07-13  9:46   ` Gerd Hoffmann

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=20200704144943.18292-19-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=aleksandar.rikalo@syrmia.com \
    --cc=alistair@alistair23.me \
    --cc=anthony.perard@citrix.com \
    --cc=armbru@redhat.com \
    --cc=b.galvani@gmail.com \
    --cc=balaton@eik.bme.hu \
    --cc=chenhc@lemote.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=dgilbert@redhat.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=ehabkost@redhat.com \
    --cc=hpoussin@reactos.org \
    --cc=i.mitsyanko@gmail.com \
    --cc=kraxel@redhat.com \
    --cc=leif@nuviainc.com \
    --cc=magnus.damm@gmail.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mst@redhat.com \
    --cc=nieklinnenbank@gmail.com \
    --cc=paul@xen.org \
    --cc=pauldzim@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=radoslaw.biernacki@linaro.org \
    --cc=rth@twiddle.net \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    --cc=ysato@users.sourceforge.jp \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.