From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C72CC2D0C8 for ; Tue, 17 Dec 2019 10:58:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3CBDE2064B for ; Tue, 17 Dec 2019 10:58:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727437AbfLQK6g (ORCPT ); Tue, 17 Dec 2019 05:58:36 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:59893 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727465AbfLQK6f (ORCPT ); Tue, 17 Dec 2019 05:58:35 -0500 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ihAYd-0001ni-EK; Tue, 17 Dec 2019 11:58:27 +0100 Received: from ukl by ptx.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1ihAYc-00054Y-76; Tue, 17 Dec 2019 11:58:26 +0100 Date: Tue, 17 Dec 2019 11:58:26 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Greg Kroah-Hartman Cc: Jacek Anaszewski , Pavel Machek , Dan Murphy , Jiri Slaby , linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, linux-serial@vger.kernel.org, kernel@pengutronix.de Subject: Re: [PATCH v2 3/3] leds: trigger: implement a tty trigger Message-ID: <20191217105826.6d2odt4k5b4qknjk@pengutronix.de> References: <20191217081718.23807-1-u.kleine-koenig@pengutronix.de> <20191217081718.23807-4-u.kleine-koenig@pengutronix.de> <20191217083211.GC2672708@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191217083211.GC2672708@kroah.com> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-serial@vger.kernel.org Sender: linux-serial-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org Hello Greg, On Tue, Dec 17, 2019 at 09:32:11AM +0100, Greg Kroah-Hartman wrote: > On Tue, Dec 17, 2019 at 09:17:18AM +0100, Uwe Kleine-König wrote: > > + ret = tty_get_icount(trigger_data->tty, &icount); > > + if (icount.rx > trigger_data->icount.rx || > > + icount.tx > trigger_data->icount.tx) { > > What happens when icount.rx and/or icount.tx wraps? It's "only" an int. Good catch. I wonder why this is not an unsigned quantity. Just grepping through drivers/tty/serial most drivers just increment these counters and don't care for overflow (which is undefined for ints) either. :-\ ..ooOO(Where is the can maintainer? --- We found a can of worms :-) > > + unsigned long delay_on = 100, delay_off = 100; > > + > > + led_blink_set_oneshot(trigger_data->led_cdev, > > + &delay_on, &delay_off, 0); > > + > > + trigger_data->icount = icount; > > Implicit memcpy of a structure? Ick. I'd call that elegant ;-) > All you care about are the two integers, why not just track them instead > of the whole thing? For now I only care about tx and rx, but I intend to add some bells and whistles to trigger on other events. (But I don't care much, can add that once I implement this support.) Best regards Uwe -- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |