Skip to contentSkip to conversation

Possible bug in s5p_sdhci.c

U-Boot New Matt Reimer 3 participants 6 messages Feb 19, 2015 – Mar 18, 2015 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

The use of SDHCI_CTRL2_SELBASECLK_SHIFT in s5p_sdhci_set_control_reg() seems wrong, because a shifting offset is being used as a mask, not to generate a mask.

It's unclear what the original intent was. Below is my suggested fix.

What think ye?

Matt

drivers/mmc/s5p_sdhci.c +1 -1
index 3899372..0eec731 100644
@@ -30,7 +30,7 @@ static void s5p_sdhci_set_control_reg(struct sdhci_host *host)
        sdhci_writel(host, SDHCI_CTRL4_DRIVE_MASK(0x3), SDHCI_CONTROL4);
 
        val = sdhci_readl(host, SDHCI_CONTROL2);
-       val &= SDHCI_CTRL2_SELBASECLK_SHIFT;
+       val &= SDHCI_CTRL2_SELBASECLK_MASK(3);
 
        val |=  SDHCI_CTRL2_ENSTAASYNCCLR |
                SDHCI_CTRL2_ENCMDCNFMSK |
#1 lore raw

Hi Matt,

Quoted 19 lines · Matt Reimer

The use of SDHCI_CTRL2_SELBASECLK_SHIFT in s5p_sdhci_set_control_reg() seems wrong, because a shifting offset is being used as a mask, not to generate a mask.

It's unclear what the original intent was. Below is my suggested fix.

What think ye?

Matt

drivers/mmc/s5p_sdhci.c +0 -0
index 3899372..0eec731 100644

drivers/mmc/s5p_sdhci.c static void s5p_sdhci_set_control_reg(struct sdhci_host *host) · line 36

Quoted 8 lines
drivers/mmc/s5p_sdhci.c +1 -1
@@ -30,7 +30,7 @@ static void s5p_sdhci_set_control_reg(struct sdhci_host *host)
       sdhci_writel(host, SDHCI_CTRL4_DRIVE_MASK(0x3), SDHCI_CONTROL4);
 
       val = sdhci_readl(host, SDHCI_CONTROL2);
-       val &= SDHCI_CTRL2_SELBASECLK_SHIFT;
+       val &= SDHCI_CTRL2_SELBASECLK_MASK(3);
 
       val |=  SDHCI_CTRL2_ENSTAASYNCCLR |
               SDHCI_CTRL2_ENCMDCNFMSK |

At first glance it seems you?re right. Please prepare a proper patch. CCing Jaehoon?

Regards

? Pantelis

#2 lore raw

PATCH 1/1 mmc: s5p: properly mask SELBASECLK

Properly mask SELBASECLK by using an actual mask rather than the number of bits to shift in order to create the mask.

---
 drivers/mmc/s5p_sdhci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/s5p_sdhci.c +1 -1
index 3899372..0eec731 100644
@@ -30,7 +30,7 @@ static void s5p_sdhci_set_control_reg(struct sdhci_host *host)
 	sdhci_writel(host, SDHCI_CTRL4_DRIVE_MASK(0x3), SDHCI_CONTROL4);
 
 	val = sdhci_readl(host, SDHCI_CONTROL2);
-	val &= SDHCI_CTRL2_SELBASECLK_SHIFT;
+	val &= SDHCI_CTRL2_SELBASECLK_MASK(3);
 
 	val |=	SDHCI_CTRL2_ENSTAASYNCCLR |
 		SDHCI_CTRL2_ENCMDCNFMSK |
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 1/1 mmc: s5p: properly mask SELBASECLK

Hi, Matt.

You're right, it's wrong masking.

Best Regards,
Jaehoon Chung

Quoted 22 lines · Matt Reimer

Properly mask SELBASECLK by using an actual mask rather than the number of bits to shift in order to create the mask.

---
 drivers/mmc/s5p_sdhci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/s5p_sdhci.c +1 -1
index 3899372..0eec731 100644
@@ -30,7 +30,7 @@ static void s5p_sdhci_set_control_reg(struct sdhci_host *host)
 	sdhci_writel(host, SDHCI_CTRL4_DRIVE_MASK(0x3), SDHCI_CONTROL4);
 
 	val = sdhci_readl(host, SDHCI_CONTROL2);
-	val &= SDHCI_CTRL2_SELBASECLK_SHIFT;
+	val &= SDHCI_CTRL2_SELBASECLK_MASK(3);
 
 	val |=	SDHCI_CTRL2_ENSTAASYNCCLR |
 		SDHCI_CTRL2_ENCMDCNFMSK |
#4 lore raw

PATCH 1/1 mmc: s5p: properly mask SELBASECLK

In reply to Matt Reimer
Quoted 21 lines · Matt Reimer

Properly mask SELBASECLK by using an actual mask rather than the number of bits to shift in order to create the mask.

---
 drivers/mmc/s5p_sdhci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/s5p_sdhci.c +1 -1
index 3899372..0eec731 100644
@@ -30,7 +30,7 @@ static void s5p_sdhci_set_control_reg(struct sdhci_host
 *host)
        sdhci_writel(host, SDHCI_CTRL4_DRIVE_MASK(0x3), SDHCI_CONTROL4);
 
        val = sdhci_readl(host, SDHCI_CONTROL2);
-       val &= SDHCI_CTRL2_SELBASECLK_SHIFT;
+       val &= SDHCI_CTRL2_SELBASECLK_MASK(3);
 
        val |=  SDHCI_CTRL2_ENSTAASYNCCLR |
Quoted 5 lines

SDHCI_CTRL2_ENCMDCNFMSK |
--
1.7.9.5

ping

#5 lore raw

PATCH 1/1 mmc: s5p: properly mask SELBASECLK

In reply to Matt Reimer

Hi Matt,

Quoted 26 lines · Matt Reimer

Properly mask SELBASECLK by using an actual mask rather than the number of bits to shift in order to create the mask.

---
drivers/mmc/s5p_sdhci.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/s5p_sdhci.c +1 -1
index 3899372..0eec731 100644
@@ -30,7 +30,7 @@ static void s5p_sdhci_set_control_reg(struct sdhci_host *host)
 	sdhci_writel(host, SDHCI_CTRL4_DRIVE_MASK(0x3), SDHCI_CONTROL4);
 
 	val = sdhci_readl(host, SDHCI_CONTROL2);
-	val &= SDHCI_CTRL2_SELBASECLK_SHIFT;
+	val &= SDHCI_CTRL2_SELBASECLK_MASK(3);
 
 	val |=	SDHCI_CTRL2_ENSTAASYNCCLR |
 		SDHCI_CTRL2_ENCMDCNFMSK |
Signature · 1 line
1.7.9.5

Thanks, applied.

? Pantelis