From nobody Mon Feb 9 06:29:10 2026 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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 581A4246348; Wed, 5 Mar 2025 13:12:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741180377; cv=none; b=AobnfrRqFNdB/OABoohS5m5o3RpVW5+11GK4R2V5Lc27sYhBaTgoP5IlfdUxs0ThvlX9VlD4ht+vdbAKzHgUtZnNwNBSBzCTi4WuOeUym3m+JhgWv3CmL6oMfhqZi3tz0QKXWhpJzShIr2QdxTMpeFZhQnE0IqIAyXQAZwuBIcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741180377; c=relaxed/simple; bh=mUxt3qz/KgBZE3PjFr5uM4Dh49iWXqqoo3enjTOs7KI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sJbT8it8j1dPvwm0MwUXE5HMdms3HektR1v7b7U0cve37/9KB3aQcbC6T26uJI2railq3kQv+inYgQfHejNxaI+yY9F9VxJlV9/pC3t+hdoEE1FElinCwwuZwyh1rYalzAlLDb1jhU/YgUkdCQjrDga+M/QigxTmHb40pyWKR28= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NHPv1B91; arc=none smtp.client-ip=209.85.167.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NHPv1B91" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-543d8badc30so7819127e87.0; Wed, 05 Mar 2025 05:12:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741180373; x=1741785173; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=++P8OGgocPeaMuo16xEVHYoWSjDiToMa6HFnAtyYwNg=; b=NHPv1B91uD9cLuvHnLCsRz8lEEkmQMYVfDOC/ehMfQqe9uWARzrgsI7hXl14kc8qEr 4GKoqCW2QDt2GX2EmUWY7SBQN8zRbWWGwuVXHAx0fom8MuKFWDJyAQcK+n274fI0xnwL YScVvPRu3PvvkF42qT5qXGBdMn7Iw7c0SkfyRf0aGknyQbJVgHxcWcLpweY50a+r5y0A bbVgMHwvOsqsKk6A5wqM5tceoYJcg5Sfs0bP7GWAUx6vBWAPVMiCBOq0NTFOQ8RBcIam zzi+fNAByiLprhmy7zRdD87UUufAMTERiiINNsGwgC6YIoixd6jM3v0fz2VgcMfHNOnF f/ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741180373; x=1741785173; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=++P8OGgocPeaMuo16xEVHYoWSjDiToMa6HFnAtyYwNg=; b=YtkANrMw84NvmuSDNGR30uirpmq8np+J4aWOX5jV1VYW7BKNjMbyznJhUMUMQ9hE/S naCuNJXHvczQHDuJZvkjnpGLQgoaEFvVwEalqse9JbwrOuCkKhyno9OFiQLlmpQTdiSP wqNvPmKiGEZPbxLeaLAanVCuuqkgtL/Z/nRhzQLKx7YBVjUxgg/urEEgsgB5VDAJTn8o qg4sD/v5g2nufOl/13ZwGdkrBimpCu5HPzD2Je+DWJDRSZ0eAfLjrtmkMHa+lDDRERiv 9jvJ+0c3QYfMfqG3HL9UhmbsllUr6C/L2CJvKKtHEPs/Ff/ODpURW9J01kmhEu+e7DyD HjLw== X-Forwarded-Encrypted: i=1; AJvYcCUE96ObT4uAjrdQS7fAi49JOMfrD7cJcTtnn94PZ425nx0xsjLsa84gDYcOphQKDTJ5W2vDQce1fTOm@vger.kernel.org, AJvYcCW95s+iGg6hvYHirWLWRSBYrMynYnv6tcVpjVARBQ+mTawNhInnEwsNdKHCADsyoRczDAfUye5cpp1Sk3L2@vger.kernel.org X-Gm-Message-State: AOJu0YwrbubvGYiUgWZsaHDGcT7Deou1N93vFjLH4vdpI9XnGGhKiCw8 vL49U7BDJiAfQj2Y87od97Z3qQ0wrPkLmD5eDv9KcvPkqnTyoHo8 X-Gm-Gg: ASbGncsySCow+zqXoySecXUHR8CJRwVSDeY+N5lhtONOHaVNRCOLI8VGODcMPjmkKdW ys3r0K4i+Fl82A4QM2sDxzI3fcid1s+gW9VAbd0CeSIecNf+zE8qKGwAYtdZWG7R3JgB86wcx6z 0CAQpyA8qvWZLh7Pdr72AsnKRyDeNr/rUgH1YgcUghS9sKjixnlWLQTFmqLuVLZ1df4cKEPj+4L Dv0kVPq30tsubWcizlFkZdEf4HAmun0jr57+GDHT835++7iExqetx+yMUx97EJnHFjv6ZX1JI1K WemgtWBMsCmB/Y47WrSdQg4hR4O7ZsPvQCTQ9SnZIvStOMIWa3Q= X-Google-Smtp-Source: AGHT+IFYgjh5om1P5ziCBs0tJzVpk/HRJSyxUZGxqLx1i5ZMB3Kd10x6efZ0KfXI/YJhWGvtIHBvzw== X-Received: by 2002:a05:6512:acd:b0:545:8a1:5379 with SMTP id 2adb3069b0e04-5497d389e46mr1302102e87.43.1741180373178; Wed, 05 Mar 2025 05:12:53 -0800 (PST) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-54950deac8bsm1543956e87.237.2025.03.05.05.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Mar 2025 05:12:52 -0800 (PST) Date: Wed, 5 Mar 2025 15:12:45 +0200 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Biju Das , Geert Uytterhoeven Subject: [PATCH v3 1/4] gpio: Respect valid_mask when requesting GPIOs Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="KAykzEu+FXuHmRBM" Content-Disposition: inline In-Reply-To: --KAykzEu+FXuHmRBM Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When GPIOs were requested the validity of GPIOs were checked only when the GPIO-chip had the request -callback populated. This made using masked GPIOs possible. The GPIO chip driver authors may find it difficult to understand the relation of enforsing the GPIO validity and the 'request' -callback because the current documentation for the 'request' callback does not mention this. It only states: * @request: optional hook for chip-specific activation, such as * enabling module power and clock; may sleep The validity of the GPIO line should be checked whether the driver provides the 'request' callback or not. Unconditionally check the GPIO validity when GPIO is being requested. Signed-off-by: Matti Vaittinen Reviewed-by: Linus Walleij --- Revision history: v2 =3D> v3: - Rebase to gpio/for-next v1 =3D> v2: - New patch (born as a spin-off from the discussion to v1: https://lore.kernel.org/all/Z71qphikHPGB0Yuv@mva-rohm/ I'm not sure if this warrants a Fixes -tag. --- drivers/gpio/gpiolib.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 8724c7d8459e..b5f472beb3bd 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2358,16 +2358,16 @@ static int gpiod_request_commit(struct gpio_desc *d= esc, const char *label) if (test_and_set_bit(FLAG_REQUESTED, &desc->flags)) return -EBUSY; =20 + offset =3D gpio_chip_hwgpio(desc); + if (!gpiochip_line_is_valid(guard.gc, offset)) + return -EINVAL; + /* NOTE: gpio_request() can be called in early boot, * before IRQs are enabled, for non-sleeping (SOC) GPIOs. */ =20 if (guard.gc->request) { - offset =3D gpio_chip_hwgpio(desc); - if (gpiochip_line_is_valid(guard.gc, offset)) - ret =3D guard.gc->request(guard.gc, offset); - else - ret =3D -EINVAL; + ret =3D guard.gc->request(guard.gc, offset); if (ret > 0) ret =3D -EBADE; if (ret) --=20 2.48.1 --KAykzEu+FXuHmRBM Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmfITc0ACgkQeFA3/03a ocUA7Qf/ZRFY9W+g5Sf7I2fazEDhkCPghF1Q249ECBlqOWHM7QtaXPd3PMFS4uEr iqXOpWZxwxfMqS39pMameGe569WXQ6s741Hyy+yAg3avRSiY474dk7tTXpgcUsgm puwYgPNjDRWWJNsBaAL65ssCJjeKRQTcxpjDLlQameuHk3Dh1QYSX2LBtTpNfuxX ub6MrnoAXPTs223560on0CZZDBwmgSyqBD9e/XVs8TOrJ8a4JjF7puMwAluIFk3N xfZnm3HehnDaWIukr4kHstgBRsTJ85jfGcRLPpLoONR67t94duCZspzO2m3aMATT G4NDqT4iKMG5fzPxOtHh+SO8tqxCBQ== =zILn -----END PGP SIGNATURE----- --KAykzEu+FXuHmRBM-- From nobody Mon Feb 9 06:29:10 2026 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 66E7B247DDD; Wed, 5 Mar 2025 13:13:07 +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=1741180389; cv=none; b=luOHcBNnQqve5WCAAeflDvJso/mTcB9iql60X08WbnPoBE1j86CowYj92tBCcTKSiyclUt63bpaCr+NYCbcihaE5HD9T0AZzJf068AGPKiP9X3IPDXu84iUr3fmd6+74D8MtJkeDpZbQ8AitiPYGtFjQG8bJk2pM6wVZ7pxIuII= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741180389; c=relaxed/simple; bh=uvmG5QJWZ2Ye2xa3dR6GgdJ0KCYJpB1tdF5a0t9tvV4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=I2xmtwRbSFySgpTSMywk2Urt5zobpgzudmtu2YqfVU+NlO7RgjUc3tXdBaw/SOgsE2gECBR4F2SAimVelsHSamYQvfSEcZUaK3NP3kx5+rOwJUZ8Ef2ufcFe4T0iMkdJ8ep7HcY501eggOBP++ffSke+LQZZg6yJoq1hFZwbs2U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hVRcSRqb; arc=none smtp.client-ip=209.85.167.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hVRcSRqb" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-543e4bbcd86so7533743e87.1; Wed, 05 Mar 2025 05:13:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741180385; x=1741785185; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=hHvBs8LqDr1CyCcVZ4KGUWjU6v/QgTZS9xOG0QkppUU=; b=hVRcSRqbrt9GtTiHrugfkjIUJJtd+XpJqZ0fyRvHX+kiIWD2BnHGQ1zJiPNkODKXkm rrCc7rhiYMc8nqVBI65Tsx99P/Pfmk0FJY0Jw9m2BqZX2TrchVeMC70290n0ZPYtSSEw bR7zZlYtNNCYMR5VqmgQFsmTpkoVbEb3V76zZhKnA8ZlrOo4ueRZeOCgrenw+bFPWmDS bKiqBGQaJalSixzK5fUdokJSnT4PDyTtKUsK1VDIWD5C2F9iS9f1fPLijJM9JyRz534w F+4OnqXzyody4DxQT23EOfKkkXVysmNDJXuPqSNsw5pwaGnMrZnJE3n6L+uQlCODnQFA c4rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741180385; x=1741785185; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=hHvBs8LqDr1CyCcVZ4KGUWjU6v/QgTZS9xOG0QkppUU=; b=le3+L6O1su7LrMa2E7sT01cTE5CeZDY8jtuL2bco0Z+AKzf/eHjtR671CzmR8Hcwv9 e5oIUlVleNYi6vHEcMi3W7qQVqZRpaj/NzXt0tnMP+VfgXdbl1wyfVcrhkM6S75qPBAV KdqevIVaOFA9qH8hI4kj5w3qR4u2mj/8YiN1LPKtgyoglBX54m3nW02VpshAc88n2eSb esGuhusOcjrYV3lMVIPQEqj3HaB89FGu3T7qGsCnvgLpFY0JpDQyUw0pUNxwqMm5GUjI h8YXAEmTBDWDpwxQM5l7ByRFybuWkgyurOFRZD7/AyvPGMqDrvxzHFs1drHm3cDJoZWW 7u8g== X-Forwarded-Encrypted: i=1; AJvYcCXLk0vlVLPToVY2HiGMdoeQ2Ft5YDHufry0HWpQ1guFoxzA2F4t7wWdzkAYPquQL3xPAJulOsYAVdeTfptK@vger.kernel.org, AJvYcCXbOzDONFws0H9lOn7fkzyxjVGkrISRFzTOZyGQRKBvZLP8EONrdn9kV6SiHUR6SER51Pq17lTLZRNy@vger.kernel.org X-Gm-Message-State: AOJu0Yz4nV2IJR2cRxcg2nrVHYEwq9tk2uALXMlBn3QbVPaslEihPbq0 e46UE+LdOl4jsDYcOkXvdRxGCjYPGqR67lBT/Bo7G1IfbwTx3HQC X-Gm-Gg: ASbGncvlUDyRN5nNYvcNKDEK1zgEU5A8v/qo3X0Gp7rmECd3V1KfUnlitA7gcEfBUow dKSPTpMJLaizC63Rr3i4GcVRcfhcwQhsIe4omv4WTmxGqz7oIpsD6Xoi58T+hsAPiqzyPj2DG2c h898PVDBxplztgHF2yh5piCfSAGBRCt7sodKFahTGpVSIjXYN6KDPPjNjq0xmH/i0QBA+7L00i0 Un6Q/FFRY6AdASk5zjlXW4ycRI+tteEmw20g5WQ+s2V7v6fPDJC9MwYafzwH2wKJXQ/P3HwXWIx 2jMG+RFj9lUX4ESduAcSWjD1+qtes8Yb64ayBXfSKWuk1aHDqOQ= X-Google-Smtp-Source: AGHT+IF25Q3LO1//ZI187Q5Vs3Za5Zt5D7e2lU8WSZqluXp3dyXsXaTJkHllLhzz99SR/KOlX7Lxgw== X-Received: by 2002:a05:6512:3089:b0:549:7394:2cd0 with SMTP id 2adb3069b0e04-5497d337e68mr1064479e87.19.1741180385016; Wed, 05 Mar 2025 05:13:05 -0800 (PST) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5494bff2636sm1674670e87.219.2025.03.05.05.13.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Mar 2025 05:13:04 -0800 (PST) Date: Wed, 5 Mar 2025 15:13:00 +0200 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Biju Das , Geert Uytterhoeven Subject: [PATCH v3 2/4] gpio: Add a valid_mask getter Message-ID: <026f9d78502eca883bfe3faeb684e23d5d6c5e84.1741180097.git.mazziesaccount@gmail.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ep+lPcCHAsNg9p+A" Content-Disposition: inline In-Reply-To: --ep+lPcCHAsNg9p+A Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The valid_mask member of the struct gpio_chip is unconditionally written by the GPIO core at driver registration. It shouldn't be directly populated by drivers. This can be prevented by moving it from the struct gpio_chip to struct gpio_device, which is internal to the GPIO core. As a preparatory step, provide a getter function which can be used by those drivers which need the valid_mask information. Signed-off-by: Matti Vaittinen Reviewed-by: Linus Walleij --- Revision history: v2 =3D> v3: - Rebase to gpio/for-next v1 =3D> v2: - New patch (spin-off from discussion to v1: https://lore.kernel.org/all/Z71qphikHPGB0Yuv@mva-rohm/) --- drivers/gpio/gpiolib.c | 16 ++++++++++++++++ include/linux/gpio/driver.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index b5f472beb3bd..4c15a70d4d80 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -723,6 +723,22 @@ static int gpiochip_add_pin_ranges(struct gpio_chip *g= c) return 0; } =20 +/** + * gpiochip_query_valid_mask - return the GPIO validity information + * @gc: gpio chip which validity information is queried + * + * Returns: bitmap representing valid GPIOs or NULL if all GPIOs are valid + * + * Some GPIO chips may support configurations where some of the pins aren't + * available. These chips can have valid_mask set to represent the valid + * GPIOs. This function can be used to retrieve this information. + */ +const unsigned long *gpiochip_query_valid_mask(const struct gpio_chip *gc) +{ + return gc->valid_mask; +} +EXPORT_SYMBOL_GPL(gpiochip_query_valid_mask); + bool gpiochip_line_is_valid(const struct gpio_chip *gc, unsigned int offset) { diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 83e0a7e86962..e3b59fda62e0 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -720,6 +720,7 @@ bool gpiochip_line_is_open_source(struct gpio_chip *gc,= unsigned int offset); /* Sleep persistence inquiry for drivers */ bool gpiochip_line_is_persistent(struct gpio_chip *gc, unsigned int offset= ); bool gpiochip_line_is_valid(const struct gpio_chip *gc, unsigned int offse= t); +const unsigned long *gpiochip_query_valid_mask(const struct gpio_chip *gc); =20 /* get driver data */ void *gpiochip_get_data(struct gpio_chip *gc); --=20 2.48.1 --ep+lPcCHAsNg9p+A Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmfITdwACgkQeFA3/03a ocUo4gf/Q+NC0QKnIMARZo9X2BFgPG5YZtjjw0Dmr5GKLHWjEKAPF4fJkBYhRLzo 5EZaSC50CGZyOGFpNdPmhvgUWRmMGG7XiqP4dNxY4ioUwUfXpTLB5oZurYHzxUzc XHbd1hrcot7q8/lUe6fdJ0PffDYsqvQnjGpgjhAEBafUjuYuaOR6sD57/8IZPBL+ xeF/w7JCczQZDPLzn65TgcMFOrkcXVg7Ma5wyfwXSP+Z0PFb39ym7WQ6NfXYIa4f O/kbzz3CCRuD9Tvh79sLsyz/z3eRtRQ2To0dO8V4RhaVQbcDusqiTIjFuJGTpqIr vHD0jXVktgBJz7PgD3Q2Banhei8moA== =zAIr -----END PGP SIGNATURE----- --ep+lPcCHAsNg9p+A-- From nobody Mon Feb 9 06:29:10 2026 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.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 99A922451F1; Wed, 5 Mar 2025 13:13:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741180402; cv=none; b=CSwnZqguaNlBmU0XDowyB25sfIeTDMORAosCUBLQ3ZDltnjdR1o7v2LyIVqpn6lFHs+GifQNEM+DmNNLS1hkwTq1IiS/6IGf9BSWBxOsKr3g5B1C2I9kAg367ejCZxY/hXZ0znmVCoyKrDR0u4/ZWM3HSAbXeli3+XacJu1oG1c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741180402; c=relaxed/simple; bh=UnkPUThlesRfrFulZd3rGz1lVj7Yt27Rl6s6uTGLymM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=f+kPcgjc5RjdYo9PyR8BgbKJXejw1U3936VEN1vdEQ7op/9X0Dd3tA77+x0Lo/BYNbxOOZTmBuA4y+DkGM5k0cryQ+y6NP1IbTm6W1djqju9k/K81BJy9CeBuNhVOyc2EAKaowtMDzXoRtRwoll99dK1Ww/FZAOGLCeH5aEi8pA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lt6FRuzX; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lt6FRuzX" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-54964606482so3454582e87.0; Wed, 05 Mar 2025 05:13:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741180399; x=1741785199; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=QHnC8rTk/VCV1yeCHKlZbcNeKu9yNOp/8mdlXdPmYxM=; b=lt6FRuzXysAnKJZ/9o6z2CIQ7w6rHVZO16pxdXI8BaqqfVpw3Mp0JoKKRZS6l6Vtky FrnVqZIWIKR3qZcARzdD+HaU+6MbHScS7wOCrEML0ZGyCO5cLHeiP5dCekMpbTVYsawx YisijPH7QymMUJZi01ghjEg78yp++J8cyTMHJovZDbaq8ji3ziBhvdnrpzaFiP7HFeKH gMKOMP2e/3MF08CsidOwGwP22NDxexf0Akg7TKY9ihQupT124eokIiGyEFbwc6wCiwlw JFPKWh4pJJQCdHn4GUkTjH/B1XQ5x3odq6DLD8IP7D8ZX5afCjKg8fkcNYgooA/h9aqy lRkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741180399; x=1741785199; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=QHnC8rTk/VCV1yeCHKlZbcNeKu9yNOp/8mdlXdPmYxM=; b=jbKz+lTHmC9onmmzdnfNthSJxXEBulUtG1Rdn0/90X7v6zI0kJyDmL3bpm1ncm24Ta g2M2A9iP0bA+2SNc0QnDY66sUcHlyEE6M92GD1MqolSAM5oTy6+624OaMeMjRlhrvCb6 8syAm+96H7543OL1mSyULozCcoICVnwnJ9xeHQovy0ULRHS0ZzWojJ6Ia2D3D22p7E7o YPfcqO2RlxcxIaOcZbDapqSs9t3/SFzLkiYRmmXXbngdT/mnB/dQNLgu9HR7xO87bDOg 6m2OsaP4o7GnPiQzKthWAkF3J1TydlaAhb7L3c/gOgbzdmiKfw+UNausK5xMRksa7MK3 lzCw== X-Forwarded-Encrypted: i=1; AJvYcCWlGNK9SPHxcjkUlcmSuN3GqHjddkrVBUlY5Inwc9cUptLEAL1IYu2ffn0eYWme0GGwmk8ufO9sLCf8@vger.kernel.org, AJvYcCXIaBXldXgf7Paxc0SnicOv5h7Vqhx7bQK9z1VyfmQLOCZMy8Uya59wU7bFsBZfLw9FazcPFyI4J7EPQtaB@vger.kernel.org X-Gm-Message-State: AOJu0YzUgZCvNioy3em0MTKlpLlb/8wn8qBTqj/rglyyKFfnQovuNU1A oY8XEGp8W/7dsqZwk/od0RrC8oDbWBrirpTmLuBYx/BBNootiWRgDNeniw== X-Gm-Gg: ASbGncvXoIHB3UOTLwzTFKm6SN06EooOxoSaogrQxjuo9wSbpJTIfrGOr6puESHu/n5 /vryk3ZOHmYcWRNV1RKwvFzPNpqDTbhzFyUJRzjLCVPVmxQtUrYqxV91XucUDHvxjncwCzNFYOd 6qTK/OWFu4jcyIomwkufEzJ2E/eNxMrg3vNCGjYXAN8tiT0NbY5OoC9J1BBN/V02y/fDcst1cAS 7rqRU9Vwg//fmeJg+LLM6xyXfy6XdVXl1U8dL22XnGlcmBw3Ijz+Alm7SyDdU6wV9SXozYgAx5J jFAlUBzf2H1eniyCYHKFowKrqf/B3hyazOMYEfZtWf7JFpuYgK8= X-Google-Smtp-Source: AGHT+IEpKQcNhVV4Fq2g9M2L3vaeHgEF81hTHFGhiGmuOzaUX8nXAWp/Fgvl1t69oczv/GT8U/t60Q== X-Received: by 2002:a05:6512:1111:b0:545:2d4d:36de with SMTP id 2adb3069b0e04-5497d354cf1mr1183548e87.31.1741180398315; Wed, 05 Mar 2025 05:13:18 -0800 (PST) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5495b97bdc5sm1193457e87.115.2025.03.05.05.13.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Mar 2025 05:13:17 -0800 (PST) Date: Wed, 5 Mar 2025 15:13:12 +0200 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Biju Das , Geert Uytterhoeven Subject: [PATCH v3 3/4] gpio: gpio-rcar: Drop direct use of valid_mask Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ghYeNW3ZTfdXU7st" Content-Disposition: inline In-Reply-To: --ghYeNW3ZTfdXU7st Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The valid_mask member of the struct gpio_chip is unconditionally written by the GPIO core at driver registration. It should not be directly populated by the drivers. Hiding the valid_mask in struct gpio_device makes it clear it is not meant to be directly populated by drivers. This means drivers should not access it directly from the struct gpio_chip. The gpio-rcar checks the valid mask in set/get_multiple() operations. This is no longer needed [1]. Drop these checks. Additionally, the valid_mask is needed for enabling the GPIO inputs at probe time. Use the new valid_mask -getter function instead of accessing it directly from the struct gpio_chip. Signed-off-by: Matti Vaittinen Reviewed-by: Linus Walleij --- Revision history: v2 =3D> v3: - Rebase to gpio/for-next Please note that this change is compile-tested only. All reviewing and testing is highly appreciated. Revision history: v1 =3D> v2: - New patch [1]: https://lore.kernel.org/all/TY3PR01MB11346EC54C8672C4D28F931F686CC2@TY= 3PR01MB11346.jpnprd01.prod.outlook.com/ --- drivers/gpio/gpio-rcar.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index 2ecee3269a0c..e32d731d0473 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -336,9 +336,6 @@ static int gpio_rcar_get_multiple(struct gpio_chip *chi= p, unsigned long *mask, unsigned long flags; =20 bankmask =3D mask[0] & GENMASK(chip->ngpio - 1, 0); - if (chip->valid_mask) - bankmask &=3D chip->valid_mask[0]; - if (!bankmask) return 0; =20 @@ -380,9 +377,6 @@ static void gpio_rcar_set_multiple(struct gpio_chip *ch= ip, unsigned long *mask, u32 val, bankmask; =20 bankmask =3D mask[0] & GENMASK(chip->ngpio - 1, 0); - if (chip->valid_mask) - bankmask &=3D chip->valid_mask[0]; - if (!bankmask) return; =20 @@ -482,10 +476,13 @@ static int gpio_rcar_parse_dt(struct gpio_rcar_priv *= p, unsigned int *npins) static void gpio_rcar_enable_inputs(struct gpio_rcar_priv *p) { u32 mask =3D GENMASK(p->gpio_chip.ngpio - 1, 0); + const unsigned long *valid_mask; + + valid_mask =3D gpiochip_query_valid_mask(&p->gpio_chip); =20 /* Select "Input Enable" in INEN */ - if (p->gpio_chip.valid_mask) - mask &=3D p->gpio_chip.valid_mask[0]; + if (valid_mask) + mask &=3D valid_mask[0]; if (mask) gpio_rcar_write(p, INEN, gpio_rcar_read(p, INEN) | mask); } --=20 2.48.1 --ghYeNW3ZTfdXU7st Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmfITegACgkQeFA3/03a ocUnCAgAjW26dDUNuzcA+xGMSOCJhKatU1Cm7sWRH2mtj3UuJrREZgi3oIdNq+Un adF64MwAzrMlSDCokumXWS4OY2IsDheLl2wfDnfpb3BU2SQ3Sc5QmyVgXKQJvAvC OrJfEwFvYc8tmazPZxGFTMRxETb6YdB3hLtAHBaWPrb6MOXx8csu0ta6IuOQ5Eu8 ELCYcQYOmJfTcy3Ew5GSP4HNWPRjkrZcwWfyxWoUUibpP6etrXQOjM7p2tXmiSdm CgB6SES2ojcre3GPwWW1NPq0U8OwWZD3+5srj4HoYylbif9+DEff09ru9QDN7ZOb 8AcOB5oJTyM3lh8I4LJWb5IwqKjhCA== =S9C7 -----END PGP SIGNATURE----- --ghYeNW3ZTfdXU7st-- From nobody Mon Feb 9 06:29:10 2026 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 AFF4224502D; Wed, 5 Mar 2025 13:13:31 +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=1741180413; cv=none; b=CA48GTC+aQp4mjzsE7HHBfxa5YmiQq2PGa8Pb9vGzzqnToM6iJeSye6EtxBrPlgss0XQKifh/OfF35rwht6c62BmGwhwW8QSCyGYmw6UnoHluXVLsSCFzL2eRWxH4u867yvwyodE8DszbxSSm6obhrErZjo0ZDA73DIXEwT7+FE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741180413; c=relaxed/simple; bh=1b56dqW04XIiQlZgdsKTpR0rfGqwLyqlxFWw2yQrr6A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WyGPgTRfZkyQDRQgeEsToMvYvEJLQ/6fh2OaVna1ed/NdLFefiGWyYEbgD63Upbde0I0I6mzKNdX1cHzTLxfiPEKNGP8WP2tD/MXM8rASZNznks+UiRQThLGmEML+/Iaxl4zHzvNw5JI8a6YYv55LelZYMaRlWTIGaoQS+s75Yw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PRswpnwq; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PRswpnwq" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-5494bc8a526so6193445e87.0; Wed, 05 Mar 2025 05:13:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741180410; x=1741785210; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=6njS7STEyzXZEmTyfJ0XJ141GOP+CIiuu0sZuNSrs2k=; b=PRswpnwqF7vybwkQlUA/OfaLL7Wl7b4mJaE8yFmV8WhjWBc1Z8AcWMxQlZr5txoy2l bidjPzVOayXE5dpDDhF0/m3X00Pg415oRvqXY6XE8yzycPsbt41qgq1bEKh6vTAcuvAw 6mtgUUQYKNfC+RTvUaChVgGAjtvgG0uFdnMUufEJqwrEwcAHNQEvFdK7HwUW5Mu6MZqt xcJJIm4bQ8+GJBK5Gt4XWwAks2ZNoY1DfS5WaRUV/E5cM3T8eS6iocrtJDRHk1c6cW34 JR1g+ApjQWR0ivtD2UMmLCxny/wVIg2erFGHaL4BAzI49VG6LK67doDJn+wUnkd+Qt6U T+WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741180410; x=1741785210; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6njS7STEyzXZEmTyfJ0XJ141GOP+CIiuu0sZuNSrs2k=; b=Zi5wZ9MJE87a0/OKpjjpkeTAxAiKNjEz1HrGxIa4l6R9eEYbfynDQFomyoMrOgFYf6 49HVfZucTlBJZAr2ZoZCAQ9ZhTG2i7C1c9pkrxrVwXuhwJDQziLZVljRtoZzEaRI3+BK ZbGcWa4GST7BIiyib0soU+NqLyOK3kBKfIxx/gtyq8nf+Rvov6hBLAV6zOlAMCqO/BYX y4TXzunDuwmHeLvi9JrXPI7cZZmTBdqYcokZYm2STxp8eonG9NMXzG47KyetFjzvBqi9 s5TTJ4+ZGmU7bmwAcTnpJYO25JDEFUaxoX0y8acYM5UucPtR/m/WX+qiDQ4dw8yOt+GX MUjg== X-Forwarded-Encrypted: i=1; AJvYcCVbsYP0+XVkootyTfn9odiwL+VyK/xUhWnB9fKJ9HyDMdMinFtfo14/LK+L3qw1iztgiFE2r9atCINhMZFk@vger.kernel.org, AJvYcCWt8IjvsYZC0zuLVOjPVYOKAiGpIpDVkXCvUZCmbi1v5u3JfIXKFRQNDCUSpni7ZgLJJkdGppYkyri1@vger.kernel.org X-Gm-Message-State: AOJu0YzCb/ZcnABWV6UhlWb8g71uwWDV5bit4GXQNTpdc5XphWQLFrw+ owzTz3dWNCP5nVT1rLELDl2neNTYCaIuWmbNITaMDe/a/r4N3FS6u1J7+A== X-Gm-Gg: ASbGncvMPEc6VkQ/n4HQ4K2kM3SdaI+Q1R1ei+6gjqo8sq9madLLowlYs/ZrsgWVRRl TprJFZ8C6qaAlr/rZ06YDMo6McboMoMEIjSICD9aWnaEDqTOeUaMG0ecl52h8mZVZ6PLB7HqxVn WaZTV3WX8PYv91DMAdYINcbHKftMyto9WTfe2P/iKJE90c8h87njOTV3w/rMbVclgL+CWSlJ56s Fv2m3LSGmmvB6maGS1JgcelO6PpKpbtEBAd9aI2EEzPsvDT8rP+3JKF5UKBAakcYYroxzPbqww3 QzQWOz9Fmzp77xUoSTR1+62rL/NbrIDtntyQVXC7uasiVlF854s= X-Google-Smtp-Source: AGHT+IHzBoz5KK3U4ujh5jgRP4Q+GBBj7IcLN7LFsYoLBE2hTjPSKWI+wQlvQnG9BB2blWe31T4XYg== X-Received: by 2002:a05:6512:281d:b0:549:5b54:2c66 with SMTP id 2adb3069b0e04-5497d345ea7mr1160393e87.23.1741180409421; Wed, 05 Mar 2025 05:13:29 -0800 (PST) Received: from mva-rohm ([2a10:a5c0:800d:dd00:8fdf:935a:2c85:d703]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5494d6d2fb6sm1678785e87.137.2025.03.05.05.13.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Mar 2025 05:13:28 -0800 (PST) Date: Wed, 5 Mar 2025 15:13:25 +0200 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Linus Walleij , Bartosz Golaszewski , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Biju Das , Geert Uytterhoeven Subject: [PATCH v3 4/4] gpio: Hide valid_mask from direct assignments Message-ID: <4547ca90d910d60cab3d56d864d59ddde47a5e93.1741180097.git.mazziesaccount@gmail.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="UyT2nDIBwLJN+qa7" Content-Disposition: inline In-Reply-To: --UyT2nDIBwLJN+qa7 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The valid_mask member of the struct gpio_chip is unconditionally written by the GPIO core at driver registration. Current documentation does not mention this but just says the valid_mask is used if it's not NULL. This lured me to try populating it directly in the GPIO driver probe instead of using the init_valid_mask() callback. It took some retries with different bitmaps and eventually a bit of code-reading to understand why the valid_mask was not obeyed. I could've avoided this trial and error if the valid_mask was hidden in the struct gpio_device instead of being a visible member of the struct gpio_chip. Help the next developer who decides to directly populate the valid_mask in struct gpio_chip by hiding the valid_mask in struct gpio_device and keep it internal to the GPIO core. Suggested-by: Linus Walleij Signed-off-by: Matti Vaittinen Reviewed-by: Linus Walleij --- Revision history: v2 =3D> v3: - Rebase to gpio/for-next v1 =3D> v2: - Hide the valid_mask instead of documenting it as internal to GPIO core as suggested by Linus W. https://lore.kernel.org/all/Z71qphikHPGB0Yuv@mva-rohm/ --- drivers/gpio/gpiolib.c | 16 ++++++++-------- drivers/gpio/gpiolib.h | 3 +++ include/linux/gpio/driver.h | 8 -------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4c15a70d4d80..e5eb3f0ee071 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -672,7 +672,7 @@ static int gpiochip_apply_reserved_ranges(struct gpio_c= hip *gc) if (start >=3D gc->ngpio || start + count > gc->ngpio) continue; =20 - bitmap_clear(gc->valid_mask, start, count); + bitmap_clear(gc->gpiodev->valid_mask, start, count); } =20 kfree(ranges); @@ -686,8 +686,8 @@ static int gpiochip_init_valid_mask(struct gpio_chip *g= c) if (!(gpiochip_count_reserved_ranges(gc) || gc->init_valid_mask)) return 0; =20 - gc->valid_mask =3D gpiochip_allocate_mask(gc); - if (!gc->valid_mask) + gc->gpiodev->valid_mask =3D gpiochip_allocate_mask(gc); + if (!gc->gpiodev->valid_mask) return -ENOMEM; =20 ret =3D gpiochip_apply_reserved_ranges(gc); @@ -696,7 +696,7 @@ static int gpiochip_init_valid_mask(struct gpio_chip *g= c) =20 if (gc->init_valid_mask) return gc->init_valid_mask(gc, - gc->valid_mask, + gc->gpiodev->valid_mask, gc->ngpio); =20 return 0; @@ -704,7 +704,7 @@ static int gpiochip_init_valid_mask(struct gpio_chip *g= c) =20 static void gpiochip_free_valid_mask(struct gpio_chip *gc) { - gpiochip_free_mask(&gc->valid_mask); + gpiochip_free_mask(&gc->gpiodev->valid_mask); } =20 static int gpiochip_add_pin_ranges(struct gpio_chip *gc) @@ -735,7 +735,7 @@ static int gpiochip_add_pin_ranges(struct gpio_chip *gc) */ const unsigned long *gpiochip_query_valid_mask(const struct gpio_chip *gc) { - return gc->valid_mask; + return gc->gpiodev->valid_mask; } EXPORT_SYMBOL_GPL(gpiochip_query_valid_mask); =20 @@ -743,9 +743,9 @@ bool gpiochip_line_is_valid(const struct gpio_chip *gc, unsigned int offset) { /* No mask means all valid */ - if (likely(!gc->valid_mask)) + if (likely(!gc->gpiodev->valid_mask)) return true; - return test_bit(offset, gc->valid_mask); + return test_bit(offset, gc->gpiodev->valid_mask); } EXPORT_SYMBOL_GPL(gpiochip_line_is_valid); =20 diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 58af0491e60e..a738e6c647d8 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -32,6 +32,8 @@ * @chip: pointer to the corresponding gpiochip, holding static * data for this device * @descs: array of ngpio descriptors. + * @valid_mask: If not %NULL, holds bitmask of GPIOs which are valid to be + * used from the chip. * @desc_srcu: ensures consistent state of GPIO descriptors exposed to use= rs * @ngpio: the number of GPIO lines on this GPIO device, equal to the size * of the @descs array. @@ -65,6 +67,7 @@ struct gpio_device { struct module *owner; struct gpio_chip __rcu *chip; struct gpio_desc *descs; + unsigned long *valid_mask; struct srcu_struct desc_srcu; unsigned int base; u16 ngpio; diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index e3b59fda62e0..e6e5304c99ca 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -514,14 +514,6 @@ struct gpio_chip { struct gpio_irq_chip irq; #endif /* CONFIG_GPIOLIB_IRQCHIP */ =20 - /** - * @valid_mask: - * - * If not %NULL, holds bitmask of GPIOs which are valid to be used - * from the chip. - */ - unsigned long *valid_mask; - #if defined(CONFIG_OF_GPIO) /* * If CONFIG_OF_GPIO is enabled, then all GPIO controllers described in --=20 2.48.1 --UyT2nDIBwLJN+qa7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmfITfUACgkQeFA3/03a ocUsuwf8Dnmqt+DyeMnAwypeJdOxFxsILGXLi0gkUoMUKkQtThfkic6qslXf7iJO b2kyRNJfpccqCgDLZr66nTZJPJlUwbQXC1KSItlpby0jE5iLPL08WOabbhtnoFcA t4/WeUW1k6OwI8pzLsu53hfgllD6iEfxzRyn8lfqm6YfXJiw6QVJkgjbdjY807tL pL2S0VaB0euog2fOU1O5Y7KYpFZ1oCcYec8whZTvSFjeCYd1ZD1ESwserS6w2MKm VP0qhRMokt9rA3LEiDGo2cWES5QcNTyHavYRUAv8uf+a1ue/7M+UdgRg3fxjCDtI V2BTUoaHZd+vaqS6HVzW1f5BLLqe1g== =ZRvV -----END PGP SIGNATURE----- --UyT2nDIBwLJN+qa7--