libpayload: usb: Fix spacing issues

Found by:
find payloads/libpayload/drivers/usb -type f -name "*.[ch]" | xargs \
util/lint/checkpatch.pl --types SPACING -q --fix-inplace -f

Change-Id: Id23e2e573e475c6d795812a4b2df9aeffbcaaaf4
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/66596
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Yidi Lin
2022-08-10 14:59:18 +08:00
committed by Martin Roth
parent ad6b27e9ef
commit 5ef258b3f6
24 changed files with 623 additions and 623 deletions

View File

@@ -39,7 +39,7 @@ typedef struct {
#define RH_INST(dev) ((rh_inst_t*)(dev)->data)
static void
uhci_rh_enable_port (usbdev_t *dev, int port)
uhci_rh_enable_port(usbdev_t *dev, int port)
{
u16 value;
hci_t *controller = dev->controller;
@@ -57,10 +57,10 @@ uhci_rh_enable_port (usbdev_t *dev, int port)
uhci_reg_write16(controller, port,
uhci_reg_read16(controller, port) | 1 << 9); /* reset */
mdelay (30); // >10ms
mdelay(30); // >10ms
uhci_reg_write16(controller, port,
uhci_reg_read16(controller, port) & ~(1 << 9));
mdelay (1); // >5.3us per spec, <3ms because some devices make trouble
mdelay(1); // >5.3us per spec, <3ms because some devices make trouble
uhci_reg_write16(controller, port,
uhci_reg_read16(controller, port) | 1 << 2); /* enable */
@@ -68,7 +68,7 @@ uhci_rh_enable_port (usbdev_t *dev, int port)
/* TOTEST: how long to wait? 100ms for now */
int timeout = 200; /* time out after 200 * 500us == 100ms */
do {
value = uhci_reg_read16 (controller, port);
value = uhci_reg_read16(controller, port);
udelay(500); timeout--;
} while (((value & (1 << 2)) == 0) && (value & 0x01) && timeout);
if (!timeout)
@@ -77,7 +77,7 @@ uhci_rh_enable_port (usbdev_t *dev, int port)
/* disable root hub */
static void
uhci_rh_disable_port (usbdev_t *dev, int port)
uhci_rh_disable_port(usbdev_t *dev, int port)
{
hci_t *controller = dev->controller;
if (port == 1)
@@ -95,7 +95,7 @@ uhci_rh_disable_port (usbdev_t *dev, int port)
/* TOTEST: how long to wait? 100ms for now */
int timeout = 200; /* time out after 200 * 500us == 100ms */
do {
value = uhci_reg_read16 (controller, port);
value = uhci_reg_read16(controller, port);
udelay(500); timeout--;
} while (((value & (1 << 2)) != 0) && timeout);
if (!timeout)
@@ -103,7 +103,7 @@ uhci_rh_disable_port (usbdev_t *dev, int port)
}
static void
uhci_rh_scanport (usbdev_t *dev, int port)
uhci_rh_scanport(usbdev_t *dev, int port)
{
int portsc, offset;
if (port == 1) {
@@ -116,42 +116,42 @@ uhci_rh_scanport (usbdev_t *dev, int port)
usb_debug("Invalid port %d\n", port);
return;
}
int devno = RH_INST (dev)->port[offset];
int devno = RH_INST(dev)->port[offset];
if ((devno != -1) && (dev->controller->devices[devno] != 0)) {
usb_detach_device(dev->controller, devno);
RH_INST (dev)->port[offset] = -1;
RH_INST(dev)->port[offset] = -1;
}
uhci_reg_write16(dev->controller, portsc,
uhci_reg_read16(dev->controller, portsc) | (1 << 3) | (1 << 2)); // clear port state change, enable port
mdelay(100); // wait for signal to stabilize
if ((uhci_reg_read16 (dev->controller, portsc) & 1) != 0) {
if ((uhci_reg_read16(dev->controller, portsc) & 1) != 0) {
// device attached
uhci_rh_disable_port (dev, port);
uhci_rh_enable_port (dev, port);
uhci_rh_disable_port(dev, port);
uhci_rh_enable_port(dev, port);
usb_speed speed = ((uhci_reg_read16 (dev->controller, portsc) >> 8) & 1);
usb_speed speed = ((uhci_reg_read16(dev->controller, portsc) >> 8) & 1);
RH_INST (dev)->port[offset] = usb_attach_device(dev->controller, dev->address, portsc, speed);
RH_INST(dev)->port[offset] = usb_attach_device(dev->controller, dev->address, portsc, speed);
}
}
static int
uhci_rh_report_port_changes (usbdev_t *dev)
uhci_rh_report_port_changes(usbdev_t *dev)
{
u16 stored, real;
stored = (RH_INST (dev)->port[0] == -1);
real = ((uhci_reg_read16 (dev->controller, PORTSC1) & 1) == 0);
stored = (RH_INST(dev)->port[0] == -1);
real = ((uhci_reg_read16(dev->controller, PORTSC1) & 1) == 0);
if (stored != real) {
usb_debug("change on port 1\n");
return 1;
}
stored = (RH_INST (dev)->port[1] == -1);
real = ((uhci_reg_read16 (dev->controller, PORTSC2) & 1) == 0);
stored = (RH_INST(dev)->port[1] == -1);
real = ((uhci_reg_read16(dev->controller, PORTSC2) & 1) == 0);
if (stored != real) {
usb_debug("change on port 2\n");
return 2;
@@ -159,11 +159,11 @@ uhci_rh_report_port_changes (usbdev_t *dev)
// maybe detach+attach happened between two scans?
if ((uhci_reg_read16 (dev->controller, PORTSC1) & 2) > 0) {
if ((uhci_reg_read16(dev->controller, PORTSC1) & 2) > 0) {
usb_debug("possibly re-attached on port 1\n");
return 1;
}
if ((uhci_reg_read16 (dev->controller, PORTSC2) & 2) > 0) {
if ((uhci_reg_read16(dev->controller, PORTSC2) & 2) > 0) {
usb_debug("possibly re-attached on port 2\n");
return 2;
}
@@ -173,35 +173,35 @@ uhci_rh_report_port_changes (usbdev_t *dev)
}
static void
uhci_rh_destroy (usbdev_t *dev)
uhci_rh_destroy(usbdev_t *dev)
{
usb_detach_device (dev->controller, 1);
usb_detach_device (dev->controller, 2);
uhci_rh_disable_port (dev, 1);
uhci_rh_disable_port (dev, 2);
free (RH_INST (dev));
usb_detach_device(dev->controller, 1);
usb_detach_device(dev->controller, 2);
uhci_rh_disable_port(dev, 1);
uhci_rh_disable_port(dev, 2);
free(RH_INST(dev));
}
static void
uhci_rh_poll (usbdev_t *dev)
uhci_rh_poll(usbdev_t *dev)
{
int port;
while ((port = uhci_rh_report_port_changes (dev)) != -1)
uhci_rh_scanport (dev, port);
while ((port = uhci_rh_report_port_changes(dev)) != -1)
uhci_rh_scanport(dev, port);
}
void
uhci_rh_init (usbdev_t *dev)
uhci_rh_init(usbdev_t *dev)
{
dev->destroy = uhci_rh_destroy;
dev->poll = uhci_rh_poll;
uhci_rh_enable_port (dev, 1);
uhci_rh_enable_port (dev, 2);
dev->data = xmalloc (sizeof (rh_inst_t));
uhci_rh_enable_port(dev, 1);
uhci_rh_enable_port(dev, 2);
dev->data = xmalloc(sizeof(rh_inst_t));
RH_INST (dev)->port[0] = -1;
RH_INST (dev)->port[1] = -1;
RH_INST(dev)->port[0] = -1;
RH_INST(dev)->port[1] = -1;
/* we can set them here because a root hub _really_ shouldn't
appear elsewhere */