Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp180210lqe; Wed, 27 Mar 2024 02:34:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXzNeQI4T+/pG2NyfhwmSCJr6UdSgr7dscZCNWwt2ykVCSJatSTGf3vFTwWmOKE4dO5PncJ9T5SqCZ4APa3yes/nnVyrWNUCd6m8iCFkQ== X-Google-Smtp-Source: AGHT+IGErDJ4lVb0VxQgWcrIbo7v+tJZcoj8Ud41C2FrdmR9AJMmyFc6m4ZcM34hLfT/2qmwHWs/ X-Received: by 2002:a17:907:9709:b0:a4e:9d3:9b94 with SMTP id jg9-20020a170907970900b00a4e09d39b94mr560358ejc.60.1711532069166; Wed, 27 Mar 2024 02:34:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711532069; cv=pass; d=google.com; s=arc-20160816; b=CekNW53T9nRPRLduiHZ9/+HVwgENL//QQiKWtt4vchCOQyI1RguNGGPM8EHz0ZCqH3 IJN4UhYvTAmQOKAhjSOwvMEFAySVooPwGYre2fOC7v1475CMIAwEa3/4lpZ1vaEa3ZiQ 3wjLhvDVynMz/ccsDBr9eHUhCEOsOaALPCNTDM+p7IcFlDUSKQ/4v3ow9rizR1ISVFY0 +3M62oIH3BUzEMsySdQUIvR3T/Kk1Ay3GgI9iCzcQqUaINZEUMWR+2jpJgE9b7zOSqjh X6eX7EbLBT5/SF9YNwmcQMju7G3wdTfSwyXammj0wWnyG/BxD7i3jc1jr5YsZvoSBQMq jDjA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=ljsa7DOMARsDu49YjMIiUAsyMB3Rmb729ch+8IkYpGc=; fh=HB2H/89BDR0Z7FUGm+S7Rsgv+riKz/zv1GafFbMrbxs=; b=cben8hESq6yaGyUFaox6LbpJ6S3Xk1fN+ZoLLeF1Lahr2E+khxzqYy5vKH2Z7wvSvX XAx0+X90usvBQjpNnsSYnH2oL2DPqLvGxkjWF8j1SeqBW9/Ef19Gd3UvSil3AMmk+FS+ BoIgrtHGgqw3fcJXlMXbGsN+nvowrx9PFUq8jA1XGMrMvCb9lN1R46UQ7N4//K1/uUcQ rvzV4op0qRE05ZzKU/1appldbWPUTFemDVqpfx9UjM1ZV4ziOlTkLnnpOwo2hKGFUzxZ UKMWNd9ixr/XWGH5FeDHqOPwrN7V1brzxuR2PVP5HGB7tScuxao5OF7MklVVV3NZI2Da Ihuw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=KyzhW8nQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-2937-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2937-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id j15-20020a170906474f00b00a4d4254c397si2096733ejs.323.2024.03.27.02.34.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 02:34:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2937-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=KyzhW8nQ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-2937-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2937-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D9BC21F2815D for ; Wed, 27 Mar 2024 09:34:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 543E6125C9; Wed, 27 Mar 2024 09:34:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KyzhW8nQ" X-Original-To: linux-crypto@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1329B36E for ; Wed, 27 Mar 2024 09:34:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711532065; cv=none; b=GwSO3/tqH98Yq75p8NZKmybSBsMvjkeggClR+tYPAi+Iw///j17uL0QGjnIkX28q8vGsGf4hiL2emd+wVN7q5NLf+57u1e4I/nx88PglHRwg5NLH9/fZqDl9m4T9+Z1GzpRcIC8VMcV+Hd0Rn9Ip/MMGZCOOJb12DhayfrT9p/Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711532065; c=relaxed/simple; bh=XOchda7odJ/zW6uaAUv9JGZx87HRnkrBQzCLGmin4Dw=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xji8YEEdIg5m5v87ZYcFK3GkgVvQWW+dU/i8eE05lVEzFQRPkI9BHjnJBLt45fpLCo0w1U9aORilIpcrvcwqFwqhpEIE6qgD28MGJo5UcBi1hoA3Uf0hnKzOakCBBULFMkNhbqUBBFiiS30VfmeTzfQMc4j4EG4uzhefBJUaUrE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KyzhW8nQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 363F1C43390; Wed, 27 Mar 2024 09:34:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711532064; bh=XOchda7odJ/zW6uaAUv9JGZx87HRnkrBQzCLGmin4Dw=; h=Date:From:To:List-Id:Cc:Subject:In-Reply-To:References:From; b=KyzhW8nQpffWoB4I/r3U7sDPkbl9c2jA0qOvFbYuE+RveNigmNv4z3wSkRTbPLcbQ gJsFalp8TAIJYTys0jclVwt+KkW2+21zPfii39f44hIsXBYjlM01aJ0MinTHZE0TXE 2Av2yHlBqgCC0ehpERNrcf1Dy1wFcdt8nhBsrN7ZEmIWmZvZXhP05hGdGBUXMkhvmO ZJNYAu7QkSrEGNoTadYhovLm8gfPEH7qoiPS6laVr0oGXv4vGi+FGqLV29YyiWb/eQ Wry0PyjKgPIiXIYbnEBEwHW/MQfQMaXWP5xZB77CJWlEpalv4h3dZyjQLU19Qjg3rD oKmQAC7m+SRJg== Date: Wed, 27 Mar 2024 10:34:19 +0100 From: Marek =?UTF-8?B?QmVow7pu?= To: Dan Carpenter Cc: Arnd Bergmann , Gregory CLEMENT , soc@kernel.org, arm@kernel.org, Hans de Goede , Matti Vaittinen , Horia =?UTF-8?B?R2VhbnTEgw==?= , Pankaj Gupta , Gaurav Jain , linux-crypto@vger.kernel.org, Herbert Xu Subject: Re: [PATCH v5 06/11] devm-helpers: Add resource managed version of irq_create_mapping() Message-ID: <20240327103419.3918953a@dellmb> In-Reply-To: <72bf31c3-337d-4747-8353-639492507a7b@moroto.mountain> References: <20240323164359.21642-1-kabel@kernel.org> <20240323164359.21642-7-kabel@kernel.org> <72bf31c3-337d-4747-8353-639492507a7b@moroto.mountain> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.39; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, 26 Mar 2024 12:00:25 +0300 Dan Carpenter wrote: > On Sat, Mar 23, 2024 at 05:43:54PM +0100, Marek Beh=C3=BAn wrote: > > +/** > > + * devm_irq_create_mapping - Resource managed version of irq_create_ma= pping() > > + * @dev: Device which lifetime the mapping is bound to > > + * @domain: domain owning this hardware interrupt or NULL for default = domain > > + * @hwirq: hardware irq number in that domain space > > + * > > + * Create an irq mapping to linux irq space which is automatically dis= posed when > > + * the driver is detached. > > + * devm_irq_create_mapping() can be used to omit the explicit > > + * irq_dispose_mapping() call when driver is detached. > > + * > > + * Returns a linux irq number on success, 0 if mapping could not be cr= eated, or =20 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^= ^^^^^ >=20 > > + * a negative error number if devm action could not be added. > > + */ > > +static inline int devm_irq_create_mapping(struct device *dev, > > + struct irq_domain *domain, > > + irq_hw_number_t hwirq) > > +{ > > + unsigned int virq =3D irq_create_mapping(domain, hwirq); > > + > > + if (!virq) > > + return 0; =20 >=20 > What is the point of returning zero instead of an error code? Neither > of the callers that are introduced later in the patchset use this. >=20 > I understand that it matches some of the other legacy irq function > behaviors, but I think we are trying to move away from that because it > just leads to bugs. >=20 > Since we don't need the zero now, let's wait until we have a user before > introducing this behavior. Then we can add a new function that returns > zero, but we'll still encourage people to use the standard error code > function where possible. And at the same time, when we do introduce the > zero is an error code, function you should contact > kernel-janitors@vger.kernel.org so someone an write a static checker > rule to detect the bugs that result from it. Hi Dan, the first user of this function is the very next patch of this series, and it does this: + irq =3D devm_irq_create_mapping(dev, mcu->gc.irq.domain, irq_idx); + if (irq <=3D 0) + return dev_err_probe(dev, irq ?: -ENXIO, + "Cannot map MESSAGE_SIGNED IRQ\n"); So it handles !irq as -ENXIO. I looked into several users who do virq =3D irq_create_mapping() and then reutrn errno if !virq: git grep -A 3 'virq =3D irq_create_mapping' Some return -ENOMEM, some -ENXIO, some -EINVAL. What do you think? Or should I send this driver without introducing this helper for now? Marek