* [PATCH 0/5] mmc: Constify struct sdhci_ops
@ 2024-04-14 7:15 Krzysztof Kozlowski
2024-04-14 7:15 ` [PATCH 1/5] mmc: sdhci-esdhc-mcf: " Krzysztof Kozlowski
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2024-04-14 7:15 UTC (permalink / raw)
To: Adrian Hunter, Angelo Dureghello, Ulf Hansson,
Vignesh Raghavendra, Orson Zhai, Baolin Wang, Chunyan Zhang,
Ben Dooks, Jaehoon Chung
Cc: linux-mmc, linux-kernel, Krzysztof Kozlowski
Hi,
The local struct sdhci_ops can be made const for code safety.
No dependencies.
Best regards,
Krzysztof
---
Krzysztof Kozlowski (5):
mmc: sdhci-esdhc-mcf: Constify struct sdhci_ops
mmc: sdhci-omap: Constify struct sdhci_ops
mmc: sdhci-sprd: Constify struct sdhci_ops
mmc: sdhci_am654: Constify struct sdhci_ops
mmc: sdhci-s3c: Choose sdhci_ops based on variant
drivers/mmc/host/sdhci-esdhc-mcf.c | 2 +-
drivers/mmc/host/sdhci-omap.c | 2 +-
drivers/mmc/host/sdhci-s3c.c | 31 +++++++++++++++++--------------
drivers/mmc/host/sdhci-sprd.c | 2 +-
drivers/mmc/host/sdhci_am654.c | 6 +++---
5 files changed, 23 insertions(+), 20 deletions(-)
---
base-commit: f67245b3062cdc225b37003085bdb2916e1670b6
change-id: 20240414-mmc-const-sdhci-ops-c85762883004
Best regards,
--
Krzysztof Kozlowski <krzk@kernel.org>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] mmc: sdhci-esdhc-mcf: Constify struct sdhci_ops
2024-04-14 7:15 [PATCH 0/5] mmc: Constify struct sdhci_ops Krzysztof Kozlowski
@ 2024-04-14 7:15 ` Krzysztof Kozlowski
2024-04-14 7:15 ` [PATCH 2/5] mmc: sdhci-omap: " Krzysztof Kozlowski
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2024-04-14 7:15 UTC (permalink / raw)
To: Adrian Hunter, Angelo Dureghello, Ulf Hansson,
Vignesh Raghavendra, Orson Zhai, Baolin Wang, Chunyan Zhang,
Ben Dooks, Jaehoon Chung
Cc: linux-mmc, linux-kernel, Krzysztof Kozlowski
The local struct sdhci_ops can be made const for code safety.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
drivers/mmc/host/sdhci-esdhc-mcf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mmc/host/sdhci-esdhc-mcf.c b/drivers/mmc/host/sdhci-esdhc-mcf.c
index c97363e2d86c..3ad87322f6a5 100644
--- a/drivers/mmc/host/sdhci-esdhc-mcf.c
+++ b/drivers/mmc/host/sdhci-esdhc-mcf.c
@@ -335,7 +335,7 @@ static void esdhc_mcf_copy_to_bounce_buffer(struct sdhci_host *host,
data->blksz * data->blocks);
}
-static struct sdhci_ops sdhci_esdhc_ops = {
+static const struct sdhci_ops sdhci_esdhc_ops = {
.reset = esdhc_mcf_reset,
.set_clock = esdhc_mcf_pltfm_set_clock,
.get_max_clock = esdhc_mcf_pltfm_get_max_clock,
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/5] mmc: sdhci-omap: Constify struct sdhci_ops
2024-04-14 7:15 [PATCH 0/5] mmc: Constify struct sdhci_ops Krzysztof Kozlowski
2024-04-14 7:15 ` [PATCH 1/5] mmc: sdhci-esdhc-mcf: " Krzysztof Kozlowski
@ 2024-04-14 7:15 ` Krzysztof Kozlowski
2024-04-14 7:15 ` [PATCH 3/5] mmc: sdhci-sprd: " Krzysztof Kozlowski
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2024-04-14 7:15 UTC (permalink / raw)
To: Adrian Hunter, Angelo Dureghello, Ulf Hansson,
Vignesh Raghavendra, Orson Zhai, Baolin Wang, Chunyan Zhang,
Ben Dooks, Jaehoon Chung
Cc: linux-mmc, linux-kernel, Krzysztof Kozlowski
The local struct sdhci_ops can be made const for code safety.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
drivers/mmc/host/sdhci-omap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c
index 94076b095571..5841a9afeb9f 100644
--- a/drivers/mmc/host/sdhci-omap.c
+++ b/drivers/mmc/host/sdhci-omap.c
@@ -925,7 +925,7 @@ static void sdhci_omap_set_timeout(struct sdhci_host *host,
__sdhci_set_timeout(host, cmd);
}
-static struct sdhci_ops sdhci_omap_ops = {
+static const struct sdhci_ops sdhci_omap_ops = {
.set_clock = sdhci_omap_set_clock,
.set_power = sdhci_omap_set_power,
.enable_dma = sdhci_omap_enable_dma,
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/5] mmc: sdhci-sprd: Constify struct sdhci_ops
2024-04-14 7:15 [PATCH 0/5] mmc: Constify struct sdhci_ops Krzysztof Kozlowski
2024-04-14 7:15 ` [PATCH 1/5] mmc: sdhci-esdhc-mcf: " Krzysztof Kozlowski
2024-04-14 7:15 ` [PATCH 2/5] mmc: sdhci-omap: " Krzysztof Kozlowski
@ 2024-04-14 7:15 ` Krzysztof Kozlowski
2024-04-14 7:15 ` [PATCH 4/5] mmc: sdhci_am654: " Krzysztof Kozlowski
2024-04-14 7:15 ` [PATCH 5/5] mmc: sdhci-s3c: Choose sdhci_ops based on variant Krzysztof Kozlowski
4 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2024-04-14 7:15 UTC (permalink / raw)
To: Adrian Hunter, Angelo Dureghello, Ulf Hansson,
Vignesh Raghavendra, Orson Zhai, Baolin Wang, Chunyan Zhang,
Ben Dooks, Jaehoon Chung
Cc: linux-mmc, linux-kernel, Krzysztof Kozlowski
The local struct sdhci_ops can be made const for code safety.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
drivers/mmc/host/sdhci-sprd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index 685b1c648901..8776f4287119 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -439,7 +439,7 @@ static void sdhci_sprd_set_power(struct sdhci_host *host, unsigned char mode,
}
}
-static struct sdhci_ops sdhci_sprd_ops = {
+static const struct sdhci_ops sdhci_sprd_ops = {
.read_l = sdhci_sprd_readl,
.write_l = sdhci_sprd_writel,
.write_w = sdhci_sprd_writew,
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/5] mmc: sdhci_am654: Constify struct sdhci_ops
2024-04-14 7:15 [PATCH 0/5] mmc: Constify struct sdhci_ops Krzysztof Kozlowski
` (2 preceding siblings ...)
2024-04-14 7:15 ` [PATCH 3/5] mmc: sdhci-sprd: " Krzysztof Kozlowski
@ 2024-04-14 7:15 ` Krzysztof Kozlowski
2024-04-14 7:15 ` [PATCH 5/5] mmc: sdhci-s3c: Choose sdhci_ops based on variant Krzysztof Kozlowski
4 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2024-04-14 7:15 UTC (permalink / raw)
To: Adrian Hunter, Angelo Dureghello, Ulf Hansson,
Vignesh Raghavendra, Orson Zhai, Baolin Wang, Chunyan Zhang,
Ben Dooks, Jaehoon Chung
Cc: linux-mmc, linux-kernel, Krzysztof Kozlowski
The local struct sdhci_ops can be made const for code safety.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
drivers/mmc/host/sdhci_am654.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/mmc/host/sdhci_am654.c b/drivers/mmc/host/sdhci_am654.c
index ba36123e4ccc..17ad32cfc0c3 100644
--- a/drivers/mmc/host/sdhci_am654.c
+++ b/drivers/mmc/host/sdhci_am654.c
@@ -543,7 +543,7 @@ static int sdhci_am654_platform_execute_tuning(struct sdhci_host *host,
return 0;
}
-static struct sdhci_ops sdhci_am654_ops = {
+static const struct sdhci_ops sdhci_am654_ops = {
.platform_execute_tuning = sdhci_am654_platform_execute_tuning,
.get_max_clock = sdhci_pltfm_clk_get_max_clock,
.get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
@@ -573,7 +573,7 @@ static const struct sdhci_am654_driver_data sdhci_am654_drvdata = {
.flags = IOMUX_PRESENT | FREQSEL_2_BIT | STRBSEL_4_BIT | DLL_PRESENT,
};
-static struct sdhci_ops sdhci_j721e_8bit_ops = {
+static const struct sdhci_ops sdhci_j721e_8bit_ops = {
.platform_execute_tuning = sdhci_am654_platform_execute_tuning,
.get_max_clock = sdhci_pltfm_clk_get_max_clock,
.get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
@@ -597,7 +597,7 @@ static const struct sdhci_am654_driver_data sdhci_j721e_8bit_drvdata = {
.flags = DLL_PRESENT | DLL_CALIB,
};
-static struct sdhci_ops sdhci_j721e_4bit_ops = {
+static const struct sdhci_ops sdhci_j721e_4bit_ops = {
.platform_execute_tuning = sdhci_am654_platform_execute_tuning,
.get_max_clock = sdhci_pltfm_clk_get_max_clock,
.get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/5] mmc: sdhci-s3c: Choose sdhci_ops based on variant
2024-04-14 7:15 [PATCH 0/5] mmc: Constify struct sdhci_ops Krzysztof Kozlowski
` (3 preceding siblings ...)
2024-04-14 7:15 ` [PATCH 4/5] mmc: sdhci_am654: " Krzysztof Kozlowski
@ 2024-04-14 7:15 ` Krzysztof Kozlowski
2024-04-14 14:05 ` Krzysztof Kozlowski
4 siblings, 1 reply; 7+ messages in thread
From: Krzysztof Kozlowski @ 2024-04-14 7:15 UTC (permalink / raw)
To: Adrian Hunter, Angelo Dureghello, Ulf Hansson,
Vignesh Raghavendra, Orson Zhai, Baolin Wang, Chunyan Zhang,
Ben Dooks, Jaehoon Chung
Cc: linux-mmc, linux-kernel, Krzysztof Kozlowski
The difference between old S3C64xx and newer Exynos4 SDHCI controller
variants is in clock handling (the "no_divider" field in drvdata).
Choose the proper sdhci_ops based on the variant instead of patching
ops in probe, if Exynos4 is used.
This allows making struct sdhci_ops const for code safety and probably
opens further options in the future, as the dynamic pointer ops table is
not anymore that dynamic.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
drivers/mmc/host/sdhci-s3c.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 6493b0edba34..6c2a42c1819a 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -130,14 +130,16 @@ struct sdhci_s3c {
* struct sdhci_s3c_drv_data - S3C SDHCI platform specific driver data
* @sdhci_quirks: sdhci host specific quirks.
* @no_divider: no or non-standard internal clock divider.
+ * @ops: sdhci_ops to use for this variant
*
* Specifies platform specific configuration of sdhci controller.
* Note: A structure for driver specific platform data is used for future
* expansion of its usage.
*/
struct sdhci_s3c_drv_data {
- unsigned int sdhci_quirks;
- bool no_divider;
+ unsigned int sdhci_quirks;
+ bool no_divider;
+ const struct sdhci_ops *ops;
};
static inline struct sdhci_s3c *to_s3c(struct sdhci_host *host)
@@ -412,7 +414,7 @@ static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
}
-static struct sdhci_ops sdhci_s3c_ops = {
+static const struct sdhci_ops sdhci_s3c_ops_s3c6410 = {
.get_max_clock = sdhci_s3c_get_max_clk,
.set_clock = sdhci_s3c_set_clock,
.get_min_clock = sdhci_s3c_get_min_clock,
@@ -421,6 +423,15 @@ static struct sdhci_ops sdhci_s3c_ops = {
.set_uhs_signaling = sdhci_set_uhs_signaling,
};
+static const struct sdhci_ops sdhci_s3c_ops_exynos4 = {
+ .get_max_clock = sdhci_cmu_get_max_clock,
+ .set_clock = sdhci_cmu_set_clock,
+ .get_min_clock = sdhci_cmu_get_min_clock,
+ .set_bus_width = sdhci_set_bus_width,
+ .reset = sdhci_reset,
+ .set_uhs_signaling = sdhci_set_uhs_signaling,
+};
+
#ifdef CONFIG_OF
static int sdhci_s3c_parse_dt(struct device *dev,
struct sdhci_host *host, struct s3c_sdhci_platdata *pdata)
@@ -560,7 +571,7 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
pdata->cfg_gpio(pdev, pdata->max_width);
host->hw_name = "samsung-hsmmc";
- host->ops = &sdhci_s3c_ops;
+ host->ops = &sdhci_s3c_ops_s3c6410;
host->quirks = 0;
host->quirks2 = 0;
host->irq = irq;
@@ -570,6 +581,7 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT;
if (drv_data) {
host->quirks |= drv_data->sdhci_quirks;
+ host->ops = drv_data->ops;
sc->no_divider = drv_data->no_divider;
}
@@ -617,16 +629,6 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
/* HSMMC on Samsung SoCs uses SDCLK as timeout clock */
host->quirks |= SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK;
- /*
- * If controller does not have internal clock divider,
- * we can use overriding functions instead of default.
- */
- if (sc->no_divider) {
- sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
- sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
- sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
- }
-
/* It supports additional host capabilities if needed */
if (pdata->host_caps)
host->mmc->caps |= pdata->host_caps;
@@ -758,6 +760,7 @@ MODULE_DEVICE_TABLE(platform, sdhci_s3c_driver_ids);
#ifdef CONFIG_OF
static const struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = {
.no_divider = true,
+ .ops = &sdhci_s3c_ops_exynos4,
};
static const struct of_device_id sdhci_s3c_dt_match[] = {
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 5/5] mmc: sdhci-s3c: Choose sdhci_ops based on variant
2024-04-14 7:15 ` [PATCH 5/5] mmc: sdhci-s3c: Choose sdhci_ops based on variant Krzysztof Kozlowski
@ 2024-04-14 14:05 ` Krzysztof Kozlowski
0 siblings, 0 replies; 7+ messages in thread
From: Krzysztof Kozlowski @ 2024-04-14 14:05 UTC (permalink / raw)
To: Adrian Hunter, Angelo Dureghello, Ulf Hansson,
Vignesh Raghavendra, Orson Zhai, Baolin Wang, Chunyan Zhang,
Ben Dooks, Jaehoon Chung
Cc: linux-mmc, linux-kernel
On 14/04/2024 09:15, Krzysztof Kozlowski wrote:
>
> -static struct sdhci_ops sdhci_s3c_ops = {
> +static const struct sdhci_ops sdhci_s3c_ops_s3c6410 = {
> .get_max_clock = sdhci_s3c_get_max_clk,
> .set_clock = sdhci_s3c_set_clock,
> .get_min_clock = sdhci_s3c_get_min_clock,
> @@ -421,6 +423,15 @@ static struct sdhci_ops sdhci_s3c_ops = {
> .set_uhs_signaling = sdhci_set_uhs_signaling,
> };
>
> +static const struct sdhci_ops sdhci_s3c_ops_exynos4 = {
> + .get_max_clock = sdhci_cmu_get_max_clock,
> + .set_clock = sdhci_cmu_set_clock,
> + .get_min_clock = sdhci_cmu_get_min_clock,
> + .set_bus_width = sdhci_set_bus_width,
> + .reset = sdhci_reset,
> + .set_uhs_signaling = sdhci_set_uhs_signaling,
> +};
> +
> #ifdef CONFIG_OF
LKP reported now unused sdhci_s3c_ops_exynos4 for !CONFIG_OF. I will
send v2 (today, due to travel)
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-04-14 14:05 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-14 7:15 [PATCH 0/5] mmc: Constify struct sdhci_ops Krzysztof Kozlowski
2024-04-14 7:15 ` [PATCH 1/5] mmc: sdhci-esdhc-mcf: " Krzysztof Kozlowski
2024-04-14 7:15 ` [PATCH 2/5] mmc: sdhci-omap: " Krzysztof Kozlowski
2024-04-14 7:15 ` [PATCH 3/5] mmc: sdhci-sprd: " Krzysztof Kozlowski
2024-04-14 7:15 ` [PATCH 4/5] mmc: sdhci_am654: " Krzysztof Kozlowski
2024-04-14 7:15 ` [PATCH 5/5] mmc: sdhci-s3c: Choose sdhci_ops based on variant Krzysztof Kozlowski
2024-04-14 14:05 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).