From 5f25590fd430265e69190aaa50f019e8dadad293 Mon Sep 17 00:00:00 2001 From: Gavin Shan Date: Tue, 21 Jun 2016 14:08:35 +1000 Subject: platforms/ibm-fsp: Fix condition for valid slot In firenze_pci_slot_init(), i2c_alloc_req() can return NULL though it's very rare. We don't cover the case. If NULL I2C request returned from the function, the I2C dependent power management won't be used. This checks if i2c_alloc_req() returns valid I2C request or not. Suggested-by: Stewart Smith Signed-off-by: Gavin Shan Signed-off-by: Stewart Smith --- platforms/ibm-fsp/firenze-pci.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'platforms') diff --git a/platforms/ibm-fsp/firenze-pci.c b/platforms/ibm-fsp/firenze-pci.c index 4a9aff3..4416f1f 100644 --- a/platforms/ibm-fsp/firenze-pci.c +++ b/platforms/ibm-fsp/firenze-pci.c @@ -767,11 +767,12 @@ static void firenze_pci_slot_init(struct pci_slot *slot) plat_slot->i2c_bus = firenze_pci_find_i2c_bus(info->chip_id, info->master_id, info->port_id); - if (plat_slot->i2c_bus) { + if (plat_slot->i2c_bus) plat_slot->req = i2c_alloc_req(plat_slot->i2c_bus); - if (!plat_slot->req) - plat_slot->i2c_bus = NULL; + else + plat_slot->req = NULL; + if (plat_slot->req) { plat_slot->req->dev_addr = info->slave_addr; plat_slot->req->offset_bytes = 1; plat_slot->req->offset = 0x69; @@ -806,7 +807,7 @@ static void firenze_pci_slot_init(struct pci_slot *slot) * be utilized. To figure out power status retrival or * configuration after we have a blocking API for that. */ - if (plat_slot->i2c_bus) { + if (plat_slot->req) { slot->ops.freset = firenze_pci_slot_freset; slot->ops.get_power_state = firenze_pci_slot_get_power_state; slot->ops.set_power_state = firenze_pci_slot_set_power_state; -- cgit v1.1