From af225a8ddd3e058da59becf2129e840475b70e27 Mon Sep 17 00:00:00 2001 From: Suraj Jitindar Singh Date: Tue, 19 Jul 2016 11:18:25 +1000 Subject: platforms/ibm-fsp: Fix incorrect struct member access and comparison For a 1004 slot mapping bit 6 (0x40) of the P0 field represents the pwr_ctl bit. This code previously accessed the wrong field (power_ctl) which is a single bit which corresponds to the 1005 mapping (which is the wrong mapping), performed a bitwise and with 0x40 (which will always be 0), and then compared to 1 (which will also always be 0). Fix this to access the byte struct member, bitwise and with 0x40 to mask the power_ctl bit, and double negate to guarantee 0 or 1 result. Fixes: Coverity Bug #97820 Fixes: 6884fe63 ("platforms/ibm-fsp: Support PCI slot") Signed-off-by: Suraj Jitindar Singh Acked-by: Gavin Shan Signed-off-by: Stewart Smith --- platforms/ibm-fsp/lxvpd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/ibm-fsp/lxvpd.c b/platforms/ibm-fsp/lxvpd.c index 78e709c..72512b7 100644 --- a/platforms/ibm-fsp/lxvpd.c +++ b/platforms/ibm-fsp/lxvpd.c @@ -207,7 +207,7 @@ static void lxvpd_parse_1004_map(struct phb *phb, s->vswitch_id = entry->pba & 0xf; s->dev_id = entry->sba; s->pluggable = ((entry->p0.byte & 0x20) == 0); - s->power_ctl = ((entry->p0.power_ctl & 0x40) == 1); + s->power_ctl = !!(entry->p0.byte & 0x40); s->bus_clock = entry->p2.bus_clock - 4; s->connector_type = entry->p2.connector_type - 5; s->card_desc = entry->p3.byte >> 6; -- cgit v1.1