Re: [Patch v9 1/4] memory: tegra: Add memory controller channels support

Dmitry Osipenko
2022-04-29T08:52:26Z

On 4/26/22 10:38, Ashish Mhetre wrote:
> +static int tegra186_mc_map_regs(struct tegra_mc *mc)
> +{
> + struct platform_device *pdev = to_platform_device(mc->dev);
> + unsigned int i;
> +
> + mc->bcast_ch_regs = devm_platform_ioremap_resource_byname(pdev, "broadcast");
> + if (IS_ERR(mc->bcast_ch_regs)) {
> + if (PTR_ERR(mc->bcast_ch_regs) == -EINVAL) {
> + dev_warn(&pdev->dev, "Broadcast channel is missing, please update your device-tree\n");
> + mc->bcast_ch_regs = NULL;
> + return 0;
> + }
> + return PTR_ERR(mc->bcast_ch_regs);
> + }
> +
> + mc->ch_regs = devm_kcalloc(mc->dev, mc->soc->num_channels,
> + sizeof(*mc->ch_regs), GFP_KERNEL);
> + if (!mc->ch_regs)
> + return -ENOMEM;
> +
> + for (i = 0; i < mc->soc->num_channels; i++) {
> + char name[5];
> +
> + snprintf(name, sizeof(name), "ch%u", i);
> + mc->ch_regs[i] = devm_platform_ioremap_resource_byname(pdev, name);
> + if (IS_ERR(mc->ch_regs[i]))
> + return PTR_ERR(mc->ch_regs[i]);
> + }
> +
> + return 0;
> +}
> +
> const struct tegra_mc_ops tegra186_mc_ops = {
> .probe = tegra186_mc_probe,
> .remove = tegra186_mc_remove,
> .resume = tegra186_mc_resume,
> .probe_device = tegra186_mc_probe_device,
> + .map_regs = tegra186_mc_map_regs,
> };

Do we really need the map_regs() callback? Could you please move it to
the tegra186_mc_probe()? .. Sorry, I haven't noticed this previously.