Skip to contentSkip to conversation

mmc: sdhci: fix the wrong type of curr

PATCH In review Chuanxiao Dong 2 participants 3 messages Aug 1, 2014 – Aug 13, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: sdhci: fix the wrong type of curr

curr should use signed type since it will contain the returned value which is possible to be a negative value. Using u32 will make the returned value to be true even there is a negative result. Change to use int instead of u32

---
 drivers/mmc/host/sdhci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +1 -1
index 47055f3..c026ec8 100644
@@ -3078,7 +3078,7 @@ int sdhci_add_host(struct sdhci_host *host)
 	 */
 	max_current_caps = sdhci_readl(host, SDHCI_MAX_CURRENT);
 	if (!max_current_caps && host->vmmc) {
-		u32 curr = regulator_get_current_limit(host->vmmc);
+		int curr = regulator_get_current_limit(host->vmmc);
 		if (curr > 0) {
 
 			/* convert to SDHCI_MAX_CURRENT format */
Signature · 1 line
1.7.10.4
#1 lore raw

Hello,

Any feedback on this fix?

Thanks
Chuanxiao

Quoted 36 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Chuanxiao Dong
Sent: Friday, August 01, 2014 2:00 PM
To: [email protected]; [email protected]; [email protected]
Subject: [PATCH] mmc: sdhci: fix the wrong type of curr

curr should use signed type since it will contain the returned value which is possible to be a negative value. Using u32 will make the returned value to be true even there is a negative result.
Change to use int instead of u32

---
 drivers/mmc/host/sdhci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci.c index renamed from drivers/mmc/host/sdhci.c +0 -0

47055f3..c026ec8 100644

drivers/mmc/host/sdhci.c +1 -2
@@ -3078,7 +3078,7 @@ int sdhci_add_host(struct sdhci_host *host)
 	 */
 	max_current_caps = sdhci_readl(host, SDHCI_MAX_CURRENT);
 	if (!max_current_caps && host->vmmc) {
-		u32 curr = regulator_get_current_limit(host->vmmc);
+		int curr = regulator_get_current_limit(host->vmmc);
 		if (curr > 0) {
 
 			/* convert to SDHCI_MAX_CURRENT format */
--

1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html

#2 lore raw
In reply to Chuanxiao Dong
Quoted 6 lines · Chuanxiao Dong

curr should use signed type since it will contain the returned value which is possible to be a negative value. Using u32 will make the returned value to be true even there is a negative result. Change to use int instead of u32

Thanks! Queued for 3.18.

Kind regards
Uffe

Quoted 19 lines
---
 drivers/mmc/host/sdhci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +1 -2
index 47055f3..c026ec8 100644
@@ -3078,7 +3078,7 @@ int sdhci_add_host(struct sdhci_host *host)
         */
        max_current_caps = sdhci_readl(host, SDHCI_MAX_CURRENT);
        if (!max_current_caps && host->vmmc) {
-               u32 curr = regulator_get_current_limit(host->vmmc);
+               int curr = regulator_get_current_limit(host->vmmc);
                if (curr > 0) {
 
                        /* convert to SDHCI_MAX_CURRENT format */
--

1.7.10.4