From patchwork Wed Mar 16 02:04:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Gibson X-Patchwork-Id: 552890 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB0D9C433F5 for ; Wed, 16 Mar 2022 02:05:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349556AbiCPCGX (ORCPT ); Tue, 15 Mar 2022 22:06:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234143AbiCPCGW (ORCPT ); Tue, 15 Mar 2022 22:06:22 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBC495E742 for ; Tue, 15 Mar 2022 19:05:09 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id p17so638559plo.9 for ; Tue, 15 Mar 2022 19:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=shPogJ7f9IzUSYn9HOTijUz5bww6Va0UQ0xxdoTkiUc=; b=eeNKYx5Jl/FCDqHfdnWG91eUHhiZYOg5T5cZzdYc7ah/KikYTLgo1qfeySg3M5ImCA 4ZKB9rYr6E6Y3U/ZAGEUkI274uoeqqobjHkO1q5JKvYJ/hQzy/kLFUUFwlrEnftnoImE i1dTvIS0giqDvHss+5YaE3ISA29dQ6VigI9R/pzfUSdJvqRgi/tx2Av3ge/vLxBohGBe baOOaWRC9XmMwSnFMn4mPEEKYb0M5+VdZLdnFPnOqrUFb/lCtrTt68pQKlVvPPLqyLKs WbiqLB9MXE6LQ/UX1bSWJqUZZh3f6yXWPaTUd2YtrLgRih147IZvMhUe76rcRKtNLPKi qabw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=shPogJ7f9IzUSYn9HOTijUz5bww6Va0UQ0xxdoTkiUc=; b=pNmOW+sDg38WjEakWVY+36ohGP7ij5N5b7H+6ZgUsNouAyG4zRr0Ll7mu4q9d2FD1q KzzkGhZkHMSmaJaSVU7KJvdLPkL8DESjbLrdw98ww/31sO1dowqxFxAZ1isoWmAUhGY3 GXE1yOiqMEmCnbxk4OFy+qVoBQofHjkxOLWWwV4Cy/Pa/s/uipmxKz4mCa/Gp26lZPbZ SsUTAIb6DrqKR8jzDILR8gDDVPyH0YyHGbX388aHrm1bJ5i7gwIhHkOYazxcSgxYQeyb sEAdQAmrmaUb+E3QNWqTXM7m0tQMQPuvWgPMs3PFjVcooFA5X2BUO7XYCp9ljl4KedNq b9mQ== X-Gm-Message-State: AOAM531ybyC7k1cLVqwf6AdJl0V1yJ54uxBQ9EyDT4sBu4/vyerYooSA V9uHgQ73B7FvfkooeYn3wfuKOOfWLZRS7Q== X-Google-Smtp-Source: ABdhPJyCPqRLVnvQKToPp4yh2MeHMIF1a/ggRS9R8ffcoViTNVghE+aGeGYtLy+ACdGRyBrcadvgeA== X-Received: by 2002:a17:90a:5802:b0:1b8:b737:a62b with SMTP id h2-20020a17090a580200b001b8b737a62bmr7790877pji.123.1647396308463; Tue, 15 Mar 2022 19:05:08 -0700 (PDT) Received: from sol.home.arpa ([124.148.64.37]) by smtp.gmail.com with ESMTPSA id u5-20020a056a00158500b004f745148736sm436885pfk.179.2022.03.15.19.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 19:05:08 -0700 (PDT) From: Kent Gibson To: linux-gpio@vger.kernel.org, brgl@bgdev.pl Cc: Kent Gibson Subject: [libgpiod v2][PATCH 1/3] doc: API documentation tweaks corrections Date: Wed, 16 Mar 2022 10:04:39 +0800 Message-Id: <20220316020441.30001-2-warthog618@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220316020441.30001-1-warthog618@gmail.com> References: <20220316020441.30001-1-warthog618@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The corrections to the doc tweaks patch 6, allowing for the omission of patches 2 and 4. Signed-off-by: Kent Gibson --- include/gpiod.h | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/include/gpiod.h b/include/gpiod.h index 883c327..1f90be5 100644 --- a/include/gpiod.h +++ b/include/gpiod.h @@ -731,7 +731,7 @@ int gpiod_line_config_get_bias_default(struct gpiod_line_config *config); * in a request. */ int gpiod_line_config_get_bias_offset(struct gpiod_line_config *config, - unsigned int offset); + unsigned int offset); /** * @brief Set the default drive setting. @@ -986,12 +986,13 @@ gpiod_line_config_set_output_value_override(struct gpiod_line_config *config, unsigned int offset, int value); /** - * @brief Override the output values for multiple offsets. + * @brief Override the output values for multiple lines. * @param config Line config object. - * @param num_values Number of offsets for which to override values. - * @param offsets Array of line offsets to override values for. - * @param values Array of output values associated with the offsets passed in - * the previous argument. + * @param num_values Number of lines for which to override values. + * @param offsets Array of offsets identifying the lines for which to override + * values, containing \p num_values entries. + * @param values Array of output values corresponding to the lines identified in + * \p offsets, also containing \p num_values entries. */ void gpiod_line_config_set_output_values(struct gpiod_line_config *config, size_t num_values, @@ -1125,18 +1126,18 @@ void gpiod_request_config_set_consumer(struct gpiod_request_config *config, const char *consumer); /** - * @brief Get the consumer string. + * @brief Get the consumer name configured in the request config. * @param config Request config object. - * @return Current consumer string stored in this request config. + * @return Consumer name stored in the request config. */ const char * gpiod_request_config_get_consumer(struct gpiod_request_config *config); /** - * @brief Set line offsets for this request. + * @brief Set the offsets of the lines to be requested. * @param config Request config object. - * @param num_offsets Number of offsets. - * @param offsets Array of line offsets. + * @param num_offsets Number of offsets to set. + * @param offsets Array of offsets, containing \p num_offsets entries. * @note If too many offsets were specified, the offsets above the limit * accepted by the kernel (64 lines) are silently dropped. */ @@ -1153,29 +1154,31 @@ size_t gpiod_request_config_get_num_offsets(struct gpiod_request_config *config); /** - * @brief Get the hardware offsets of lines in this request config. + * @brief Get the offsets of lines in the request config. * @param config Request config object. - * @param offsets Array to store offsets. Must hold at least the number of - * lines returned by ::gpiod_request_config_get_num_offsets. + * @param offsets Array to store offsets. Must be sized to hold the number of + * lines returned by ::gpiod_request_config_get_num_offsets. */ void gpiod_request_config_get_offsets(struct gpiod_request_config *config, unsigned int *offsets); /** - * @brief Set the size of the kernel event buffer. + * @brief Set the size of the kernel event buffer for the request. * @param config Request config object. * @param event_buffer_size New event buffer size. * @note The kernel may adjust the value if it's too high. If set to 0, the * default value will be used. + * @note The kernel buffer is distinct from and independent of the user space + * buffer (::gpiod_edge_event_buffer_new). */ void gpiod_request_config_set_event_buffer_size(struct gpiod_request_config *config, size_t event_buffer_size); /** - * @brief Get the edge event buffer size from this request config. + * @brief Get the edge event buffer size for the request config. * @param config Request config object. - * @return Current edge event buffer size setting. + * @return Edge event buffer size setting from the request config. */ size_t gpiod_request_config_get_event_buffer_size(struct gpiod_request_config *config); From patchwork Wed Mar 16 02:04:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Gibson X-Patchwork-Id: 552051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6B52C433EF for ; Wed, 16 Mar 2022 02:05:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349951AbiCPCGa (ORCPT ); Tue, 15 Mar 2022 22:06:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234143AbiCPCGa (ORCPT ); Tue, 15 Mar 2022 22:06:30 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 788ED5E743 for ; Tue, 15 Mar 2022 19:05:17 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id e3so985487pjm.5 for ; Tue, 15 Mar 2022 19:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c88olSaYzoI6pzyS5wd13kl2WHwAbWnHPzt2pvEh670=; b=d3OdnY1ZE6nXDPq60CO8lcbDE03RZ/COsbG98AcedVcbGzNUi8sSSntCL4RTrWtbc2 IFNeJV6MLs0dDzz9Xqz6/8vKm9b8vrssmpbp9yK4jw/oh5T/jegY9RYDH90e3WqHyDpz E9ziEHC54idBZgkEXUi7SsKjCSU4ZdplknvFFP71DKxYTlfrQ0QlxBrp661CGIrCVS6a 84aOp9r4x8FH8btKnWHrqdIvXXk56lluYY95pAIFQPpB0irXQkU6ezYpjohmoZBc0s/g ZAMrMQYyrLTYEsgDYPDHV6QhX/zrxNTqexrH5RSEMDCmQ3GHmQxmGPqjJwI4Ijab0gZ6 n/9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c88olSaYzoI6pzyS5wd13kl2WHwAbWnHPzt2pvEh670=; b=KmlX4sqzPJ7j6h9cscTiAyrTz3J7EFT1Sm5OzuljaeiG1baanjIZv24GugvcFnQj6b 6iVKbp1vqFM2QKixcTfHaCncGAwe5yen0TLRzMpPCrUYQ6lKazjqL1eCdsNR4EIcbTjW unphbMAgi07nBZq+eI4Bq1BSp/bXX/7wMYtALtYXwbtBojJjnX9tpl/kgVsTD/g/Oej+ ZsRv5+fbjwJy9NH/hgEVbGqswoclxI/BfGhsz1iBncgGano6FflHXYQxQeMxELyJIrKC Q6BE0vta2G+QDEIpCvNgJ59S1J6pgVNJRSrFP7Pp52hMfKq7kDb63TYlLQeHJMAyFWwt fX4Q== X-Gm-Message-State: AOAM530vIZktCW23/0nshMhNsljKH2VO3e9o8IOH/32iJ8mB1p+WV8ST R69ODgTVYGRs6PrutQgRAUAOSvso2T3Odw== X-Google-Smtp-Source: ABdhPJw5PL6XL8jD4j0RMlWisjhi3kdOKEEZ3rfZCfTa/47AaJTBbfcxBtFnB537mMoOMd2qAmIZIw== X-Received: by 2002:a17:903:124a:b0:151:8174:8cff with SMTP id u10-20020a170903124a00b0015181748cffmr30977575plh.38.1647396316517; Tue, 15 Mar 2022 19:05:16 -0700 (PDT) Received: from sol.home.arpa ([124.148.64.37]) by smtp.gmail.com with ESMTPSA id u5-20020a056a00158500b004f745148736sm436885pfk.179.2022.03.15.19.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 19:05:16 -0700 (PDT) From: Kent Gibson To: linux-gpio@vger.kernel.org, brgl@bgdev.pl Cc: Kent Gibson Subject: [libgpiod v2][PATCH 2/3] core: use num_values rather than num_lines when dealing with subsets of values Date: Wed, 16 Mar 2022 10:04:40 +0800 Message-Id: <20220316020441.30001-3-warthog618@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220316020441.30001-1-warthog618@gmail.com> References: <20220316020441.30001-1-warthog618@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org To be consistent with other usage, when getting or setting a subset of requested line values, the array sizes should be named after the values being accessed, not "lines" as that could be confused with the number of lines in the request, not the subset. Signed-off-by: Kent Gibson --- include/gpiod.h | 14 +++++++------- lib/line-request.c | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/gpiod.h b/include/gpiod.h index 1f90be5..eaf6334 100644 --- a/include/gpiod.h +++ b/include/gpiod.h @@ -1226,16 +1226,16 @@ int gpiod_line_request_get_value(struct gpiod_line_request *request, /** * @brief Get the values of a subset of requested lines. * @param request GPIO line request. - * @param num_lines Number of lines for which to read values. + * @param num_values Number of lines for which to read values. * @param offsets Array of offsets identifying the subset of requested lines * from which to read values. * @param values Array in which the values will be stored. Must be sized - * to hold \p num_lines entries. Each value is associated with the + * to hold \p num_values entries. Each value is associated with the * line identified by the corresponding entry in \p offsets. * @return 0 on success, -1 on failure. */ int gpiod_line_request_get_values_subset(struct gpiod_line_request *request, - size_t num_lines, + size_t num_values, const unsigned int *offsets, int *values); @@ -1265,17 +1265,17 @@ int gpiod_line_request_set_value(struct gpiod_line_request *request, /** * @brief Set the values of a subset of requested lines. * @param request GPIO line request. - * @param num_lines Number of lines for which to set values. + * @param num_values Number of lines for which to set values. * @param offsets Array of offsets, containing the number of entries specified - * by \p num_lines, identifying the requested lines for + * by \p num_values, identifying the requested lines for * which to set values. * @param values Array of values to set, containing the number of entries - * specified by \p num_lines. Each value is associated with the + * specified by \p num_values. Each value is associated with the * line identified by the corresponding entry in \p offsets. * @return 0 on success, -1 on failure. */ int gpiod_line_request_set_values_subset(struct gpiod_line_request *request, - size_t num_lines, + size_t num_values, const unsigned int *offsets, const int *values); diff --git a/lib/line-request.c b/lib/line-request.c index 51b4ac1..31e82f8 100644 --- a/lib/line-request.c +++ b/lib/line-request.c @@ -85,7 +85,7 @@ static int offset_to_bit(struct gpiod_line_request *request, GPIOD_API int gpiod_line_request_get_values_subset(struct gpiod_line_request *request, - size_t num_lines, + size_t num_values, const unsigned int *offsets, int *values) { struct gpio_v2_line_values buf; @@ -95,7 +95,7 @@ gpiod_line_request_get_values_subset(struct gpiod_line_request *request, buf.bits = 0; - for (i = 0; i < num_lines; i++) { + for (i = 0; i < num_values; i++) { bit = offset_to_bit(request, offsets[i]); if (bit < 0) { errno = EINVAL; @@ -112,9 +112,9 @@ gpiod_line_request_get_values_subset(struct gpiod_line_request *request, return -1; bits = buf.bits; - memset(values, 0, sizeof(*values) * num_lines); + memset(values, 0, sizeof(*values) * num_values); - for (i = 0; i < num_lines; i++) { + for (i = 0; i < num_values; i++) { bit = offset_to_bit(request, offsets[i]); values[i] = gpiod_line_mask_test_bit(&bits, bit) ? 1 : 0; } @@ -138,7 +138,7 @@ GPIOD_API int gpiod_line_request_set_value(struct gpiod_line_request *request, GPIOD_API int gpiod_line_request_set_values_subset(struct gpiod_line_request *request, - size_t num_lines, + size_t num_values, const unsigned int *offsets, const int *values) { @@ -147,7 +147,7 @@ gpiod_line_request_set_values_subset(struct gpiod_line_request *request, size_t i; int bit; - for (i = 0; i < num_lines; i++) { + for (i = 0; i < num_values; i++) { bit = offset_to_bit(request, offsets[i]); if (bit < 0) { errno = EINVAL; From patchwork Wed Mar 16 02:04:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Gibson X-Patchwork-Id: 552889 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF334C433F5 for ; Wed, 16 Mar 2022 02:05:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350647AbiCPCGi (ORCPT ); Tue, 15 Mar 2022 22:06:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234143AbiCPCGh (ORCPT ); Tue, 15 Mar 2022 22:06:37 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDBC25E743 for ; Tue, 15 Mar 2022 19:05:23 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id v4so1008562pjh.2 for ; Tue, 15 Mar 2022 19:05:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eZU8aX2kba0+2CModmHm41+QR7TtCrdNLf+bklOz2oM=; b=O68KPX//cNaDYtn26jt97/dTlyV+KUOkuaSZBkM7pMmLz/jLWnZmvrE4GKg+bHpDxS SequY1BPPNS+WhQyKjBKUyd6whZPZTCZFQbuzEheNVcOCf/2P3mOT4YjEl+aisGGt6Td L04NL5BPAVz8RiPHDrCD/Hst4XPBq+jqCifIvLQ4FykMimlLgUeu6PiGvmBIabLA1x9+ //wQV18GGcw4BbkAuCfMrsvm3fEp6HtMsJoLkRokJG7UO8r83Caqs4i+u2S3wG98Fe8o k88QXv029SWwdEgSUqrMw2yUz/SroG+EEKUWz7+c8TonoFuWcNMjSUoZZOV+LRJzps+t v88g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eZU8aX2kba0+2CModmHm41+QR7TtCrdNLf+bklOz2oM=; b=jcFO7CqicywfTzZbcKg9+c7l5gnmBzVymARNz1c7Nrm9uH2L+o388kyVyqKq/mMq8f JfSuEnkI9MGUF5saCSV/Nn+3sSx/UKn2Ana0D2ffE1WUSzYmH/2CvPrQ4YpBJii6E6GT 43sATNr1VBmXFAsVFcoCTPOint8cgg1vJ6szhOeWfFq1iWUZUUoXkE2io9wkqpmvII8M yifmEGjfI8Fy0ZinPMIsn+b0TfUFbqmDQj5t0F28DhGynJKZ+U+HHhYGnPbYrTvTg7Tf KfsdD0+wUdImhDTgmYNw6sKkUXkK9CZ460uVrKMj37b8iNBuGAmLQEa7XKe41mRGGC79 KxGA== X-Gm-Message-State: AOAM533zDDG8kEUdUQqBqVjLwIdif+mShGpEMoZZ8RB4Nw8hOnckSEDP RyA7KEr2lsQ0+3eZvnQ0pO0xnba6I38Z/w== X-Google-Smtp-Source: ABdhPJwPU3KW9plyrUnzIpdJV+MvCREMOuIzAoz57LaN/StM0pGfzdUCjaqZ91hDHgw2rki+Nwj6sg== X-Received: by 2002:a17:902:d2d1:b0:151:ef69:c27d with SMTP id n17-20020a170902d2d100b00151ef69c27dmr30788189plc.34.1647396322815; Tue, 15 Mar 2022 19:05:22 -0700 (PDT) Received: from sol.home.arpa ([124.148.64.37]) by smtp.gmail.com with ESMTPSA id u5-20020a056a00158500b004f745148736sm436885pfk.179.2022.03.15.19.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Mar 2022 19:05:22 -0700 (PDT) From: Kent Gibson To: linux-gpio@vger.kernel.org, brgl@bgdev.pl Cc: Kent Gibson Subject: [libgpiod v2][PATCH 3/3] core: rename uAPI related variables and functions to uapi. Date: Wed, 16 Mar 2022 10:04:41 +0800 Message-Id: <20220316020441.30001-4-warthog618@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220316020441.30001-1-warthog618@gmail.com> References: <20220316020441.30001-1-warthog618@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Rename variables using the "buf" suffix to a "uapi_" prefix to identify them as being uAPI types. Similarly, rename the corresponding uAPI conversion functions from "kernel" to "uapi". Signed-off-by: Kent Gibson --- lib/chip-info.c | 2 +- lib/chip.c | 24 ++++++++++++------------ lib/info-event.c | 18 +++++++++--------- lib/internal.h | 20 ++++++++++---------- lib/line-config.c | 24 ++++++++++++------------ lib/line-info.c | 2 +- lib/line-request.c | 38 +++++++++++++++++++------------------- lib/request-config.c | 12 ++++++------ 8 files changed, 70 insertions(+), 70 deletions(-) diff --git a/lib/chip-info.c b/lib/chip-info.c index 1ab9b5e..584c9d4 100644 --- a/lib/chip-info.c +++ b/lib/chip-info.c @@ -37,7 +37,7 @@ GPIOD_API size_t gpiod_chip_info_get_num_lines(struct gpiod_chip_info *info) } struct gpiod_chip_info * -gpiod_chip_info_from_kernel(struct gpiochip_info *uapi_info) +gpiod_chip_info_from_uapi(struct gpiochip_info *uapi_info) { struct gpiod_chip_info *info; diff --git a/lib/chip.c b/lib/chip.c index b1435e2..edb2dfd 100644 --- a/lib/chip.c +++ b/lib/chip.c @@ -82,7 +82,7 @@ GPIOD_API struct gpiod_chip_info *gpiod_chip_get_info(struct gpiod_chip *chip) if (ret < 0) return NULL; - return gpiod_chip_info_from_kernel(&info); + return gpiod_chip_info_from_uapi(&info); } GPIOD_API const char *gpiod_chip_get_path(struct gpiod_chip *chip) @@ -118,7 +118,7 @@ chip_get_line_info(struct gpiod_chip *chip, unsigned int offset, bool watch) if (ret) return NULL; - return gpiod_line_info_from_kernel(&info); + return gpiod_line_info_from_uapi(&info); } GPIOD_API struct gpiod_line_info * @@ -202,34 +202,34 @@ gpiod_chip_request_lines(struct gpiod_chip *chip, struct gpiod_request_config *req_cfg, struct gpiod_line_config *line_cfg) { - struct gpio_v2_line_request reqbuf; + struct gpio_v2_line_request uapi_req; struct gpiod_line_request *request; int ret; - memset(&reqbuf, 0, sizeof(reqbuf)); + memset(&uapi_req, 0, sizeof(uapi_req)); - ret = gpiod_request_config_to_kernel(req_cfg, &reqbuf); + ret = gpiod_request_config_to_uapi(req_cfg, &uapi_req); if (ret) return NULL; - ret = gpiod_line_config_to_kernel(line_cfg, &reqbuf.config, - reqbuf.num_lines, reqbuf.offsets); + ret = gpiod_line_config_to_uapi(line_cfg, &uapi_req.config, + uapi_req.num_lines, uapi_req.offsets); if (ret) return NULL; - ret = ioctl(chip->fd, GPIO_V2_GET_LINE_IOCTL, &reqbuf); + ret = ioctl(chip->fd, GPIO_V2_GET_LINE_IOCTL, &uapi_req); if (ret < 0) return NULL; - ret = set_fd_noblock(reqbuf.fd); + ret = set_fd_noblock(uapi_req.fd); if (ret) { - close(reqbuf.fd); + close(uapi_req.fd); return NULL; } - request = gpiod_line_request_from_kernel(&reqbuf); + request = gpiod_line_request_from_uapi(&uapi_req); if (!request) { - close(reqbuf.fd); + close(uapi_req.fd); return NULL; } diff --git a/lib/info-event.c b/lib/info-event.c index 1776d82..4abed57 100644 --- a/lib/info-event.c +++ b/lib/info-event.c @@ -15,7 +15,7 @@ struct gpiod_info_event { }; struct gpiod_info_event * -gpiod_info_event_from_kernel(struct gpio_v2_line_info_changed *evbuf) +gpiod_info_event_from_uapi(struct gpio_v2_line_info_changed *uapi_evt) { struct gpiod_info_event *event; @@ -24,9 +24,9 @@ gpiod_info_event_from_kernel(struct gpio_v2_line_info_changed *evbuf) return NULL; memset(event, 0, sizeof(*event)); - event->timestamp = evbuf->timestamp_ns; + event->timestamp = uapi_evt->timestamp_ns; - switch (evbuf->event_type) { + switch (uapi_evt->event_type) { case GPIOLINE_CHANGED_REQUESTED: event->event_type = GPIOD_INFO_EVENT_LINE_REQUESTED; break; @@ -43,7 +43,7 @@ gpiod_info_event_from_kernel(struct gpio_v2_line_info_changed *evbuf) return NULL; } - event->info = gpiod_line_info_from_kernel(&evbuf->info); + event->info = gpiod_line_info_from_uapi(&uapi_evt->info); if (!event->info) { free(event); return NULL; @@ -80,18 +80,18 @@ gpiod_info_event_get_line_info(struct gpiod_info_event *event) struct gpiod_info_event *gpiod_info_event_read_fd(int fd) { - struct gpio_v2_line_info_changed evbuf; + struct gpio_v2_line_info_changed uapi_evt; ssize_t rd; - memset(&evbuf, 0, sizeof(evbuf)); + memset(&uapi_evt, 0, sizeof(uapi_evt)); - rd = read(fd, &evbuf, sizeof(evbuf)); + rd = read(fd, &uapi_evt, sizeof(uapi_evt)); if (rd < 0) { return NULL; - } else if ((unsigned int)rd < sizeof(evbuf)) { + } else if ((unsigned int)rd < sizeof(uapi_evt)) { errno = EIO; return NULL; } - return gpiod_info_event_from_kernel(&evbuf); + return gpiod_info_event_from_uapi(&uapi_evt); } diff --git a/lib/internal.h b/lib/internal.h index ffef578..c87df91 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -19,21 +19,21 @@ #define GPIOD_BIT(nr) (1UL << (nr)) struct gpiod_chip_info * -gpiod_chip_info_from_kernel(struct gpiochip_info *infobuf); +gpiod_chip_info_from_uapi(struct gpiochip_info *uapi_info); struct gpiod_line_info * -gpiod_line_info_from_kernel(struct gpio_v2_line_info *infobuf); -int gpiod_request_config_to_kernel(struct gpiod_request_config *config, - struct gpio_v2_line_request *reqbuf); -int gpiod_line_config_to_kernel(struct gpiod_line_config *config, - struct gpio_v2_line_config *cfgbuf, - unsigned int num_lines, - const unsigned int *offsets); +gpiod_line_info_from_uapi(struct gpio_v2_line_info *uapi_info); +int gpiod_request_config_to_uapi(struct gpiod_request_config *config, + struct gpio_v2_line_request *uapi_req); +int gpiod_line_config_to_uapi(struct gpiod_line_config *config, + struct gpio_v2_line_config *uapi_cfg, + unsigned int num_lines, + const unsigned int *offsets); struct gpiod_line_request * -gpiod_line_request_from_kernel(struct gpio_v2_line_request *reqbuf); +gpiod_line_request_from_uapi(struct gpio_v2_line_request *uapi_req); int gpiod_edge_event_buffer_read_fd(int fd, struct gpiod_edge_event_buffer *buffer, size_t max_events); struct gpiod_info_event * -gpiod_info_event_from_kernel(struct gpio_v2_line_info_changed *evbuf); +gpiod_info_event_from_uapi(struct gpio_v2_line_info_changed *uapi_evt); struct gpiod_info_event *gpiod_info_event_read_fd(int fd); int gpiod_poll_fd(int fd, uint64_t timeout); diff --git a/lib/line-config.c b/lib/line-config.c index b7e154f..f9cd6ac 100644 --- a/lib/line-config.c +++ b/lib/line-config.c @@ -1062,7 +1062,7 @@ static void set_kernel_attr_mask(uint64_t *out, const uint64_t *in, } static int process_overrides(struct gpiod_line_config *config, - struct gpio_v2_line_config *cfgbuf, + struct gpio_v2_line_config *uapi_cfg, unsigned int *attr_idx, unsigned int num_lines, const unsigned int *offsets, @@ -1113,7 +1113,7 @@ static int process_overrides(struct gpiod_line_config *config, } } - attr = &cfgbuf->attrs[(*attr_idx)++]; + attr = &uapi_cfg->attrs[(*attr_idx)++]; set_kernel_attr_mask(&mask, &marked, num_lines, offsets, config); @@ -1142,10 +1142,10 @@ static bool has_at_least_one_output_direction(struct gpiod_line_config *config) return false; } -int gpiod_line_config_to_kernel(struct gpiod_line_config *config, - struct gpio_v2_line_config *cfgbuf, - unsigned int num_lines, - const unsigned int *offsets) +int gpiod_line_config_to_uapi(struct gpiod_line_config *config, + struct gpio_v2_line_config *uapi_cfg, + unsigned int num_lines, + const unsigned int *offsets) { struct gpio_v2_line_config_attribute *attr; unsigned int attr_idx = 0; @@ -1160,7 +1160,7 @@ int gpiod_line_config_to_kernel(struct gpiod_line_config *config, * If so, let's take one attribute for the default values. */ if (has_at_least_one_output_direction(config)) { - attr = &cfgbuf->attrs[attr_idx++]; + attr = &uapi_cfg->attrs[attr_idx++]; attr->attr.id = GPIO_V2_LINE_ATTR_ID_OUTPUT_VALUES; set_kernel_output_values(&mask, &values, config, @@ -1173,7 +1173,7 @@ int gpiod_line_config_to_kernel(struct gpiod_line_config *config, /* If we have a default debounce period - use another attribute. */ if (config->defaults.debounce_period_us) { - attr = &cfgbuf->attrs[attr_idx++]; + attr = &uapi_cfg->attrs[attr_idx++]; attr->attr.id = GPIO_V2_LINE_ATTR_ID_DEBOUNCE; attr->attr.debounce_period_us = config->defaults.debounce_period_us; @@ -1193,22 +1193,22 @@ int gpiod_line_config_to_kernel(struct gpiod_line_config *config, * further processing. */ - ret = process_overrides(config, cfgbuf, &attr_idx, num_lines, offsets, + ret = process_overrides(config, uapi_cfg, &attr_idx, num_lines, offsets, base_config_flags_are_equal, override_config_flags_are_equal, set_base_config_flags); if (ret) return -1; - ret = process_overrides(config, cfgbuf, &attr_idx, num_lines, offsets, + ret = process_overrides(config, uapi_cfg, &attr_idx, num_lines, offsets, base_debounce_period_is_equal, override_config_debounce_period_is_equal, set_base_config_debounce_period); if (ret) return -1; - cfgbuf->flags = make_kernel_flags(&config->defaults); - cfgbuf->num_attrs = attr_idx; + uapi_cfg->flags = make_kernel_flags(&config->defaults); + uapi_cfg->num_attrs = attr_idx; return 0; diff --git a/lib/line-info.c b/lib/line-info.c index 0724120..65eca48 100644 --- a/lib/line-info.c +++ b/lib/line-info.c @@ -106,7 +106,7 @@ gpiod_line_info_get_debounce_period_us(struct gpiod_line_info *info) } struct gpiod_line_info * -gpiod_line_info_from_kernel(struct gpio_v2_line_info *uapi_info) +gpiod_line_info_from_uapi(struct gpio_v2_line_info *uapi_info) { struct gpio_v2_line_attribute *attr; struct gpiod_line_info *info; diff --git a/lib/line-request.c b/lib/line-request.c index 31e82f8..33f7f67 100644 --- a/lib/line-request.c +++ b/lib/line-request.c @@ -17,7 +17,7 @@ struct gpiod_line_request { }; struct gpiod_line_request * -gpiod_line_request_from_kernel(struct gpio_v2_line_request *reqbuf) +gpiod_line_request_from_uapi(struct gpio_v2_line_request *uapi_req) { struct gpiod_line_request *request; @@ -26,9 +26,9 @@ gpiod_line_request_from_kernel(struct gpio_v2_line_request *reqbuf) return NULL; memset(request, 0, sizeof(*request)); - request->fd = reqbuf->fd; - request->num_lines = reqbuf->num_lines; - memcpy(request->offsets, reqbuf->offsets, + request->fd = uapi_req->fd; + request->num_lines = uapi_req->num_lines; + memcpy(request->offsets, uapi_req->offsets, sizeof(*request->offsets) * request->num_lines); return request; @@ -88,12 +88,12 @@ gpiod_line_request_get_values_subset(struct gpiod_line_request *request, size_t num_values, const unsigned int *offsets, int *values) { - struct gpio_v2_line_values buf; + struct gpio_v2_line_values uapi_values; uint64_t mask = 0, bits = 0; size_t i; int bit, ret; - buf.bits = 0; + uapi_values.bits = 0; for (i = 0; i < num_values; i++) { bit = offset_to_bit(request, offsets[i]); @@ -105,13 +105,13 @@ gpiod_line_request_get_values_subset(struct gpiod_line_request *request, gpiod_line_mask_set_bit(&mask, bit); } - buf.mask = mask; + uapi_values.mask = mask; - ret = ioctl(request->fd, GPIO_V2_LINE_GET_VALUES_IOCTL, &buf); + ret = ioctl(request->fd, GPIO_V2_LINE_GET_VALUES_IOCTL, &uapi_values); if (ret) return -1; - bits = buf.bits; + bits = uapi_values.bits; memset(values, 0, sizeof(*values) * num_values); for (i = 0; i < num_values; i++) { @@ -142,7 +142,7 @@ gpiod_line_request_set_values_subset(struct gpiod_line_request *request, const unsigned int *offsets, const int *values) { - struct gpio_v2_line_values buf; + struct gpio_v2_line_values uapi_values; uint64_t mask = 0, bits = 0; size_t i; int bit; @@ -158,11 +158,11 @@ gpiod_line_request_set_values_subset(struct gpiod_line_request *request, gpiod_line_mask_assign_bit(&bits, bit, values[i]); } - memset(&buf, 0, sizeof(buf)); - buf.mask = mask; - buf.bits = bits; + memset(&uapi_values, 0, sizeof(uapi_values)); + uapi_values.mask = mask; + uapi_values.bits = bits; - return ioctl(request->fd, GPIO_V2_LINE_SET_VALUES_IOCTL, &buf); + return ioctl(request->fd, GPIO_V2_LINE_SET_VALUES_IOCTL, &uapi_values); } GPIOD_API int gpiod_line_request_set_values(struct gpiod_line_request *request, @@ -176,17 +176,17 @@ GPIOD_API int gpiod_line_request_reconfigure_lines(struct gpiod_line_request *request, struct gpiod_line_config *config) { - struct gpio_v2_line_config cfgbuf; + struct gpio_v2_line_config uapi_cfg; int ret; - memset(&cfgbuf, 0, sizeof(cfgbuf)); + memset(&uapi_cfg, 0, sizeof(uapi_cfg)); - ret = gpiod_line_config_to_kernel(config, &cfgbuf, - request->num_lines, request->offsets); + ret = gpiod_line_config_to_uapi(config, &uapi_cfg, + request->num_lines, request->offsets); if (ret) return ret; - ret = ioctl(request->fd, GPIO_V2_LINE_SET_CONFIG_IOCTL, &cfgbuf); + ret = ioctl(request->fd, GPIO_V2_LINE_SET_CONFIG_IOCTL, &uapi_cfg); if (ret) return ret; diff --git a/lib/request-config.c b/lib/request-config.c index d22af80..3a84106 100644 --- a/lib/request-config.c +++ b/lib/request-config.c @@ -91,8 +91,8 @@ gpiod_request_config_get_event_buffer_size(struct gpiod_request_config *config) return config->event_buffer_size; } -int gpiod_request_config_to_kernel(struct gpiod_request_config *config, - struct gpio_v2_line_request *reqbuf) +int gpiod_request_config_to_uapi(struct gpiod_request_config *config, + struct gpio_v2_line_request *uapi_req) { size_t i; @@ -102,11 +102,11 @@ int gpiod_request_config_to_kernel(struct gpiod_request_config *config, } for (i = 0; i < config->num_offsets; i++) - reqbuf->offsets[i] = config->offsets[i]; + uapi_req->offsets[i] = config->offsets[i]; - reqbuf->num_lines = config->num_offsets; - strcpy(reqbuf->consumer, config->consumer); - reqbuf->event_buffer_size = config->event_buffer_size; + uapi_req->num_lines = config->num_offsets; + strcpy(uapi_req->consumer, config->consumer); + uapi_req->event_buffer_size = config->event_buffer_size; return 0; }