Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Shawn Lin and committed by
Ulf Hansson
792bd24b ec6d8bb3

+17 -41
+3 -3
drivers/mmc/host/dw_mmc-pci.c
··· 24 24 MMC_CAP_SD_HIGHSPEED | MMC_CAP_8_BIT_DATA |\ 25 25 MMC_CAP_SDIO_IRQ) 26 26 27 - static struct dw_mci_board pci_board_data = { 28 - .caps = DW_MCI_CAPABILITIES, 27 + static const struct dw_mci_drv_data pci_drv_data = { 28 + .common_caps = DW_MCI_CAPABILITIES, 29 29 }; 30 30 31 31 static int dw_mci_pci_probe(struct pci_dev *pdev, ··· 44 44 45 45 host->irq = pdev->irq; 46 46 host->irq_flags = IRQF_SHARED; 47 - host->pdata = &pci_board_data; 48 47 host->fifo_depth = 32; 49 48 host->detect_delay_ms = 200; 50 49 host->bus_hz = 33 * 1000 * 1000; 50 + host->drv_data = &pci_drv_data; 51 51 52 52 ret = pcim_iomap_regions(pdev, 1 << PCI_BAR_NO, pci_name(pdev)); 53 53 if (ret)
+14 -31
drivers/mmc/host/dw_mmc.c
··· 2837 2837 struct mmc_host *mmc = host->mmc; 2838 2838 int ctrl_id; 2839 2839 2840 - if (host->pdata->caps) 2841 - mmc->caps = host->pdata->caps; 2842 - 2843 2840 if (drv_data) 2844 2841 mmc->caps |= drv_data->common_caps; 2845 2842 ··· 3149 3152 spin_unlock_irqrestore(&host->irq_lock, irqflags); 3150 3153 } 3151 3154 3152 - #ifdef CONFIG_OF 3153 - static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) 3155 + static int dw_mci_parse_dt(struct dw_mci *host) 3154 3156 { 3155 - struct dw_mci_board *pdata; 3156 3157 struct device *dev = host->dev; 3157 3158 const struct dw_mci_drv_data *drv_data = host->drv_data; 3158 3159 int ret; 3159 3160 u32 clock_frequency; 3160 3161 3161 - pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 3162 - if (!pdata) 3163 - return ERR_PTR(-ENOMEM); 3164 - 3165 3162 /* find reset controller when exist */ 3166 3163 host->rstc = devm_reset_control_get_optional_exclusive(dev, "reset"); 3167 3164 if (IS_ERR(host->rstc)) 3168 - return ERR_CAST(host->rstc); 3165 + return PTR_ERR(host->rstc); 3169 3166 3170 - if (device_property_read_u32(dev, "fifo-depth", &host->fifo_depth)) 3167 + if (!host->fifo_depth && device_property_read_u32(dev, "fifo-depth", &host->fifo_depth)) 3171 3168 dev_info(dev, 3172 3169 "fifo-depth property not found, using value of FIFOTH register as default\n"); 3173 3170 3174 - device_property_read_u32(dev, "card-detect-delay", 3175 - &host->detect_delay_ms); 3171 + if (!host->detect_delay_ms) 3172 + device_property_read_u32(dev, "card-detect-delay", 3173 + &host->detect_delay_ms); 3176 3174 3177 - device_property_read_u32(dev, "data-addr", &host->data_addr_override); 3175 + if (!host->data_addr_override) 3176 + device_property_read_u32(dev, "data-addr", &host->data_addr_override); 3178 3177 3179 3178 if (device_property_present(dev, "fifo-watermark-aligned")) 3180 3179 host->wm_aligned = true; 3181 3180 3182 - if (!device_property_read_u32(dev, "clock-frequency", &clock_frequency)) 3181 + if (!host->bus_hz && !device_property_read_u32(dev, "clock-frequency", &clock_frequency)) 3183 3182 host->bus_hz = clock_frequency; 3184 3183 3185 3184 if (drv_data && drv_data->parse_dt) { 3186 3185 ret = drv_data->parse_dt(host); 3187 3186 if (ret) 3188 - return ERR_PTR(ret); 3187 + return ret; 3189 3188 } 3190 3189 3191 - return pdata; 3190 + return 0; 3192 3191 } 3193 - 3194 - #else /* CONFIG_OF */ 3195 - static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) 3196 - { 3197 - return ERR_PTR(-EINVAL); 3198 - } 3199 - #endif /* CONFIG_OF */ 3200 3192 3201 3193 static void dw_mci_enable_cd(struct dw_mci *host) 3202 3194 { ··· 3231 3245 int width, i, ret = 0; 3232 3246 u32 fifo_size; 3233 3247 3234 - if (!host->pdata) { 3235 - host->pdata = dw_mci_parse_dt(host); 3236 - if (IS_ERR(host->pdata)) 3237 - return dev_err_probe(host->dev, PTR_ERR(host->pdata), 3238 - "platform data not available\n"); 3239 - } 3248 + ret = dw_mci_parse_dt(host); 3249 + if (ret) 3250 + return dev_err_probe(host->dev, ret, "parse dt failed\n"); 3240 3251 3241 3252 host->biu_clk = devm_clk_get(host->dev, "biu"); 3242 3253 if (IS_ERR(host->biu_clk)) {
-7
drivers/mmc/host/dw_mmc.h
··· 103 103 * @fifoth_val: The value of FIFOTH register. 104 104 * @verid: Denote Version ID. 105 105 * @dev: Device associated with the MMC controller. 106 - * @pdata: Platform data associated with the MMC controller. 107 106 * @drv_data: Driver specific data for identified variant of the controller 108 107 * @priv: Implementation defined private data. 109 108 * @biu_clk: Pointer to bus interface unit clock instance. ··· 207 208 u32 fifoth_val; 208 209 u16 verid; 209 210 struct device *dev; 210 - struct dw_mci_board *pdata; 211 211 const struct dw_mci_drv_data *drv_data; 212 212 void *priv; 213 213 struct clk *biu_clk; ··· 264 266 void (*stop)(struct dw_mci *host); 265 267 void (*cleanup)(struct dw_mci *host); 266 268 void (*exit)(struct dw_mci *host); 267 - }; 268 - 269 - /* Board platform data */ 270 - struct dw_mci_board { 271 - u32 caps; /* Capabilities */ 272 269 }; 273 270 274 271 /* Support for longer data read timeout */