lkml.org 
[lkml]   [2019]   [Jan]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v14 3/3] pps: pps-gpio pps-echo implementation
From
Date
On 30/12/2018 09:33, Tom Burkart wrote:
> This patch implements the pps echo functionality for pps-gpio, that
> sysfs claims is available already.
>
> Configuration is done via device tree bindings.
>
> This patch was originally written by Lukas Senger as part of a masters
> thesis project and modified for inclusion into the linux kernel by Tom
> Burkart.

[snip]

> +static void pps_gpio_echo(struct pps_device *pps, int event, void *data)
> +{
> + /* add_timer() needs to write into info->echo_timer */
> + struct pps_gpio_device_data *info;
> +
> + info = data;

Maybe you can write as below and saving two lines and having better readability:

struct pps_gpio_device_data *info = data;

> + switch (event) {
> + case PPS_CAPTUREASSERT:
> + if (pps->params.mode & PPS_ECHOASSERT)
> + gpiod_set_value(info->echo_pin, 1);
> + break;
> +
> + case PPS_CAPTURECLEAR:
> + if (pps->params.mode & PPS_ECHOCLEAR)
> + gpiod_set_value(info->echo_pin, 1);
> + break;
> + }
> +
> + /* fire the timer */
> + if (info->pps->params.mode & (PPS_ECHOASSERT | PPS_ECHOCLEAR)) {
> + info->echo_timer.expires = jiffies + info->echo_timeout;
> + add_timer(&info->echo_timer);
> + }
> +}

I think is better firing the timer if and only if we set the echo GPIO otherwise
it's useless...

Ciao,

Rodolfo

--
GNU/Linux Solutions e-mail: giometti@enneenne.com
Linux Device Driver giometti@linux.it
Embedded Systems phone: +39 349 2432127
UNIX programming skype: rodolfo.giometti

\
 
 \ /
  Last update: 2019-01-04 18:16    [W:0.085 / U:6.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site