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

From: Dmitry Osipenko
Date: Mon Apr 25 2022 - 15:25:54 EST


On 4/25/22 10:50, Ashish Mhetre wrote:
> +static int tegra186_mc_map_regs(struct tegra_mc *mc)
> +{
> + struct platform_device *pdev = to_platform_device(mc->dev);
> + 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(void __iomem *), GFP_KERNEL);

You should use sizeof(*mc->ch_regs) in general to prevent mistakes.

> + 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);

The type of "i" variable is int, change it to unsigned int.

With that:

Reviewed-by: Dmitry Osipenko <dmitry.osipenko@xxxxxxxxxxxxx>