Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1204302rwd; Thu, 15 Jun 2023 07:37:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5TVxUwwbZN/ibVvj/Z7cyu7KCO67U0gpHQdfbe9RZH+CgeBLsR5UI0Fuk9doWjx0dsVdjb X-Received: by 2002:a05:6a00:1a0e:b0:644:8172:3ea9 with SMTP id g14-20020a056a001a0e00b0064481723ea9mr5198465pfv.15.1686839866927; Thu, 15 Jun 2023 07:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686839866; cv=none; d=google.com; s=arc-20160816; b=owYYy3QRHO1YGTofqtONyuSuoclyXZha6p5N2uHDVhrbMyuZUhc5w/ZY/iNwAlzu2v 4gqcoEdfsYCLN4cIDNOqLs1q1ep2w3VAD4HZ/eN3z9yLtWwsM3XP6pzLcUpTwWAlCaz+ 2cMb4fzR2eRChZQTvSXXYw2M9fwODX6svNpaYvveXcyTkvELYxt0Xh6iKeyzJS04Wblz KAqCZY86C18oAmHooA37KfFVrPEJoWJHfK33c+iZA2bWPuOKR5wDZx13VNl/xksdGCr4 +PobE8jqIprhA0q+EHBNCKVViJhoH4BCvgnC1nYwVEN/4pIBT1yhR5N08d5fcSFYz0P+ Yy1w== 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=Civfg+w6RBB1DYo3LF4+agNhAZgu+8ZdDW9ae84GPgY=; b=C+j66vozjnq4RBMc5G5cRH5za2N6EE+jzevRBmajGcE4qBnRgh9isq/H0QFMNqaOq2 WONU27Tc0JSluBN9aoI8AtbNRGHxI1pTPDDd3lFlM0y8gSQSvogYLt2lNIvsswjTD5vF JFsaJdP0MsIE65Yzq2ekjRVlQ2nIzRhGpaGjh2z3FYZpNzHtyTuv4+Dav/HTK1xxte15 4dr+m1oXn2WElg4FBc5xqsvkMscVhRVee3ay6c6wQffIII/aYwyEX7miowutLJRibH9G 0IczknIhjMedzD1oZXSnX8wTsQsCootB2n0ldpiThJ6wIaIPbQCUqCxNZQvCtBaABUeQ 2hjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=h8wkNM8u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t123-20020a637881000000b0053422305c20si14039113pgc.14.2023.06.15.07.37.34; Thu, 15 Jun 2023 07:37:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=h8wkNM8u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344463AbjFONvX (ORCPT + 99 others); Thu, 15 Jun 2023 09:51:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343567AbjFONvW (ORCPT ); Thu, 15 Jun 2023 09:51:22 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36DC11BDB; Thu, 15 Jun 2023 06:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1686837081; x=1718373081; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m1IxT8Tqx2Xt34NPHZ0FTzyvORZk2opPVHLCk2AQe2Q=; b=h8wkNM8ultuahNJM4vyepIO0733nK4fLVi5NBzHxuc7NUnTs8fdjwbEZ hfYwG98kg60oFjUg6l4iR2pCYPSJP7xNaCHlAn6c7+mmCBpjW/Mr1LKB2 9goeH04/v99qj/zrOnNgoT7B1O+++OfsLhcVOPY1y65h7mqHs1exilRnK NP/ITUmSmP+BNS34oWMhHWqsB8/xGLfOc1/kGwDm9tOQhpchs46ZZOGkO xotKqPPtIkc5PwTfB3YyE13cbzJGSCt5cDOZWOO4ZbnbBZ89a12Sb407b xF2yRNunnJCP4ANkTmlDS5xP246Ai/uBktaRg5Fepvy5QvMKZugf5NMls Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="361404873" X-IronPort-AV: E=Sophos;i="6.00,245,1681196400"; d="scan'208";a="361404873" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2023 06:20:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10742"; a="802338784" X-IronPort-AV: E=Sophos;i="6.00,244,1681196400"; d="scan'208";a="802338784" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 15 Jun 2023 06:20:19 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 5E1A5677; Thu, 15 Jun 2023 16:20:28 +0300 (EEST) From: Andy Shevchenko To: Bartosz Golaszewski , Andy Shevchenko , Geert Uytterhoeven , Linus Walleij , Alexander Stein , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Bartosz Golaszewski , Andy Shevchenko Subject: [PATCH v3 3/5] gpio: aggregator: Prevent collisions between DT and user device IDs Date: Thu, 15 Jun 2023 16:20:21 +0300 Message-Id: <20230615132023.13801-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230615132023.13801-1-andriy.shevchenko@linux.intel.com> References: <20230615132023.13801-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 #include +#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