On 6 November 2014 12:35, Mikko Perttunen <[email protected]> wrote:
> On 11/06/2014 09:56 AM, Alexandre Courbot wrote:
>>
>> On 10/30/2014 01:22 AM, Tomeu Vizoso wrote:
>>> +static int tegra_emc_probe(struct platform_device *pdev)
>>> +{
>>> +    struct tegra_emc *tegra;
>>> +    struct device_node *node;
>>> +    struct platform_device *mc_pdev;
>>> +    struct resource *res;
>>> +    u32 ram_code, node_ram_code;
>>> +    int err;
>>> +
>>> +    tegra = devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL);
>>> +    if (!tegra)
>>> +        return -ENOMEM;
>>> +
>>> +    tegra->pdev = pdev;
>>> +
>>> +    res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>> +    tegra->emc_regs = devm_ioremap_resource(&pdev->dev, res);
>>> +    if (IS_ERR(tegra->emc_regs)) {
>>> +        dev_err(&pdev->dev, "failed to map EMC regs\n");
>>> +        return PTR_ERR(tegra->emc_regs);
>>> +    }
>>> +
>>> +    node = of_parse_phandle(pdev->dev.of_node,
>>> +                "nvidia,memory-controller", 0);
>>> +    if (!node) {
>>> +        dev_err(&pdev->dev, "could not get memory controller\n");
>>> +        return -ENOENT;
>>> +    }
>>> +
>>> +    mc_pdev = of_find_device_by_node(node);
>>> +    if (!mc_pdev)
>>> +        return -ENOENT;
>>
>>
>> Isn't there a risk that we will return -ENOENT depending on the probe
>> order? I.e. if this device is probed before the MC device?
>
>
> Yes.. I remember having some trouble with this code. IIRC, I couldn't figure
> out a way to sanely detect if the MC driver had been probed or not. Clearly
> this is not good, though.

Yeah, I found this issue during testing and resorted to
subsys_initcall(). Any better ideas?

Thanks,

Tomeu
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to