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>
This commit is contained in:
parent
3d6d1075b2
commit
a9caa50e8a
5 changed files with 41 additions and 46 deletions
|
@ -174,9 +174,9 @@ static int wait_for_valid(u8 *base)
|
||||||
reg32 |= HDA_ICII_BUSY | HDA_ICII_VALID;
|
reg32 |= HDA_ICII_BUSY | HDA_ICII_VALID;
|
||||||
write32(base + HDA_ICII_REG, reg32);
|
write32(base + HDA_ICII_REG, reg32);
|
||||||
|
|
||||||
while (timeout--) {
|
while (timeout--)
|
||||||
udelay(1);
|
udelay(1);
|
||||||
}
|
|
||||||
timeout = 50;
|
timeout = 50;
|
||||||
while (timeout--) {
|
while (timeout--) {
|
||||||
reg32 = read32(base + HDA_ICII_REG);
|
reg32 = read32(base + HDA_ICII_REG);
|
||||||
|
|
|
@ -166,8 +166,8 @@ static void read_resources(struct bus *bus)
|
||||||
|
|
||||||
if (!curdev->ops || !curdev->ops->read_resources) {
|
if (!curdev->ops || !curdev->ops->read_resources) {
|
||||||
if (curdev->path.type != DEVICE_PATH_APIC)
|
if (curdev->path.type != DEVICE_PATH_APIC)
|
||||||
printk(BIOS_ERR, "%s missing read_resources\n",
|
printk(BIOS_ERR, "%s missing %s\n",
|
||||||
dev_path(curdev));
|
dev_path(curdev), __func__);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
post_log_path(curdev);
|
post_log_path(curdev);
|
||||||
|
@ -178,8 +178,8 @@ static void read_resources(struct bus *bus)
|
||||||
read_resources(link);
|
read_resources(link);
|
||||||
}
|
}
|
||||||
post_log_clear();
|
post_log_clear();
|
||||||
printk(BIOS_SPEW, "%s read_resources bus %d link: %d done\n",
|
printk(BIOS_SPEW, "%s %s bus %d link: %d done\n",
|
||||||
dev_path(bus->dev), bus->secondary, bus->link_num);
|
dev_path(bus->dev), __func__, bus->secondary, bus->link_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct device *vga_pri = NULL;
|
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!");
|
"A bridge on the path doesn't support 16-bit VGA decoding!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev->on_mainboard) {
|
if (dev->on_mainboard)
|
||||||
vga_onboard = dev;
|
vga_onboard = dev;
|
||||||
} else {
|
else
|
||||||
vga = dev;
|
vga = dev;
|
||||||
}
|
|
||||||
|
|
||||||
/* It isn't safe to enable all VGA cards. */
|
/* It isn't safe to enable all VGA cards. */
|
||||||
dev->command &= ~(PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
|
dev->command &= ~(PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
|
||||||
|
@ -269,8 +268,8 @@ void assign_resources(struct bus *bus)
|
||||||
{
|
{
|
||||||
struct device *curdev;
|
struct device *curdev;
|
||||||
|
|
||||||
printk(BIOS_SPEW, "%s assign_resources, bus %d link: %d\n",
|
printk(BIOS_SPEW, "%s %s, bus %d link: %d\n",
|
||||||
dev_path(bus->dev), bus->secondary, bus->link_num);
|
dev_path(bus->dev), __func__, bus->secondary, bus->link_num);
|
||||||
|
|
||||||
for (curdev = bus->children; curdev; curdev = curdev->sibling) {
|
for (curdev = bus->children; curdev; curdev = curdev->sibling) {
|
||||||
if (!curdev->enabled || !curdev->resource_list)
|
if (!curdev->enabled || !curdev->resource_list)
|
||||||
|
@ -285,8 +284,8 @@ void assign_resources(struct bus *bus)
|
||||||
curdev->ops->set_resources(curdev);
|
curdev->ops->set_resources(curdev);
|
||||||
}
|
}
|
||||||
post_log_clear();
|
post_log_clear();
|
||||||
printk(BIOS_SPEW, "%s assign_resources, bus %d link: %d\n",
|
printk(BIOS_SPEW, "%s %s, bus %d link: %d\n",
|
||||||
dev_path(bus->dev), bus->secondary, bus->link_num);
|
dev_path(bus->dev), __func__, bus->secondary, bus->link_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include <device/resource.h>
|
#include <device/resource.h>
|
||||||
|
|
||||||
/** Linked list of ALL devices */
|
/** 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.
|
* Given a PCI bus and a devfn number, find the device structure.
|
||||||
|
|
|
@ -370,7 +370,8 @@ struct resource *new_resource(struct device *dev, unsigned int index)
|
||||||
resource->next = NULL;
|
resource->next = NULL;
|
||||||
tail = dev->resource_list;
|
tail = dev->resource_list;
|
||||||
if (tail) {
|
if (tail) {
|
||||||
while (tail->next) tail = tail->next;
|
while (tail->next)
|
||||||
|
tail = tail->next;
|
||||||
tail->next = resource;
|
tail->next = resource;
|
||||||
} else {
|
} else {
|
||||||
dev->resource_list = resource;
|
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 it is a subtractive resource recurse. */
|
||||||
if (res->flags & IORESOURCE_SUBTRACTIVE) {
|
if (res->flags & IORESOURCE_SUBTRACTIVE) {
|
||||||
struct bus * subbus;
|
struct bus *subbus;
|
||||||
for (subbus = curdev->link_list; subbus;
|
for (subbus = curdev->link_list; subbus;
|
||||||
subbus = subbus->next)
|
subbus = subbus->next)
|
||||||
if (subbus->link_num
|
if (subbus->link_num
|
||||||
|
@ -604,11 +605,10 @@ void dev_set_enabled(struct device *dev, int enable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dev->enabled = enable;
|
dev->enabled = enable;
|
||||||
if (dev->ops && dev->ops->enable) {
|
if (dev->ops && dev->ops->enable)
|
||||||
dev->ops->enable(dev);
|
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);
|
dev->chip_ops->enable_dev(dev);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void disable_children(struct bus *bus)
|
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);
|
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;
|
struct device *dev;
|
||||||
|
|
||||||
|
|
|
@ -48,19 +48,17 @@ int i2c_dev_readb(struct device *const dev)
|
||||||
.len = sizeof(val),
|
.len = sizeof(val),
|
||||||
};
|
};
|
||||||
|
|
||||||
const int ret = busdev->ops->ops_i2c_bus->
|
const int ret = busdev->ops->ops_i2c_bus->transfer(busdev, &msg, 1);
|
||||||
transfer(busdev, &msg, 1);
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
else
|
else
|
||||||
return val;
|
return val;
|
||||||
} else if (busdev->ops->ops_smbus_bus->recv_byte) {
|
} else if (busdev->ops->ops_smbus_bus->recv_byte) {
|
||||||
return busdev->ops->ops_smbus_bus->recv_byte(dev);
|
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)
|
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);
|
return busdev->ops->ops_i2c_bus->transfer(busdev, &msg, 1);
|
||||||
} else if (busdev->ops->ops_smbus_bus->send_byte) {
|
} else if (busdev->ops->ops_smbus_bus->send_byte) {
|
||||||
return busdev->ops->ops_smbus_bus->send_byte(dev, val);
|
return busdev->ops->ops_smbus_bus->send_byte(dev, val);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
printk(BIOS_ERR, "%s Missing ops_smbus_bus->send_byte",
|
printk(BIOS_ERR, "%s Missing ops_smbus_bus->send_byte",
|
||||||
dev_path(busdev));
|
dev_path(busdev));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int i2c_dev_readb_at(struct device *const dev, uint8_t off)
|
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->
|
const int ret = busdev->ops->ops_i2c_bus->transfer(busdev, msg,
|
||||||
transfer(busdev, msg, ARRAY_SIZE(msg));
|
ARRAY_SIZE(msg));
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
else
|
else
|
||||||
return val;
|
return val;
|
||||||
} else if (busdev->ops->ops_smbus_bus->read_byte) {
|
} else if (busdev->ops->ops_smbus_bus->read_byte) {
|
||||||
return busdev->ops->ops_smbus_bus->read_byte(dev, off);
|
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,
|
int i2c_dev_writeb_at(struct device *const dev, const uint8_t off, const uint8_t val)
|
||||||
const uint8_t off, const uint8_t val)
|
|
||||||
{
|
{
|
||||||
struct device *const busdev = i2c_busdev(dev);
|
struct device *const busdev = i2c_busdev(dev);
|
||||||
if (!busdev)
|
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);
|
return busdev->ops->ops_i2c_bus->transfer(busdev, &msg, 1);
|
||||||
} else if (busdev->ops->ops_smbus_bus->write_byte) {
|
} else if (busdev->ops->ops_smbus_bus->write_byte) {
|
||||||
return busdev->ops->ops_smbus_bus->write_byte(dev, off, val);
|
return busdev->ops->ops_smbus_bus->write_byte(dev, off, val);
|
||||||
} else {
|
}
|
||||||
|
|
||||||
printk(BIOS_ERR, "%s Missing ops_smbus_bus->write_byte",
|
printk(BIOS_ERR, "%s Missing ops_smbus_bus->write_byte",
|
||||||
dev_path(busdev));
|
dev_path(busdev));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int i2c_dev_read_at16(struct device *const dev,
|
int i2c_dev_read_at16(struct device *const dev, uint8_t *const buf, const size_t len,
|
||||||
uint8_t *const buf, const size_t len, uint16_t off)
|
uint16_t off)
|
||||||
{
|
{
|
||||||
struct device *const busdev = i2c_busdev(dev);
|
struct device *const busdev = i2c_busdev(dev);
|
||||||
if (!busdev)
|
if (!busdev)
|
||||||
|
@ -173,8 +169,8 @@ int i2c_dev_read_at16(struct device *const dev,
|
||||||
};
|
};
|
||||||
|
|
||||||
write_be16(&off, off);
|
write_be16(&off, off);
|
||||||
const int ret = busdev->ops->ops_i2c_bus->transfer(
|
const int ret = busdev->ops->ops_i2c_bus->transfer(busdev, msg,
|
||||||
busdev, msg, ARRAY_SIZE(msg));
|
ARRAY_SIZE(msg));
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue