Re: [PATCH V2 4/4] soc: imx: Add blk-ctl driver for i.MX8MM

From: Fabio Estevam
Date: Tue May 04 2021 - 07:14:27 EST


Hi Peng,

On Fri, Apr 30, 2021 at 1:56 AM Peng Fan (OSS) <peng.fan@xxxxxxxxxxx> wrote:

> +static int imx8mm_blk_ctl_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + const struct imx_blk_ctl_dev_data *dev_data = of_device_get_match_data(dev);
> + struct regmap *regmap;
> + struct resource *res;
> + struct imx_blk_ctl *ctl;
> + void __iomem *base;
> +
> + ctl = devm_kzalloc(dev, sizeof(*ctl), GFP_KERNEL);
> + if (!ctl)
> + return -ENOMEM;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + base = devm_ioremap_resource(dev, res);
> + if (IS_ERR(base))
> + return PTR_ERR(base);
> +
> + regmap = devm_regmap_init_mmio(dev, base, &dev_data->config);
> + if (IS_ERR(regmap))
> + return PTR_ERR(regmap);
> +
> + ctl->regmap = regmap;
> + ctl->dev = dev;
> + atomic_set(&ctl->power_count, 0);
> +
> + ctl->num_clks = devm_clk_bulk_get_all(dev, &ctl->clks);
> + if (ctl->num_clks < 0)
> + return ctl->num_clks;
> +
> + dev_set_drvdata(dev, ctl);
> + ctl->dev_data = of_device_get_match_data(dev);

No need to call of_device_get_match_data() twice. You could do:

ctl->dev_data = dev_data;