From: Shawn Lin Date: Tue, 6 Jan 2026 02:17:01 +0000 (+0800) Subject: mmc: dw_mmc: Remove struct dw_mci_board X-Git-Tag: v7.1-rc1~157^2~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=792bd24b6eb6625e9b7ea926597c5c15a5554266;p=thirdparty%2Fkernel%2Fstable.git mmc: dw_mmc: Remove struct dw_mci_board The only user of dw_mci_board is dw_pci-pci, now we can provide the caps from dw_mci_drv_data, so we could let dw_pci-pci use dw_mci_drv_data and remove caps from struct dw_mci_board. With that, struct dw_mci_board is no longer needed, we can remove it. Then we should check all settings in dw_mci_parse_dt in order not to overwrite them if provided from variant drivers. Also, without CONFIG_OF support, dw_mmc doesn' work as host->pdata is always ERR_PTR(-EINVAL), we could remove it together. Signed-off-by: Shawn Lin Signed-off-by: Ulf Hansson --- diff --git a/drivers/mmc/host/dw_mmc-pci.c b/drivers/mmc/host/dw_mmc-pci.c index 95e91f816ccf0..c82c23e4ea9a0 100644 --- a/drivers/mmc/host/dw_mmc-pci.c +++ b/drivers/mmc/host/dw_mmc-pci.c @@ -24,8 +24,8 @@ MMC_CAP_SD_HIGHSPEED | MMC_CAP_8_BIT_DATA |\ MMC_CAP_SDIO_IRQ) -static struct dw_mci_board pci_board_data = { - .caps = DW_MCI_CAPABILITIES, +static const struct dw_mci_drv_data pci_drv_data = { + .common_caps = DW_MCI_CAPABILITIES, }; static int dw_mci_pci_probe(struct pci_dev *pdev, @@ -44,10 +44,10 @@ static int dw_mci_pci_probe(struct pci_dev *pdev, host->irq = pdev->irq; host->irq_flags = IRQF_SHARED; - host->pdata = &pci_board_data; host->fifo_depth = 32; host->detect_delay_ms = 200; host->bus_hz = 33 * 1000 * 1000; + host->drv_data = &pci_drv_data; ret = pcim_iomap_regions(pdev, 1 << PCI_BAR_NO, pci_name(pdev)); if (ret) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index a5a7ef696d528..2b3f95017dbac 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -2837,9 +2837,6 @@ static int dw_mci_init_host_caps(struct dw_mci *host) struct mmc_host *mmc = host->mmc; int ctrl_id; - if (host->pdata->caps) - mmc->caps = host->pdata->caps; - if (drv_data) mmc->caps |= drv_data->common_caps; @@ -3152,54 +3149,43 @@ exit: spin_unlock_irqrestore(&host->irq_lock, irqflags); } -#ifdef CONFIG_OF -static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) +static int dw_mci_parse_dt(struct dw_mci *host) { - struct dw_mci_board *pdata; struct device *dev = host->dev; const struct dw_mci_drv_data *drv_data = host->drv_data; int ret; u32 clock_frequency; - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); - if (!pdata) - return ERR_PTR(-ENOMEM); - /* find reset controller when exist */ host->rstc = devm_reset_control_get_optional_exclusive(dev, "reset"); if (IS_ERR(host->rstc)) - return ERR_CAST(host->rstc); + return PTR_ERR(host->rstc); - if (device_property_read_u32(dev, "fifo-depth", &host->fifo_depth)) + if (!host->fifo_depth && device_property_read_u32(dev, "fifo-depth", &host->fifo_depth)) dev_info(dev, "fifo-depth property not found, using value of FIFOTH register as default\n"); - device_property_read_u32(dev, "card-detect-delay", - &host->detect_delay_ms); + if (!host->detect_delay_ms) + device_property_read_u32(dev, "card-detect-delay", + &host->detect_delay_ms); - device_property_read_u32(dev, "data-addr", &host->data_addr_override); + if (!host->data_addr_override) + device_property_read_u32(dev, "data-addr", &host->data_addr_override); if (device_property_present(dev, "fifo-watermark-aligned")) host->wm_aligned = true; - if (!device_property_read_u32(dev, "clock-frequency", &clock_frequency)) + if (!host->bus_hz && !device_property_read_u32(dev, "clock-frequency", &clock_frequency)) host->bus_hz = clock_frequency; if (drv_data && drv_data->parse_dt) { ret = drv_data->parse_dt(host); if (ret) - return ERR_PTR(ret); + return ret; } - return pdata; -} - -#else /* CONFIG_OF */ -static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) -{ - return ERR_PTR(-EINVAL); + return 0; } -#endif /* CONFIG_OF */ static void dw_mci_enable_cd(struct dw_mci *host) { @@ -3245,12 +3231,9 @@ int dw_mci_probe(struct dw_mci *host) int width, i, ret = 0; u32 fifo_size; - if (!host->pdata) { - host->pdata = dw_mci_parse_dt(host); - if (IS_ERR(host->pdata)) - return dev_err_probe(host->dev, PTR_ERR(host->pdata), - "platform data not available\n"); - } + ret = dw_mci_parse_dt(host); + if (ret) + return dev_err_probe(host->dev, ret, "parse dt failed\n"); host->biu_clk = devm_clk_get(host->dev, "biu"); if (IS_ERR(host->biu_clk)) { diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h index cb0e06b01d22e..76bf8a72b6bd8 100644 --- a/drivers/mmc/host/dw_mmc.h +++ b/drivers/mmc/host/dw_mmc.h @@ -103,7 +103,6 @@ struct dw_mci_dma_slave { * @fifoth_val: The value of FIFOTH register. * @verid: Denote Version ID. * @dev: Device associated with the MMC controller. - * @pdata: Platform data associated with the MMC controller. * @drv_data: Driver specific data for identified variant of the controller * @priv: Implementation defined private data. * @biu_clk: Pointer to bus interface unit clock instance. @@ -208,7 +207,6 @@ struct dw_mci { u32 fifoth_val; u16 verid; struct device *dev; - struct dw_mci_board *pdata; const struct dw_mci_drv_data *drv_data; void *priv; struct clk *biu_clk; @@ -268,11 +266,6 @@ struct dw_mci_dma_ops { void (*exit)(struct dw_mci *host); }; -/* Board platform data */ -struct dw_mci_board { - u32 caps; /* Capabilities */ -}; - /* Support for longer data read timeout */ #define DW_MMC_QUIRK_EXTENDED_TMOUT BIT(0) /* Force 32-bit access to the FIFO */