linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Linus Walleij <linus.walleij@linaro.org>,
	Alexander Stein <alexander.stein@ew.tq-group.com>,
	linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org
Cc: Bartosz Golaszewski <brgl@bgdev.pl>, Andy Shevchenko <andy@kernel.org>
Subject: [PATCH v3 3/5] gpio: aggregator: Prevent collisions between DT and user device IDs
Date: Thu, 15 Jun 2023 16:20:21 +0300	[thread overview]
Message-ID: <20230615132023.13801-4-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20230615132023.13801-1-andriy.shevchenko@linux.intel.com>

In case we have a device instantiated via DT or other means than
via new_device sysfs node, the collision with the latter is possible.
Prevent such collisions by allocating user instantiated devices with
higher IDs, currently set to 1024.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-aggregator.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c
index 4a470dd8b75d..8892cb37ad79 100644
--- a/drivers/gpio/gpio-aggregator.c
+++ b/drivers/gpio/gpio-aggregator.c
@@ -26,6 +26,7 @@
 #include <linux/gpio/driver.h>
 #include <linux/gpio/machine.h>
 
+#define AGGREGATOR_MIN_DEVID 1024
 #define AGGREGATOR_MAX_GPIOS 512
 
 /*
@@ -135,7 +136,7 @@ static ssize_t new_device_store(struct device_driver *driver, const char *buf,
 	}
 
 	mutex_lock(&gpio_aggregator_lock);
-	id = idr_alloc(&gpio_aggregator_idr, aggr, 0, 0, GFP_KERNEL);
+	id = idr_alloc(&gpio_aggregator_idr, aggr, AGGREGATOR_MIN_DEVID, 0, GFP_KERNEL);
 	mutex_unlock(&gpio_aggregator_lock);
 
 	if (id < 0) {
-- 
2.40.0.1.gaa8946217a0b


  parent reply	other threads:[~2023-06-15 13:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-15 13:20 [PATCH v3 0/5] gpio: aggregator: Incorporate gpio-delay functionality Andy Shevchenko
2023-06-15 13:20 ` [PATCH v3 1/5] gpio: aggregator: Remove CONFIG_OF and of_match_ptr() protections Andy Shevchenko
2023-06-15 13:20 ` [PATCH v3 2/5] gpio: aggregator: Support delay for setting up individual GPIOs Andy Shevchenko
2023-06-15 13:20 ` Andy Shevchenko [this message]
2023-06-15 14:54   ` [PATCH v3 3/5] gpio: aggregator: Prevent collisions between DT and user device IDs Geert Uytterhoeven
2023-06-15 15:36     ` Andy Shevchenko
2023-06-15 13:20 ` [PATCH v3 4/5] gpio: aggregator: Set up a parser of delay line parameters Andy Shevchenko
2023-06-15 13:20 ` [PATCH v3 5/5] gpio: delay: Remove duplicative functionality Andy Shevchenko
2023-06-16  9:00 ` [PATCH v3 0/5] gpio: aggregator: Incorporate gpio-delay functionality Bartosz Golaszewski
2023-06-16  9:01 ` Alexander Stein
2023-06-16 13:33   ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230615132023.13801-4-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=alexander.stein@ew.tq-group.com \
    --cc=andy@kernel.org \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=geert+renesas@glider.be \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).