Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2884250pxb; Tue, 24 Aug 2021 09:49:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVApwWO7cvx5GVl2cM3Yd+JbnEBwNZpIqvYfennV7V2TZxY8JVvMQ2nU9JApmOAfk4z2WK X-Received: by 2002:a05:6e02:e51:: with SMTP id l17mr27886207ilk.73.1629823777201; Tue, 24 Aug 2021 09:49:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629823777; cv=none; d=google.com; s=arc-20160816; b=uSMPVe3z5B6eGOxp1U1/SM57szlAj6025IRII/0/rlc98QLtrCcb4uVdkOmQcpYQ3L hlJIRkaFSGGK2cS1pWpuBBZJeND1nnVTT/t2KtheQKzZP4hf2MAhsGfzVMIFNctXb0+8 RHTdw/5586A4ALGPOANxYjM1lt0/iejZQ2W5YKpnE4WssKKdt45qA5I6o7zgPRD/evKZ 9+GXutYwA7cOxwi7ay4WFgEHfAIRb9xBUfOD2yOJF1eprcEPB7qKBzD8khG2HsWFf8dx wOqMnczRUsHyHduk3En02DfC7XBRytd9W6fKkPsi2zp2b5449LR0kNa3clO1Gi9b3IQN yQaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=x3TKbrCBcl+wGbORHezWzFLesZ+qdy/ttiMyLCO7udc=; b=bbOnzZQ2lSKnMvwwZVDtf815b61X1GIwkQWGdYVFVmz2JErgSsBcLqCQfx8yXk0a/C Xvi/U26ri8Pi6t7fN/pCC90I1qeDXRdPnA4i0c89j44tuLw/qe6izXfK5ISaMhUmhy3v CVeYvJXykUMF8OdXIQKOt8yKsHU85ND9b8NV5zp7VuJxq2RpcIUnX5GMvq+yDtVb9Gsh hHjktn/h5ihI4/GDu71+SRsGpxW7xzPuQDsLvucC2/+C2P8qM8hPcRoqApYxOY0RQVKV qaV0D+lFTu0KFumHGr1kzie/DM8kiCOiXA1ibLiT2gQDTvx0wmb/J4SgA0CCttMhp/dN SPJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c1si17052324jap.87.2021.08.24.09.49.25; Tue, 24 Aug 2021 09:49:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233040AbhHXQtG (ORCPT + 99 others); Tue, 24 Aug 2021 12:49:06 -0400 Received: from mga02.intel.com ([134.134.136.20]:10207 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229896AbhHXQtE (ORCPT ); Tue, 24 Aug 2021 12:49:04 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10086"; a="204550681" X-IronPort-AV: E=Sophos;i="5.84,347,1620716400"; d="scan'208";a="204550681" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Aug 2021 09:48:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,347,1620716400"; d="scan'208";a="684036740" Received: from inlubt0177.iind.intel.com ([10.223.67.91]) by fmsmga006.fm.intel.com with ESMTP; 24 Aug 2021 09:48:17 -0700 From: lakshmi.sowjanya.d@intel.com To: linus.walleij@linaro.org Cc: linux-gpio@vger.kernel.org, bgolaszewski@baylibre.com, linux-kernel@vger.kernel.org, mgross@linux.intel.com, andriy.shevchenko@linux.intel.com, tamal.saha@intel.com, bala.senthil@intel.com, lakshmi.sowjanya.d@intel.com Subject: [RFC PATCH v1 05/20] tools: gpio: Add additional polling support to gpio-event-mon Date: Tue, 24 Aug 2021 22:17:46 +0530 Message-Id: <20210824164801.28896-6-lakshmi.sowjanya.d@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210824164801.28896-1-lakshmi.sowjanya.d@intel.com> References: <20210824164801.28896-1-lakshmi.sowjanya.d@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christopher Hall Intel Timed I/O hardware doesn't support reading the current levels, allow application to continue if this fails. The Timed I/O hardware aggregates muliple events, but doesn't distinguish between rising and falling edges *if* both types are selected. Add output 'verbiage' for unknown event type. Add verbosity parameter to suppress printing of "nothing available" poll result. This can be re-enabled at runtime with "-vv" parameter. Signed-off-by: Christopher Hall Signed-off-by: Tamal Saha Co-developed-by: Lakshmi Sowjanya D Signed-off-by: Lakshmi Sowjanya D Reviewed-by: Mark Gross --- include/uapi/linux/gpio.h | 1 + tools/gpio/gpio-event-mon.c | 42 ++++++++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/include/uapi/linux/gpio.h b/include/uapi/linux/gpio.h index eaaea3d8e6b4..ed84805baee8 100644 --- a/include/uapi/linux/gpio.h +++ b/include/uapi/linux/gpio.h @@ -267,6 +267,7 @@ struct gpio_v2_line_info_changed { enum gpio_v2_line_event_id { GPIO_V2_LINE_EVENT_RISING_EDGE = 1, GPIO_V2_LINE_EVENT_FALLING_EDGE = 2, + GPIO_V2_LINE_EVENT_UNKNOWN_EDGE = 3, }; /** diff --git a/tools/gpio/gpio-event-mon.c b/tools/gpio/gpio-event-mon.c index a2b233fdb572..d8f0bbf78728 100644 --- a/tools/gpio/gpio-event-mon.c +++ b/tools/gpio/gpio-event-mon.c @@ -29,7 +29,8 @@ int monitor_device(const char *device_name, unsigned int *lines, unsigned int num_lines, struct gpio_v2_line_config *config, - unsigned int loops) + unsigned int loops, + int verbosity) { struct gpio_v2_line_values values; char *chrdev_name; @@ -62,16 +63,23 @@ int monitor_device(const char *device_name, gpiotools_set_bit(&values.mask, i); ret = gpiotools_get_values(lfd, &values); if (ret < 0) { - fprintf(stderr, - "Failed to issue GPIO LINE GET VALUES IOCTL (%d)\n", - ret); - goto exit_line_close; + if (errno == EIO) { + fprintf(stdout, + "Failed to get line values. Function unimplemented, continuing\n"); + } else { + ret = -errno; + fprintf(stderr, + "Failed to issue GPIO LINE GET VALUES IOCTL (%d)\n", + ret); + goto exit_line_close; + } } if (num_lines == 1) { fprintf(stdout, "Monitoring line %d on %s\n", lines[0], device_name); - fprintf(stdout, "Initial line value: %d\n", - gpiotools_test_bit(values.bits, 0)); + if (ret != -1) + fprintf(stdout, "Initial line value: %d\n", + gpiotools_test_bit(values.bits, 0)); } else { fprintf(stdout, "Monitoring lines %d", lines[0]); for (i = 1; i < num_lines - 1; i++) @@ -91,8 +99,9 @@ int monitor_device(const char *device_name, ret = read(lfd, &event, sizeof(event)); if (ret == -1) { - if (errno == -EAGAIN) { - fprintf(stderr, "nothing available\n"); + if (errno == EAGAIN) { + if (verbosity >= 2) + fprintf(stdout, "nothing available\n"); continue; } else { ret = -errno; @@ -117,8 +126,11 @@ int monitor_device(const char *device_name, case GPIO_V2_LINE_EVENT_FALLING_EDGE: fprintf(stdout, "falling edge"); break; + case GPIO_V2_LINE_EVENT_UNKNOWN_EDGE: + fprintf(stdout, "rising/falling edge"); + break; default: - fprintf(stdout, "unknown event"); + fprintf(stdout, "unknown event spec: %x", event.id); } fprintf(stdout, "\n"); @@ -150,6 +162,7 @@ void print_usage(void) " -f Listen for falling edges\n" " -w Report the wall-clock time for events\n" " -b Debounce the line with period n microseconds\n" + " -v Verbosity\n" " [-c ] Do loops (optional, infinite loop if not stated)\n" " -? This helptext\n" "\n" @@ -169,12 +182,13 @@ int main(int argc, char **argv) unsigned int num_lines = 0; unsigned int loops = 0; struct gpio_v2_line_config config; + int verbosity = 0; int c, attr, i; unsigned long debounce_period_us = 0; memset(&config, 0, sizeof(config)); config.flags = GPIO_V2_LINE_FLAG_INPUT; - while ((c = getopt(argc, argv, "c:n:o:b:dsrfw?")) != -1) { + while ((c = getopt(argc, argv, "c:n:o:b:dsrfwv?")) != -1) { switch (c) { case 'c': loops = strtoul(optarg, NULL, 10); @@ -208,6 +222,9 @@ int main(int argc, char **argv) case 'w': config.flags |= GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME; break; + case 'v': + ++verbosity; + break; case '?': print_usage(); return -1; @@ -232,5 +249,6 @@ int main(int argc, char **argv) "falling edges\n"); config.flags |= EDGE_FLAGS; } - return monitor_device(device_name, lines, num_lines, &config, loops); + return monitor_device(device_name, lines, num_lines, &config, loops, + verbosity); } -- 2.17.1