Skip to contentSkip to conversation

mmc: sdhci: Always apply sdhci-caps-mask and sdhci-caps to caps

PATCH In review Marek Vasut 2 participants 3 messages Jan 5, 2023 – Jan 18, 2023

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

PATCH 1/1 mmc: sdhci: Always apply sdhci-caps-mask and sdhci-caps to caps

The original implementation in the commit referenced below only modifies caps in case no caps are passed to sdhci_read_caps() via parameter, this does not seem correct. Always modify the caps according to the properties from DT.

While at it, drop the always NULL caps and caps1 function parameters.

---
Cc: Adrian Hunter <[email protected]>
Cc: Bough Chen <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: Zach Brown <[email protected]>
To: [email protected]

---
 drivers/mmc/host/sdhci-cadence.c |  2 +-
 drivers/mmc/host/sdhci.c         | 23 +++++++----------------
 drivers/mmc/host/sdhci.h         |  5 ++---
 3 files changed, 10 insertions(+), 20 deletions(-)
drivers/mmc/host/sdhci-cadence.c +1 -1
index 6f2de54a59877..af1bd66402cb7 100644
@@ -390,7 +390,7 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
 	host->mmc_host_ops.hs400_enhanced_strobe =
 				sdhci_cdns_hs400_enhanced_strobe;
 	sdhci_enable_v4_mode(host);
-	__sdhci_read_caps(host, &version, NULL, NULL);
+	__sdhci_read_caps(host, &version);
 
 	sdhci_get_of_property(pdev);
 
drivers/mmc/host/sdhci.c +7 -16
index f3af1bd0f7b95..0ed8c5b36ecb9 100644
@@ -4090,8 +4090,7 @@ static int sdhci_set_dma_mask(struct sdhci_host *host)
 	return ret;
 }
 
-void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver,
-		       const u32 *caps, const u32 *caps1)
+void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver)
 {
 	u16 v;
 	u64 dt_caps_mask = 0;
@@ -4124,24 +4123,16 @@ void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver,
 	if (host->quirks & SDHCI_QUIRK_MISSING_CAPS)
 		return;
 
-	if (caps) {
-		host->caps = *caps;
-	} else {
-		host->caps = sdhci_readl(host, SDHCI_CAPABILITIES);
-		host->caps &= ~lower_32_bits(dt_caps_mask);
-		host->caps |= lower_32_bits(dt_caps);
-	}
+	host->caps = sdhci_readl(host, SDHCI_CAPABILITIES);
+	host->caps &= ~lower_32_bits(dt_caps_mask);
+	host->caps |= lower_32_bits(dt_caps);
 
 	if (host->version < SDHCI_SPEC_300)
 		return;
 
-	if (caps1) {
-		host->caps1 = *caps1;
-	} else {
-		host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
-		host->caps1 &= ~upper_32_bits(dt_caps_mask);
-		host->caps1 |= upper_32_bits(dt_caps);
-	}
+	host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
+	host->caps1 &= ~upper_32_bits(dt_caps_mask);
+	host->caps1 |= upper_32_bits(dt_caps);
 }
 EXPORT_SYMBOL_GPL(__sdhci_read_caps);
 
drivers/mmc/host/sdhci.h +2 -3
index 605eaee805f74..19695e542161e 100644
@@ -757,8 +757,7 @@ static inline void *sdhci_priv(struct sdhci_host *host)
 	return host->private;
 }
 
-void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver,
-		       const u32 *caps, const u32 *caps1);
+void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver);
 int sdhci_setup_host(struct sdhci_host *host);
 void sdhci_cleanup_host(struct sdhci_host *host);
 int __sdhci_add_host(struct sdhci_host *host);
@@ -767,7 +766,7 @@ void sdhci_remove_host(struct sdhci_host *host, int dead);
 
 static inline void sdhci_read_caps(struct sdhci_host *host)
 {
-	__sdhci_read_caps(host, NULL, NULL, NULL);
+	__sdhci_read_caps(host, NULL);
 }
 
 u16 sdhci_calc_clk(struct sdhci_host *host, unsigned int clock,
Signature · 1 line
2.39.0
maintainer
#1 lore raw
Quoted 6 lines · Marek Vasut

The original implementation in the commit referenced below only modifies caps in case no caps are passed to sdhci_read_caps() via parameter, this does not seem correct. Always modify the caps according to the properties from DT.

While at it, drop the always NULL caps and caps1 function parameters.

Please re-base on top of:

https://lore.kernel.org/linux-mmc/[email protected]/T/#t

Quoted 95 lines

---
Cc: Adrian Hunter <[email protected]>
Cc: Bough Chen <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: Zach Brown <[email protected]>
To: [email protected]

---
 drivers/mmc/host/sdhci-cadence.c |  2 +-
 drivers/mmc/host/sdhci.c         | 23 +++++++----------------
 drivers/mmc/host/sdhci.h         |  5 ++---
 3 files changed, 10 insertions(+), 20 deletions(-)
drivers/mmc/host/sdhci-cadence.c +1 -1
index 6f2de54a59877..af1bd66402cb7 100644
@@ -390,7 +390,7 @@ static int sdhci_cdns_probe(struct platform_device *pdev)
 	host->mmc_host_ops.hs400_enhanced_strobe =
 				sdhci_cdns_hs400_enhanced_strobe;
 	sdhci_enable_v4_mode(host);
-	__sdhci_read_caps(host, &version, NULL, NULL);
+	__sdhci_read_caps(host, &version);
 
 	sdhci_get_of_property(pdev);
 
drivers/mmc/host/sdhci.c +7 -16
index f3af1bd0f7b95..0ed8c5b36ecb9 100644
@@ -4090,8 +4090,7 @@ static int sdhci_set_dma_mask(struct sdhci_host *host)
 	return ret;
 }
 
-void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver,
-		       const u32 *caps, const u32 *caps1)
+void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver)
 {
 	u16 v;
 	u64 dt_caps_mask = 0;
@@ -4124,24 +4123,16 @@ void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver,
 	if (host->quirks & SDHCI_QUIRK_MISSING_CAPS)
 		return;
 
-	if (caps) {
-		host->caps = *caps;
-	} else {
-		host->caps = sdhci_readl(host, SDHCI_CAPABILITIES);
-		host->caps &= ~lower_32_bits(dt_caps_mask);
-		host->caps |= lower_32_bits(dt_caps);
-	}
+	host->caps = sdhci_readl(host, SDHCI_CAPABILITIES);
+	host->caps &= ~lower_32_bits(dt_caps_mask);
+	host->caps |= lower_32_bits(dt_caps);
 
 	if (host->version < SDHCI_SPEC_300)
 		return;
 
-	if (caps1) {
-		host->caps1 = *caps1;
-	} else {
-		host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
-		host->caps1 &= ~upper_32_bits(dt_caps_mask);
-		host->caps1 |= upper_32_bits(dt_caps);
-	}
+	host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
+	host->caps1 &= ~upper_32_bits(dt_caps_mask);
+	host->caps1 |= upper_32_bits(dt_caps);
 }
 EXPORT_SYMBOL_GPL(__sdhci_read_caps);
 
drivers/mmc/host/sdhci.h +2 -3
index 605eaee805f74..19695e542161e 100644
@@ -757,8 +757,7 @@ static inline void *sdhci_priv(struct sdhci_host *host)
 	return host->private;
 }
 
-void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver,
-		       const u32 *caps, const u32 *caps1);
+void __sdhci_read_caps(struct sdhci_host *host, const u16 *ver);
 int sdhci_setup_host(struct sdhci_host *host);
 void sdhci_cleanup_host(struct sdhci_host *host);
 int __sdhci_add_host(struct sdhci_host *host);
@@ -767,7 +766,7 @@ void sdhci_remove_host(struct sdhci_host *host, int dead);
 
 static inline void sdhci_read_caps(struct sdhci_host *host)
 {
-	__sdhci_read_caps(host, NULL, NULL, NULL);
+	__sdhci_read_caps(host, NULL);
 }
 
 u16 sdhci_calc_clk(struct sdhci_host *host, unsigned int clock,
#2 lore raw
Quoted 11 lines · Adrian Hunter
Quoted 6 lines · Marek Vasut

The original implementation in the commit referenced below only modifies caps in case no caps are passed to sdhci_read_caps() via parameter, this does not seem correct. Always modify the caps according to the properties from DT.

While at it, drop the always NULL caps and caps1 function parameters.

Please re-base on top of:

https://lore.kernel.org/linux-mmc/[email protected]/T/#t

Rebase on top of that series means I can just discard this entire patch, so done.