Re: [RFC PATCH v6 6/9] media: tegra: Add Tegra210 Video input driver
From: Dmitry Osipenko
Date: Sun Apr 05 2020 - 15:46:02 EST
04.04.2020 04:25, Sowjanya Komatineni ÐÐÑÐÑ:
...
> +static int tegra_vi_probe(struct platform_device *pdev)
> +{
> + struct resource *res;
> + struct tegra_vi *vi;
> + int ret;
> +
> + vi = kzalloc(sizeof(*vi), GFP_KERNEL);
devm_kzalloc()?
> + if (!vi)
> + return -ENOMEM;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + vi->iomem = devm_ioremap_resource(&pdev->dev, res);
devm_platform_ioremap_resource()?
> + if (IS_ERR(vi->iomem)) {
> + ret = PTR_ERR(vi->iomem);
> + goto cleanup;
> + }
> +
> + vi->soc = of_device_get_match_data(&pdev->dev);
This can't fail because match already happened.
> + if (!vi->soc) {
> + ret = -ENODATA;
> + goto cleanup;
> + }
> +
> + vi->clk = devm_clk_get(&pdev->dev, NULL);
> + if (IS_ERR(vi->clk)) {
> + ret = PTR_ERR(vi->clk);
> + dev_err(&pdev->dev, "failed to get vi clock: %d\n", ret);
> + goto cleanup;
> + }
> +
> + vi->vdd = devm_regulator_get(&pdev->dev, "avdd-dsi-csi");
> + if (IS_ERR(vi->vdd)) {
> + ret = PTR_ERR(vi->vdd);
> + dev_err(&pdev->dev, "failed to get VDD supply: %d\n", ret);
> + goto cleanup;
> + }
> +
> + if (!pdev->dev.pm_domain) {
> + ret = -ENOENT;
> + dev_warn(&pdev->dev, "PM domain is not attached: %d\n", ret);
> + goto cleanup;
> + }
> +
> + ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
> + if (ret) {
> + dev_err(&pdev->dev,
> + "failed to populate vi child device: %d\n", ret);
> + goto cleanup;
> + }
> +
> + vi->dev = &pdev->dev;
> + vi->ops = vi->soc->ops;
> + platform_set_drvdata(pdev, vi);
> + pm_runtime_enable(&pdev->dev);
> +
> + /* initialize host1x interface */
> + INIT_LIST_HEAD(&vi->client.list);
> + vi->client.ops = &vi_client_ops;
> + vi->client.dev = &pdev->dev;
> +
> + ret = host1x_client_register(&vi->client);
> + if (ret < 0) {
> + dev_err(vi->dev,
> + "failed to register host1x client: %d\n", ret);
> + ret = -ENODEV;
> + goto rpm_disable;
> + }
> +
> + return 0;
> +
> +rpm_disable:
> + pm_runtime_disable(&pdev->dev);
> + of_platform_depopulate(vi->dev);
> +cleanup:
> + kfree(vi);
> + return ret;
> +}
> +
> +static int tegra_vi_remove(struct platform_device *pdev)
> +{
> + struct tegra_vi *vi = platform_get_drvdata(pdev);
> + int err;
> +
> + pm_runtime_disable(vi->dev);
> +
> + err = host1x_client_unregister(&vi->client);
> + if (err < 0) {
> + dev_err(vi->dev,
> + "failed to unregister host1x client: %d\n", err);
> + return err;
> + }
The removal order should be opposite to the registration order.