Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2849606rdh; Wed, 27 Sep 2023 15:01:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE6NSouYnZZqbHPbn91cah1LRSVtBUhf1m+UqZFpJEkKANaAGKYoo8mxMKEil/Tmr3XRJdP X-Received: by 2002:a17:90b:3644:b0:26d:ae3:f6a7 with SMTP id nh4-20020a17090b364400b0026d0ae3f6a7mr2998839pjb.21.1695852113753; Wed, 27 Sep 2023 15:01:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695852113; cv=none; d=google.com; s=arc-20160816; b=zLKKoxZiD/+35UNsvNCzTIxmVWiLbyAxIeba+A3N3PLMcBdp85eEdj21W9XPu+81nQ AyDvr7v/kIaQJUxR58FdSzkOZFPeNj4qHQNKHRxjkUrg+cUDM+BWOFjsBPwUtVYM8B2l Je2aOI6u6FG/Nm854lVK7CVNBs9LsWS9jcOXG7fRJqUkqCPUB9NC9f6g19rV/dL/1ync iqhYm7iAwZFS//1jQA1Ijj5Gv2GaO/ucuKG+zriRt/2ShbOzaOSb+6/B8Kpky5Mo42VF NQxQamr0AMJSneaV2NlVx9oGmJs3pwALXwKCLhZ+Bj8jQLLgsw9rvbmcV+6UsTDkC9mz /Pyg== 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 :dkim-signature; bh=TBnyuiDOj3yAHdZQ44pdmLniIewRmVISdqXbyoGpKk0=; fh=OMyGNThDLEyrENz31ntd+z2pAgwbwtUofxYhJ1gVUJw=; b=CBGksgEdXxKzftA2QD6BBqfmxQbusbJ+cBp7vm7PTfpQQGDIaisQ0GWwSRy1b8DXmY iE2zadawRhiM6/50uQfzCh6OgZY9YIy/xfkjdwfaJ8FFTDg9ARCeZmvrp0+qbjOONTOw EDWNGyGotwnDEKXr6/uUMOsHgOn8HMQF301t8haqm0kQI3ZEM/rWWnvyiMArYqHqwHA5 gwX2YTV5Gy3R99eB+P7EtndEdWETai7OR02jCCkXBXULLfF/VdzUxztiehd26cZT+zeW UKHrtyMPgAuwoRbyVQOceKLK7efcnu9tI8nxJd6Ln1u5cb1amJ20kQYXXBY0+pHtjYfj PMXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TZGhz3D9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id c8-20020a17090ad90800b0027749a98349si10146808pjv.4.2023.09.27.15.01.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 15:01:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TZGhz3D9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 21B3F81EE2E5; Wed, 27 Sep 2023 07:02:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232030AbjI0OCO (ORCPT + 99 others); Wed, 27 Sep 2023 10:02:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231758AbjI0OCN (ORCPT ); Wed, 27 Sep 2023 10:02:13 -0400 Received: from mail-yb1-xb30.google.com (mail-yb1-xb30.google.com [IPv6:2607:f8b0:4864:20::b30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B84E910A for ; Wed, 27 Sep 2023 07:02:11 -0700 (PDT) Received: by mail-yb1-xb30.google.com with SMTP id 3f1490d57ef6-d89ba259964so3040299276.2 for ; Wed, 27 Sep 2023 07:02:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695823331; x=1696428131; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=TBnyuiDOj3yAHdZQ44pdmLniIewRmVISdqXbyoGpKk0=; b=TZGhz3D9g85w+FGYnx1rBvQ+Kal7RELhFpKLXL1BCPDdRX/yiDDBhOzZqbQOImw0fX YHdADvGt2+kbguBEnlYKB9sNVIx9lelr4QqjDTwqFR+UTn8/79IAu1TRYfWTz7aOpCeB hP2H0G0bQQNOcbBX6RpLH9jLtRjy6xSqqFXOYlspmYNNSPmmWhijfR9Nm02QFJWzbCCI RuBPdKtbZDYkRg0F8qUqV+Zl1+W7o0wZhwRdNrP7qUw9zpCyT8St/KgmHTwmF7ZCEB8Z VCXlkpJPwIcQY1vxt4ZCz6PvRcI9YC6p3bk1A2hFQDRxdgDEeLJZs5ydr6N4Ef8vA+KM gK5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695823331; x=1696428131; 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=TBnyuiDOj3yAHdZQ44pdmLniIewRmVISdqXbyoGpKk0=; b=siS+WByakBVD9tZzJvq0iexn3pPaAqKgpe5yHGhcV5NvylscRmg4PzGKvCdZIGkX8J frY4ah8xLQ6M2FXop6eWsOHeLL6pIxaXhrEyv0D+jVcfAGjt8ExO5g1M6wwzBmrMWv04 5vslctZvFPRDgfiHUwXgLJEjsPTLjja74qPagAUXKnhGXYkv+u/GXw9a1vxdjdGE2wV7 bDeVi63AInJM2GJdUkWccmEmZyq1rjeUMyLRgQpdz1WdE7/pMuzC7RU2BuKXsGAxyS5s 4TIxwr9UPrTywQeY/fpTURB6WrVhPcWLaZ0ALjewLUyzTE9EKrV8Wc8sJNO7YkuGoAV0 Ja/g== X-Gm-Message-State: AOJu0YyWjENZBR0wemuB4nAt4wqkj8bksFLPVV+Pqn60IJ8Ut2FVqWXD g0Z5rWs+4gCq1+wtFO5k+o7Ypl4FL99v0ZWFGcfLJA== X-Received: by 2002:a05:6902:4f2:b0:d4b:6a0:fe2b with SMTP id w18-20020a05690204f200b00d4b06a0fe2bmr2221423ybs.36.1695823330766; Wed, 27 Sep 2023 07:02:10 -0700 (PDT) MIME-Version: 1.0 References: <20230924-pxa-gpio-v1-0-2805b87d8894@skole.hr> <20230924-pxa-gpio-v1-1-2805b87d8894@skole.hr> In-Reply-To: From: Linus Walleij Date: Wed, 27 Sep 2023 16:01:58 +0200 Message-ID: Subject: Re: [PATCH RFC 1/6] ARM: pxa: Convert Spitz OHCI to GPIO descriptors To: Andy Shevchenko , Kent Gibson Cc: =?UTF-8?Q?Duje_Mihanovi=C4=87?= , Daniel Mack , Haojian Zhuang , Robert Jarzmik , Russell King , Alan Stern , Greg Kroah-Hartman , Bartosz Golaszewski , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, linux-gpio@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 27 Sep 2023 07:02:27 -0700 (PDT) On Mon, Sep 25, 2023 at 9:30=E2=80=AFAM Andy Shevchenko w= rote: > > + if (pxa_ohci->usb_host) > > + gpiod_put(pxa_ohci->usb_host); > > Linus, Bart, do we have misdesigned _optinal() GPIO APIs? > > In GPIOLIB=3Dn, the above requires that redundant check. Shouldn't we rep= lace > gpiod_put() stub to be simply no-op? You mean the WARN_ON(desc) in gpiod_put() in the static inline stub version? I thought about it for a bit, drafted a patch removing them, and then realized the following: If someone is making the gpiolib optional for a driver, i.e. neither DEPENDS ON GPIOLIB nor SELECT GPIOLIB, they are a quite narrow segment. I would say in 9 cases out of 10 or more this is just a driver that should depend on or select GPIOLIB. I think such drivers should actually do the NULL checks and not be too convenient, the reason is readability: someone reading that driver will be thinking gpios are not optional if they can call gpiod_set_value(), gpiod_put() etc without any sign that the desc is optional. If the driver uses [devm_]gpiod_get_optional() the library is not using the stubs and does the right thing, and it is clear that the GPIO is *runtime* optional. But *compile time* optional, *combined* with runtime optional - I'm not so happy if we try to avoid warnings around that. I think it leads to confusing configs and code that looks like gpiolib is around despite it wasn't selected. If the code isn't depending on or selecting GPIOLIB and still use _optional() calls, it better be ready to do some extra checks, because this is a weird combo, it can't be common. Could be a documentation update making this clear though. What do you other people think? Yours, Linus Walleij