Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1247671rwd; Thu, 15 Jun 2023 08:08:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5+PT+krGfgfdxXHE3TQp10Y4QY+71BbSvdAXNx1ulhXSuJJlVm08VAwMBtEWvzklTy939t X-Received: by 2002:a05:6402:1202:b0:518:9174:9b5f with SMTP id c2-20020a056402120200b0051891749b5fmr4296129edw.1.1686841695040; Thu, 15 Jun 2023 08:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686841695; cv=none; d=google.com; s=arc-20160816; b=mjDcWxNyW8xOlRUi9tCUgdUXmi9qvGsQTOcUvyY07h/wUraN2Jv8/BlxUiioevvo9x e6es+g1A0IWlb0r3yBFsfpwEJCfWBlbWEHhA8VOo1RWERbLtLIKKNqV1MgF1+boj6QIz QuOQZtBuzdm4pYeYuJ1LAGt69GACz4hb/slImI9s5qjvTsW90DeDKivkVVxFBpwiv9P4 igVkzPl0tFi0gMNyshhsP1hEJ/yCbmwMCkv12fhcyOAfcw5rDsSajtCTuiGTEP+Jbyit WiTgvkmSUjEKLlszwrHteHvSYPPv4WppnwCX4GQKtb2aKjkhk8if4UJyz4KmqTAzofQo WOIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=CrbY5D4v4I1hs2+/P2zG/ou5IiEwF33UJDy+mcegd1U=; b=LFeglvj62RslfaNMpotIOon6jnj9KJ4kl3r6m+JNG3DbX6PheKG2fw8puc84n4YfXO l5CL419+7+so1MkaMByDZYLxhFGqdaJsECw+ZQyxVMoThZkpep3X3mWvL22310IGQmKC /Wt/n/AlHlLupWYogJugnTQ36sHmcbOxxxmlubmfRJrijnrI4tkTupqumjpsXagzbQlB P8epPTCE9vDcT9nlYBlChLB+zOtOg0gG4GAE34WW4Dl+oqJsh4SJxkUw7ZslGah+xh3b VRC4sLyS2M/7x8TLWydoL4Y1vJSkwWKO+A27JT713/lnDZy29CU5EcIiICGk+ePahTvF lYug== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c5-20020aa7d605000000b0051821440ec7si8434251edr.316.2023.06.15.08.07.43; Thu, 15 Jun 2023 08:08:15 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344696AbjFOOyh convert rfc822-to-8bit (ORCPT + 99 others); Thu, 15 Jun 2023 10:54:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344980AbjFOOya (ORCPT ); Thu, 15 Jun 2023 10:54:30 -0400 Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89CD0273D; Thu, 15 Jun 2023 07:54:29 -0700 (PDT) Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-bb167972cffso1825933276.1; Thu, 15 Jun 2023 07:54:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686840868; x=1689432868; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pSYZW9Ic0ZUjs7I0R7WkG+kButHO3oEwKmEXzQ8pRqY=; b=k7UtgOpcgLzMTA6nB8gRrHmYHidsuUhknM0yVsqeoum24+qmkpoRBFhEYdw53joGav hs5fW88/1/B4Ez/FKjCFCXBZ9Lw9EzBNY3jv9fSnTFwyJn+vaJ5hAvhtuaD6tf65Jgq+ YwRcgPpHBAaZlK0a2ROr0BnEgWDnTyo5uCJ0AyQhwGmBJR9VNHAR3NJAlhwZtqfA/L9P +0NeGRz+ohDQkScPkDWyNPpI+K7N3Vfb1NAqAoZaempyLdiQY1GUwIidoYu2M1ahDPcR YtC0bznxzSTLqp15qsB1I340Na8F/WLrrJv+OkTYVDcjQWWuIV9Txu1cOt1KEpknLWQF 1acA== X-Gm-Message-State: AC+VfDyYvYUd9OPSPWT7lOJjGtfjoxJfWupRj86TmiFjNE1NA4CQt40R sTVtlGxeRhKIp/0d6w+oeFqFKzOEkez4ig== X-Received: by 2002:a25:e056:0:b0:bc2:b993:848f with SMTP id x83-20020a25e056000000b00bc2b993848fmr5145534ybg.35.1686840868448; Thu, 15 Jun 2023 07:54:28 -0700 (PDT) Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com. [209.85.128.173]) by smtp.gmail.com with ESMTPSA id d17-20020a258891000000b00b99768e3b83sm3982828ybl.25.2023.06.15.07.54.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Jun 2023 07:54:28 -0700 (PDT) Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-57045429f76so4856297b3.0; Thu, 15 Jun 2023 07:54:27 -0700 (PDT) X-Received: by 2002:a81:d34f:0:b0:56d:2bab:947e with SMTP id d15-20020a81d34f000000b0056d2bab947emr5000726ywl.43.1686840867726; Thu, 15 Jun 2023 07:54:27 -0700 (PDT) MIME-Version: 1.0 References: <20230615132023.13801-1-andriy.shevchenko@linux.intel.com> <20230615132023.13801-4-andriy.shevchenko@linux.intel.com> In-Reply-To: <20230615132023.13801-4-andriy.shevchenko@linux.intel.com> From: Geert Uytterhoeven Date: Thu, 15 Jun 2023 16:54:14 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 3/5] gpio: aggregator: Prevent collisions between DT and user device IDs To: Andy Shevchenko Cc: Bartosz Golaszewski , Linus Walleij , Alexander Stein , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Bartosz Golaszewski , Andy Shevchenko Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Andy, Thanks for your patch! On Thu, Jun 15, 2023 at 3:51 PM Andy Shevchenko wrote: > 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. Can you please elaborate? How exactly is this possible? Aggregators instantiated through sysfs are named "gpio-aggregator.", and are IDR-based. Aggregators instantiated from DT are named ".". How can this conflict? When instantiated from ACPI? What am I missing? > Signed-off-by: Andy Shevchenko > --- 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); Iff this would solve an issue, it would be only temporarily, until someone instantiates 1024 aggregators through some other means ;-) > mutex_unlock(&gpio_aggregator_lock); > > if (id < 0) { Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds