Re: [PATCH v6 10/11] rtc: isl1208: Add isl1208_set_xtoscb()

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

 



Hi Biju,

On Fri, Jun 2, 2023 at 4:25 PM Biju Das <biju.das.jz@xxxxxxxxxxxxxx> wrote:
> As per the HW manual, set the XTOSCB bit as follows:
>
> If using an external clock signal, set the XTOSCB bit as 1 to
> disable the crystal oscillator.
>
> If using an external crystal, the XTOSCB bit needs to be set at 0
> to enable the crystal oscillator.
>
> Add isl1208_set_xtoscb() to set XTOSCB bit based on the clock-names
> property. Fallback is enabling the internal crystal oscillator.
>
> While at it, introduce a variable "sr" for reading the status register
> in probe() as it is reused for writing.
>
> Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> ---
> v5->v6:
>  * Added Rb tag from Geert
>  * Replaced u8->int for xtosb_val parameter.
>  * Introduced isl1208_clk_present() for checking the presence of "xin" and
>    "clkin" for determining internal oscillator is enabled or not.

Thanks for the update!

> --- a/drivers/rtc/rtc-isl1208.c
> +++ b/drivers/rtc/rtc-isl1208.c
> @@ -805,12 +816,33 @@ static int isl1208_setup_irq(struct i2c_client *client, int irq)
>         return rc;
>  }
>
> +static int
> +isl1208_clk_present(struct i2c_client *client, const char *name)
> +{
> +       struct clk *clk;
> +       int ret;
> +
> +       clk = devm_clk_get_optional(&client->dev, name);
> +       if (IS_ERR(clk)) {
> +               ret = PTR_ERR(clk);
> +       } else {
> +               if (!clk)

What about "else if"? ;-)
But in this case, you can make the code even simpler (less indented)
by returning early after each test.

> +                       ret = 0;
> +               else
> +                       ret = 1;
> +       }

if (IS_ERR(clk))
        return PTR_ERR(clk);

return !!clk;

> +
> +       return ret;
> +}
> +

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds



[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux