[PATCH] leds: sun50i-a100: avoid division-by-zero warning

Arnd Bergmann arnd at arndb.de
Tue Dec 12 22:32:14 PST 2023


On Wed, Dec 13, 2023, at 02:26, Guo Ren wrote:
> On Wed, Dec 13, 2023 at 5:45 AM Arnd Bergmann <arnd at kernel.org> wrote:
>>  {
>>         const struct sun50i_a100_ledc_timing *timing = &priv->timing;
>>         unsigned long mod_freq = clk_get_rate(priv->mod_clk);
>> -       u32 cycle_ns = NSEC_PER_SEC / mod_freq;
>> +       u32 cycle_ns;
>>         u32 control;
>>
>> +       if (!mod_freq)
>> +               return;
>> +
> Shall we need err_disable_bus_clk?
>
> + static int sun50i_a100_ledc_set_timing(struct sun50i_a100_ledc *priv)
> - static void sun50i_a100_ledc_set_timing(struct sun50i_a100_ledc *priv)

I'm not worried about it too much, as there is already an error check
on priv->mod_clk being unavailable during initialization. The case that
the warning is about is just for build-testing on architectures that
don't even use COMMON_CLK.

     Arnd



More information about the linux-arm-kernel mailing list