[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 10/23] usb: assert on calling usb_attach(port, NULL)
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 10/23] usb: assert on calling usb_attach(port, NULL) on a port without a dev |
Date: |
Fri, 8 Jul 2011 11:51:00 +0200 |
From: Hans de Goede <address@hidden>
with the "usb-ehci: cleanup port reset handling" patch in place no callers
are calling usb_attach(port, NULL) for a port where port->dev is NULL.
Doing that makes no sense as that causes the port detach op to get called
for a port with nothing attached. Add an assert that port->dev != NULL when
dev == NULL, and remove the check for not having a port->dev in the dev == NULL
case.
Signed-off-by: Hans de Goede <address@hidden>
Signed-off-by: Gerd Hoffmann <address@hidden>
---
hw/usb.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/hw/usb.c b/hw/usb.c
index 735ffd1..27a983c 100644
--- a/hw/usb.c
+++ b/hw/usb.c
@@ -40,12 +40,11 @@ void usb_attach(USBPort *port, USBDevice *dev)
} else {
/* detach */
dev = port->dev;
+ assert(dev);
port->ops->detach(port);
- if (dev) {
- usb_send_msg(dev, USB_MSG_DETACH);
- dev->port = NULL;
- port->dev = NULL;
- }
+ usb_send_msg(dev, USB_MSG_DETACH);
+ dev->port = NULL;
+ port->dev = NULL;
}
}
--
1.7.1
- [Qemu-devel] [PULL] usb patch queue, Gerd Hoffmann, 2011/07/08
- [Qemu-devel] [PATCH 03/23] usb: Move (initial) call of usb_port_location to usb_fill_port, Gerd Hoffmann, 2011/07/08
- [Qemu-devel] [PATCH 04/23] usb: Add a register_companion USB bus op., Gerd Hoffmann, 2011/07/08
- [Qemu-devel] [PATCH 02/23] usb: Add a usb_fill_port helper function, Gerd Hoffmann, 2011/07/08
- [Qemu-devel] [PATCH 10/23] usb: assert on calling usb_attach(port, NULL) on a port without a dev,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 09/23] usb-ehci: cleanup port reset handling, Gerd Hoffmann, 2011/07/08
- [Qemu-devel] [PATCH 08/23] usb-ehci: Connect Status bit is read only, don't allow changing it by the guest, Gerd Hoffmann, 2011/07/08
- [Qemu-devel] [PATCH 11/23] usb-ehci: Fix handling of PED and PEDC port status bits, Gerd Hoffmann, 2011/07/08
- [Qemu-devel] [PATCH 01/23] hw/usb-musb.c: Don't misuse usb_packet_complete(), Gerd Hoffmann, 2011/07/08
- [Qemu-devel] [PATCH 07/23] usb-ehci: drop unused num-ports state member, Gerd Hoffmann, 2011/07/08
- [Qemu-devel] [PATCH 05/23] usb: Make port wakeup and complete ops take a USBPort instead of a Device, Gerd Hoffmann, 2011/07/08
- [Qemu-devel] [PATCH 14/23] usb-ohci: Add support for being a companion controller, Gerd Hoffmann, 2011/07/08
- [Qemu-devel] [PATCH 13/23] usb-uhci: Add support for being a companion controller, Gerd Hoffmann, 2011/07/08
- [Qemu-devel] [PATCH 06/23] usb: Replace device_destroy bus op with a child_detach port op, Gerd Hoffmann, 2011/07/08
- [Qemu-devel] [PATCH 12/23] usb-ehci: Add support for registering companion controllers, Gerd Hoffmann, 2011/07/08