Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp996954imu; Fri, 4 Jan 2019 10:59:24 -0800 (PST) X-Google-Smtp-Source: ALg8bN47eIc/wXpU+rigTG1hBmw3g+emx5whiTKn0Sr36BVvr52R4IWlSKQD3PThCLGUviE7HJG7 X-Received: by 2002:a62:c185:: with SMTP id i127mr41283964pfg.43.1546628364262; Fri, 04 Jan 2019 10:59:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546628364; cv=none; d=google.com; s=arc-20160816; b=PzmTbpnu7jYpe//NVhtpY0gfraKwfwjB9MdQdL6ZpU7gCL+a2sIDkg7JIw6yPy2EoI DxvRtvZ0P7yoKGkys8F2lRuQPSFh8oTgINxKrkaR+lZayISwrDAQUQ7jKEeFxpM+RRa8 e2PX5klbiaF/f2JzJLAt/tf5yFrVZAcA2qWpVUyYu4fLtrYosmnRbCkVZMfJvJSxtiEh oik7heg/cU4nczZrPaayZnqk3NzcvIHr1Dr3tmKZZX1WDYB7oXp4VAGPcmAFTyMZjYNq buYTvmetudb5U5qnB7K7Epm+/JwawAv9SI1/1/wTvLiVwRaHehI/VsgMEyckF9X25wVL 8VEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=rhbkH+KM6NmIyK8ETyvSe3Yd/5IuQZ9ljNzqukES93w=; b=RDs8WCS6uWNLjilGivlvzSlXRq5kbjDBhaBNF2aVliWTCQN9MwD1o3P0rP/IDiEvKJ lQTN3Eja5lmR3aQ+eShT/vOnod27jxdx5oUzx1mfQJIfgYUIHBC8ZZ7d9GCyQT4knOLx ytu8seQ9VSgk48w7Z8CGvoUrz5Cqpf55A1310emAow4xNrSzstdn1cm27GAuhaVaP8ra mxNf3mqk3tByyIIYHDgUX6r0q5a/R/uMIfqGfhVaSL0+wyGkCXYo69VGHZZxXhpdgiY6 4ZlMvnaNBCO3+m/OI87cRZ3HDT1IzLXbbEx3RargjSfDrvWaHsX/xdyPgqhwZqXerY79 FscA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aruba.it header.s=a1 header.b=oE+Zp9ge; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o13si7088487pgp.540.2019.01.04.10.59.08; Fri, 04 Jan 2019 10:59:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@aruba.it header.s=a1 header.b=oE+Zp9ge; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727556AbfADRQU (ORCPT + 99 others); Fri, 4 Jan 2019 12:16:20 -0500 Received: from smtpcmd13146.aruba.it ([62.149.156.146]:43806 "EHLO smtpcmd13146.aruba.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726271AbfADRQU (ORCPT ); Fri, 4 Jan 2019 12:16:20 -0500 Received: from [192.168.188.46] ([93.34.66.13]) by smtpcmd13.ad.aruba.it with bizsmtp id LHGJ1z0070H9oKh01HGJss; Fri, 04 Jan 2019 18:16:19 +0100 Subject: Re: [PATCH v14 3/3] pps: pps-gpio pps-echo implementation To: Tom Burkart , Linux kernel mailing list Cc: Ricardo Martins , James Nuss , Lukas Senger References: <20181230083333.27210-1-tom@aussec.com> <20181230083333.27210-2-tom@aussec.com> <20181230083333.27210-3-tom@aussec.com> <20181230083333.27210-4-tom@aussec.com> From: Rodolfo Giometti Message-ID: <5eba2cc4-75fa-e1dc-8a86-68f1221d5e78@enneenne.com> Date: Fri, 4 Jan 2019 18:16:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181230083333.27210-4-tom@aussec.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aruba.it; s=a1; t=1546622179; bh=rhbkH+KM6NmIyK8ETyvSe3Yd/5IuQZ9ljNzqukES93w=; h=Subject:To:From:Date:MIME-Version:Content-Type; b=oE+Zp9ge74xyZEQ7tnPK5tZkgqszuD7ZE8ryr7Gy6JrfpmZUYejC7eA+s/6516jOn pacwLnCc2fIhCn1ceEniNGtK6f0YJTTu1VA/kHA2kV38gRO3xoEyZUg48YFZBA2yzR mwr1IRW2UqKgB7jrLwD591BZ1gJgy8nooxz8FvHLdVGn6wGx3nOksrorrFGV1t2LlN 1E2kCaFRbDO2AszgGuEmb0xBP3C2F2GL2+ECYAfzoZBcvJLcyC5TmBEAXmhcNUs64d 9OaTLkKw9IEmmI67m2J/EIU7FTo+rCFAJ2ZK9J8QS72YOYPTYvRlDpvTFgJvSzijEB st4EeWvQZKC4g== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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