From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C5966C27C4F for ; Wed, 26 Jun 2024 16:17:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Date:Cc:To:From :Subject:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=inivZe8nYcsjwruEn7HQhkR9gckTm2eOYDHgd5IMYMk=; b=T1lb7/2YvwYwLbGPzLHBd18KP1 FcP1ngyXxMTY1wAHWo6UttGWq6nVug9irn9J12AbME0HdJFc1XvEEyvJlC7T2+29S/WM5AfXXHg/o pd2M7EYkqdqTyLLPvxr2Vf2InttSQQSyIIjPI1RjfiQw+v9Nb/LQ+8vUuhaJtwg6PrBeTZChGgA0Z FaEnGOkwluC5CcRBYW9du77HwVzhEA4UpqOCTLDGHghm2H18bSLPDowPI7BL/0WY6HS52N5fRhjig erDBEI4mQDymzpC7KMxj0+68mjkeKvAPFM5VaGCg5nRmK0hOt+WS8qle8vlbtUsltuZKjNHEEzDYr Xi0TKXPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMVL0-00000007Z3X-2Df5; Wed, 26 Jun 2024 16:17:38 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMVKt-00000007Z0B-19KV for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2024 16:17:32 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sMVKc-0008Dt-Ad; Wed, 26 Jun 2024 18:17:14 +0200 Received: from [2a0a:edc0:0:900:1d::4e] (helo=lupine) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sMVKa-005ASZ-1K; Wed, 26 Jun 2024 18:17:12 +0200 Received: from pza by lupine with local (Exim 4.96) (envelope-from ) id 1sMVKZ-000FZ7-39; Wed, 26 Jun 2024 18:17:11 +0200 Message-ID: <5500e3d44be69f5bc843e5b2159f6d0aead24ff9.camel@pengutronix.de> Subject: Re: [PATCH RFC 1/3] reset: replace boolean parameters with flags parameter From: Philipp Zabel To: Uwe =?ISO-8859-1?Q?Kleine-K=F6nig?= Cc: Kunihiko Hayashi , Masami Hiramatsu , Lad Prabhakar , Geert Uytterhoeven , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@pengutronix.de Date: Wed, 26 Jun 2024 18:17:11 +0200 In-Reply-To: References: <20240621-reset-get-deasserted-v1-0-94ee76fb7b7d@pengutronix.de> <20240621-reset-get-deasserted-v1-1-94ee76fb7b7d@pengutronix.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4-2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: p.zabel@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240626_091731_337531_A95110E3 X-CRM114-Status: GOOD ( 22.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Uwe, On Sa, 2024-06-22 at 09:47 +0200, Uwe Kleine-K=C3=B6nig wrote: > Hello Philipp, >=20 > I like the idea in general. Just a detail concern down below. Thank you, much appreciated. > On Fri, Jun 21, 2024 at 04:45:02PM +0200, Philipp Zabel wrote: > > @@ -999,8 +1001,9 @@ static struct reset_controller_dev *__reset_find_r= cdev(const struct of_phandle_a > > =20 > > struct reset_control * > > __of_reset_control_get(struct device_node *node, const char *id, int i= ndex, > > - bool shared, bool optional, bool acquired) > > + enum reset_control_flags flags) > > { > > + bool optional =3D flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL; > > bool gpio_fallback =3D false; > > struct reset_control *rstc; > > struct reset_controller_dev *rcdev; > > @@ -1065,7 +1068,7 @@ __of_reset_control_get(struct device_node *node, = const char *id, int index, > > } > > =20 > > /* reset_list_mutex also protects the rcdev's reset_control list */ > > - rstc =3D __reset_control_get_internal(rcdev, rstc_id, shared, acquire= d); > > + rstc =3D __reset_control_get_internal(rcdev, rstc_id, flags); >=20 > If RESET_CONTROL_FLAGS_BIT_OPTIONAL was passed to > __of_reset_control_get(), you're forwarding it to > __reset_control_get_internal(). But the latter doesn't do anything with > that flag. I wonder if the API would be still less prone to error if > you'd filter out RESET_CONTROL_FLAGS_BIT_OPTIONAL before passing to > __reset_control_get_internal() and in __reset_control_get_internal() add > a check for unsupported flags. Yes, I'll do that. For every enum value with the optional bit set, there is a corresponding value without it. > > out_unlock: > > mutex_unlock(&reset_list_mutex); > > @@ -1096,8 +1099,9 @@ __reset_controller_by_name(const char *name) > > =20 > > static struct reset_control * > > __reset_control_get_from_lookup(struct device *dev, const char *con_id= , > > - bool shared, bool optional, bool acquired) > > + enum reset_control_flags flags) > > { > > + bool optional =3D flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL; > > const struct reset_control_lookup *lookup; > > struct reset_controller_dev *rcdev; > > const char *dev_id =3D dev_name(dev); > > [...] > > @@ -1422,7 +1423,7 @@ EXPORT_SYMBOL_GPL(of_reset_control_array_get); > > * Returns pointer to allocated reset_control on success or error on f= ailure > > */ > > struct reset_control * > > -devm_reset_control_array_get(struct device *dev, bool shared, bool opt= ional) > > +devm_reset_control_array_get(struct device *dev, enum reset_control_fl= ags flags) > > { > > struct reset_control **ptr, *rstc; > > =20 > > @@ -1431,7 +1432,7 @@ devm_reset_control_array_get(struct device *dev, = bool shared, bool optional) > > if (!ptr) > > return ERR_PTR(-ENOMEM); > > =20 > > - rstc =3D of_reset_control_array_get(dev->of_node, shared, optional, t= rue); > > + rstc =3D of_reset_control_array_get(dev->of_node, flags); >=20 > Is it an error if the new devm_reset_control_array_get() is called > without RESET_CONTROL_FLAGS_BIT_ACQUIRED in flags? I'd be inclined to consider this not-an-error. There is one user of of_reset_control_array_get_exclusive_released(), so it should work in theory. Of course nobody is using both devres and the acquire/release API at the same time, and there is no devm_reset_control_array_get_exclusive_released() wrapper. regards Philipp