[PATCH] mtd: rawnand: denali_dt: make the core clock optional

Marek Vasut marex at denx.de
Fri Jan 10 01:15:18 CET 2020


On 1/9/20 4:36 PM, Masahiro Yamada wrote:
> On Thu, Jan 9, 2020 at 10:20 PM Marek Vasut <marex at denx.de> wrote:
>>
>> On 1/9/20 1:02 PM, Masahiro Yamada wrote:
>>> The "nand_x" and "ecc" clocks are currently optional. Make the core
>>> clock optional in the same way. This will allow platforms with no clock
>>> driver support to use this driver.
>>>
>>> Signed-off-by: Masahiro Yamada <yamada.masahiro at socionext.com>
>>> ---
>>>
>>>  drivers/mtd/nand/raw/denali_dt.c | 10 ++++++----
>>>  1 file changed, 6 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/mtd/nand/raw/denali_dt.c b/drivers/mtd/nand/raw/denali_dt.c
>>> index 0ce81324b90e..b1e14982c443 100644
>>> --- a/drivers/mtd/nand/raw/denali_dt.c
>>> +++ b/drivers/mtd/nand/raw/denali_dt.c
>>> @@ -91,7 +91,7 @@ static int denali_dt_probe(struct udevice *dev)
>>>       if (ret)
>>>               ret = clk_get_by_index(dev, 0, &clk);
>>>       if (ret)
>>> -             return ret;
>>> +             clk.dev = NULL;
>>>
>>>       ret = clk_get_by_name(dev, "nand_x", &clk_x);
>>>       if (ret)
>>> @@ -101,9 +101,11 @@ static int denali_dt_probe(struct udevice *dev)
>>>       if (ret)
>>>               clk_ecc.dev = NULL;
>>>
>>> -     ret = clk_enable(&clk);
>>> -     if (ret)
>>> -             return ret;
>>> +     if (clk.dev) {
>>> +             ret = clk_enable(&clk);
>>> +             if (ret)
>>> +                     return ret;
>>> +     }
>>>
>>>       if (clk_x.dev) {
>>>               ret = clk_enable(&clk_x);
>>>
>>
>> Why do we need any of the clock code if the clock aren't available ? It
>> just takes space for no reason.
> 
> Are you sure?
> 
> The compiler optimizes the unreachable code out.
> 
> 
> My compiler is this:
> 
> $ aarch64-linux-gnu-gcc --version
> aarch64-linux-gnu-gcc (Linaro GCC 7.4-2019.02) 7.4.1 20181213
> [linaro-7.4-2019.02 revision 56ec6f6b99cc167ff0c2f8e1a2eed33b1edc85d4]
> Copyright (C) 2017 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> 
> 
> 
> I compiled the denali_dt.c with CONFIG_CLK disabled
> and here is the disassembly.
> 
> My patch and yours produce exactly the same code.

Ha, there's indeed no increase. I tested this patch and it works too.
Thanks

I sent this again as part of the reworked series with a T-B.


More information about the U-Boot mailing list