Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/49963 )
Change subject: device: correct code style ......................................................................
device: correct code style
Revise the following aspects to follow coreboot's coding style: - Drop braces for single-statement condition and loop bodies. - Use `__func__` to print the current function's name. - Reflow pointer dereferences to fit in a single line. - Adjust the `*` position in pointer variable declarations. - Drop unnecessary `else` statements.
BUG = N/A TEST = Build Compulab Intense-PC with secure oprom enabled
Change-Id: I780251d946d5bea97658476d61d25555ec768dfc Signed-off-by: Frans Hendriks fhendriks@eltan.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/49963 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Angel Pons th3fanbus@gmail.com --- M src/device/azalia_device.c M src/device/device.c M src/device/device_const.c M src/device/device_util.c M src/device/i2c_bus.c 5 files changed, 41 insertions(+), 46 deletions(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved
diff --git a/src/device/azalia_device.c b/src/device/azalia_device.c index e1899f1..e383821 100644 --- a/src/device/azalia_device.c +++ b/src/device/azalia_device.c @@ -174,9 +174,9 @@ reg32 |= HDA_ICII_BUSY | HDA_ICII_VALID; write32(base + HDA_ICII_REG, reg32);
- while (timeout--) { + while (timeout--) udelay(1); - } + timeout = 50; while (timeout--) { reg32 = read32(base + HDA_ICII_REG); diff --git a/src/device/device.c b/src/device/device.c index ffdfeac..fe1ced5 100644 --- a/src/device/device.c +++ b/src/device/device.c @@ -166,8 +166,8 @@
if (!curdev->ops || !curdev->ops->read_resources) { if (curdev->path.type != DEVICE_PATH_APIC) - printk(BIOS_ERR, "%s missing read_resources\n", - dev_path(curdev)); + printk(BIOS_ERR, "%s missing %s\n", + dev_path(curdev), __func__); continue; } post_log_path(curdev); @@ -178,8 +178,8 @@ read_resources(link); } post_log_clear(); - printk(BIOS_SPEW, "%s read_resources bus %d link: %d done\n", - dev_path(bus->dev), bus->secondary, bus->link_num); + printk(BIOS_SPEW, "%s %s bus %d link: %d done\n", + dev_path(bus->dev), __func__, bus->secondary, bus->link_num); }
struct device *vga_pri = NULL; @@ -210,11 +210,10 @@ "A bridge on the path doesn't support 16-bit VGA decoding!"); }
- if (dev->on_mainboard) { + if (dev->on_mainboard) vga_onboard = dev; - } else { + else vga = dev; - }
/* It isn't safe to enable all VGA cards. */ dev->command &= ~(PCI_COMMAND_MEMORY | PCI_COMMAND_IO); @@ -269,8 +268,8 @@ { struct device *curdev;
- printk(BIOS_SPEW, "%s assign_resources, bus %d link: %d\n", - dev_path(bus->dev), bus->secondary, bus->link_num); + printk(BIOS_SPEW, "%s %s, bus %d link: %d\n", + dev_path(bus->dev), __func__, bus->secondary, bus->link_num);
for (curdev = bus->children; curdev; curdev = curdev->sibling) { if (!curdev->enabled || !curdev->resource_list) @@ -285,8 +284,8 @@ curdev->ops->set_resources(curdev); } post_log_clear(); - printk(BIOS_SPEW, "%s assign_resources, bus %d link: %d\n", - dev_path(bus->dev), bus->secondary, bus->link_num); + printk(BIOS_SPEW, "%s %s, bus %d link: %d\n", + dev_path(bus->dev), __func__, bus->secondary, bus->link_num); }
/** diff --git a/src/device/device_const.c b/src/device/device_const.c index 5288a74..2ce76c6 100644 --- a/src/device/device_const.c +++ b/src/device/device_const.c @@ -9,7 +9,7 @@ #include <device/resource.h>
/** Linked list of ALL devices */ -DEVTREE_CONST struct device * DEVTREE_CONST all_devices = &dev_root; +DEVTREE_CONST struct device *DEVTREE_CONST all_devices = &dev_root;
/** * Given a PCI bus and a devfn number, find the device structure. diff --git a/src/device/device_util.c b/src/device/device_util.c index 0337fb2..71c281e 100644 --- a/src/device/device_util.c +++ b/src/device/device_util.c @@ -370,7 +370,8 @@ resource->next = NULL; tail = dev->resource_list; if (tail) { - while (tail->next) tail = tail->next; + while (tail->next) + tail = tail->next; tail->next = resource; } else { dev->resource_list = resource; @@ -555,7 +556,7 @@
/* If it is a subtractive resource recurse. */ if (res->flags & IORESOURCE_SUBTRACTIVE) { - struct bus * subbus; + struct bus *subbus; for (subbus = curdev->link_list; subbus; subbus = subbus->next) if (subbus->link_num @@ -604,11 +605,10 @@ return;
dev->enabled = enable; - if (dev->ops && dev->ops->enable) { + if (dev->ops && dev->ops->enable) dev->ops->enable(dev); - } else if (dev->chip_ops && dev->chip_ops->enable_dev) { + else if (dev->chip_ops && dev->chip_ops->enable_dev) dev->chip_ops->enable_dev(dev); - } }
void disable_children(struct bus *bus) @@ -814,7 +814,7 @@ buf, resource_type(resource), comment); }
-void show_all_devs_resources(int debug_level, const char* msg) +void show_all_devs_resources(int debug_level, const char *msg) { struct device *dev;
diff --git a/src/device/i2c_bus.c b/src/device/i2c_bus.c index a65cdad..93ec854 100644 --- a/src/device/i2c_bus.c +++ b/src/device/i2c_bus.c @@ -48,19 +48,17 @@ .len = sizeof(val), };
- const int ret = busdev->ops->ops_i2c_bus-> - transfer(busdev, &msg, 1); + const int ret = busdev->ops->ops_i2c_bus->transfer(busdev, &msg, 1); if (ret) return ret; else return val; } else if (busdev->ops->ops_smbus_bus->recv_byte) { return busdev->ops->ops_smbus_bus->recv_byte(dev); - } else { - printk(BIOS_ERR, "%s Missing ops_smbus_bus->recv_byte", - dev_path(busdev)); - return -1; } + + printk(BIOS_ERR, "%s Missing ops_smbus_bus->recv_byte", dev_path(busdev)); + return -1; }
int i2c_dev_writeb(struct device *const dev, uint8_t val) @@ -79,11 +77,11 @@ return busdev->ops->ops_i2c_bus->transfer(busdev, &msg, 1); } else if (busdev->ops->ops_smbus_bus->send_byte) { return busdev->ops->ops_smbus_bus->send_byte(dev, val); - } else { - printk(BIOS_ERR, "%s Missing ops_smbus_bus->send_byte", - dev_path(busdev)); - return -1; } + + printk(BIOS_ERR, "%s Missing ops_smbus_bus->send_byte", + dev_path(busdev)); + return -1; }
int i2c_dev_readb_at(struct device *const dev, uint8_t off) @@ -109,23 +107,21 @@ }, };
- const int ret = busdev->ops->ops_i2c_bus-> - transfer(busdev, msg, ARRAY_SIZE(msg)); + const int ret = busdev->ops->ops_i2c_bus->transfer(busdev, msg, + ARRAY_SIZE(msg)); if (ret) return ret; else return val; } else if (busdev->ops->ops_smbus_bus->read_byte) { return busdev->ops->ops_smbus_bus->read_byte(dev, off); - } else { - printk(BIOS_ERR, "%s Missing ops_smbus_bus->read_byte", - dev_path(busdev)); - return -1; } + + printk(BIOS_ERR, "%s Missing ops_smbus_bus->read_byte", dev_path(busdev)); + return -1; }
-int i2c_dev_writeb_at(struct device *const dev, - const uint8_t off, const uint8_t val) +int i2c_dev_writeb_at(struct device *const dev, const uint8_t off, const uint8_t val) { struct device *const busdev = i2c_busdev(dev); if (!busdev) @@ -142,15 +138,15 @@ return busdev->ops->ops_i2c_bus->transfer(busdev, &msg, 1); } else if (busdev->ops->ops_smbus_bus->write_byte) { return busdev->ops->ops_smbus_bus->write_byte(dev, off, val); - } else { - printk(BIOS_ERR, "%s Missing ops_smbus_bus->write_byte", - dev_path(busdev)); - return -1; } + + printk(BIOS_ERR, "%s Missing ops_smbus_bus->write_byte", + dev_path(busdev)); + return -1; }
-int i2c_dev_read_at16(struct device *const dev, - uint8_t *const buf, const size_t len, uint16_t off) +int i2c_dev_read_at16(struct device *const dev, uint8_t *const buf, const size_t len, + uint16_t off) { struct device *const busdev = i2c_busdev(dev); if (!busdev) @@ -173,8 +169,8 @@ };
write_be16(&off, off); - const int ret = busdev->ops->ops_i2c_bus->transfer( - busdev, msg, ARRAY_SIZE(msg)); + const int ret = busdev->ops->ops_i2c_bus->transfer(busdev, msg, + ARRAY_SIZE(msg)); if (ret) return ret; else