[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 4/7] usb/ohci: Move a function next to where it is used
From: |
BALATON Zoltan |
Subject: |
[PATCH v2 4/7] usb/ohci: Move a function next to where it is used |
Date: |
Mon, 20 Feb 2023 19:15:07 +0100 (CET) |
The ohci_port_set_if_connected() function is only used by
ohci_port_set_status(), move next to it to have them at the same place.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/usb/hcd-ohci.c | 60 +++++++++++++++++++++++------------------------
1 file changed, 30 insertions(+), 30 deletions(-)
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index a2cdba4058..52fcfcd4ab 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1271,36 +1271,6 @@ void ohci_bus_stop(OHCIState *ohci)
timer_del(ohci->eof_timer);
}
-/*
- * Sets a flag in a port status reg but only set it if the port is connected.
- * If not set ConnectStatusChange flag. If flag is enabled return 1.
- */
-static int ohci_port_set_if_connected(OHCIState *ohci, int i, uint32_t val)
-{
- int ret = 1;
-
- /* writing a 0 has no effect */
- if (val == 0) {
- return 0;
- }
- /* If CurrentConnectStatus is cleared we set ConnectStatusChange */
- if (!(ohci->rhport[i].ctrl & OHCI_PORT_CCS)) {
- ohci->rhport[i].ctrl |= OHCI_PORT_CSC;
- if (ohci->rhstatus & OHCI_RHS_DRWE) {
- /* TODO: CSC is a wakeup event */
- }
- return 0;
- }
-
- if (ohci->rhport[i].ctrl & val) {
- ret = 0;
- }
- /* set the bit */
- ohci->rhport[i].ctrl |= val;
-
- return ret;
-}
-
/* Frame interval toggle is manipulated by the hcd only */
static void ohci_set_frame_interval(OHCIState *ohci, uint16_t val)
{
@@ -1422,6 +1392,36 @@ static void ohci_set_hub_status(OHCIState *ohci,
uint32_t val)
}
}
+/*
+ * Sets a flag in a port status reg but only set it if the port is connected.
+ * If not set ConnectStatusChange flag. If flag is enabled return 1.
+ */
+static int ohci_port_set_if_connected(OHCIState *ohci, int i, uint32_t val)
+{
+ int ret = 1;
+
+ /* writing a 0 has no effect */
+ if (val == 0) {
+ return 0;
+ }
+ /* If CurrentConnectStatus is cleared we set ConnectStatusChange */
+ if (!(ohci->rhport[i].ctrl & OHCI_PORT_CCS)) {
+ ohci->rhport[i].ctrl |= OHCI_PORT_CSC;
+ if (ohci->rhstatus & OHCI_RHS_DRWE) {
+ /* TODO: CSC is a wakeup event */
+ }
+ return 0;
+ }
+
+ if (ohci->rhport[i].ctrl & val) {
+ ret = 0;
+ }
+ /* set the bit */
+ ohci->rhport[i].ctrl |= val;
+
+ return ret;
+}
+
/* Set root hub port status */
static void ohci_port_set_status(OHCIState *ohci, int portnum, uint32_t val)
{
--
2.30.7
- [PATCH v2 0/7] OHCI changes, BALATON Zoltan, 2023/02/20
- [PATCH v2 3/7] usb/ohci: Code style fix missing braces and extra parenthesis, BALATON Zoltan, 2023/02/20
- [PATCH v2 6/7] usb/ohci: Implement resume on connection status change, BALATON Zoltan, 2023/02/20
- [PATCH v2 1/7] usb/ohci: Code style fix comments, BALATON Zoltan, 2023/02/20
- [PATCH v2 4/7] usb/ohci: Move a function next to where it is used,
BALATON Zoltan <=
- [PATCH v2 5/7] usb/ohci: Add trace points for register access, BALATON Zoltan, 2023/02/20
- [PATCH v2 2/7] usb/ohci: Code style fix white space errors, BALATON Zoltan, 2023/02/20
- [PATCH v2 7/7] hw/usb/hcd-ohci: Fix typo, BALATON Zoltan, 2023/02/20