Re: [PATCHv6 3/4] iio: devicetree: Add DT binding documentation for Exynos3250 ADC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 21.07.2014 10:00, Arnd Bergmann wrote:
> On Monday 21 July 2014 10:52:28 Chanwoo Choi wrote:
>>> Yes, your current version is certainly better than this, but another way
>>> to address Tomasz' comment would be to change the binding to list the "sclk"
>>> as optional for any device and make the code silently ignore missing sclk
>>> entries, like:
>>>
>>>
>>>       info->sclk = devm_clk_get(&pdev->dev, "sclk");
>>>       if (IS_ERR(info->sclk)) {
>>>               switch (PTR_ERR(info->sclk)) {
>>>               case -EPROBE_DEFER:
>>>                       /* silently return error so we can retry */
>>>                       return -EPROBE_DEFER:
>>>               case -ENOENT:
>>>                       /* silently ignore missing optional clk */
>>>                       info->sclk = NULL;
>>>                       break;
>>>               default:
>>>                       /* any other error: clk is defined by doesn't work  */
>>>                       dev_err(&pdev->dev, "failed getting sclk clock, err = %ld\n",
>>>                               PTR_ERR(info->sclk));
>>>                       return PTR_ERR(info->sclk));
>>>               }
>>>       }
>>
>> I tested this patch suggested by you.
>> But, devm_clk_get returns always '-ENOENT' on follwong two cases:
>>
>> Case 1.
>> ADC dt node in exynos3250.dtsi don't include 'sclk' clock as following:
>>
>>                 adc: adc@126C0000 {
>>                         compatible = "samsung,exynos3250-adc";
>>                         reg = <0x126C0000 0x100>, <0x10020718 0x4>;
>>                         interrupts = <0 137 0>;
>>                         clock-names = "adc";
>>                         clocks = <&cmu CLK_TSADC>;
>>                         #io-channel-cells = <1>;
>>                         io-channel-ranges;
>>                 };
>>
>> Case 2.
>> ADC dt node in exynos3250.dtsi don't include 'sclk' clock
>> but, exynos3250 clock controller don't support CLK_SCLK_TSADC clock as following:
>>
>>                 adc: adc@126C0000 {
>>                         compatible = "samsung,exynos3250-adc";
>>                         reg = <0x126C0000 0x100>, <0x10020718 0x4>;
>>                         interrupts = <0 137 0>;
>>                         clock-names = "adc", "sclk";
>>                         clocks = <&cmu CLK_TSADC>, <&cmu CLK_SCLK_TSADC>;
>>                         #io-channel-cells = <1>;
>>                         io-channel-ranges;
>>                 };
> 
> But neither of those cases is actually a correct DT representation for
> exynos3250: The first case describes an ADC that doesn't need a second
> clock, so if the hardware actually needs it to function, it is clearly
> unsufficiently described. The second case is even worse because it refers
> to a clock that isn't there. Actually that should probably return a different
> error code, but that's a different matter.
> 
>> So, I think exynos-adc needs to use 'needs_sclk' field suggested by Tomasz Figa.
> 
> I don't mind you adding a field to the data, especially since you already
> need to have separate structures to encode the different number of channels.
> However, I don't see it as necessary either. What you do here is just
> checking the DT representation for correctness and consistency. It's not
> harmful but we don't normally do that because passing incorrect DT blobs
> can cause an infinite number of other problems that we don't check for.

I believe we should be enforcing as much correctness on DT data as
possible without too much burden in the code. Otherwise how we are
supposed to know if an error is caused by wrong/missing data in DT, bug
in the driver or who knows else?

In this case making this clock required depending on compatible string
doesn't seem too bothersome to me.

Best regards,
Tomasz
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux