soc/intel/{common,apollolake}: Add checks to handle negative values
Fix issues reported by coverity scan in the below files. src/soc/intel/common/block/i2c 1375440: Improper use of negative value 1375441: Improper use of negative value 1375444: Improper use of negative value src/soc/intel/apollolake/i2c.c 1375442: Unsigned compared against 0 Change-Id: Ic65400c934631e3dcd3aa664c24cb451616e7f4d Signed-off-by: Rizwan Qureshi <rizwan.qureshi@intel.com> Reviewed-on: https://review.coreboot.org/21875 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
b3e18c7a43
commit
7f72c64195
2 changed files with 8 additions and 2 deletions
|
@ -44,7 +44,7 @@ uintptr_t i2c_get_soc_early_base(unsigned int bus)
|
||||||
/* Convert I2C bus number to PCI device and function */
|
/* Convert I2C bus number to PCI device and function */
|
||||||
int i2c_soc_bus_to_devfn(unsigned int bus)
|
int i2c_soc_bus_to_devfn(unsigned int bus)
|
||||||
{
|
{
|
||||||
if (bus >= 0 && bus <= 3)
|
if (bus <= 3)
|
||||||
return PCI_DEVFN(PCH_DEV_SLOT_SIO1, bus);
|
return PCI_DEVFN(PCH_DEV_SLOT_SIO1, bus);
|
||||||
else if (bus >= 4 && bus <= 7)
|
else if (bus >= 4 && bus <= 7)
|
||||||
return PCI_DEVFN(PCH_DEV_SLOT_SIO2, (bus - 4));
|
return PCI_DEVFN(PCH_DEV_SLOT_SIO2, (bus - 4));
|
||||||
|
|
|
@ -96,9 +96,12 @@ static void lpss_i2c_dev_init(struct device *dev)
|
||||||
const struct lpss_i2c_bus_config *config;
|
const struct lpss_i2c_bus_config *config;
|
||||||
int bus = lpss_i2c_dev_to_bus(dev);
|
int bus = lpss_i2c_dev_to_bus(dev);
|
||||||
|
|
||||||
|
if (bus < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
config = i2c_get_soc_cfg(bus, dev);
|
config = i2c_get_soc_cfg(bus, dev);
|
||||||
|
|
||||||
if (!config || bus < 0)
|
if (!config)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lpss_i2c_init(bus, config);
|
lpss_i2c_init(bus, config);
|
||||||
|
@ -126,6 +129,9 @@ static void lpss_i2c_acpi_fill_ssdt(struct device *dev)
|
||||||
|
|
||||||
bus = lpss_i2c_dev_to_bus(dev);
|
bus = lpss_i2c_dev_to_bus(dev);
|
||||||
|
|
||||||
|
if (bus < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
bcfg = i2c_get_soc_cfg(bus, dev);
|
bcfg = i2c_get_soc_cfg(bus, dev);
|
||||||
|
|
||||||
if (!bcfg)
|
if (!bcfg)
|
||||||
|
|
Loading…
Reference in a new issue