Re: [PATCH v5 13/36] PM / devfreq: tegra30: Use MC timings for building OPP table
From: Dmitry Osipenko
Date: Fri Aug 14 2020 - 12:47:16 EST
14.08.2020 05:02, Chanwoo Choi пишет:
> Hi Dmitry,
>
> I add the minor comment. Except of some comments, it looks good to me.
Hello, Chanwoo! Thank you for the review!
...
>> +struct tegra_devfreq_soc_data {
>> + const char *mc_compatible;
>> +};
>> +
>> +static const struct tegra_devfreq_soc_data tegra30_soc = {
>> + .mc_compatible = "nvidia,tegra30-mc",
>> +};
>> +
>> +static const struct tegra_devfreq_soc_data tegra124_soc = {
>> + .mc_compatible = "nvidia,tegra124-mc",
>> +};
.
>> + soc_data = of_device_get_match_data(&pdev->dev);
>
> I think that better to check whether 'soc_data' is not NULL.
It's a quite common misconception among kernel developers that
of_device_get_match_data() may "accidentally" return NULL, but it
couldn't if every driver's of_match[] entry has a non-NULL .data field
and because the OF-matching already happened at the driver's probe-time
[1], which is the case of this driver.
[1] https://elixir.bootlin.com/linux/v5.8/source/drivers/of/device.c#L189
Hence the NULL-checking is unnecessary.
When I first encountered the of_device_get_match_data(), I was also
thinking that adding the NULL-checks is a good idea, but later on
somebody pointed out to me (maybe Thierry) that it's unnecessary to do.
>> +
>> + mc = tegra_get_memory_controller(soc_data->mc_compatible);
>> + if (IS_ERR(mc))
>> + return PTR_ERR(mc);
>
> You better to add error log.
In practice we should get only -EPROBE_DEFER here ever. I'll consider
adding the message in the next revision, at least just for consistency.
Thanks!
...
>> static const struct of_device_id tegra_devfreq_of_match[] = {
>> - { .compatible = "nvidia,tegra30-actmon" },
>> - { .compatible = "nvidia,tegra124-actmon" },
>> + { .compatible = "nvidia,tegra30-actmon", .data = &tegra30_soc, },
>> + { .compatible = "nvidia,tegra124-actmon", .data = &tegra124_soc, },
>> { },
>> };