From patchwork Mon Dec 4 09:35:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 173160 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2647627vqy; Mon, 4 Dec 2023 01:36:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtTbvCUHSj6LIwWTBG/d5B4qrH2RfClPbS1y0tuAVIKPv6zk4JrMhbM+9RVqSoy9DRUq3O X-Received: by 2002:a05:6a00:98d:b0:6cd:fd83:7a1d with SMTP id u13-20020a056a00098d00b006cdfd837a1dmr1758465pfg.8.1701682585067; Mon, 04 Dec 2023 01:36:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701682585; cv=none; d=google.com; s=arc-20160816; b=peRzbMPRdeDoszP9Yg3hxuIa18sDRy+gKlTwxr0slZDNxXhTmg8Sr5ivBY3+ko/VXU mLmiZKvekgrAWUvEPYgBb2iFSj5k8WJuw5TmDmHDMmMSfEocR99VbF2r0DQWo9/RH8am ZbGMMQFwOJvpdgLY0fAInFwytWvtIQKv5wmbGBTtEEARi9lDVvElZtZJZGU4DCV79At3 7Cn6yz9CxxCHZiE8Qb6FQOuaJNjzrstg5/93Q0U2oCx6YqFsqK1SFajho9RuiKX/+STk inUYM93J2T/8EHCkiTDrPs/VVGNO2wMb1dBAVDWhM9V0pQ5SKzia3+QeKw2U9IXAFqAl Uzag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qUM8/16TtFRuJWbQL1BXzPDgwc0PUnSgAFPYdXYTVlM=; fh=fw6biwzn34ngIUS3OuPB+D+TvAzoz1YwnvitHxA+Jyw=; b=Ztgq2y+LgwQbtIMPRIpgD/eXS/Jq4asFjjImiOhmiLSK0rbFoIZkSpGGflLPqLpn9Q 5r8To2kDkYtanCOlXIGi2ptsOibefSDVCArRp7mPbs8y4Fq6bSGadRi2Nyk/PFe37iVz 0tpDKZPGGdnP1586BzBM8r6evMS6G+hF0jaJohmBexkbWdYMM5NBLd9+NzE36SL4VOTD P3HgJp4B8DKSkxGw3/rgPMnFp7cUkYUTP8rFOSTmVWekdNuuP1D7PNmtdhW55JCep8gf KTIWwPuQY64bVphO2fYjmsRIslcahHN8OrE9SJ+R+35BrTUnwHoTo2kPo5qWek5XbxZ7 hewQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=FyFfMo7H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id j9-20020a63ec09000000b005c6075f8a31si2318049pgh.153.2023.12.04.01.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:36:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=FyFfMo7H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 278668092151; Mon, 4 Dec 2023 01:36:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235313AbjLDJgM (ORCPT + 99 others); Mon, 4 Dec 2023 04:36:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235320AbjLDJfa (ORCPT ); Mon, 4 Dec 2023 04:35:30 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DC8C1A2 for ; Mon, 4 Dec 2023 01:35:25 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-40c09d62b70so11320875e9.1 for ; Mon, 04 Dec 2023 01:35:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701682524; x=1702287324; 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=qUM8/16TtFRuJWbQL1BXzPDgwc0PUnSgAFPYdXYTVlM=; b=FyFfMo7HI5+vw6MJIdRERUca43k5eYUzMMRtv3IJ4beevHXsYl/Xqdzg+hFR2UxqBz J/n61hAUMqRf/v4cT72e4fM4bYXXHmX1Emqunn7A4SYznehtvhhZifQbpDzZ3OYZ3gqh M+pN5bAFFzndXW333+WVRjNvFCj8dfEQyaatai5GicMThDfA5d/4qYwoCQ0MC51g2Rak 361wrFDOO3UjsYgg5K6dxfCP/hgque6u3vESzRJ80KJ6KkaEZ6TRG2CR/MG1LnEjQw1K KKem0GS4J2JuMCcMxnrrKcjReFVwcqyQ4KEKAxMaQyiKIvx6ebYrGGxpagOWbwGeq2wa 1YzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701682524; x=1702287324; 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=qUM8/16TtFRuJWbQL1BXzPDgwc0PUnSgAFPYdXYTVlM=; b=IyHVFfH5KzrVOu/4nCHBlOK/MtjP8PYtwIgBFKUn+BWtDbMI/jX4S7+8RANJe3VmO/ AL4cvAw4abhR3DzUL9kr9R6OFfH4HNJa+qDKhYjrX8jkjQayC//Ub2ctzO60aYaFGDux T1u1OrXkvnP2dRaknnqubfviSuP3gQ+C48q1MiloiV498se+dkNlp0oHopi+4acUT3Np /FnZ1W1vCL4fIH4rPoX/0lqtLtrgIVx9aAWUlRl7CxRInxNC7C0KgLfDt9riBAKrk+GK L5jC0M8d040MMB2BJFrle7DCspT5sG3raF/OOIuZue6WePN1fux75xOqF3tDu6GbS9/C e7jw== X-Gm-Message-State: AOJu0Yy9XL+f4giF/gNbTH+iooSUkc3yMwtRVKFwWObegVdhH2+aPLYJ aNZ0Q1uqRvDlo/KgUm9+ZQZzmg== X-Received: by 2002:a05:600c:364d:b0:40b:5e21:c5c7 with SMTP id y13-20020a05600c364d00b0040b5e21c5c7mr1679318wmq.149.1701682523813; Mon, 04 Dec 2023 01:35:23 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4cb1:229e:8c33:122a]) by smtp.gmail.com with ESMTPSA id fs16-20020a05600c3f9000b0040b48690c49sm14266219wmb.6.2023.12.04.01.35.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:35:23 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 10/10] gpiolib: remove gpiochip_is_requested() Date: Mon, 4 Dec 2023 10:35:09 +0100 Message-Id: <20231204093509.19225-11-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231204093509.19225-1-brgl@bgdev.pl> References: <20231204093509.19225-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 04 Dec 2023 01:36:22 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784343518126755424 X-GMAIL-MSGID: 1784343518126755424 From: Bartosz Golaszewski We have no external users of gpiochip_is_requested(). Let's remove it and replace its internal calls with direct testing of the REQUESTED flag. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpiolib.c | 48 ++++++++++--------------------------- include/linux/gpio/driver.h | 1 - 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index d4b33782cc10..4e190be75dc2 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1085,7 +1085,7 @@ void gpiochip_remove(struct gpio_chip *gc) spin_lock_irqsave(&gpio_lock, flags); for (i = 0; i < gdev->ngpio; i++) { - if (gpiochip_is_requested(gc, i)) + if (test_bit(FLAG_REQUESTED, &gdev->descs[i].flags)) break; } spin_unlock_irqrestore(&gpio_lock, flags); @@ -2373,33 +2373,6 @@ void gpiod_free(struct gpio_desc *desc) gpio_device_put(desc->gdev); } -/** - * gpiochip_is_requested - return string iff signal was requested - * @gc: controller managing the signal - * @offset: of signal within controller's 0..(ngpio - 1) range - * - * Returns NULL if the GPIO is not currently requested, else a string. - * The string returned is the label passed to gpio_request(); if none has been - * passed it is a meaningless, non-NULL constant. - * - * This function is for use by GPIO controller drivers. The label can - * help with diagnostics, and knowing that the signal is used as a GPIO - * can help avoid accidentally multiplexing it to another controller. - */ -const char *gpiochip_is_requested(struct gpio_chip *gc, unsigned int offset) -{ - struct gpio_desc *desc; - - desc = gpiochip_get_desc(gc, offset); - if (IS_ERR(desc)) - return NULL; - - if (test_bit(FLAG_REQUESTED, &desc->flags) == 0) - return NULL; - return desc->label; -} -EXPORT_SYMBOL_GPL(gpiochip_is_requested); - /** * gpiochip_dup_line_label - Get a copy of the consumer label. * @gc: GPIO chip controlling this line. @@ -2414,18 +2387,23 @@ EXPORT_SYMBOL_GPL(gpiochip_is_requested); */ char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset) { - const char *label; - char *copy; + struct gpio_desc *desc; + char *label; - label = gpiochip_is_requested(gc, offset); - if (!label) + desc = gpiochip_get_desc(gc, offset); + if (IS_ERR(desc)) return NULL; - copy = kstrdup(label, GFP_KERNEL); - if (!copy) + guard(spinlock_irqsave)(&gpio_lock); + + if (!test_bit(FLAG_REQUESTED, &desc->flags)) + return NULL; + + label = kstrdup(desc->label, GFP_KERNEL); + if (!label) return ERR_PTR(-ENOMEM); - return copy; + return label; } EXPORT_SYMBOL_GPL(gpiochip_dup_line_label); diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 910fc50d3ab5..bd9bea7cb270 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -531,7 +531,6 @@ struct gpio_chip { #endif /* CONFIG_OF_GPIO */ }; -const char *gpiochip_is_requested(struct gpio_chip *gc, unsigned int offset); char *gpiochip_dup_line_label(struct gpio_chip *gc, unsigned int offset);