From patchwork Mon Jun 21 19:18:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 464776 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 250FFC4743C for ; Mon, 21 Jun 2021 19:18:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 043FA611CE for ; Mon, 21 Jun 2021 19:18:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231182AbhFUTUw (ORCPT ); Mon, 21 Jun 2021 15:20:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbhFUTUu (ORCPT ); Mon, 21 Jun 2021 15:20:50 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A4DFC06175F for ; Mon, 21 Jun 2021 12:18:36 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id v20-20020a05600c2154b02901dcefb16af0so709593wml.5 for ; Mon, 21 Jun 2021 12:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9vnXDcb/InbvlkMkDsIMqHDLTc2kzXqa6l+0J9MdQ+k=; b=F0AfatU0TEJiTz81zFKMK9gBiSkCLixq3+Nqizb9u74dBfZICYNyTZmseOQQFA4hEV hJUGrzhi92FSWVted5r5XOO67jm3sx/DFimMGoWbX9c9F2yoRGNjfdc9EkJNoxEmJer2 2FZqN6deNrmQ/j02RssuElut75qb1C/rqisn3o2+TMKwCpNmpwXK8Og5UWye2XUqRRU6 tk3rXa1yWz1urnieNiAAKDIShVmRSMRcfbnSuy9rfYgamXZfiS7gqxuHhkfTGofH4WaO Fnr47SmL1W1Z765B2sB8C//5SzD4WZK7ZmiqnPo9QknC5qrhtrGm4Bsuxb7jW7mI2Bkn MZAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9vnXDcb/InbvlkMkDsIMqHDLTc2kzXqa6l+0J9MdQ+k=; b=Wlh00Zaz+VSkCY/VfgqT/pqop9AuCD+u/6BFZgfWpbTMJdGmdMNkac7aI30miLvpFf 5bWABuv95YzwkqlqPrZh6UYPQc1FcbyHLGPrJgN5IfeFIsl/tGJG5ej2lPf5fYH3x5wD 05dcfSr7CYb2b3VRhDlixOdOwHJUKsiNHTueVQTIsv9kzTJP6dTMa+7TrJ80Z6wZIxcv yYC0jHTsku472tZUK2lR9w4qVOtJjuq74hJXfKmeZdfyGrQs30vCOrbyUZyhY7nnt91L 45QjMOASSeLAcqTA/nNQQHjn8gy/LNTa8eb1x17xJOBGbHXxIWyAXYgeCACsEY/vXnpr yqYA== X-Gm-Message-State: AOAM532klYxrs2S3holy58B20Lum7e6jgtV/0DyMWQ3/BZYx8rwcGs6T B4AtxvZVhVqBSRW18yThCTufLQ== X-Google-Smtp-Source: ABdhPJxByHTCRBBExYhdaMfnb8ZG2sid9ilGh/oNzaPdXlA5vIOkyyPNocj+FWXyQYUDXz3QLxLHZw== X-Received: by 2002:a7b:c089:: with SMTP id r9mr8386372wmh.167.1624303114677; Mon, 21 Jun 2021 12:18:34 -0700 (PDT) Received: from debian-brgl.home (lfbn-nic-1-146-78.w2-15.abo.wanadoo.fr. [2.15.229.78]) by smtp.gmail.com with ESMTPSA id j34sm19438243wms.19.2021.06.21.12.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 12:18:34 -0700 (PDT) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij , Andy Shevchenko , Jack Winch , Helmut Grohne Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [libgpiod][PATCH 1/4] events: hide the *_read_fd() symbols from the API header Date: Mon, 21 Jun 2021 21:18:27 +0200 Message-Id: <20210621191830.10628-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210621191830.10628-1-brgl@bgdev.pl> References: <20210621191830.10628-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org While exposing file descriptors for polling (for use by event loops) is a common pattern, allowing to read data directly from file descriptors isn't really a thing in most linux libraries. Sane event loops allow to associate data with polled file descriptors so users know which object to use for receiving data when it's available. Signed-off-by: Bartosz Golaszewski --- include/gpiod.h | 24 ------------------------ lib/edge-event.c | 5 ++--- lib/info-event.c | 2 +- lib/internal.h | 3 +++ 4 files changed, 6 insertions(+), 28 deletions(-) diff --git a/include/gpiod.h b/include/gpiod.h index 50987a3..f3d20d4 100644 --- a/include/gpiod.h +++ b/include/gpiod.h @@ -410,14 +410,6 @@ gpiod_info_event_peek_line_info(struct gpiod_info_event *event); struct gpiod_line_info * gpiod_info_event_get_line_info(struct gpiod_info_event *event); -/** - * @brief Read the line info event from a file descriptor. - * @param fd File descriptor to read from. - * @return New info event object or NULL on error. The returned object must be - * freed using ::gpiod_info_event_free. - */ -struct gpiod_info_event *gpiod_info_event_read_fd(int fd); - /** * @} * @@ -1036,22 +1028,6 @@ gpiod_edge_event_buffer_get_event(struct gpiod_edge_event_buffer *buffer, unsigned int gpiod_edge_event_buffer_num_events(struct gpiod_edge_event_buffer *buffer); -/** - * @brief Read GPIO edge events directly from a file descriptor. - * @param fd File descriptor. - * @param buffer Line event buffer. - * @param max_events Maximum number of events to read. - * @return On success returns the number of events read from the file - * descriptor, on failure return -1. - * - * Users who directly poll the file descriptor for incoming events can also - * directly read the event data from it using this routine. This function - * translates the kernel representation of the event to the libgpiod format. - */ -int gpiod_edge_event_buffer_read_fd(int fd, - struct gpiod_edge_event_buffer *buffer, - unsigned int max_events); - /** * @} * diff --git a/lib/edge-event.c b/lib/edge-event.c index 4618116..f8aaa33 100644 --- a/lib/edge-event.c +++ b/lib/edge-event.c @@ -146,9 +146,8 @@ gpiod_edge_event_buffer_num_events(struct gpiod_edge_event_buffer *buffer) return buffer->num_events; } -GPIOD_API int -gpiod_edge_event_buffer_read_fd(int fd, struct gpiod_edge_event_buffer *buffer, - unsigned int max_events) +int gpiod_edge_event_buffer_read_fd(int fd, struct gpiod_edge_event_buffer *buffer, + unsigned int max_events) { struct gpio_v2_line_event *curr; struct gpiod_edge_event *event; diff --git a/lib/info-event.c b/lib/info-event.c index 587a599..3c55d36 100644 --- a/lib/info-event.c +++ b/lib/info-event.c @@ -86,7 +86,7 @@ gpiod_info_event_get_line_info(struct gpiod_info_event *event) return gpiod_line_info_copy(event->info); } -GPIOD_API struct gpiod_info_event *gpiod_info_event_read_fd(int fd) +struct gpiod_info_event *gpiod_info_event_read_fd(int fd) { struct gpio_v2_line_info_changed evbuf; ssize_t rd; diff --git a/lib/internal.h b/lib/internal.h index 20ef2e4..225e2b0 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -25,8 +25,11 @@ int gpiod_line_config_to_kernel(struct gpiod_line_config *config, const unsigned int *offsets); struct gpiod_line_request * gpiod_line_request_from_kernel(struct gpio_v2_line_request *reqbuf); +int gpiod_edge_event_buffer_read_fd(int fd, struct gpiod_edge_event_buffer *buffer, + unsigned int max_events); struct gpiod_info_event * gpiod_info_event_from_kernel(struct gpio_v2_line_info_changed *evbuf); +struct gpiod_info_event *gpiod_info_event_read_fd(int fd); int gpiod_poll_fd(int fd, uint64_t timeout); From patchwork Mon Jun 21 19:18:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 464775 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=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham 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 9C4D6C49EA2 for ; Mon, 21 Jun 2021 19:18:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DA4A611CE for ; Mon, 21 Jun 2021 19:18:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230464AbhFUTUy (ORCPT ); Mon, 21 Jun 2021 15:20:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231157AbhFUTUw (ORCPT ); Mon, 21 Jun 2021 15:20:52 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4724CC061756 for ; Mon, 21 Jun 2021 12:18:37 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id d11so18516960wrm.0 for ; Mon, 21 Jun 2021 12:18:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hz5gns+p3AhDjqhAsiXeZSwXwzEdrRvl08LEhr+L1D4=; b=xMOGfwhGzSTs0enDlVuS6L94owGvRKc674tCVRlseSvLPW7DiDMAkDVjLwycNm42qZ PO9Z6xbTCoxcqbt2xanQIJV/CwxpMXtvZ2oe4erFhoGbCd4a+1Vs7yr6d80u+Z3XGIaR KXEIp+4D7lLaIfDNLMDUPdY1YW0KOUJ/sXSnY5aj+4h7x4Mz1f1cUxC751Ze3PcRVKvq xswlbq/Z9ujTgmTe6hBoQtOA0c0eM4vJgs52SN7qww/8Xso3diUigisQHIPn5RpbH/lI Prd69FMogIwqzoyM3+WDoUTQeDIIrZTnpHy6FgNCVRk+X0s6OuSlhVLO21lXo47BGnc5 s3TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hz5gns+p3AhDjqhAsiXeZSwXwzEdrRvl08LEhr+L1D4=; b=sVG/r6pWn3T5UEsStoxnsiIUIUqYXY4BfZl5l9FUOe8FhmUuU21Lu44GLlhCqCvbsA 95od9MNDw7zNoRZunDgkbKCkLr3RNAJjQv5DtvKCn9cLL5vaOSi2Pr/fxAT6Xkkqe5x6 V67pxmF4coSy94h8d29BoJwuJyytFWCoGCVDj6gi1bV56hpRvbjniIaXiwKKd6wGZnH/ sT/sO6hsSXKXg/MzjVbEz6wINKW10ewYlLZnAfPge66CrFKwzQnFNP68AKI+Fwhzy2Ro OXDT4tDnKMJQa17+0DYdb8e7CbrFl5aQBrAluuY9rOIJFBuiT8O12QdL16Vi8WOSyODT GUbQ== X-Gm-Message-State: AOAM533IP97dwehh6pGUHQ6GDqB8VXmnWwDHgLFwV5YTIHbsKWYjXiDl UnHzZKfLm/AL+vlbWnyrlugegw== X-Google-Smtp-Source: ABdhPJxw3QZI5dNdg5DfmTlK71BxHYQNxvVt9MPDYXVWURCAWjsL72oLXBcZa6fpganbZ/P1nlofBw== X-Received: by 2002:a5d:6d8d:: with SMTP id l13mr30357572wrs.304.1624303115951; Mon, 21 Jun 2021 12:18:35 -0700 (PDT) Received: from debian-brgl.home (lfbn-nic-1-146-78.w2-15.abo.wanadoo.fr. [2.15.229.78]) by smtp.gmail.com with ESMTPSA id j34sm19438243wms.19.2021.06.21.12.18.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 12:18:35 -0700 (PDT) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij , Andy Shevchenko , Jack Winch , Helmut Grohne Cc: linux-gpio@vger.kernel.org, Bartosz Golaszewski Subject: [libgpiod][PATCH 3/4] API: add an AS_IS value for bias setting Date: Mon, 21 Jun 2021 21:18:29 +0200 Message-Id: <20210621191830.10628-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210621191830.10628-1-brgl@bgdev.pl> References: <20210621191830.10628-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org We don't have an explicit default "as-is" value for the bias setting. This adds it. Signed-off-by: Bartosz Golaszewski --- include/gpiod.h | 4 +++- lib/line-config.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/gpiod.h b/include/gpiod.h index 3671c2d..629601a 100644 --- a/include/gpiod.h +++ b/include/gpiod.h @@ -451,7 +451,9 @@ enum { * @brief Available internal bias settings for line requests. */ enum { - GPIOD_LINE_CONFIG_BIAS_DISABLED = 1, + GPIOD_LINE_CONFIG_BIAS_AS_IS = 1, + /**< Don't change the current bias setting. */ + GPIOD_LINE_CONFIG_BIAS_DISABLED, /**< The internal bias should be disabled (the default). */ GPIOD_LINE_CONFIG_BIAS_PULL_UP, /**< The internal pull-up bias is enabled. */ diff --git a/lib/line-config.c b/lib/line-config.c index 5b6dab4..24dc5f4 100644 --- a/lib/line-config.c +++ b/lib/line-config.c @@ -496,6 +496,7 @@ static int gpiod_make_kernel_flags(uint64_t *flags, struct base_config *config) case GPIOD_LINE_CONFIG_BIAS_PULL_DOWN: *flags |= GPIO_V2_LINE_FLAG_BIAS_PULL_DOWN; break; + case GPIOD_LINE_CONFIG_BIAS_AS_IS: case 0: break; default: