aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrans Hendriks <fhendriks@eltan.com>2021-02-01 11:44:37 +0100
committerPatrick Georgi <pgeorgi@google.com>2021-02-05 09:42:19 +0000
commita9caa50e8ac08338caf29c8452d624e316e07581 (patch)
tree444af3e557fa8444cf36d4aed3cf1dd1d16551c7
parent3d6d1075b2ba17a357143f518715a911e09b38ec (diff)
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>
-rw-r--r--src/device/azalia_device.c4
-rw-r--r--src/device/device.c21
-rw-r--r--src/device/device_const.c2
-rw-r--r--src/device/device_util.c12
-rw-r--r--src/device/i2c_bus.c48
5 files changed, 41 insertions, 46 deletions
diff --git a/src/device/azalia_device.c b/src/device/azalia_device.c
index e1899f13c0..e383821d55 100644
--- a/src/device/azalia_device.c
+++ b/src/device/azalia_device.c
@@ -174,9 +174,9 @@ static int wait_for_valid(u8 *base)
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 ffdfeac22c..fe1ced5805 100644
--- a/src/device/device.c
+++ b/src/device/device.c
@@ -166,8 +166,8 @@ static void read_resources(struct bus *bus)
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 @@ static void read_resources(struct bus *bus)
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 @@ static void set_vga_bridge_bits(void)
"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 @@ void assign_resources(struct bus *bus)
{
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 @@ void assign_resources(struct bus *bus)
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 5288a743b6..2ce76c61e5 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 0337fb2fb2..71c281e33e 100644
--- a/src/device/device_util.c
+++ b/src/device/device_util.c
@@ -370,7 +370,8 @@ struct resource *new_resource(struct device *dev, unsigned int index)
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 @@ void search_bus_resources(struct bus *bus, unsigned long type_mask,
/* 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 @@ void dev_set_enabled(struct device *dev, int enable)
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 @@ void show_one_resource(int debug_level, struct device *dev,
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 a65cdada89..93ec854cf8 100644
--- a/src/device/i2c_bus.c
+++ b/src/device/i2c_bus.c
@@ -48,19 +48,17 @@ int i2c_dev_readb(struct device *const dev)
.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 @@ int i2c_dev_writeb(struct device *const dev, uint8_t val)
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 @@ int i2c_dev_readb_at(struct device *const dev, uint8_t 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
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 @@ int i2c_dev_writeb_at(struct device *const dev,
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 @@ int i2c_dev_read_at16(struct device *const dev,
};
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