mmc: Fix bug in sd_set_card_speed()
authorJean-Jacques Hiblot <jjhiblot@ti.com>
Fri, 9 Feb 2018 11:09:27 +0000 (12:09 +0100)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 19 Feb 2018 07:59:21 +0000 (16:59 +0900)
After settings the speed of the sd with the switch command, a check is
done to make sure that the new speed has been set. The current check has a
masking error: speed are encoded on 4 bits only.
Fix it by masking the upper bits.

This fixes a problem seen with QEmu emulating a vexpress-a15.

Reported-by: Jonathan Gray <jsg@jsg.id.au>
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Tested-by: Jonathan Gray <jsg@jsg.id.au>
drivers/mmc/mmc.c

index 3a2e3b353fe2409eb48c03b962c89107ba5ff8ac..b46e3f60242fb7f4d8987d5fdeff85c33ae71e14 100644 (file)
@@ -1333,7 +1333,7 @@ static int sd_set_card_speed(struct mmc *mmc, enum bus_mode mode)
        if (err)
                return err;
 
-       if ((__be32_to_cpu(switch_status[4]) >> 24) != speed)
+       if (((__be32_to_cpu(switch_status[4]) >> 24) & 0xF) != speed)
                return -ENOTSUPP;
 
        return 0;