lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VdphCGXYEMrF0eJ4WLe=wg_0o_xH833jJ1xjGynKV3jXA@mail.gmail.com>
Date:   Thu, 18 May 2017 19:01:59 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Geert Uytterhoeven <geert+renesas@...der.be>
Cc:     Mark Brown <broonie@...nel.org>, Rob Herring <robh+dt@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Magnus Damm <magnus.damm@...il.com>,
        Wolfram Sang <wsa+renesas@...g-engineering.com>,
        Hiromitsu Yamasaki <hiromitsu.yamasaki.ym@...esas.com>,
        Jiada Wang <jiada_wang@...tor.com>,
        Matt Porter <mporter@...sulko.com>,
        linux-spi <linux-spi@...r.kernel.org>,
        devicetree <devicetree@...r.kernel.org>,
        Linux-Renesas <linux-renesas-soc@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4 5/6] spi: slave: Add SPI slave handler reporting uptime
 at previous message

On Wed, May 17, 2017 at 3:47 PM, Geert Uytterhoeven
<geert+renesas@...der.be> wrote:
> Add an example SPI slave handler responding with the uptime at the time
> of reception of the last SPI message.
>
> This can be used by an external microcontroller as a dead man's switch.

> +static int spi_slave_time_submit(struct spi_slave_time_priv *priv)
> +{
> +       u32 rem_ns;
> +       int ret;
> +       u64 ts;
> +
> +       ts = local_clock();
> +       rem_ns = do_div(ts, 1000000000) / 1000;

You divide ts by 10^9, which makes it seconds if it was nanoseconds.

But reminder is still in nanoseconds and you divide it by 10^3.

If I didn't miss anything it should be called like

rem_ns -> reminder_ms

> +
> +       priv->buf[0] = cpu_to_be32(ts);
> +       priv->buf[1] = cpu_to_be32(rem_ns);
> +
> +       spi_message_init_with_transfers(&priv->msg, &priv->xfer, 1);
> +
> +       priv->msg.complete = spi_slave_time_complete;
> +       priv->msg.context = priv;
> +
> +       ret = spi_async(priv->spi, &priv->msg);
> +       if (ret)
> +               pr_err("%s: spi_async() failed %d\n", __func__, ret);

Perhaps dev_err() ?

> +
> +       return ret;
> +}

> +static int spi_slave_time_probe(struct spi_device *spi)
> +{
> +       struct spi_slave_time_priv *priv;
> +       int ret;
> +
> +       /*
> +        * bits_per_word cannot be configured in platform data
> +        */
> +       spi->bits_per_word = 8;

Is it worth to define it? If so, can we use device properties for that?

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ