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:
committed by
Patrick Georgi
parent
3d6d1075b2
commit
a9caa50e8a
@@ -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
|
||||
|
Reference in New Issue
Block a user