Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp681711lqp; Wed, 12 Jun 2024 12:57:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW3z5fKTvF667yX2wuzVWNH2Mg3Cd48oQL9sZClj0Cge85JvMM5rXlhpoeXcvoAmhp8lWeRnLG7Z/zrcfROWu0ff5i5RzENtVdMnkbQmA== X-Google-Smtp-Source: AGHT+IHN0ytb3X0R7DGku7pfw3Y2JA+2Sbuvryvrku6b7k6y2hVzmC/DLpe+jLizOcN6PGGiFjSc X-Received: by 2002:a17:90a:c084:b0:2c2:f2d6:60d4 with SMTP id 98e67ed59e1d1-2c4a761b86emr3063375a91.8.1718222223481; Wed, 12 Jun 2024 12:57:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718222223; cv=pass; d=google.com; s=arc-20160816; b=aSO1u/i+5S6vTIxgFcT6QX0DGxzEK4/CcvCzc76YaVsHc3Pp8Z9/DJ7tuTu6TMR1cK yEJ4YICDajQ4a6efG+5k+DIqwRfXDe/5a6IStrEN6ZFIg6pWwI2+WbNmknpxTn+man0o NP/Ve7vFA86z2nXz0Zvv4zvUe4g0iWataDwyddi6qJ30Aqk/3f6/sDtDBnpnbizW7OfO ky9WyecqjIe0aAWWbHavCnRp+CF++/atNLXT+kUqFhCjjdbhH1eDDIplZeTsceWQxIg2 PYvNBD5Ae2ASsgxlqOAFT5z4vLWw3J7n2a6Mln+HsShpxld541HEZ9Ucuztz3di9rwVk qsng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Cmew680A86e6P0TJ/CSWiTzW4h4Q5bXUMWdZRLFG580=; fh=MldfIKyToKj07WRlPl5j8hA8s3zBNTAo5dk1hozcgc8=; b=OtGPISztusGCumzYn8FIRGNhVzss9K63rGFUzDwwKRu3Io3N6bienB219Y4/Oo6uAM 5FqofYT+2pvGOaurAr9stt6EnlTNl4qsNo5dn0EXZOCod32eC95ufRY37NHfw8Yn9kyy axRVvlwUb0sO16I6XxSKfYaS22Yd0zAYfJLpZv0yDRzvIlmIPom+dzOUetsWd+KwAuAT VXxHTyVSrDOIrXdMvSxVfgIuy34p6Oaw6jxPjXhwoPj8IjeAZi9B3ggn8JSBhZi5vEGG iQpv+J1iML96OC82S/Jufti7G8Pb6Nmt7nbMQ6E3js8+sx6hNdPQ3CaXc6xVTu1ELfoT jspA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=KaAWPsH0; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-212117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212117-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c4a75fc6ecsi2223567a91.52.2024.06.12.12.57.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 12:57:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=KaAWPsH0; arc=pass (i=1 dkim=pass dkdomain=bgdev-pl.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-212117-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212117-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 95871B229E1 for ; Wed, 12 Jun 2024 18:48:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE4904F8A0; Wed, 12 Jun 2024 18:48:38 +0000 (UTC) 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="KaAWPsH0" Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 585DA2F3B for ; Wed, 12 Jun 2024 18:48:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718218117; cv=none; b=oN7h0FWoZdLW9z/JX2tqZNLauhrIA10d3HJVFR6ZJgeNewF4ngkJk/cgcbyjO0tSCwy9zymE/l2NyvlSkXEm+CQhEf5+xQ5YLN3yT6HHRGFe9dpVhS+gIQ5uJxZZigGQmY5AYX6u6AEwqHe+4u9lNsJG0m9L2eCgmx06ujdznkU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718218117; c=relaxed/simple; bh=zzetqvw9rE3z6luIaQuIn5l8rk0hobL8f1wgIozEpBk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=B0D51aP5RGgbHhMrSJFuaB19LfqJKrDU7YqXd0u8a9bwA1THPr5xkcS/JXr8HmsZ95qckz6cE8EgPet+iHRdvA5QjfCeTZ50GBAADIENvlWTqdILvZ4coR3QtZg7XAUirOTZJ2Gh0KrsOVlxxZMrkobuXAKvXXII22PLbFmKYk0= 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=KaAWPsH0; arc=none smtp.client-ip=209.85.128.52 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 Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-42108856c33so8398165e9.1 for ; Wed, 12 Jun 2024 11:48:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1718218112; x=1718822912; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Cmew680A86e6P0TJ/CSWiTzW4h4Q5bXUMWdZRLFG580=; b=KaAWPsH0iWi05MR3CjibinOnyUfKs6Vrjk5z1YFfhxvwb4xtWBQvS8mgsDpFbekVuZ VVrEqT456Ak+f14gxTiYuTHpVVoyqkPUzJ5o9b8Snot4o3ExzEOaGq7DAC+a/DzZMu3C yWjBZmYlHa0zo6d6nXxA/HP0Q3udWAFi8baG+z45q2782bletBp/HuBzgQDlSlU6N4no RE8ihe6S4vVLxO4lfCjjQwRHaAcgdxQU7dN7jkGWLI+c/Zuz+ugpsT7Vgo98RB2G4SER xFyOS81/IFleLfNRTnVTvMYgOVs+IgmckIZjRp39l+18sNi0gDkEeKzD7WcVVUQYcF0I Y6qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718218112; x=1718822912; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Cmew680A86e6P0TJ/CSWiTzW4h4Q5bXUMWdZRLFG580=; b=NDqROR2fg6f42X0IeqS/KRQj5nO1fwsRbrGsSLtwwY2a1AJ53uxtIiY8iHt0/tDH2m PiDrD9SpJrMVOdNzG0JppouLlB/gTMP1EGRTnUvDWnwQVzAT29y8IY5TMhewsUy2CE1H SPKc3MZXU+Kiizeb+iTpMW4CdTPReWEYPFu+JAtoa6oJUinxdY18m7C6372sstQ5tmT3 lwAtz1QfTGklHOyFWu44eOxo3cF2tB8frVJ4xvfvS+X4fUBdpN4jM2QWD7yhpjiXZv9h lXNkn/TWO86A2cvfIqF2TIkYfrRYXBma9t3q8bpsrJWctguer9xSJqqnd26C/knjJTsE 8wOg== X-Forwarded-Encrypted: i=1; AJvYcCWragwqvs0CWpsmDL2NtXQGO282f8EgRcbHFYWtQYMV+l2SSULgOmLfEa+zmlvo/IBczP4h0ZVHZI7WJlhRvj1lM+Y2yELVZ7xz63PW X-Gm-Message-State: AOJu0YychzhmfkmoLtF9wl23JNf5UMQVa6/yQGCXwJJh9zO2kg8HpVNB 7831ekFusHodIDf3zF41VqWMWX8ScmHgV1U9RI4UFfpoeIBHrOpjBGJNo3JkCV8= X-Received: by 2002:adf:e646:0:b0:35f:e890:fbe1 with SMTP id ffacd0b85a97d-360718df02amr480736f8f.19.1718218111541; Wed, 12 Jun 2024 11:48:31 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:8d3:3800:a172:4e8b:453e:2f03]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35ef5fc1c77sm17147058f8f.95.2024.06.12.11.48.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 11:48:30 -0700 (PDT) From: Bartosz Golaszewski To: Mika Westerberg , Andy Shevchenko , Linus Walleij Cc: linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH] gpiolib: put gpio_suffixes in a single compilation unit Date: Wed, 12 Jun 2024 20:48:21 +0200 Message-ID: <20240612184821.58053-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Bartosz Golaszewski The gpio_suffixes array is defined in the gpiolib.h header. This means the array is stored in .rodata of every compilation unit that includes it. Put the definition for the array in gpiolib.c and export just the symbol in the header. We need the size of the array so expose it too. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpiolib-acpi.c | 4 ++-- drivers/gpio/gpiolib-of.c | 4 ++-- drivers/gpio/gpiolib.c | 4 ++++ drivers/gpio/gpiolib.h | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index bb063b81cee6..69cd2be9c7f3 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -976,7 +976,7 @@ __acpi_find_gpio(struct fwnode_handle *fwnode, const char *con_id, unsigned int int i; /* Try first from _DSD */ - for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { + for (i = 0; i < gpio_suffix_count; i++) { if (con_id) { snprintf(propname, sizeof(propname), "%s-%s", con_id, gpio_suffixes[i]); @@ -1453,7 +1453,7 @@ int acpi_gpio_count(const struct fwnode_handle *fwnode, const char *con_id) unsigned int i; /* Try first from _DSD */ - for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { + for (i = 0; i < gpio_suffix_count; i++) { if (con_id) snprintf(propname, sizeof(propname), "%s-%s", con_id, gpio_suffixes[i]); diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index d75f6ee37028..49d533df2cd9 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -103,7 +103,7 @@ int of_gpio_count(const struct fwnode_handle *fwnode, const char *con_id) if (ret > 0) return ret; - for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { + for (i = 0; i < gpio_suffix_count; i++) { if (con_id) snprintf(propname, sizeof(propname), "%s-%s", con_id, gpio_suffixes[i]); @@ -676,7 +676,7 @@ struct gpio_desc *of_find_gpio(struct device_node *np, const char *con_id, unsigned int i; /* Try GPIO property "foo-gpios" and "foo-gpio" */ - for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) { + for (i = 0; i < gpio_suffix_count; i++) { if (con_id) snprintf(prop_name, sizeof(prop_name), "%s-%s", con_id, gpio_suffixes[i]); diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 0ec82ac7f0f4..ed620442f32c 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 #include +#include #include #include #include @@ -89,6 +90,9 @@ DEFINE_STATIC_SRCU(gpio_devices_srcu); static DEFINE_MUTEX(gpio_machine_hogs_mutex); static LIST_HEAD(gpio_machine_hogs); +const char *const gpio_suffixes[] = { "gpios", "gpio" }; +const size_t gpio_suffix_count = ARRAY_SIZE(gpio_suffixes); + static void gpiochip_free_hogs(struct gpio_chip *gc); static int gpiochip_add_irqchip(struct gpio_chip *gc, struct lock_class_key *lock_key, diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 48e086c2f416..a75635891c6f 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -90,7 +90,8 @@ static inline struct gpio_device *to_gpio_device(struct device *dev) } /* gpio suffixes used for ACPI and device tree lookup */ -static __maybe_unused const char * const gpio_suffixes[] = { "gpios", "gpio" }; +extern const char *const gpio_suffixes[]; +extern const size_t gpio_suffix_count; /** * struct gpio_array - Opaque descriptor for a structure of GPIO array attributes -- 2.43.0