From patchwork Mon Feb 5 09:33:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 770179 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 3D3C312B9C for ; Mon, 5 Feb 2024 09:34:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125671; cv=none; b=aBp+d5v+NLYjowmL81WVkWLO67rAhQgGrOyl91MuKaW1p8ERnfFmZtBrG+pJeXGy5o1ek2NkoupBkwsSAITCUWM6vLYyldyM4Q3BmuQ+535RVMnmniIV6I5+gRekFzNu1DmEnrDh1PM8tO9JYalJccVCcYX5juojZaA06wzzri4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125671; c=relaxed/simple; bh=wKoekw2eVVFcj9oxq6vzdf2ok15iXRtTtNq2jliv4lA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tolKB4g3D0l9nT64Eu4bdUTwkINqR4YZ9D9olvykeZMd1YPf6cdOf5LZV4uz9EPrAwq37jc1kJt4y45qr1/NJVeGLS3Ka6LSsTILn7/FrzjDnrRl9RrlPgqbm0a/3DuynJEzalwA9zZPjsQdhk9KdagSyta0+WziNpR/UxlMbRs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=RVuSZXDU; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="RVuSZXDU" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-40fdd65a9bdso2704375e9.2 for ; Mon, 05 Feb 2024 01:34:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707125668; x=1707730468; 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=ZZDQVAK/m+EwHZp2HJIrHIBUSEbpzq9pOlgL2Kpkkjg=; b=RVuSZXDU1PPPz0u88nlb5x4+Ori5uy8kod2URqu0ndVD0AKG32/31hpR+Pvp/gc3b9 opVFI3FwfHGnVS2rk1TrPdYId4493uyRFx2V3pymUrV/9WPhPaTgeRPeFlp1GhDhFXif 6hfC5uL9+jo0HXqN6YntjPPC3fU166Ur4ddE2TTwZ13eUz+ivZ+r0FzO7f85bcLi51D0 xTPZ6qVdzEince491l5iGgp4Vt9uQrbXOwdYLCwqIKPaI5LykkTvG41rVmAwwFhyLkn7 WacRFnHgX3iPN8eMqF6ooKIkR3GjB4OrbakdAxYLBnvqhGEZJhkvcti+ZOGf8nOuTnsz mYTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707125668; x=1707730468; 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=ZZDQVAK/m+EwHZp2HJIrHIBUSEbpzq9pOlgL2Kpkkjg=; b=DfwyB95Qj5iez0v1JOaIBP1SXNalfOv+mTh4cktIwKrtSXxUujW0emGwVXv53aUKT5 fjVe/WFBUTf0jz4d84rF7a/v1QXlvhPs2ywRDPV7gc+y9dVyqTB4Lqo8AxbDHqu1446T xdnE+qqm3aNaCV0aJ4PnhVDsnL5611FiaDXpIEoWKW2D9FQ4AjI855LmE7mF4uFZNUIS zwUsHFcIALcRoxxqwzBf1gx5ir7ld84Mkgy45KQtxLV706boCHUCosAW+KUou1ULc5DW JCJXnvFBW8ushnjIL4qfv0ldAYLDX4bLqmZzrd+x+j5l0hawuOwEfOXF7tPBQydnzKoQ eOFA== X-Gm-Message-State: AOJu0Yyz3pRs7MwWWaG7Aod41iM8pWNrzOoiQzU3KzoIDRScTr7/TRJB on4UnqOXgg18cPoYHIXEGb+1GukQ2JukP/sl7oKl6oyeCn269hf6mk2mSOl8cfk= X-Google-Smtp-Source: AGHT+IGOzddUhMQZJ0PD2K9+76g0yiZag3OnprMbiqKxoQPCFOLRGilGiVvAOxPHQD+R4ETWI4CyHQ== X-Received: by 2002:a05:600c:a01:b0:40f:c1f9:c884 with SMTP id z1-20020a05600c0a0100b0040fc1f9c884mr4142575wmp.39.1707125668491; Mon, 05 Feb 2024 01:34:28 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUm83IhfTyQ7y6ls6Z3lT+Xx58RcKqxvlQep2ldxlrwxsmT6NcjogMnkVoMyYiXpWnpXWVIeKQtwOrmmrndaMAqI5KG9I60lg++7fcDO3ZPAQtwB/f2qKxHFMp0HkGXLedguNBPIg9CgET6gFQkgOEtAdQyYdY40lzTOYSeuOSfs/TkjOj2V0B1oloOCsHFU9z+cI8EgYAjCt1kBBVBqrpLZr8g/scnZo6DE9UR4/jE+/+Qvy50gfaRgAa57BMfsB5lFKBORni4uhRb7XTe46mfdX0t/Es7DCy64o5WBJFoIew/LJv4F2Y4AGKITDNSsozpyl6QecaDvfaJiMIFf8Yf7T81pzJ8bw== Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b0040fc771c864sm7980397wmg.14.2024.02.05.01.34.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 01:34:28 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Kent Gibson , Alex Elder , Geert Uytterhoeven , "Paul E . McKenney" , Andy Shevchenko , Wolfram Sang Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 03/23] gpio: remove unused logging helpers Date: Mon, 5 Feb 2024 10:33:58 +0100 Message-Id: <20240205093418.39755-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205093418.39755-1-brgl@bgdev.pl> References: <20240205093418.39755-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski The general rule of the kernel is to not provide symbols that have no users upstream. Let's remove logging helpers that are not used anywhere. This will save us work later when we'll be modifying them to use the upcoming SRCU infrastructure. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index a4a2520b5f31..c3ae5bfa3f2e 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -219,31 +219,18 @@ static inline int gpio_chip_hwgpio(const struct gpio_desc *desc) /* With descriptor prefix */ -#define gpiod_emerg(desc, fmt, ...) \ - pr_emerg("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?",\ - ##__VA_ARGS__) -#define gpiod_crit(desc, fmt, ...) \ - pr_crit("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?", \ - ##__VA_ARGS__) #define gpiod_err(desc, fmt, ...) \ pr_err("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?", \ ##__VA_ARGS__) #define gpiod_warn(desc, fmt, ...) \ pr_warn("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?", \ ##__VA_ARGS__) -#define gpiod_info(desc, fmt, ...) \ - pr_info("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?", \ - ##__VA_ARGS__) #define gpiod_dbg(desc, fmt, ...) \ pr_debug("gpio-%d (%s): " fmt, desc_to_gpio(desc), desc->label ? : "?",\ ##__VA_ARGS__) /* With chip prefix */ -#define chip_emerg(gc, fmt, ...) \ - dev_emerg(&gc->gpiodev->dev, "(%s): " fmt, gc->label, ##__VA_ARGS__) -#define chip_crit(gc, fmt, ...) \ - dev_crit(&gc->gpiodev->dev, "(%s): " fmt, gc->label, ##__VA_ARGS__) #define chip_err(gc, fmt, ...) \ dev_err(&gc->gpiodev->dev, "(%s): " fmt, gc->label, ##__VA_ARGS__) #define chip_warn(gc, fmt, ...) \ From patchwork Mon Feb 5 09:33:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 770178 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 28B74134AA for ; Mon, 5 Feb 2024 09:34:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125673; cv=none; b=LMEwSWtle6ZTC4eFjvZuz9F/Y/RWyJOg8SqexWYhwY6pQj+OBVtmNLYwrKJZyWwf3V6h9ZZvpn3MG5S7a4G9BX+DPd+6u6DtFypBZPiSbF1bELNg8q5TMVJE6tzx5aZYpxGD7nRVmwhQ6lM1TCDYOxREvHhNU7kgsOUKVoiuHIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125673; c=relaxed/simple; bh=rvDmiJvoOjsEAG1Ifqh4V4UhyPYg6qZuDJ20zQ/Khlg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=A6sYhcNGU0Ri8FrA0UGXTKGnyjUyC+MuCL6Qt/KhTgZuFTqGVzVD5QV8okKyZ3xwru085TcqNONl7JSfYtOSgzd2uOSlX5oWSLvCL+0jEG2uCQeeXGDb3v5YRNaS3x0bymhR4KRn7+DejoUjjGGf8y6tCTygjhGU9yj/2KOwJrg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=lw5MOHFe; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="lw5MOHFe" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-33b29b5ea96so929065f8f.0 for ; Mon, 05 Feb 2024 01:34:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707125669; x=1707730469; 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=ggk/HS4V+gdB4Ghsw/F6Qu63h8wKplBC7+YEgEKvm/I=; b=lw5MOHFe8DfzKx2vttTyd4yHtivqVHI/wtoGHeHt5J7vTRC3sYrZzviPf1HrqARmgD xQSkKqKjjnm+3cP63K7x7DRBxapvqLVP0/OMavRCOHlz8guTZO+4YDENwr6jGzlSBHRk +7tfSmiIBOxxZtYeLnutc9Y2WndHGL2eFOsrHeCx92zBiL6g+uWTWX3xaMafAqMjm/k9 dbNZano0JMJRp5Ox+F7OkcSsgsXv7AYgCrxBn7Efa4hAU0I5pJpO+c8Db1tzDMG4wA44 q/+sqIMjObQyezTG8NMcQVnw4sOuSGTqkVi/z3ZfRSuakqgXORGU/qYfisPBNmv369j3 NH+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707125669; x=1707730469; 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=ggk/HS4V+gdB4Ghsw/F6Qu63h8wKplBC7+YEgEKvm/I=; b=EvGHR7xFdRmLpD3phD+CJ3KzglIK52s3e5P0Xzd/ZIbZgc4fCJ9asN3cTWIOxwnSN9 9ZIX14Jqj7rhPNsbW+R2/lOOqHYbAbLNRvGJGiextAcGepu78M6/F5vkG9oeKLystOqf 1/xDlL8dSfgYHvLnyuKZQvP2YjffOuJTIjehaQvV8hNjDymzNAowvlsqtcl7yrk+VkjB qnjIGPUG1K088SSnWlHYYUqLT8gVsz2ONLOKDweIY/VWaZUfDfkLBWP6pa6mE7ROoLfN Zcb/wAaJApyLRVERsoJ3pKXrNkBEEWtlnr8JRffoiTSp3As1LFEMZ72SvqdNWuQPlMkl CSXg== X-Gm-Message-State: AOJu0YxVC1SDISQs98nc83iGIEw62OV6cL5rC8QFoO+jQ+tungKKSCNJ tzs9TxlXm4eydjKMV0W672oJz99F9SXyE53+vc7jPnHfamPcizXQAayQ3LNPE0Y= X-Google-Smtp-Source: AGHT+IGmV+7oO3tTihglftOvAY9ys2JC0HqwERsmzJ5U7qwgZaAkLeRUyf/il5ao0F9eBGp+iUhtKA== X-Received: by 2002:adf:db44:0:b0:337:d84c:1d6 with SMTP id f4-20020adfdb44000000b00337d84c01d6mr3723241wrj.18.1707125669370; Mon, 05 Feb 2024 01:34:29 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUwWtApFLfLTngT2lkUY8xlP8ZuNiah9r0wTDnJOYT7AjyUHSkQKKGQ/LAQz4/cydeGnZShFBn1MrvvPVo/PkEc/nACNX+IyRUnM6M6nnXnwZ5cLfLN9WuOwBvoZIQ8jVjIRsfP4LjMT9bEHv5eGfFCyvaqi2HLcKfSKh30/U8qIZGz652uPwvvV5NnrCwmS86MRCJlRPMWEzxmid9j6frzRqQglH9W+JAnkZ62dFIMHeHpTYmsJitoD+KMtC0WfZ3L52/QzmDYeIpiX6dbbdG5xCY/HxtiuaEoOi3IGQTnUW4FWAEQKJ9N3pVajdFRfKjOEuBNYk5MEiZqc1Qju124+XnPndyvkQ== Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b0040fc771c864sm7980397wmg.14.2024.02.05.01.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 01:34:28 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Kent Gibson , Alex Elder , Geert Uytterhoeven , "Paul E . McKenney" , Andy Shevchenko , Wolfram Sang Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 04/23] gpio: provide and use gpiod_get_label() Date: Mon, 5 Feb 2024 10:33:59 +0100 Message-Id: <20240205093418.39755-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205093418.39755-1-brgl@bgdev.pl> References: <20240205093418.39755-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski We will soon serialize access to the descriptor label using SRCU. The write-side of the protection will require calling synchronize_srcu() which must not be called from atomic context. We have two irq helpers: gpiochip_lock_as_irq() and gpiochip_unlock_as_irq() that set the label if the GPIO is not requested but is being used as interrupt. They are called with a spinlock held from the interrupt subsystem. They must not do it if we are to use SRCU so instead let's move the special corner case to a dedicated getter. First: let's implement and use the getter where it's applicable. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib-cdev.c | 4 ++-- drivers/gpio/gpiolib.c | 9 +++++++-- drivers/gpio/gpiolib.h | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c index 34d6712fa07c..2c0a0700762d 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -2305,8 +2305,8 @@ static void gpio_desc_to_lineinfo(struct gpio_desc *desc, if (desc->name) strscpy(info->name, desc->name, sizeof(info->name)); - if (desc->label) - strscpy(info->consumer, desc->label, + if (gpiod_get_label(desc)) + strscpy(info->consumer, gpiod_get_label(desc), sizeof(info->consumer)); dflags = READ_ONCE(desc->flags); diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4c18b693d06c..cfd311ec5dda 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -105,6 +105,11 @@ static void gpiochip_irqchip_free_valid_mask(struct gpio_chip *gc); static bool gpiolib_initialized; +const char *gpiod_get_label(struct gpio_desc *desc) +{ + return desc->label; +} + static inline void desc_set_label(struct gpio_desc *d, const char *label) { d->label = label; @@ -2385,7 +2390,7 @@ char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset) * * Until this happens, this allocation needs to be atomic. */ - label = kstrdup(desc->label, GFP_ATOMIC); + label = kstrdup(gpiod_get_label(desc), GFP_ATOMIC); if (!label) return ERR_PTR(-ENOMEM); @@ -4726,7 +4731,7 @@ static void gpiolib_dbg_show(struct seq_file *s, struct gpio_device *gdev) is_irq = test_bit(FLAG_USED_AS_IRQ, &desc->flags); active_low = test_bit(FLAG_ACTIVE_LOW, &desc->flags); seq_printf(s, " gpio-%-3d (%-20.20s|%-20.20s) %s %s %s%s\n", - gpio, desc->name ?: "", desc->label, + gpio, desc->name ?: "", gpiod_get_label(desc), is_out ? "out" : "in ", value >= 0 ? (value ? "hi" : "lo") : "? ", is_irq ? "IRQ " : "", diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index c3ae5bfa3f2e..1058f326fe2b 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -208,6 +208,7 @@ int gpio_set_debounce_timeout(struct gpio_desc *desc, unsigned int debounce); int gpiod_hog(struct gpio_desc *desc, const char *name, unsigned long lflags, enum gpiod_flags dflags); int gpiochip_get_ngpios(struct gpio_chip *gc, struct device *dev); +const char *gpiod_get_label(struct gpio_desc *desc); /* * Return the GPIO number of the passed descriptor relative to its chip From patchwork Mon Feb 5 09:34:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 770177 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 3AE5D134D7 for ; Mon, 5 Feb 2024 09:34:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125675; cv=none; b=tzmIJb2BCOienVaCYUPrTQUsoFE1A41pBdfiTD3pLrY4LC1jVHC3K/d7O6JFlfnUC7emMrTlNkuNqR6b3D5NOlBf2qIvQcgPVoHHhcjr/MF0y07pDSBdsL6azAUd1ZRpDXZqHmvvoZgbBVWllC1ls9w9ZPTqdVUN8klItw8TcrE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125675; c=relaxed/simple; bh=L91BBpikBkHqwcQ57UiFh0/5/PsxnAo8v9+gu/rUrOM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oQyAHjufamgHptzQmdSFDp39y6PQ1i63IGJiNg7wYoFHBuPWrMdwpQhK2ccdBTMZ1g2nZ78jIJJi8u9yA9pPLSsItmPjSp8pUo3hJCyxt+Grykf2Uv5pnN8cXrcPFqB312KaZbd3Yx1tgGKmi5eoHPIwMH01phyw38nbgobSXZs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=EvMogXAG; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="EvMogXAG" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-511234430a4so7268581e87.3 for ; Mon, 05 Feb 2024 01:34:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707125670; x=1707730470; 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=RSEnfVuvu8Q/tNHp1neFQSbtxw3POuiVtvIa5az8diw=; b=EvMogXAGlsh8KWLG0umTfCX7vtaABlzwJdWaKMsuxtbJoYfEfi1kL8vzQxMo9Li1nl JHEnXPvxJgm2c5W3FrtYOHuvi97i5zs2r9VyhhIBgB/KUfwIBznnq2TRy+SW9sIa7I7X 4O7qkHbIjkja9QZ4/f7gCvE5/ZEw8LTuS/oZShaSqRWe2B/7xDUqYNTGCfOEfE3gPs26 EXTpBv2CKYdJZsrupiz1oakh8SQ/9/carta/uD37Om4SNhdrj5O/N8bszHRw7qsnG/MM 5nK6Sw7lBhWtXPpvAN8xJVyNdhbdw6UCS6fI3Mry+n+WgBGS8Ke2wLNgxhjHRXHeJeCS an1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707125670; x=1707730470; 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=RSEnfVuvu8Q/tNHp1neFQSbtxw3POuiVtvIa5az8diw=; b=BDcDA5JB0aRYmyePKQucNR52G7SEBDgs9AAKk/X5PS8V9xaK4LqKld1M4JR1rosaWN 9eSx7S/GtGPGAYNeUArahPlkQIHSunBDvAHmdpIQBLYZnsaCiTHDBRssQEBzp2Vc1Kvz ZmSJWg4pBdsxA4yrvaYyPG0f8wcdaLLiGc1ORb8KFtvZVbEdR8TUmdz43lSZ+7P8sL5X /2XrtbWmSRULB4e5q0ku24SK7E00jgL18vyH6m0DDMTQTNbQn7tbUlipJXmXeiKv8G+D K9Olw8E4//w3MfJhc1OH/FU6JE2No6jUS8U99ibi9kw7/s8j2w7q7ER2/s/sxm7iHRep dCYw== X-Gm-Message-State: AOJu0YxvBqtBaGeB52PYjEsNLdSeY/x2w5k5tK+DW9jAoG2NHO6JWsXH no/Edyo/lw1eD3Z5GZU1mLtiigbwkle4pfcSpO0zcySIP4+CKNuvzzgVBF3XY2E= X-Google-Smtp-Source: AGHT+IEcPafTTkHgGkgn+DFvdWRnWTQwe2o6OEptnHsezn9spoJf9YLIqVdfi0Crff3zOVppi25yBQ== X-Received: by 2002:a19:f711:0:b0:511:51af:7548 with SMTP id z17-20020a19f711000000b0051151af7548mr1026924lfe.9.1707125670191; Mon, 05 Feb 2024 01:34:30 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXobqsD3Uis6hLjobTZp6XBfCqM+9f4VYj5owOVxKdXHlS2gCu1PCPgofYK23757bJ/XK2ElC26nPRA4h4YtVC/gdKQ4wq4XOjIOmbTYckFQlDJOqPc6AsLuLziM8+0Qyio6nOZmt8AyTrQuDJ+EJfop1t007ahMAjUqU+0A9qQ3eREHCs9wSMC3KjHXY0TEGrQlG9f6P3CakEMHWrkvp0gv9rO0NFnYOjqOkep+YgX9qCyiwo8Bxsf6PzudPDrsZ+MrNRJho9xwCRjRDokEx9AHlLZ42c+XoqwEem2lZAO+yd4LRCowmQWbAnvrsWp/7n1976/gdhfl9QqNOnLRGwgblsF8s3yYg== Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b0040fc771c864sm7980397wmg.14.2024.02.05.01.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 01:34:29 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Kent Gibson , Alex Elder , Geert Uytterhoeven , "Paul E . McKenney" , Andy Shevchenko , Wolfram Sang Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 05/23] gpio: don't set label from irq helpers Date: Mon, 5 Feb 2024 10:34:00 +0100 Message-Id: <20240205093418.39755-6-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205093418.39755-1-brgl@bgdev.pl> References: <20240205093418.39755-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski We will soon serialize access to the descriptor label using SRCU. The write-side of the protection will require calling synchronize_srcu() which must not be called from atomic context. We have two irq helpers: gpiochip_lock_as_irq() and gpiochip_unlock_as_irq() that set the label if the GPIO is not requested but is being used as interrupt. They are called with a spinlock held from the interrupt subsystem. They must not do it if we are to use SRCU so instead let's move the special corner case to a dedicated getter. Don't actually set the label to "interrupt" in the above case but rather use the newly added gpiod_get_label() helper to hide the logic that atomically checks the descriptor flags and returns the address of a static "interrupt" string. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index cfd311ec5dda..5c041d57077b 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -107,7 +107,14 @@ static bool gpiolib_initialized; const char *gpiod_get_label(struct gpio_desc *desc) { - return desc->label; + unsigned long flags; + + flags = READ_ONCE(desc->flags); + if (test_bit(FLAG_USED_AS_IRQ, &flags) && + !test_bit(FLAG_REQUESTED, &flags)) + return "interrupt"; + + return test_bit(FLAG_REQUESTED, &flags) ? desc->label : NULL; } static inline void desc_set_label(struct gpio_desc *d, const char *label) @@ -3593,14 +3600,6 @@ int gpiochip_lock_as_irq(struct gpio_chip *gc, unsigned int offset) set_bit(FLAG_USED_AS_IRQ, &desc->flags); set_bit(FLAG_IRQ_IS_ENABLED, &desc->flags); - /* - * If the consumer has not set up a label (such as when the - * IRQ is referenced from .to_irq()) we set up a label here - * so it is clear this is used as an interrupt. - */ - if (!desc->label) - desc_set_label(desc, "interrupt"); - return 0; } EXPORT_SYMBOL_GPL(gpiochip_lock_as_irq); @@ -3623,10 +3622,6 @@ void gpiochip_unlock_as_irq(struct gpio_chip *gc, unsigned int offset) clear_bit(FLAG_USED_AS_IRQ, &desc->flags); clear_bit(FLAG_IRQ_IS_ENABLED, &desc->flags); - - /* If we only had this marking, erase it */ - if (desc->label && !strcmp(desc->label, "interrupt")) - desc_set_label(desc, NULL); } EXPORT_SYMBOL_GPL(gpiochip_unlock_as_irq); From patchwork Mon Feb 5 09:34:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 770176 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 DE83A14005 for ; Mon, 5 Feb 2024 09:34:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125676; cv=none; b=b29+n96nfnp/9PIZv2xJyLbwDqAGL1/DMoGRunUzSM0nJo1AceDiSsxllC0uSkECM1R63xONzmGV8ukSus7wZSZT0rdrv71dgp355ycGyPwy+lI+ckCiu9goDTBPso3GR+62mOMTLrylTDESupnfQdV1615eGoArmN0TYNy8bgc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125676; c=relaxed/simple; bh=QndNeSWqDTX/zFjnwCo02F7D/CRpA6gYSyfRPlHOvEw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qFwS8M4eeaecconQa/I3KP85znfXzS3wgXbXjHZYYKE5m0+e9dcUtv7PEs6pSZtlAPlHAE4TuTh9kQ4nZA34ZwFHHJdgdB6pBJMkvy8ZMIv+O2arvd7UUJFSFgQqTrWVVHUorSqiPFBoYgBJ5E4jifwyy6+IWHrIoUBoqLGUQbs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=RKjTqk2Z; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="RKjTqk2Z" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-511234430a4so7268633e87.3 for ; Mon, 05 Feb 2024 01:34:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707125673; x=1707730473; 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=GkfvkjtzEhDkQSOg4G+yVVF8O3dwJMh/iXMkfAAfTgY=; b=RKjTqk2ZylDq88zxeYhB89loVrt+e0Nihxz+aoTPRicgpNW/Nq/PAsowxtWAHfCAOL +3maT8cXr9s/COgOsAOn+n++p42AXHtfvk09WtU0CyVNvAS0TU8meeDfRp/4UGtmBkqw 0r+96EsJWBBZPloV646QtKRk3F/Oyi0s0on8sdiakvWUW4WKg6dIz+YcoUVHcDp/y5Ci aqYy4vdhLiF4YqO+RsLKC7/sIqlb6wuEHtW1bGnxJ0/NNPLqUEe/CcHITbN7JGsaDtwB jKDT6SVU4lcy5ukyeqD7kUOYrLBAEEOVM7MsUAG31QPBlPCKzyv1pjSsNTUxNL4USNCE CHtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707125673; x=1707730473; 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=GkfvkjtzEhDkQSOg4G+yVVF8O3dwJMh/iXMkfAAfTgY=; b=VJQcN2uEOMejY4BJf0lDAtauG8vuA0RoSOE4hxgzVFq+Wb/Pt8mh6c1SFhXBWRCtpJ IiSXYWK10VRhLyJfbMtQ+VKhxguIyLZTEJSjDf9IcEdu0CLvNZ4GoaVheUpyDprcBi1+ +gd4P9stO26swAp7Z8ZglXmbY8LjATfTnpS4qXPSFlM5pEp7RwOvEb0vCgrsFW+8Ylu9 /oo3ENA/0R19ck49U3YO1j/i5fpJe11JSUd74gbW2KpxVjxN+xmQcGHiq4t7EYrzv10Q 4HULPCwbxci3lehvSLMyQTh9mxWlqQqLrAjPpClZYyo2VaglojXg1MAHNjhWiXkodb/S 6CAA== X-Gm-Message-State: AOJu0Yz8iXnCbme6KMfOYMu+EHvurXYed2HNvNlebW3rXo6vX6IRGEwF jNiBwIj8pR4OMdetJNI3gV87HA65NhLRwhVE3oSkbdymPk0xxiRnVPxwOe8zwrI= X-Google-Smtp-Source: AGHT+IEioOygbwzOiy8IYXaqffGjI1iQJ28ymii8IJ/QHZobuyxDN4NK6zExQjLK8wD8AOwGSbQsug== X-Received: by 2002:a19:7008:0:b0:511:4f1c:ef43 with SMTP id h8-20020a197008000000b005114f1cef43mr1520317lfc.10.1707125672969; Mon, 05 Feb 2024 01:34:32 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXJv09UAJMwHDheEwlhQmtq785dpHyI9qQU6Sgt9oU0/XH58nkLzfK4Bg+uwolkHslsZJtdQtN4SCOXjNBH6ed0woHAAYAU+ld5fGgnmcxc2E1Bjgsl2aMg5IKMOmz2uhvVUwZblNOp9bfso8qZFr7LGF3fppU6zTPTdPxdcFj976hV2v4tkrSccdQNR9ej7kqvq0CnDQUVVExd0LCXkqGZwpwUPNLKTPhaQ0XW1yRn1+KvpQYICzjMU2F76H1/xZgg85QgN010/3S8yovMH2xqkHgaMlCyFTD/4ZPPYbeYAYnW/rDr6h2AWHrbDZcq9qiXA4B2dRCn4R8zmJtwkP0Dl8q6P4D77Q== Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b0040fc771c864sm7980397wmg.14.2024.02.05.01.34.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 01:34:32 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Kent Gibson , Alex Elder , Geert Uytterhoeven , "Paul E . McKenney" , Andy Shevchenko , Wolfram Sang Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 08/23] gpio: sysfs: use gpio_device_find() to iterate over existing devices Date: Mon, 5 Feb 2024 10:34:03 +0100 Message-Id: <20240205093418.39755-9-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205093418.39755-1-brgl@bgdev.pl> References: <20240205093418.39755-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski With the list of GPIO devices now protected with SRCU we can use gpio_device_find() to traverse it from sysfs. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib-sysfs.c | 41 ++++++++++++++++-------------------- drivers/gpio/gpiolib.c | 2 +- drivers/gpio/gpiolib.h | 1 - 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 6bf5332136e5..3c3b8559cff5 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c @@ -790,11 +790,24 @@ void gpiochip_sysfs_unregister(struct gpio_device *gdev) } } +static int gpiofind_sysfs_register(struct gpio_chip *gc, void *data) +{ + struct gpio_device *gdev = gc->gpiodev; + int ret; + + if (gdev->mockdev) + return 0; + + ret = gpiochip_sysfs_register(gdev); + if (ret) + chip_err(gc, "failed to register the sysfs entry: %d\n", ret); + + return 0; +} + static int __init gpiolib_sysfs_init(void) { - int status; - unsigned long flags; - struct gpio_device *gdev; + int status; status = class_register(&gpio_class); if (status < 0) @@ -806,26 +819,8 @@ static int __init gpiolib_sysfs_init(void) * We run before arch_initcall() so chip->dev nodes can have * registered, and so arch_initcall() can always gpiod_export(). */ - spin_lock_irqsave(&gpio_lock, flags); - list_for_each_entry(gdev, &gpio_devices, list) { - if (gdev->mockdev) - continue; + gpio_device_find(NULL, gpiofind_sysfs_register); - /* - * TODO we yield gpio_lock here because - * gpiochip_sysfs_register() acquires a mutex. This is unsafe - * and needs to be fixed. - * - * Also it would be nice to use gpio_device_find() here so we - * can keep gpio_chips local to gpiolib.c, but the yield of - * gpio_lock prevents us from doing this. - */ - spin_unlock_irqrestore(&gpio_lock, flags); - status = gpiochip_sysfs_register(gdev); - spin_lock_irqsave(&gpio_lock, flags); - } - spin_unlock_irqrestore(&gpio_lock, flags); - - return status; + return 0; } postcore_initcall(gpiolib_sysfs_init); diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index f425e0264b7e..6cfb75ee739d 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -85,7 +85,7 @@ DEFINE_SPINLOCK(gpio_lock); static DEFINE_MUTEX(gpio_lookup_lock); static LIST_HEAD(gpio_lookup_list); -LIST_HEAD(gpio_devices); +static LIST_HEAD(gpio_devices); /* Protects the GPIO device list against concurrent modifications. */ static DEFINE_MUTEX(gpio_devices_lock); /* Ensures coherence during read-only accesses to the list of GPIO devices. */ diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index d2e73eea9e92..2bf3f9e13ae4 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -136,7 +136,6 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep, int gpiod_set_transitory(struct gpio_desc *desc, bool transitory); extern spinlock_t gpio_lock; -extern struct list_head gpio_devices; void gpiod_line_state_notify(struct gpio_desc *desc, unsigned long action); From patchwork Mon Feb 5 09:34:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 770175 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (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 E67B814ABA for ; Mon, 5 Feb 2024 09:34:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125679; cv=none; b=mFp7Zl+UsTsc9vVEvPS6NzqyvOYmRc6NZb8qSi/Pmzy9Cl1YEBF17ROVzruNPgaXy0o0lxIM81I7c2v0Xne3AOfOe7Sbu/EuSWMdGIC1bnIFQZ/qewjt2GSgpg1GrdIXORvbUIhJLH6rEMXy5fLJcp1YL36h6YOGv6gIVR4icJM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125679; c=relaxed/simple; bh=rfKavv+WG6jGS5BHlahGWQusPjVqbbXZ7CB6SI+xjkE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aZpQeCiuzhNIydPusrN6C4vOFGyFrn4qhPYVEUs6KSp4/quCk4IAjjtWD+7Q7LaHFmJsGgE6I/Cyxc4/vtjyxkPcklw7vYV2daxKFGM1b6sdlBF3wCcVTky6kxZtcvXvmHmdDaGNkUw2u6wIUx24Al9sR0VSdIBZJAHdkvX7IMg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=eo6843DD; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="eo6843DD" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-511344235c6so4714373e87.0 for ; Mon, 05 Feb 2024 01:34:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707125675; x=1707730475; 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=oBVIUbEZhzPUY5wnbR8PSqxrCBFBG4RRWNGnrCutvhg=; b=eo6843DD9eFSeuKm9WWRqFLHKuNJsAsJCe1t5eP56+JJ5PPb0Uy35xAGsWJC47J78V ooKBZR48+Crkfcf8B5H0p9bmvcyvopaVnz/xZSJxjaRS7kWL+SwnlUxUDSJY6AbFAbTK DreAJ6YjZ6jU3kvpSdJ5RSE1G87roRZLMP/SdKjb0YHLiH4fn4wC2j9PFtuvfwdBTLa3 tN2C8mo/YzPr9ch9cyxyjTXVxNZeTnLmnu2UT7FXZ0hiY1v/KQFIfRyjBGn0knCWk3/k 3viNMxPwTRhIJwo5KlAhmwXfZjBTAkMB/PTNG85LG9DgDOuMgxM10k4ehNo7RKrQ1p/E 1upQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707125675; x=1707730475; 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=oBVIUbEZhzPUY5wnbR8PSqxrCBFBG4RRWNGnrCutvhg=; b=o1VpBwLoef8bL9OhK9OQw/UGBiHrKl4GrpDr6aw2nFQgsRD2zhA3F0hBlZ79oQOs3E Wr196+82iYK+lc5yO+8JIQXunQEwxxCHt7PeyXZbbHfChxKAb9Zrt1MWYY3NimgoM+cE KiroOVaXwhQ7GdP7o9sga+SaISr78XjwSBjdN9VlaXCAGZhacbWFOF+6odPsNOhoWkIm QnkRdNjO3ikjcNOVSsy0sZsLy9QDhKdZ/mNgtMM3ViK2oZBO3WbpI7tjsBKEMZ2j0YLp HdlilhRoX1kESa7nNt5UWSMStrSR0tjAKQ545wVtsS4Cp8JYMGNx3A17GWdYqne/3EDc xO8g== X-Gm-Message-State: AOJu0YyTAO/gJ54obKs5bh4OqxoQhbggLc2/6cxNo78DypELlLkjToBs ySdqiNV+2D+cBy4iNR/6qG0zeuwz9eH+F8KwkCObnxAkV08ZkWGLJwgLekTus7w= X-Google-Smtp-Source: AGHT+IFf5V3o092bmqPbbvpWyHNdPE2eO7k80aGf9SuKa1MQgaO3K0nCTsSkjqLFZNeKshudZ6G6cQ== X-Received: by 2002:a05:6512:10c8:b0:50e:7410:d5b0 with SMTP id k8-20020a05651210c800b0050e7410d5b0mr6312960lfg.28.1707125674803; Mon, 05 Feb 2024 01:34:34 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCU+vRrFS3A2LQom52oicbbrO1+QRNmZbSVSC2RqEnatt0iYkThW7J9MLI/MMTZItiNU4cz3RvUAZw2i+BnyZCheQOcyCcYrKBEa8LZGPtzgg/Wbvo/C/fo9aHnqMgD6aWctF6ZMr1nY7P7LAql/Z9HOAXR7qHTosr4yZLKD4rzhVqqsFyyrS9fNhgwstDS+qJVd6aaaAzK7zoN3jCZdzJRfHMJihL3AFoPtaXNULJtw5Ru1s8z6IDJDfwolEKW3s8fRKtgu9xPmBB/H5TQ3sGWvIkPe3/njUZsQevjoFlwMadyF1zAa8VW9+gzCEtVs2/zxSHsttQNI1q2RrRxH1QAI4Xe8GEtACw== Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b0040fc771c864sm7980397wmg.14.2024.02.05.01.34.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 01:34:34 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Kent Gibson , Alex Elder , Geert Uytterhoeven , "Paul E . McKenney" , Andy Shevchenko , Wolfram Sang Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 10/23] gpio: reinforce desc->flags handling Date: Mon, 5 Feb 2024 10:34:05 +0100 Message-Id: <20240205093418.39755-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205093418.39755-1-brgl@bgdev.pl> References: <20240205093418.39755-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski We now removed the gpio_lock spinlock and modified the places previously protected by it to handle desc->flags access in a consistent way. Let's improve other places that were previously unprotected by reading the flags field of gpio_desc once and using the stored value for logic consistency. If we need to modify the field, let's also write it back once with a consistent value resulting from the function's logic. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 5ed5b71590ab..d49f84d692ce 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -336,18 +336,20 @@ static int gpiochip_find_base_unlocked(int ngpio) int gpiod_get_direction(struct gpio_desc *desc) { struct gpio_chip *gc; + unsigned long flags; unsigned int offset; int ret; gc = gpiod_to_chip(desc); offset = gpio_chip_hwgpio(desc); + flags = READ_ONCE(desc->flags); /* * Open drain emulation using input mode may incorrectly report * input here, fix that up. */ - if (test_bit(FLAG_OPEN_DRAIN, &desc->flags) && - test_bit(FLAG_IS_OUT, &desc->flags)) + if (test_bit(FLAG_OPEN_DRAIN, &flags) && + test_bit(FLAG_IS_OUT, &flags)) return 0; if (!gc->get_direction) @@ -361,7 +363,8 @@ int gpiod_get_direction(struct gpio_desc *desc) if (ret > 0) ret = 1; - assign_bit(FLAG_IS_OUT, &desc->flags, !ret); + assign_bit(FLAG_IS_OUT, &flags, !ret); + WRITE_ONCE(desc->flags, flags); return ret; } @@ -747,9 +750,6 @@ static void gpiochip_machine_hog(struct gpio_chip *gc, struct gpiod_hog *hog) return; } - if (test_bit(FLAG_IS_HOGGED, &desc->flags)) - return; - rv = gpiod_hog(desc, hog->line_name, hog->lflags, hog->dflags); if (rv) gpiod_err(desc, "%s: unable to hog GPIO line (%s:%u): %d\n", @@ -2522,13 +2522,16 @@ static int gpio_set_config(struct gpio_desc *desc, enum pin_config_param mode) static int gpio_set_bias(struct gpio_desc *desc) { enum pin_config_param bias; + unsigned long flags; unsigned int arg; - if (test_bit(FLAG_BIAS_DISABLE, &desc->flags)) + flags = READ_ONCE(desc->flags); + + if (test_bit(FLAG_BIAS_DISABLE, &flags)) bias = PIN_CONFIG_BIAS_DISABLE; - else if (test_bit(FLAG_PULL_UP, &desc->flags)) + else if (test_bit(FLAG_PULL_UP, &flags)) bias = PIN_CONFIG_BIAS_PULL_UP; - else if (test_bit(FLAG_PULL_DOWN, &desc->flags)) + else if (test_bit(FLAG_PULL_DOWN, &flags)) bias = PIN_CONFIG_BIAS_PULL_DOWN; else return 0; @@ -2694,24 +2697,28 @@ EXPORT_SYMBOL_GPL(gpiod_direction_output_raw); */ int gpiod_direction_output(struct gpio_desc *desc, int value) { + unsigned long flags; int ret; VALIDATE_DESC(desc); - if (test_bit(FLAG_ACTIVE_LOW, &desc->flags)) + + flags = READ_ONCE(desc->flags); + + if (test_bit(FLAG_ACTIVE_LOW, &flags)) value = !value; else value = !!value; /* GPIOs used for enabled IRQs shall not be set as output */ - if (test_bit(FLAG_USED_AS_IRQ, &desc->flags) && - test_bit(FLAG_IRQ_IS_ENABLED, &desc->flags)) { + if (test_bit(FLAG_USED_AS_IRQ, &flags) && + test_bit(FLAG_IRQ_IS_ENABLED, &flags)) { gpiod_err(desc, "%s: tried to set a GPIO tied to an IRQ as output\n", __func__); return -EIO; } - if (test_bit(FLAG_OPEN_DRAIN, &desc->flags)) { + if (test_bit(FLAG_OPEN_DRAIN, &flags)) { /* First see if we can enable open drain in hardware */ ret = gpio_set_config(desc, PIN_CONFIG_DRIVE_OPEN_DRAIN); if (!ret) @@ -2721,7 +2728,7 @@ int gpiod_direction_output(struct gpio_desc *desc, int value) ret = gpiod_direction_input(desc); goto set_output_flag; } - } else if (test_bit(FLAG_OPEN_SOURCE, &desc->flags)) { + } else if (test_bit(FLAG_OPEN_SOURCE, &flags)) { ret = gpio_set_config(desc, PIN_CONFIG_DRIVE_OPEN_SOURCE); if (!ret) goto set_output_value; @@ -4418,21 +4425,22 @@ int gpiod_hog(struct gpio_desc *desc, const char *name, int hwnum; int ret; + if (test_and_set_bit(FLAG_IS_HOGGED, &desc->flags)) + return 0; + gc = gpiod_to_chip(desc); hwnum = gpio_chip_hwgpio(desc); local_desc = gpiochip_request_own_desc(gc, hwnum, name, lflags, dflags); if (IS_ERR(local_desc)) { + clear_bit(FLAG_IS_HOGGED, &desc->flags); ret = PTR_ERR(local_desc); pr_err("requesting hog GPIO %s (chip %s, offset %d) failed, %d\n", name, gc->label, hwnum, ret); return ret; } - /* Mark GPIO as hogged so it can be identified and removed later */ - set_bit(FLAG_IS_HOGGED, &desc->flags); - gpiod_dbg(desc, "hogged as %s%s\n", (dflags & GPIOD_FLAGS_BIT_DIR_OUT) ? "output" : "input", (dflags & GPIOD_FLAGS_BIT_DIR_OUT) ? From patchwork Mon Feb 5 09:34:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 770174 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 588B2171A9 for ; Mon, 5 Feb 2024 09:34:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125680; cv=none; b=SxLrv+Hm/78DMj96bMYVvQ3Zxurn/nwcqBoacfD5V9R6E1q2hQwW038A92VJOb+oF65reCca0W/EH7HLfYpfwHvjMxlYRS6FMXt9ghOjvoTIfagvmut81qg6zkSz7dQHHup+ItCxrnuVp2aItZDQ6kUEjFQ4SZYBtT0Kcn1stpA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125680; c=relaxed/simple; bh=6pZf3MPfcP7U/qzAucrcxQHtn245jLEQDsd8yxAaDXY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Vpkw3thWjpskifRHhya5uvFEuypXnjsH+H6EYBWSbi9wIQ59VkMbqvO4i+L4LKCphNaLSIJ5sD798uN90NCfLfWIxd5UAlfA4DEQA+oscis52zIAxqFhiUdEhzKhDNZu54ZBdZqtJtOsQRPmDAPg/qP1/Oc300F8f2foZ8KPlxQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=Wv111LTZ; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="Wv111LTZ" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-40fdc500db5so3727085e9.1 for ; Mon, 05 Feb 2024 01:34:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707125676; x=1707730476; 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=fPWICPIbUQqhQWXK/aPucJT3q02Uu3yz0IoZJm+ImZ4=; b=Wv111LTZxj8WUrUEuKtOGY7+yl5fqYo+8RKnHXmCJAphqtZbowkZHWQ/rB+aSqq29s QCLOYrGNPsnWDpdpEo7rVvKWPc4ROlrZVrdoQ1Ayo/JHorbX4YHau+YDZtv5aMcsAAu+ ofD4xkCP7G8qFUaKE+gJhrUBiDg8rH2lWcZbi3tVP16yn1pIRFeBdi7Zo9MelAxmb2Y9 rJSYX4pev8T5jtVycnl2HKPgoeIJzF6oe1t+xDTKpb31Jcf9xCyPcUclQTzxK1DTVvyM x0iSu+hKjYSmQj1DXh9fz7c7cfKoslZmumUjmhGU+6m7SM6T6T07YYovyEfaZ6vXd9tP CqSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707125676; x=1707730476; 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=fPWICPIbUQqhQWXK/aPucJT3q02Uu3yz0IoZJm+ImZ4=; b=TJhynL8B77s+pOG01ZI+2xrWagOTsWB4sf/GK9/zWsDpL/A7xDhHDc0oS3+oTIoIQe 13r4PkAbWFId9xinB21ykYzC2SL3WAUnv9tayqGzudf7kVeGYlTcUVmjxM0UivKVnCI4 Z4/5uVtyZ5K7LVI2fekOd4Ni1MXSkAsvRu5fUk+5YNgCiSTgKIx+cr48nHlmDQpjCe5Y wrTwmYXsq1JFNLp0Wc/q8I0s2e3DcYOHHNvUvbDXQ4OElvRyiAaZHF3OdovhAkyPPqHZ eFqldAVXdo44yuAMKpHppkAyH1ySzS9zpd9i8Iwfl1i3vNLC35+JpEpDrvzxQeQRLtgz JGmg== X-Gm-Message-State: AOJu0YwBC3ICJ80ACJxdgljVViG4lIj85JAf6+xuxpCRGD1wpF7oLtsJ SHVVqnj9kzIGia7nwPWcnxgzks9oWI/VAaLg8mG+HcgQv9VY847qKopvmV0rrkk= X-Google-Smtp-Source: AGHT+IG21q8aYCNLml1cXS2JVIuYakcxkQAkcMiZABjqWfdpPL7byMFcdGrefOCQfYZl8ybztm6cMg== X-Received: by 2002:a05:600c:5191:b0:40e:60c3:c327 with SMTP id fa17-20020a05600c519100b0040e60c3c327mr3910240wmb.1.1707125676576; Mon, 05 Feb 2024 01:34:36 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUU/8yo/GZ+OF/G9T3pL+XmpQ6Byf0DyWVqn2QJEbCSns32/4tJB8SUprsV9AxBNmx3gG8oW13Wux0CylhKHd+TQbXiCadEdaXmUNbKIUZOOU7cZfDMXGjArmp/8bw58Pd9nBhV+X8b/WFw9qRiCgC92K8BBZH8t/7DHrvC3Q/K/QaCIlYwY6mzCXWT4peHngvkkVfXI6rzKLf65ONr91uKuWmOoMRre5LsmqAI3PxHVakQnNWGRYLjqe1y/y0QXfHK4YPAvk4fM9CdQIufi1Rhb62ZH5bEvd7LkDRDuLhx2VooOIwIq1qrvdaTKBghypZyJ9D9O2A9wYgS7OMYkp5fN+ml4DBJnA== Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b0040fc771c864sm7980397wmg.14.2024.02.05.01.34.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 01:34:36 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Kent Gibson , Alex Elder , Geert Uytterhoeven , "Paul E . McKenney" , Andy Shevchenko , Wolfram Sang Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 12/23] gpio: sysfs: extend the critical section for unregistering sysfs devices Date: Mon, 5 Feb 2024 10:34:07 +0100 Message-Id: <20240205093418.39755-13-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205093418.39755-1-brgl@bgdev.pl> References: <20240205093418.39755-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski Checking the gdev->mockdev pointer for NULL must be part of the critical section. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib-sysfs.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpiolib-sysfs.c b/drivers/gpio/gpiolib-sysfs.c index 1cc707685f87..5da316ea9cc7 100644 --- a/drivers/gpio/gpiolib-sysfs.c +++ b/drivers/gpio/gpiolib-sysfs.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include #include @@ -768,15 +769,15 @@ void gpiochip_sysfs_unregister(struct gpio_device *gdev) struct gpio_desc *desc; struct gpio_chip *chip = gdev->chip; - if (!gdev->mockdev) - return; + scoped_guard(mutex, &sysfs_lock) { + if (!gdev->mockdev) + return; - device_unregister(gdev->mockdev); + device_unregister(gdev->mockdev); - /* prevent further gpiod exports */ - mutex_lock(&sysfs_lock); - gdev->mockdev = NULL; - mutex_unlock(&sysfs_lock); + /* prevent further gpiod exports */ + gdev->mockdev = NULL; + } /* unregister gpiod class devices owned by sysfs */ for_each_gpio_desc_with_flag(chip, desc, FLAG_SYSFS) { From patchwork Mon Feb 5 09:34:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 770173 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (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 613A61759F for ; Mon, 5 Feb 2024 09:34:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125682; cv=none; b=W/hFDxJ8YQ7h8heu8VMOIKxJ57sX4v60yYozUWt41qbruiVnHb9NrLQ1BNsL6Uk4fEI7M0jJ0jmTBZ+ajWNUvQiJeUAI7HejmXa42DIsm3ekiyke3ScuNz9WqOOXcuUXUkPcNuoSUqQyaT1tlJ2BIX4IvhQUC40CKsHCzDiDqqY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125682; c=relaxed/simple; bh=yLFHAeDDaUuIFRqdSf+MG12ymiBBzwEskiNkeG6cKEk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l3ANzdS6MWxuQeHffxISzlSTynbva+blVEBHpa8Hl7fr6v7lGOYeaax2TlQDnNp1uPaJyq89Y6Ehhc/xelTtnRNOB+B98DxgBv062WZDjNRpmEvpgx33s9XPHauUKpUR+fkX2tSzabKErQuhO/pqTIKD8+e+lp2r4wNriuNYNTY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=HU9Nb2/u; arc=none smtp.client-ip=209.85.167.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="HU9Nb2/u" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-511531f03f6so397001e87.0 for ; Mon, 05 Feb 2024 01:34:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707125678; x=1707730478; 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=IsALcY7SVXjN//VI/pQguwi8KjWlDmDQg/LjiqJYZd0=; b=HU9Nb2/uyHGQwalTZDAF9Pk53iHHcGQmSFF3R+DwkIp3akQljNzZzkhAeZjoiAKnlw KWWSGf4BDMR7jSowS51HVJFA+K1SOTV6wxgSJhWpLfoM5gR0gZY+/C8upIopDm9MiTP3 dBkNJT0UErgrQe/IGr1zEovflTcNW8W0OS58pde+ctdqgDIu+PLeDsAtC5Qf225th4Jv ME3zodHI6gEO5jE0rKRO9dETanET90ep7/GvGvL1FvIUWZqwFsGFPKcA2q0FdGSWwFer ZI93Gi55Iukg5IUqlw6e+cw4w9Znm9lkjdOO18P3svoDY2rpy40mTWFUQgzBvNAXAiyl /9wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707125678; x=1707730478; 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=IsALcY7SVXjN//VI/pQguwi8KjWlDmDQg/LjiqJYZd0=; b=VNtKPIewJyByJOOs/cMsB7cxpGIJ1I57ge2NSs3kxJWGNqrmlQDPE1WJPa02N3pM2L EzquIQsXRPHxzi+DAYPmeRTlFAZXQdP05Mmd5D0VZ8qaTkWsHsxYHndXMwU+2C0KsFjR Hycc0yavORG5sTypRXOzpglrA6Dq0eAoinsz1Ae0ntleAT91DDxULkUXGGaIL9kU88I7 grMLeXe61unzJEOTZxUW54+uNYoVGSiLAnNG2cbPYADZEgC1JNajn1ubs8+HX6Orllf3 WW+StvTgWkVsMWvrPfInJxqv/LqpVGc7O211MgBD7ExilJdY/f/KtiUMmjTVsU66mPBt E11Q== X-Gm-Message-State: AOJu0YwHyg5kAE61Dnc0Or+n2HqBL22tvyT/13ZOV+uc92Eg9RG3voua VpUTcg702xnKbtl/vK4LnUFMpqXxpoagctViYRcv6ffJPLM1lFU3RFmMrGdF8gw= X-Google-Smtp-Source: AGHT+IHJSPbTzeawrSm1nAoPiS4N3G71Ns86R6QPG9cspUSWjZVEyhsD2m1pxHBJmfCPkCAmQllpZg== X-Received: by 2002:a19:e058:0:b0:511:553a:a963 with SMTP id g24-20020a19e058000000b00511553aa963mr234884lfj.46.1707125678325; Mon, 05 Feb 2024 01:34:38 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXTHkt/qB5FXU75JA1jOYrtC+7TPevSXOu647eXrUYKxxCr1lss+Tz7tEhMBCZMheoh1VgOSfnyR48SNftUuoObspzJ4U6YMtYp8Xlb3zVzsG9ceD2B1fDwCNkhBNs90EAUoEYYyj37VzclnsG4bqiMp4TqH5FqU0KZSPiDxE3q0cc0AS5qC0/ngPCp9347dK/67/lxRHOpQ4o0GlswOOLW6i4C6JtMonyL3Hul7DOkyOAcLuUWL1/bO7YdHGkXgvG7Fdqz+uLjzXxdNxmp2ZoaR6KHVt9+ui/iE8+txviUdrNRZZ9Y7omDdq1voIY8Cx1KZt5G4MgWOEGv0+1CyYJOnwf1rha82Q== Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b0040fc771c864sm7980397wmg.14.2024.02.05.01.34.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 01:34:37 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Kent Gibson , Alex Elder , Geert Uytterhoeven , "Paul E . McKenney" , Andy Shevchenko , Wolfram Sang Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 14/23] gpio: cdev: replace gpiochip_get_desc() with gpio_device_get_desc() Date: Mon, 5 Feb 2024 10:34:09 +0100 Message-Id: <20240205093418.39755-15-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205093418.39755-1-brgl@bgdev.pl> References: <20240205093418.39755-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski gpio_device_get_desc() is the safer alternative to gpiochip_get_desc(). As we don't really need to dereference the chip pointer to retrieve the descriptors in character device code, let's use it. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib-cdev.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c index 3588aaf90e45..8e37e3befa08 100644 --- a/drivers/gpio/gpiolib-cdev.c +++ b/drivers/gpio/gpiolib-cdev.c @@ -332,7 +332,7 @@ static int linehandle_create(struct gpio_device *gdev, void __user *ip) /* Request each GPIO */ for (i = 0; i < handlereq.lines; i++) { u32 offset = handlereq.lineoffsets[i]; - struct gpio_desc *desc = gpiochip_get_desc(gdev->chip, offset); + struct gpio_desc *desc = gpio_device_get_desc(gdev, offset); if (IS_ERR(desc)) { ret = PTR_ERR(desc); @@ -1739,7 +1739,7 @@ static int linereq_create(struct gpio_device *gdev, void __user *ip) /* Request each GPIO */ for (i = 0; i < ulr.num_lines; i++) { u32 offset = ulr.offsets[i]; - struct gpio_desc *desc = gpiochip_get_desc(gdev->chip, offset); + struct gpio_desc *desc = gpio_device_get_desc(gdev, offset); if (IS_ERR(desc)) { ret = PTR_ERR(desc); @@ -2123,7 +2123,7 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) lflags = eventreq.handleflags; eflags = eventreq.eventflags; - desc = gpiochip_get_desc(gdev->chip, offset); + desc = gpio_device_get_desc(gdev, offset); if (IS_ERR(desc)) return PTR_ERR(desc); @@ -2419,7 +2419,7 @@ static int lineinfo_get_v1(struct gpio_chardev_data *cdev, void __user *ip, return -EFAULT; /* this doubles as a range check on line_offset */ - desc = gpiochip_get_desc(cdev->gdev->chip, lineinfo.line_offset); + desc = gpio_device_get_desc(cdev->gdev, lineinfo.line_offset); if (IS_ERR(desc)) return PTR_ERR(desc); @@ -2456,7 +2456,7 @@ static int lineinfo_get(struct gpio_chardev_data *cdev, void __user *ip, if (memchr_inv(lineinfo.padding, 0, sizeof(lineinfo.padding))) return -EINVAL; - desc = gpiochip_get_desc(cdev->gdev->chip, lineinfo.offset); + desc = gpio_device_get_desc(cdev->gdev, lineinfo.offset); if (IS_ERR(desc)) return PTR_ERR(desc); From patchwork Mon Feb 5 09:34:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 770172 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 DD36E17BA6 for ; Mon, 5 Feb 2024 09:34:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125683; cv=none; b=gIsaWPDg0+ZXjsvX9Qxt5ujDyNJvDR29AzjS2VO7oXIcbITHoRrX3TsC4m5GXFtB0vXMomuMtfhPjlXlFHFXtoIA0axrxahc0W7R5UD1j2qNGneXcOfzwVKBVuAypzaLiKM+TDn7ify03WYeGtXDqzAwC3omuYAjvQWyqEPPNqs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125683; c=relaxed/simple; bh=eyC1HYM9++8jEVAFNoIc4hkrxl4iukZ0gJFO/TcS1lM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dvK9b2CMupT8qLdyBPXl34Ganc+snDPnvdfdS1nmJobHs1QWHd5oHh6Q92dXN9MT9n3TkmqvATmUo5NUt6gxVrASlbPTbQSCwWISMlNRUxnK3E6VxQDaXt8Tk6q4cU5nM2nhkDsBO+qm9q59sOLibnZXYCStH+9RQsKe1Wj8+W4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=dWw4p9kU; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="dWw4p9kU" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-40fc654a56dso24711445e9.3 for ; Mon, 05 Feb 2024 01:34:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707125680; x=1707730480; 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=4fizk7gLi6MsEYz29o/FD8jywGHpms/n5O2KFkgE/SM=; b=dWw4p9kUydg9enHFOM/CVcIeJ9JZKRZI8F4CXx9Tu+UmvJIkt+3HRAVZyjR20U9q82 vUY+biHeILC5MEA6AiszZI9UYZu4zPsUNX37UB2yOssBYZi6s1EOQ0JbnnhnsgUzOZYU HHkFQsDad0FggEoUsOskGFVTcFNDB8zXIetWAZouUustteGCSUFoy3Dg/h3H96TZU3kS 4KgZeJLPs89LtA8nfEesb9CyPBW+cCmxSm/iyrLed3IxnmWhb6bBbfFttpC++Rd1tQJI QISmSimtjyHRcEIr2IPM2QhzaKbSqvWUJJdk42O790doGBYpWDU/en87UQk/P1I3+k2n Efag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707125680; x=1707730480; 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=4fizk7gLi6MsEYz29o/FD8jywGHpms/n5O2KFkgE/SM=; b=E52XmlBR6DnMK0BOoLlWAHziJ6PmX5MgFP1b61ZVKoDqepehppie5j02KahAQDJof3 NiSfKAJCvjM+P0jAun/azd7sqepImknMHp4GGd74nkHiFxvISR+eEAIPTJqGFYXNy93H xWa5ynR4MpuEkczXsCHL2Oz3p3/uKO4ff17/PjsIioW9Fz/sWjkAh5sKTFARSSqnZyYa WbN5x5fo5HHANu7V2qr+gqIY4mbD/bv1JSJmb+z+7oCZR6WV36hvDdbVm8ow+XI/4O1H 1l9n69lQp4BhCMqvBWEDY1jX2dSm2Ndag8vt9jjmoxXehnfBwQ6M1EYWOHfCgqfSUTFA UYzQ== X-Gm-Message-State: AOJu0YzNAiLdq5Il5JMlJ/MoTQOME9IpmuEreZqoL1okuJ7+jJ7sxL/R ReEbN6LWY/RWseqIPI0Bj7VZ756IiHu8ACaceRU49OVxR3YglK7Mjl16ji/rQL8= X-Google-Smtp-Source: AGHT+IHs8NsEz1j8efT31ngqMa1MhlmQPpIvYA/AUkpcjmbj0I9bIIh8/Kf/eWarc0dkyZLPNEzXWw== X-Received: by 2002:a05:600c:4e11:b0:40f:cb9d:bbea with SMTP id b17-20020a05600c4e1100b0040fcb9dbbeamr4038067wmq.0.1707125680144; Mon, 05 Feb 2024 01:34:40 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWBl3aOBWX59ah/FQPmhhvtdeqTvaVZ1j6HnJC4Kzm8kRil+MNUNO2s0OId3ecuwtYNrW+7WfwwrMoXstcfipbTh/MqkFaiCmePXRAX8x1QWvwgNHEPJC3JZvVnxdjP7xTaP45Dtc7SulEuda7FEDRL+b/VE8C9eUg9K7hXTSnJX864Q0/hMm2h5TQlII9ldj7hvZlDap/kw39/A7gkcU7LXRq3n9ZjtTWxkO9hIV81Q9hXw8lEm4XGJnKfQvvRmKdQGSD4LDpefXhYrcZLTCXtF8WxTHKhmg0/7J5FjozChL+1lhlvvBLaMSMpFAvGGSwpIs1+Q+r/LLHkwiOHKKVHNQcgjeN5oA== Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b0040fc771c864sm7980397wmg.14.2024.02.05.01.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 01:34:39 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Kent Gibson , Alex Elder , Geert Uytterhoeven , "Paul E . McKenney" , Andy Shevchenko , Wolfram Sang Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 16/23] gpio: don't dereference gdev->chip in gpiochip_setup_dev() Date: Mon, 5 Feb 2024 10:34:11 +0100 Message-Id: <20240205093418.39755-17-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205093418.39755-1-brgl@bgdev.pl> References: <20240205093418.39755-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski We don't need to dereference gdev->chip in gpiochip_setup_dev() as at the time it's called, the label in the associated struct gpio_device is already set. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index f77f919dbad9..f8d53ebbf25b 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -719,7 +719,7 @@ static int gpiochip_setup_dev(struct gpio_device *gdev) goto err_remove_device; dev_dbg(&gdev->dev, "registered GPIOs %d to %d on %s\n", gdev->base, - gdev->base + gdev->ngpio - 1, gdev->chip->label ? : "generic"); + gdev->base + gdev->ngpio - 1, gdev->label); return 0; From patchwork Mon Feb 5 09:34:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 770171 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 87D991863F for ; Mon, 5 Feb 2024 09:34:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125685; cv=none; b=hheS0kd0b6S59iuNEfVxnnA7agS7CIStTl1rJQEPr4V51k1z8RAo899HsWsCNt/shKWy9h77XgNHUbyV3Lb0qe1JWWy0eTwee8E7mZr4LFiFy5ogX89id6XJE4A93GTDOnsGjTjFbcN40kYEufA6sp93Y5breIG+MNrR7fcYIOI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125685; c=relaxed/simple; bh=pEGFI4FzSuM9h9FPQ1IrcofNm0GzKPkH6oHp6XPXvQE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AawZvSYMZstW6AeXS5GB8f8HReo21XU3U7bao9GUGs8URXU7mx594xGiuNQ7MmPeqciq8ZsE0Ivp/03prEY/6nmw1hhlGBV4MIwQA4D6QBZuBCSjM9BXYkpwoqKgyZxFRGFIKArUAXzKOdI6PVufz2wbH1MUY8BL58AE7h5lYqg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=yndcTLQ0; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="yndcTLQ0" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-40fc22f372cso31824025e9.1 for ; Mon, 05 Feb 2024 01:34:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707125682; x=1707730482; 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=ooFRRocehP/GMHGdd997Hq+dPT1Zk15K+dtqhfO9BRA=; b=yndcTLQ0J+XMpWeWrTV69r+9Jv7+XpYXtiJ+SizmO2PPad0aPD8ZHtd+SanHbaquam fW+EhxZHfBFO9+guedt4pzkoiDJXzOdPlC6Jz1xKRV7MdX7XrYbcNWwwuRKqD3jbGZHn WN4mnGLU4Fc7XqGucb/QtVpnghKEQ5oTb46cvharxyDZaBQpt+maLDSsl8CTDTeVvfxQ YmIEAHFvKvsFvjJWbCwUJqGSS+Tc6WZ/vug0+IFOB/XAT5MNFUgKRURMEN8acDiTCdLB oOcifWTRzVANKBC78/KfXIo0ehGvrapQzeRrG0ACHu0B3qEW1o+GjsguR37W23D+OdHP T4aA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707125682; x=1707730482; 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=ooFRRocehP/GMHGdd997Hq+dPT1Zk15K+dtqhfO9BRA=; b=LmAbZ+fon9BUC9YNmOCxeR6c6XuHHqdnWsKaQe27Q7AXSYS23X6k1PFoNAwmi86M5B 5MlAuOVmHFi8dWX5GpdiNIz+xl/ILnxezSAj7jsD220PdNVJ7vqI6MW2lsNNlGvRoV6+ EP1BW2nDTNEW6L6aw1G7BXGZx6OoL44Y+BGEJrIqgUkeirGNL28dHYNcy7gvDZGztx+J 0CnbfFsEH//XqimXKv6ttufphhUgXl+ePrhyXCOt8lIvERoMdfUouwy1C+vSE4Z/lxoG 6qlGZifRdbKwQ6CKhvWKGOqWQCmNN150tEQDXK6wyPQSoVvq7ocwu7VdFk2G98xH6tKr R76g== X-Gm-Message-State: AOJu0YzvYE19b4ya5JJCwF3XikxY4DU9gz8I7EMxrBVI6QD8xQsK0KTG bB0BZj6ie0tBXaChJJPCDs2WvEklYjKl5IUwjIY0rDGe2MLMM6IHpN37ScCp7tw= X-Google-Smtp-Source: AGHT+IFhcLgkx8KHMiKDvuZqNmGC8eNgjwJXoKIcgWEf6Qq0l9U2BDTDNM+uWBEonFwKj2EUg30Mww== X-Received: by 2002:a05:600c:468a:b0:40f:d738:c213 with SMTP id p10-20020a05600c468a00b0040fd738c213mr2655782wmo.29.1707125681808; Mon, 05 Feb 2024 01:34:41 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVeChOtUDPQKIzjVR3gHFJwm13T5fUfp2EvjfPDa0WJAsGA4ulrpHbHNP3ClsXHPf9p/pjCSdJ9BDfYItHn2ag2YYMH9PdOge/KVOSeui5uWnZJwmduSIulnijzimN6uT1BuwnUCCMSQ/y2CoqN8mmCLI/u0lYAG07zbiYh3EDl/Nz8fOgfDfN89X8ZFGEaX/ykGrIPR2ZBNuQet0yxFq0v+ZJdcSitIRDGmnT2yY7htzxh7T+Yd3N1lFAgjziOo6pBuIkRaVDvaOsoiajQziNN5oSlXXaTn7uqCVCvDm3OXQY51irCEEPyXNBzaaKja7uiftMiFshUuLfqmzXsuoQB4/bd8f8TDg== Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b0040fc771c864sm7980397wmg.14.2024.02.05.01.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 01:34:41 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Kent Gibson , Alex Elder , Geert Uytterhoeven , "Paul E . McKenney" , Andy Shevchenko , Wolfram Sang Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 18/23] gpio: remove unnecessary checks from gpiod_to_chip() Date: Mon, 5 Feb 2024 10:34:13 +0100 Message-Id: <20240205093418.39755-19-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205093418.39755-1-brgl@bgdev.pl> References: <20240205093418.39755-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski We don't need to check the gdev pointer in struct gpio_desc - it's always assigned and never cleared. It's also pointless to check gdev->chip before we actually serialize access to it. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 7d897c807e95..95b480f01fca 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -214,7 +214,7 @@ EXPORT_SYMBOL_GPL(desc_to_gpio); */ struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc) { - if (!desc || !desc->gdev) + if (!desc) return NULL; return desc->gdev->chip; } @@ -3499,7 +3499,7 @@ int gpiod_to_irq(const struct gpio_desc *desc) * requires this function to not return zero on an invalid descriptor * but rather a negative error number. */ - if (!desc || IS_ERR(desc) || !desc->gdev || !desc->gdev->chip) + if (!desc || IS_ERR(desc)) return -EINVAL; gc = desc->gdev->chip; From patchwork Mon Feb 5 09:34:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 770170 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 878A219BA6 for ; Mon, 5 Feb 2024 09:34:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125687; cv=none; b=C3yZOGgV6ZWBg8fJ0DRwN8iOQodU9YbDcNsXk7TDvIL8bPYQidHLV+CuFuMlwXS6Z5Myab2wpbnb9bDKy1nODDDMNvhONxbjkxsrp36CpjLRdORgYagoaYpQXj0+J/+9AREyQaALMR4oRDd/dl2jItHx2IewI687CyhUPNAIwYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125687; c=relaxed/simple; bh=7mJd5R2FfiEUg4aI1+D/j4yKbEfikBS+gEjl/iwhNCA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DJ+qBSU2M0uZZxrO1XGYbgapscZKtds2BDTMhEU1QMyQcowLxrSbkHdAzy/g6K37UWRaOnufoLj0yrvyhmqL0Bb/ZyR4/oa26cKadxty9vAmjpgTrN5bSxVMowP7FyF4Zj4AOnBSNM+6vJxPzwKvDcflIjHHnlB4enShSbRdG7g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=EFOnRDkp; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="EFOnRDkp" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-51147d0abd1so1370896e87.1 for ; Mon, 05 Feb 2024 01:34:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707125683; x=1707730483; 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=EfCUtQSab/f+GEUcOlTEQIAjO6ADTWtbYYTnCznFDE8=; b=EFOnRDkp0AzyqNzWQHSJTgd0l2m0EZwSGebIvXeU0SQS/fsB0MV3tv1XH7eZbmeT1S 6G6WUJKUmjUwfNh5E6uyZVnpbsg8mSomtUUZNMfjD4CZtZmgFhmIy/ZZV04KjYxDEfrJ v/VKFv3wpZIUAhxyILlfiayI2Kj3/xSkBvQ2u976iThf7XEsgNyQL2H82hGW5RAAccui IwkcqBsBWDyU4Iwftqb77vvNB/qg7qF+Tud8OTunSamKhNKSZI+KKNeHBpgHNf0FDOwI SeTFxuLW9IMMjrHzEdZfZc+wVM3wQYm7iU57gDaNGhZ3KULvhN7WELTX9GJL4gUpInud 1VuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707125683; x=1707730483; 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=EfCUtQSab/f+GEUcOlTEQIAjO6ADTWtbYYTnCznFDE8=; b=fzfUzLccHU/FtJOju8MGThukvKD2sXSiiejfeU5EvnZvT5I1Sv50lHeVnBk6cP7+Bu ozqD/8x5g1YlBjiajX8ExP5WT0D3piSkQedLdgLi9bMTsYOLu73fUKsOGPBQXn4cU/hW PSa8QPgmaunwC382mamY1pfMm2KpZPxf8XfX89YlrCjMCzBEGd+yXMNidnOTUWdeIcNZ zzDGPkT4uZvpymZhd/VfUJkDvce3Uga43xYD0Ysx42f+373nvE514YzVSjn5T/uSSKl7 EYhqWu0orOE0s6XzjgGsNiR/L3bNqu/Z22V9Wo6XkVf+SQPBWJmi7FP2K6K1g/fmkDYH Zzjg== X-Gm-Message-State: AOJu0YxoF8SXaW6oiRyDOQdC70lNZGSe/GQMb/8zu6nnfCl6t8Rce+ub DUmkgeER1HwB9uAyUrmmM+7F/y6RZj9Q7DWEwHiICJssSu7CFBgGmEhveRZ4+/A= X-Google-Smtp-Source: AGHT+IGbzkspZ2OxUbf5+9mtQYHG+0DglASi8UuDhWIORLHqIuJm4X1N/9W/AZO7TglbOMxo/nZ8Cw== X-Received: by 2002:a05:6512:3b27:b0:511:2e7c:768f with SMTP id f39-20020a0565123b2700b005112e7c768fmr9577478lfv.46.1707125683608; Mon, 05 Feb 2024 01:34:43 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCU40ycQ2gHSQqNLzlj+wixA3sX46WZJeEInwacBub0YUBh0qHj392LloTrzZIyWuLx667WiMDnJRNeTuP623WmzduvSr04AQZqLrZCkoB3AX5UAloP49CHvarI5HWcXvoYbWXPj2xIYdLPIekKoHs411woSyIg0B5WWKqO2OrmkRScRLnjkDBKJYdBINEhy/jf8QFsFWsRw7RLcMPM2b99dUjtU3zLHxrC8OuRF1lSEREI5QLQnG3GJvSL6luR99Thwo11m/SbBCroaL+2LXs0eyNNwi4BH9alZYSA5kVsQ8zP7TEfm/gebww/JNVS7pkxOHYyrOWHqIjyfpqzrXsRKute8BGH/Eg== Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b0040fc771c864sm7980397wmg.14.2024.02.05.01.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 01:34:43 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Kent Gibson , Alex Elder , Geert Uytterhoeven , "Paul E . McKenney" , Andy Shevchenko , Wolfram Sang Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 20/23] gpio: add SRCU infrastructure to struct gpio_device Date: Mon, 5 Feb 2024 10:34:15 +0100 Message-Id: <20240205093418.39755-21-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205093418.39755-1-brgl@bgdev.pl> References: <20240205093418.39755-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski Add the SRCU struct to GPIO device. It will be used to serialize access to the GPIO chip pointer. Initialize and clean it up where applicable. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 13 ++++++++++--- drivers/gpio/gpiolib.h | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 2f78fa9f8dbf..c49d7a156bdd 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -680,6 +680,7 @@ static void gpiodev_release(struct device *dev) ida_free(&gpio_ida, gdev->id); kfree_const(gdev->label); kfree(gdev->descs); + cleanup_srcu_struct(&gdev->srcu); kfree(gdev); } @@ -943,6 +944,10 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, BLOCKING_INIT_NOTIFIER_HEAD(&gdev->device_notifier); init_rwsem(&gdev->sem); + ret = init_srcu_struct(&gdev->srcu); + if (ret) + goto err_remove_from_list; + #ifdef CONFIG_PINCTRL INIT_LIST_HEAD(&gdev->pin_ranges); #endif @@ -950,15 +955,15 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, if (gc->names) { ret = gpiochip_set_desc_names(gc); if (ret) - goto err_remove_from_list; + goto err_cleanup_gdev_srcu; } ret = gpiochip_set_names(gc); if (ret) - goto err_remove_from_list; + goto err_cleanup_gdev_srcu; ret = gpiochip_init_valid_mask(gc); if (ret) - goto err_remove_from_list; + goto err_cleanup_gdev_srcu; ret = of_gpiochip_add(gc); if (ret) @@ -1038,6 +1043,8 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data, gpio_device_put(gdev); goto err_print_message; } +err_cleanup_gdev_srcu: + cleanup_srcu_struct(&gdev->srcu); err_remove_from_list: scoped_guard(mutex, &gpio_devices_lock) list_del_rcu(&gdev->list); diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 43ff4931e2c3..35d71e30c546 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -49,6 +49,7 @@ * @sem: protects the structure from a NULL-pointer dereference of @chip by * user-space operations when the device gets unregistered during * a hot-unplug event + * @srcu: protects the pointer to the underlying GPIO chip * @pin_ranges: range of pins served by the GPIO driver * * This state container holds most of the runtime variable data @@ -73,6 +74,7 @@ struct gpio_device { struct blocking_notifier_head line_state_notifier; struct blocking_notifier_head device_notifier; struct rw_semaphore sem; + struct srcu_struct srcu; #ifdef CONFIG_PINCTRL /* From patchwork Mon Feb 5 09:34:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 770169 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 2EEB01B944 for ; Mon, 5 Feb 2024 09:34:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125690; cv=none; b=JoUWhdi7qIXKSESM6GcLyFPGhySeyDZY/SzB7nLUz57GAPx9fVXNHagA8k7+MNAG4iY4+FSFxarSfjUHfDCrGS31NqwXDqzxh9facBC5ZDksExG9kIEWhyPu5frIQge4vXNGLVjZWc/6332pEspL+70lYfyj6PG2iW1d7rW1i20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707125690; c=relaxed/simple; bh=CiYSawPebEql0iEz39lQ3pUTtJzpFVAjWsd3kTouEKs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YyB9bDhbQBzHPPJk/OAjHqXM4R/8zQiqrZjn0Xg/d7gdtgBzJR/EExYV7W8CR558TddxsmJGyundhQnAabNSrMpgfRR5Eyks/o6OgItpMyhSg3CgTIkXjeyKZJfDBuBLjj6aPnT8wxlPkA6m6YJ7fe9eqxpIlBpBYQ/PbmxL7Jg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl; spf=none smtp.mailfrom=bgdev.pl; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b=lHv8qbOz; arc=none smtp.client-ip=209.85.167.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bgdev.pl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20230601.gappssmtp.com header.i=@bgdev-pl.20230601.gappssmtp.com header.b="lHv8qbOz" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-5112d5ab492so5538738e87.0 for ; Mon, 05 Feb 2024 01:34:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1707125686; x=1707730486; 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=IuD4jOVymyzS+IMUJo9eXlxxJz0pfH/DcmsAoXHdB48=; b=lHv8qbOzq2mTAPK7Kz9abzgZmMscc7YNlJf/fLpSSC3dCYHpTBuHtWRdKb3BkB2D7m rScQwt6Q+U1MPsQaLb7/XmBesEJy/c185vg42b9CWPdPys/n+UyRai1pMHAS1lLKvHYx Xoht/0vox05N192vamLBMsNICfFYJT/UpUSZY3aYWmrxpAFu0sg1h1Q0UEiJbhhAesz+ oyqdMQY371RSC2mg5nEaHFncFJ3bmHM6JRcAlGPUxaDpiKIcsHUa4hou/4wPnM/CxlAq yM9sN4dJft4ZUHRtyoRA9fglh7tBTIi7Ywaz6N+l8hQO6ZzRA2HM2qvM1VV43ZCifSIB qBsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707125686; x=1707730486; 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=IuD4jOVymyzS+IMUJo9eXlxxJz0pfH/DcmsAoXHdB48=; b=unAm+zYrRUVprOXXYlpI/aTGVI7//TGSBT9cZ1bCZpsjobx0/Br308k6sE1359bTa5 i4NJAQLseMpwW+P4FHSFoOJLZSB0k3dKDxq6cLvi4p4XL8rJKF2dg2kY8qHswQcf28HT h3gqG23cH97cqBsnHogB+XBB/e5MShYkY3YiP4T8MNKHws+6nTcNehBvLc+ARNo0a9v+ UKo51CgTAzpBCG0v0zf47zmANaIGJABX9nUrLAr1KmC7k1oVnaHn9EBpo/x9TL/mrIHx gvDgJv93f/jVfb+7Ko/HPZtlKwm4AgHjSZWCW9Zt7DJe5DE8aN3g4Dm0Cp6vakXGBLKl 223A== X-Gm-Message-State: AOJu0YzLqkYOWX7X+cEVZOhiuriV5PA9XF7y6IOkBZvoBNC8QrKbjvVO 5FGuuq912PUqB1VOpGykhz2Ioej1AeOdx5YHtRlWUHBD4pfoT8K5QI6n5TWTR1Q= X-Google-Smtp-Source: AGHT+IEPB2Je0SCogU+2gBiEiwjBglfb7KBSZJDiXKT4w6QPedNh07U5ZXtAspIFMe6Orcy3j89JkQ== X-Received: by 2002:a05:6512:220b:b0:511:4df9:1949 with SMTP id h11-20020a056512220b00b005114df91949mr2488688lfu.41.1707125686310; Mon, 05 Feb 2024 01:34:46 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWTnt8FacEOq6jarDsKcu1MJgylOwFHQHyWfITCiQqSjZiNyiEEjTGyq/NHvbkGJ3OF/qrhyzqtMkON24A487SywNaoeMRpos6ffiHwIOw1HDtvNu1tmdtUS9SZP4piE/w0mjapU5+tBc84QAizizuLfpQb53U1YBDSpAMVbRWEbZYr99rZSCsyrh0LGbWsKTN1oEOTuEe4fYLSuz29qg1BwcmZ6zv4xAXNq3ozMHNuj7Tw+bgNrvAa6At858h1RHQC9d1ymtd2hS0xMWg943JNQSS6jdHVJMB8vQm/xfRvMmZMyb3Lejqwb373HK7T99A3s3nlDyg7gNIxr5oVJcchmSTrWDWAiw== Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:d929:10db:5b5c:b49d]) by smtp.gmail.com with ESMTPSA id f15-20020a05600c154f00b0040fc771c864sm7980397wmg.14.2024.02.05.01.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 01:34:45 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Kent Gibson , Alex Elder , Geert Uytterhoeven , "Paul E . McKenney" , Andy Shevchenko , Wolfram Sang Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 23/23] gpio: mark unsafe gpio_chip manipulators as deprecated Date: Mon, 5 Feb 2024 10:34:18 +0100 Message-Id: <20240205093418.39755-24-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240205093418.39755-1-brgl@bgdev.pl> References: <20240205093418.39755-1-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Bartosz Golaszewski We still have some functions that return the address of the GPIO chip associated with the GPIO device. This is dangerous and the users should find a better solution. Let's add appropriate comments to the kernel docs. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij --- drivers/gpio/gpiolib.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index c7b039398e0d..dc00eeed6253 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -211,6 +211,11 @@ EXPORT_SYMBOL_GPL(desc_to_gpio); /** * gpiod_to_chip - Return the GPIO chip to which a GPIO descriptor belongs * @desc: descriptor to return the chip of + * + * *DEPRECATED* + * This function is unsafe and should not be used. Using the chip address + * without taking the SRCU read lock may result in dereferencing a dangling + * pointer. */ struct gpio_chip *gpiod_to_chip(const struct gpio_desc *desc) { @@ -275,6 +280,7 @@ EXPORT_SYMBOL(gpio_device_get_label); * Returns: * Address of the GPIO chip backing this device. * + * *DEPRECATED* * Until we can get rid of all non-driver users of struct gpio_chip, we must * provide a way of retrieving the pointer to it from struct gpio_device. This * is *NOT* safe as the GPIO API is considered to be hot-unpluggable and the