lkml.org 
[lkml]   [2014]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3 10/13] memory: tegra: Add EMC (external memory controller) driver
On 6 November 2014 12:35, Mikko Perttunen <mikko.perttunen@kapsi.fi> 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


\
 
 \ /
  Last update: 2014-11-07 17:41    [W:0.147 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site