On Wed, Jun 22, 2016 at 03:42:07PM +0200, Geert Uytterhoeven wrote:
> Add an SPI slave handler responding with the time of reception of the
> last SPI message.
> 
> This can be used by an external microcontroller as a dead man's switch.

The subject says boot up time, this says time of reception of the last
message.  Which is it?

> +static int spi_slave_time_send(struct spi_device *spi)
> +{
> +     __be32 msg[2];
> +     u32 rem_ns;
> +     u64 ts;
> +
> +     ts = local_clock();
> +     rem_ns = do_div(ts, 1000000000) / 1000;
> +
> +     msg[0] = cpu_to_be32(ts);
> +     msg[1] = cpu_to_be32(rem_ns);
> +
> +     return spi_write(spi, &msg, sizeof(msg));
> +}

Looks like uptime which is a third thing.

> +static int spi_slave_time_remove(struct spi_device *spi)
> +{
> +     struct spi_slave_time_priv *priv = spi_get_drvdata(spi);
> +
> +     /* FIXME Doesn't work, as spi_write() is blocked on a completion */
> +     kthread_stop(priv->thread);

spi_async()?  Still no cancellation on the actual operation but it
pushes it more inside the framework.

Attachment: signature.asc
Description: PGP signature

Reply via email to