From patchwork Wed Jun 26 05:29:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Gibson X-Patchwork-Id: 807603 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25A1E3C463; Wed, 26 Jun 2024 05:29:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719379788; cv=none; b=gRPQPnZA6ftiqqB2F/CSzbbmrCEJj6kWYUQygf+sMRT4+Gxx4hayQK+ngyNgFv9wNm22mXJuF9YP6KIyVEDSusfd0/DmZS4H94RSCNKwDtkHgq4K7C0vg71HELuH8S/Rg6oNh+0zUgGA+uRUD7hoDOvFFcvR6lwwiRm1tC8Znhc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719379788; c=relaxed/simple; bh=d1Ru6Gtk5I3b0V5nJ36RVm63btvPvgdVLQTAwHf0MPs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KRWkC2YZFya6ihw/TrOwNv59pehO2vbAo9ZqY+8x8GD0JLiuRlR6lT2EyJAdA/pMv5ci3R2sMkOxzxc0j1BkqvSMeiYlW+I24VVFxv4I0Xp/CtNgFiEHcwWez1FCd6SybeZTWuM0tuwzmwWAqlFtVWjUeWJA2zQh9sOiz2pO6iI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=a8bzT3gV; arc=none smtp.client-ip=209.85.210.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a8bzT3gV" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-7065e2fe7d9so3396427b3a.3; Tue, 25 Jun 2024 22:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719379786; x=1719984586; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=B5nqx7BHy6rJlWMySteyHdWT11os3qiUN4VHjcEhwA4=; b=a8bzT3gVshlwHelomzZK910fhB+QrsD6yJbLEjil2POVppzESVaodM02aBuPPN5Ixb UlNpGpOIMZi6vD6GhtX2+M5Hchy23LuScsetOXs9qBbUYOW9d6wOY/or8PpVHjAPG/e+ j4tRGlLg6IYrIE1Ef4QcWRNQoB+xo6rnPwsZocKwRAU7gqEzMsIRMOXgo8QKqHh4gO0X wV2ZBsfSQPdkCywvZkqTZ8GfLdGneRPRze6D8oHifDZlKoy2B2oJsYZ2/rx2uFs4nBpk HiVC8BAto9vV3of7y0HH+NEzLKnL0Qf7CHQqa2tfZxxMIesXc8fjiCsB/LW7BGFlme1X 573w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719379786; x=1719984586; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=B5nqx7BHy6rJlWMySteyHdWT11os3qiUN4VHjcEhwA4=; b=DQVRuxAQsXF0TWMkTHCmCki6RpWjxUwNnY0YJqf8tMMn6+WEVJuSnnAuxfXzFHF35r L9dAArMnDOGb0toUcsFPlsCSyN0ZaEIZGF/9sViF8pd79yr2UEUnC29uLlJr54m4Cilv IdaMFt1pnhOGXT2TMJeZvTNMVkQ/huh8L5R8Ip0FLqvYshCE8vJBJevuPvLZ5OHnblrt KQm+uvejMw8rW/wHMkT7utzEjmxeZFdF1s7HPXwDKhq7LoI3Edhk5y2CtZ2Pvsu0hL1l jijLYimm2CS/2XdNkYb1ibrvxc/Nmd215pHaONmpsET34t4z0j9cFn9ne/KznQAjObkG CqjQ== X-Forwarded-Encrypted: i=1; AJvYcCUGfzPlv+VxJB4I0tKn0yibqIF4Bij4PSHGelyRoHg52vBytuvQG5z3QRpBAYp/eo5mbcjZrF2qG+0BeDJaMVopCSXpGtM12dbzHA== X-Gm-Message-State: AOJu0YwvOaVjCrBexUhuNsD4Oxbvec5qj6zJ6AxFL1iLhEjlRoKH6JJ+ xQ32ARqdh6tGSKdDZA1AXse10Z0d0KeUs2JEn0gGucZUgVtZsHwQgEE+Iw== X-Google-Smtp-Source: AGHT+IG7o63rWxast+RVPWKxgBIQwtxFTHyWsdOgJ2HHBFpRmEj/ETj31UDVDezt3PUk75LBD1ejqg== X-Received: by 2002:a05:6a00:138a:b0:706:381e:318c with SMTP id d2e1a72fcca58-7067459db3amr13473558b3a.7.1719379786089; Tue, 25 Jun 2024 22:29:46 -0700 (PDT) Received: from rigel.home.arpa ([118.209.204.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70661b9f2f6sm7804000b3a.187.2024.06.25.22.29.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 22:29:45 -0700 (PDT) From: Kent Gibson To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, brgl@bgdev.pl, linus.walleij@linaro.org Cc: Kent Gibson Subject: [PATCH 1/4] gpiolib: cdev: Disallow reconfiguration without direction (uAPI v1) Date: Wed, 26 Jun 2024 13:29:22 +0800 Message-Id: <20240626052925.174272-2-warthog618@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626052925.174272-1-warthog618@gmail.com> References: <20240626052925.174272-1-warthog618@gmail.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 linehandle_set_config() behaves badly when direction is not set. The configuration validation is borrowed from linehandle_create(), where, to verify the intent of the user, the direction must be set to in order to effect a change to the electrical configuration of a line. But, when applied to reconfiguration, that validation does not allow for the unset direction case, making it possible to clear flags set previously without specifying the line direction. Adding to the inconsistency, those changes are not immediately applied by linehandle_set_config(), but will take effect when the line value is next get or set. For example, by requesting a configuration with no flags set, an output line with GPIOHANDLE_REQUEST_ACTIVE_LOW and GPIOHANDLE_REQUEST_OPEN_DRAIN requested could have those flags cleared, inverting the sense of the line and changing the line drive to push-pull on the next line value set. Ensure the intent of the user by disallowing configurations which do not have direction set, returning an error to userspace to indicate that the configuration is invalid. And, for clarity, use lflags, a local copy of gcnf.flags, throughout when dealing with the requested flags, rather than a mixture of both. Fixes: e588bb1eae31 ("gpio: add new SET_CONFIG ioctl() to gpio chardev") Signed-off-by: Kent Gibson --- drivers/gpio/gpiolib-cdev.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c index 1cb952daacfb..f7a129d67b7d 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -89,6 +89,10 @@ struct linehandle_state { GPIOHANDLE_REQUEST_OPEN_DRAIN | \ GPIOHANDLE_REQUEST_OPEN_SOURCE) +#define GPIOHANDLE_REQUEST_DIRECTION_FLAGS \ + (GPIOHANDLE_REQUEST_INPUT | \ + GPIOHANDLE_REQUEST_OUTPUT) + static int linehandle_validate_flags(u32 flags) { /* Return an error if an unknown flag is set */ @@ -169,21 +173,21 @@ static long linehandle_set_config(struct linehandle_state *lh, if (ret) return ret; + /* Lines must be reconfigured explicitly as input or output. */ + if (!(lflags & GPIOHANDLE_REQUEST_DIRECTION_FLAGS)) + return -EINVAL; + for (i = 0; i < lh->num_descs; i++) { desc = lh->descs[i]; - linehandle_flags_to_desc_flags(gcnf.flags, &desc->flags); + linehandle_flags_to_desc_flags(lflags, &desc->flags); - /* - * Lines have to be requested explicitly for input - * or output, else the line will be treated "as is". - */ if (lflags & GPIOHANDLE_REQUEST_OUTPUT) { int val = !!gcnf.default_values[i]; ret = gpiod_direction_output(desc, val); if (ret) return ret; - } else if (lflags & GPIOHANDLE_REQUEST_INPUT) { + } else { ret = gpiod_direction_input(desc); if (ret) return ret; From patchwork Wed Jun 26 05:29:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Gibson X-Patchwork-Id: 808410 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60A62143882; Wed, 26 Jun 2024 05:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719379799; cv=none; b=YvXXmJ70YvbdYJQ/lyjvXXL4toThisD9kYNVF0uZcQwACUo+HHeGBaKA9QkzYURGTVv0N2ZL4jXMdndcShsZD0h/iXvwJTbtXEjkFqVBZqotrl5N7C6R2p8CJQ2ZuU+MMN/zfHrOopXWjJpSYn1+Nckch9nMq4jr+lONtPaD34Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719379799; c=relaxed/simple; bh=OIEjf1PmNuRJQdMYjG/K8J0cSTFB4cdxAArbfqrK5vw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jf95FCkGANphO/7kMBU/2R9WfRZnE1AGNqPlz3YPh7uafILqaVhaugnQGnaODkeFLjo37rwnwYFwO5cmg45OlHTkOCGVhl1M4EKemky5NpkKbGUEIxwHe6bYpn4EaRBQNlm4zRhDk4MX9jWmsWPRWCXSLxn9TnTq3eZKFtFaZdk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UTntpJMS; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UTntpJMS" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-70666ac8f81so159064b3a.1; Tue, 25 Jun 2024 22:29:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719379797; x=1719984597; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F2HewnJ2y3xpq3HKpApD6R+6vfVQF+cUrNl05u8p3oY=; b=UTntpJMS3VwxwuNoegKGPEq2g/4hodZWAUnvDa5eJEWUN5vW0fWU9TkDyZhPQl55is L70fmjLSaXxQAm+1yEoW3D8tH1hlTjtaufrZZGiIicsVcP3pnF95I8te6PuMbaZncWnR lRY/+iKAsbx0QS5ixht2DziS1SKaxVbbggjaK+AQa7zlNFgKYaiMcRdMCj7qmjqVHB0h WsBLzGv+uGn7H6DyE+OTB5S4PJH8eOeg4UsMIS+1Lh0lTVOys/HKRq/W7qivSRDwD/nr nWufa4p72hfF0BYBjpqGYCMdoIKoKDu0kewoNkH4/Nvg7DKyfM7rIv0aH03x/r8r9spj KX4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719379797; x=1719984597; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F2HewnJ2y3xpq3HKpApD6R+6vfVQF+cUrNl05u8p3oY=; b=ICBD0aor8tuca6FSEo0ipNttzS2Fh8ugsDTpFiMR0v5tT0Kp8TqkjrrBWwyDS8ZsGA xo1aCOZ9hawpqzHL6IB3XXAKGg0z1U8xQzOBtE8NloxsZr2q9jc9q7i0D/InZCQCHr63 B01NWlcxRzVSaT204q3edXrXOMkgcGkDspi5MpeHbCNeqxb3uYhlsZkziCagRsaENSE9 /3VtRqAp2frjDbe7n6Okis02mY2H+X8I3nUNCUW+1R2HD7d7B/cOaW0UD666xl5VaNSy HNTfZeyYg9VngCo6gT0zCn15hHPdTMvgpMvJunQT6ko3CF0n/2ksmSBNZ7H41LvMUcrd z4Dw== X-Forwarded-Encrypted: i=1; AJvYcCU1oVwb0yLOCK4ONJApJUE2vs0Pscd1lVLqmEvONlFypNWKHqb+bg6ra4367wtUnhWuSdDzNju7fN023zchauYXhsZNm1yWODrHgA== X-Gm-Message-State: AOJu0YzkcopI9PerpmQBDxY3LUGtflURvIfa4Iyof7Qu5LDPII/twpBu f1E8e7qqbo6rsQ+cnPliKE5DF1UqsU1M7tsaAArXrfVteutfyB2Wlhd4Qw== X-Google-Smtp-Source: AGHT+IG31733UcUI+4wlncV0gMyPhtutHGo8Sw2LufM7FncAEos4V2X1raZr9gthAU8YfZ1lupAnMg== X-Received: by 2002:a05:6a20:4694:b0:1bd:2cb0:2e8e with SMTP id adf61e73a8af0-1bd2cb0325dmr1471901637.12.1719379797292; Tue, 25 Jun 2024 22:29:57 -0700 (PDT) Received: from rigel.home.arpa ([118.209.204.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70661b9f2f6sm7804000b3a.187.2024.06.25.22.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 22:29:56 -0700 (PDT) From: Kent Gibson To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, brgl@bgdev.pl, linus.walleij@linaro.org Cc: Kent Gibson Subject: [PATCH 2/4] gpiolib: cdev: Ignore reconfiguration without direction Date: Wed, 26 Jun 2024 13:29:23 +0800 Message-Id: <20240626052925.174272-3-warthog618@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626052925.174272-1-warthog618@gmail.com> References: <20240626052925.174272-1-warthog618@gmail.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 linereq_set_config() behaves badly when direction is not set. The configuration validation is borrowed from linereq_create(), where, to verify the intent of the user, the direction must be set to in order to effect a change to the electrical configuration of a line. But, when applied to reconfiguration, that validation does not allow for the unset direction case, making it possible to clear flags set previously without specifying the line direction. Adding to the inconsistency, those changes are not immediately applied by linereq_set_config(), but will take effect when the line value is next get or set. For example, by requesting a configuration with no flags set, an output line with GPIO_V2_LINE_FLAG_ACTIVE_LOW and GPIO_V2_LINE_FLAG_OPEN_DRAIN set could have those flags cleared, inverting the sense of the line and changing the line drive to push-pull on the next line value set. Skip the reconfiguration of lines for which the direction is not set, and only reconfigure the lines for which direction is set. Fixes: a54756cb24ea ("gpiolib: cdev: support GPIO_V2_LINE_SET_CONFIG_IOCTL") Signed-off-by: Kent Gibson --- drivers/gpio/gpiolib-cdev.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c index f7a129d67b7d..ef08b23a56e2 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -1534,12 +1534,14 @@ static long linereq_set_config(struct linereq *lr, void __user *ip) line = &lr->lines[i]; desc = lr->lines[i].desc; flags = gpio_v2_line_config_flags(&lc, i); + /* + * Lines not explicitly reconfigured as input or output + * are left unchanged. + */ + if (!(flags & GPIO_V2_LINE_DIRECTION_FLAGS)) + continue; gpio_v2_line_config_flags_to_desc_flags(flags, &desc->flags); edflags = flags & GPIO_V2_LINE_EDGE_DETECTOR_FLAGS; - /* - * Lines have to be requested explicitly for input - * or output, else the line will be treated "as is". - */ if (flags & GPIO_V2_LINE_FLAG_OUTPUT) { int val = gpio_v2_line_config_output_value(&lc, i); @@ -1547,7 +1549,7 @@ static long linereq_set_config(struct linereq *lr, void __user *ip) ret = gpiod_direction_output(desc, val); if (ret) return ret; - } else if (flags & GPIO_V2_LINE_FLAG_INPUT) { + } else { ret = gpiod_direction_input(desc); if (ret) return ret; From patchwork Wed Jun 26 05:29:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Gibson X-Patchwork-Id: 807602 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A6EF143882; Wed, 26 Jun 2024 05:30:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719379810; cv=none; b=fPGW6Zh/NjKE2O2Wuqt/azDiDWaD2lUyLXwdzd2mR5JLQOftV1xi3PZ85O9WUaigZoQP0AmwQm+6S40K/pHdTDhnHGADHBjktTLhfnLhlQaUVzwUsEYBOznYjtd45exBmkVNVfNlBVMCj7RkLfzJ9f3tJsWhtNaBSOHTkrhOpZo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719379810; c=relaxed/simple; bh=FsKp+orMRlKLPXvYpe9KT8WdKvix6GklcVgngmT3RMY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NoP0X5nCwrJV4vePjnAVP6KGp2tsu37RbU9SxXo2eaX28N3Wrnh54yNNw2YfBysmkWwPCh6W9hwdVjW0HtgFYGRV58MB9l+pvsBmqgLXC5VZUDeqpLZsY5QvJjdAkXVd/kSMKqz8JqzR/4huEqvKKLoTMyN4zPZPzPoMIMOaz/0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WPDXONG9; arc=none smtp.client-ip=209.85.167.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WPDXONG9" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3d562b35fb6so67468b6e.3; Tue, 25 Jun 2024 22:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719379808; x=1719984608; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u8JRA8YA8hNKryyYG9sIN3Q3e47oeZv1yWhHnRlL+LQ=; b=WPDXONG9BVWJw67mPU4C6JmBopBRUjvK49hudF0wRpMVcquUF829v8hLVTG53oIm/O Xo01g90IlTKjfch3FYYkyHQHce0g1Q1vqCgmuxTwn+/AaEUrpdIdDbHb/pe4BXMDte1R Z0GvcyeLbhifBwWNTVGn6p4iwceG5iyyX7pnqSdfHjyueDgyeATXGIMuKJfYQwFyB9MY ohSjTl3IfQXOvBE74U5cWmtDDFZD34GZzbcvnS21FKLU0nalRhFExeLdOjmeTOzgRoY4 QLFV10x4UWRDO7rBaaKDwpCL1MWuUY8PqXaSQgRKUiHCiWcnU2SFpPkwSZVxUKu09edH 6+pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719379808; x=1719984608; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u8JRA8YA8hNKryyYG9sIN3Q3e47oeZv1yWhHnRlL+LQ=; b=mxQelca5rnZ6jEQJo5P9KV5zUmOOV5zsc5cbcT9/5jffTy/p83Z+oWiu8H7Ll8ONWX Bh72OrB/ONTI/8HcNlubNLFfYnNc6ntd08CWpXFMTTACZXnVO4sDpMJ1cTSqj21OOlzv +CYx60ssJyihcnSYgVn5gI0CsKZcZJgl8jBNxW8swkABmGaRI+Drwx2Gnk+vHlsZ1mTl 8zlRaL0Ihnx+VMUo4LayMWvaABsHqH0t5NdyDxjwy/1eWndouscetDqdgNzQ2395QSZI nPx+gT4fnPAdLevs7AzlkwerFiM76qSR0ODK9XjAxd6Z45cbLzDPjFoyQQwfEF2+knrl oGYA== X-Forwarded-Encrypted: i=1; AJvYcCVBmvgnNQHfahsPo5g5yaIgAjbWie6kbEAnOMJN8SHtnq0VrUYllb7Z7j/9nIfNq4kdkQWZ9WGUf8UuIOnzoaV1Qvm2ttq6yRq0rhews1pqiRe6Re+ezclbnfPhxOjWSRkaNlvgkg== X-Gm-Message-State: AOJu0YxGkh1HfPRw7JcI9e2zgdkeo3zH6r0EnB5eDsiunnyEHtpUlSlN 6QzG1ty4TwpwIvzWh4ly9SaR29bbirfICRvIEOI22sS2NcURY/HsJefI8g== X-Google-Smtp-Source: AGHT+IHwqt4wrcjc9eDBmy5l3JxEyb57OHWlFtqiCMH4L2axjSe8UpafpNzs7kK24+MUPgwLSdkREA== X-Received: by 2002:a05:6808:4497:b0:3d5:376c:f9b2 with SMTP id 5614622812f47-3d541c50615mr11571432b6e.2.1719379807914; Tue, 25 Jun 2024 22:30:07 -0700 (PDT) Received: from rigel.home.arpa ([118.209.204.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70661b9f2f6sm7804000b3a.187.2024.06.25.22.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 22:30:07 -0700 (PDT) From: Kent Gibson To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, brgl@bgdev.pl, linus.walleij@linaro.org Cc: Kent Gibson , corbet@lwn.net, linux-doc@vger.kernel.org Subject: [PATCH 3/4] Documentation: gpio: Reconfiguration with unset direction (uAPI v1) Date: Wed, 26 Jun 2024 13:29:24 +0800 Message-Id: <20240626052925.174272-4-warthog618@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626052925.174272-1-warthog618@gmail.com> References: <20240626052925.174272-1-warthog618@gmail.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Update description of reconfiguration rules, adding requirement that a direction flag be set or the configuration is considered invalid. Signed-off-by: Kent Gibson --- .../userspace-api/gpio/gpio-handle-set-config-ioctl.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/userspace-api/gpio/gpio-handle-set-config-ioctl.rst b/Documentation/userspace-api/gpio/gpio-handle-set-config-ioctl.rst index d002a84681ac..a03f30db63ab 100644 --- a/Documentation/userspace-api/gpio/gpio-handle-set-config-ioctl.rst +++ b/Documentation/userspace-api/gpio/gpio-handle-set-config-ioctl.rst @@ -43,7 +43,10 @@ The configuration applies to all requested lines. The same :ref:`gpio-get-linehandle-config-rules` and :ref:`gpio-get-linehandle-config-support` that apply when requesting the -lines also apply when updating the line configuration. +lines also apply when updating the line configuration, with the additional +restriction that a direction flag must be set. Requesting an invalid +configuration, including without a direction flag set, is an error +(**EINVAL**). The motivating use case for this command is changing direction of bi-directional lines between input and output, but it may be used more From patchwork Wed Jun 26 05:29:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Gibson X-Patchwork-Id: 808409 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 380D4143882; Wed, 26 Jun 2024 05:30:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719379820; cv=none; b=p7lHDsKU+iaOTbMCJzMmdZURrbGoOu5ihKLVuqu3/atzOqV4cYrrKptwIkJB3ipjOsw8WSjKDfx7nNpdEyDP4GmJNSDqJ5LQ6nOhZsC+tqI/QoO4kpt1nW/VwzqofnDHeMpjSJqH5MAeQwlCVfmTR5tMRnElNwKFvsolSFd1sGI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719379820; c=relaxed/simple; bh=pyTNIJ/mfCiFyk/9v2xchwhFP5IkP0waEl+KVnxzSa8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JRLLYae1Prvfd/+bbt4Yx+e4hwyT3Il4fT8VpbiEfFlEzzYVcognWXXvQv8c6qpynxBU4G1SOW5lPt6WjQAQ6NSxQbh4W4urBMo4keq/A4PDGRjlfiD3FbnKmJka/XojJGicyapB+eii9f1v1uEvf2oCCaND6JUDbZJwVK4BYt4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IPuQ8RLG; arc=none smtp.client-ip=209.85.167.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IPuQ8RLG" Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3c9c36db8eeso3276516b6e.0; Tue, 25 Jun 2024 22:30:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719379818; x=1719984618; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FXS4AAOZJR0UaGbdrhIdaIzZL1JDPw0J2iPwwadrXKo=; b=IPuQ8RLGwiGVysV5t7o8tKeyJBdchGlnRndJFOX9JBn0+/UzljcZIGiNklGNo9Ii0l n1vgqjox1k9wQSKOqIYa28OGKdWcMHGts9dzxQVIvcKiR02tKfSwKFrcJpfaAKKRog07 reA414WabVtUTsOnnFxMpbTm1npjmTyRvh4WfsE5b2fTl0GIADXTKJOvN3kAsoHF12UD hhXFdognEfLDAGwVATZK0BMG4hDaiZm3xJKlf5KjuedwuAmYq+76JML+L3aWZPstZp2c yhGYsgW2iYJ6dFclz2OFliy2fBTnQMVcxEDtVOl8e7FasiJQu5F8wmE9O8+P1ISIgrUT qTfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719379818; x=1719984618; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FXS4AAOZJR0UaGbdrhIdaIzZL1JDPw0J2iPwwadrXKo=; b=o6mRpj8C06slTH0p68cxf+RIzqkC5lrfwryCMpQm7gb1SDKqHhrIi7rOrBeFPhGz3l t8iqNqxHQ9JJYhgvSzmxz26Buv6zA+jsyPuGEm7D8CVTh+tOPqTdbi+odpiJub81g0z7 hANeRyD93banzNmasiF6iegHwj5E6iqqfue9Tee++SYISuwGwe7YAZanptugbNWJCtXJ akeATHdUuJHjxBHZXa2i6NqfkN0w4VMrYCqwAVq2aTAmRd5mRIpr3TDWN7OHSEZ+lw3B 9DSEHEn+IDjE2TJ9dqzZqA1NRYtzM7EEl0tA/fjN6s1eB7bhQz5z0Ev284HCyEc89IKd h20g== X-Forwarded-Encrypted: i=1; AJvYcCWqv/+k5NqISIQIY/+11QQuHCE4cZqOruWnHFZpHcqHZZYQGZjqYalCRAQXHNXs8nM2XVuD0NhJARwThNJDrJHcbiBcsLQCIng70pj8cV8C0ZETolq+Z2He6bM7nxL9tY4tvmpSFA== X-Gm-Message-State: AOJu0YxEXDviWPfFhpAs7Sx3lFQupxZgwX/RFvLJSFuQ3APx0r+l1ISw jm0+GAYBFcRbwvJ9zgCsKCRvQ3TaTB+J2ZoAFaJHe9nw1oizjBvibD8Slw== X-Google-Smtp-Source: AGHT+IF2iZNXFdcMiu4tlPNcyAV5+W33UIG2SffQvkLk1L62EqF/fM2Z2RIwnkLgqahPRwiqq+Lpqw== X-Received: by 2002:a05:6870:46a1:b0:258:359f:6a95 with SMTP id 586e51a60fabf-25d06e28f37mr11132845fac.38.1719379817949; Tue, 25 Jun 2024 22:30:17 -0700 (PDT) Received: from rigel.home.arpa ([118.209.204.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70661b9f2f6sm7804000b3a.187.2024.06.25.22.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 22:30:17 -0700 (PDT) From: Kent Gibson To: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, brgl@bgdev.pl, linus.walleij@linaro.org Cc: Kent Gibson , corbet@lwn.net, linux-doc@vger.kernel.org Subject: [PATCH 4/4] Documentation: gpio: Reconfiguration with unset direction (uAPI v2) Date: Wed, 26 Jun 2024 13:29:25 +0800 Message-Id: <20240626052925.174272-5-warthog618@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626052925.174272-1-warthog618@gmail.com> References: <20240626052925.174272-1-warthog618@gmail.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Update description of reconfiguration rules, adding requirement that a direction flag be set to enable changing configuration for a line. Signed-off-by: Kent Gibson --- .../userspace-api/gpio/gpio-v2-line-set-config-ioctl.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/userspace-api/gpio/gpio-v2-line-set-config-ioctl.rst b/Documentation/userspace-api/gpio/gpio-v2-line-set-config-ioctl.rst index 9b942a8a53ca..cfaab801556c 100644 --- a/Documentation/userspace-api/gpio/gpio-v2-line-set-config-ioctl.rst +++ b/Documentation/userspace-api/gpio/gpio-v2-line-set-config-ioctl.rst @@ -35,11 +35,14 @@ Description Update the configuration of previously requested lines, without releasing the line or introducing potential glitches. -The new configuration must specify the configuration of all requested lines. +The new configuration must specify a configuration for all requested lines. The same :ref:`gpio-v2-get-line-config-rules` and :ref:`gpio-v2-get-line-config-support` that apply when requesting the lines -also apply when updating the line configuration. +also apply when updating the line configuration, with the additional +restriction that a direction flag must be set to enable reconfiguration. +If no direction flag is set in the configuration for a given line then the +configuration for that line is left unchanged. The motivating use case for this command is changing direction of bi-directional lines between input and output, but it may also be used to