Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp241704lqe; Wed, 27 Mar 2024 04:39:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWO6U1DbXV+XQGTKMRhHDKDy87A6BFOLA1Sb2r3I/Uel7KVVXMSqiHyVh9fggN96hMscnU4n0tAbCYfmi5sE/jYb+pmmP80lQGv89z/zg== X-Google-Smtp-Source: AGHT+IGnS9/GsQxPyh1OVqpdMwdGHbX+BzlO82DrZsaPXsDjdBTyHJ2n84RercqAt14BAw7TmTey X-Received: by 2002:a17:902:d489:b0:1e2:577:f694 with SMTP id c9-20020a170902d48900b001e20577f694mr341040plg.61.1711539580153; Wed, 27 Mar 2024 04:39:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711539580; cv=pass; d=google.com; s=arc-20160816; b=m4vgKbpdp1V68ELYZmJfglGPOqlgbtm52LOJOdvLmi0fF2qh7MUmEBsgNhYVi6cLUB pyWVsbbn/gbTX9rIVYFR2niO7X2tcGObnYpVNhkqncYmYK3vEK8Sgp/JYO7STh/ENz4R b8FloSNeNbz+T0wqt1iOpGoDSnMRgMuDozb3brxMVkHEg3JEexHVE/H9Cq7/V9Z1vPqW wgg3BmMsqJE4d5oAnzpOfs8sjrzvgVW0xWvQcHZ6KDWbRjQXRM0nJenKKFjPdW6Ipdzs IiOrK2fMeui4BWJbQVmKMcfcHzS8xPtgOeQXAWDrlo96P5jct2M0kWLan3Bv9g7DnGVi 1Nsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=m93ME46lQ7B8wqoBDoWv3GJg3rLMXw/sn+I50eOHnUw=; fh=PR9eR6q2aiscjiGOILTm6MWKFj2Dv12RJ18/pZmqKLg=; b=P98lXxrSuzmWR4s1U1gUL/S9HiqPM32ipKdEjLmrWMTC00EuRGgvvgmfD05k0FyB40 j39ienocAYtTjcQTzC9LzDyN5iv1Y5WrZv+PTJqcYMjdbWcvgdgbypFhdQryR2q/yEz8 pzpdJftJyZSMMMnVpSanVTNoK24BRjlAV7OfCTsLaGbi12qFglnJr8bI+V4pwOAfzB74 OFRmwNKsWqnWFrU0cGc0RDQww6mhzole3lLAi47uBMQJcMV9xmxZBMlxGDG+MMWd9XOc +WwNPP3yeNqY+flYBuPO0ggB5GK8VAu35WrLP+vrSn+zobTMrilcwlj2NyPZHes2qfs1 071A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q8YsY57C; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-crypto+bounces-2938-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2938-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e13-20020a17090301cd00b001dd00449266si9387734plh.280.2024.03.27.04.39.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 04:39:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2938-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Q8YsY57C; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-crypto+bounces-2938-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2938-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2A0CA299B73 for ; Wed, 27 Mar 2024 11:39:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5E06F8665F; Wed, 27 Mar 2024 11:39:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Q8YsY57C" X-Original-To: linux-crypto@vger.kernel.org Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 525A586AC1 for ; Wed, 27 Mar 2024 11:39:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711539569; cv=none; b=krBWkADh1gqqIzKE9i9mMn+9CP3rngy1ZWDGzTFFXwob2acQIAZjqXLDhZi/znDqMdaZa0Gv+cG9SxlYn5J6ouXonnDcWvnpN7qwPo6Y9kDrhxp0vM6Q/XVct1WALdFmZ8ATuzVsdbxPUHohTWHHyYUZagun51E0eag3tTFR2uE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711539569; c=relaxed/simple; bh=pXBzSvnixq/m57ple/gS8ExDn2YvQoVopxlyyxgarts=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NtPsjOzJ3vR+5sO7Zgn4Ck+iDYYY6ppHPmAbbq2MhX8w5UVkayeKq3WBodYvhqmSAvuH2RgFM85vdx62MGBP1g7+k3CB5bRozTpP7CzJeVqRRzN0BgGKoJt4eGEaxqbID2m3ubel4kSfQDNw0pMwF2hFygOC39Dldrqin5pgY8o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Q8YsY57C; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-a466a27d30aso813092166b.1 for ; Wed, 27 Mar 2024 04:39:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711539565; x=1712144365; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=m93ME46lQ7B8wqoBDoWv3GJg3rLMXw/sn+I50eOHnUw=; b=Q8YsY57CPGxlTNbXw0mCdSQaF4kGNDeoIzgCoiXtTEEvLJ0PTbSKOUpXip9pj/BQm+ QitzbpeZ73jRbiBe58DiGPZIY6XS7xTp4syIrwIckzqzWiqtIAdHxW9F38uahyugHMPI NMmBQyZXeeZaJ4WduDruYaCEVGgANCEu2oEJEMEBJsEpwF8Tn0Oakh+cKX4Lk87NWNt+ hDWHP87T6oooIoPlcTnQt7ANhPHYN0DDCn2sksqUF9QuGhPRj1hZT7NYiFV48bMlA/O7 WHTFPjW9WhUAGWuTfJynMyZd7YvB8ilReaKS00A65nv1rkqv/knEu9YIm0nlhFgCdTan 9fhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711539565; x=1712144365; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=m93ME46lQ7B8wqoBDoWv3GJg3rLMXw/sn+I50eOHnUw=; b=BDL9fscq9SwH2USiNGD/2UcASnU6CmV1+keXvb0wpOUnH62um7tFmxFDDu7rgv8LWa 9dch9peW0Lr5OeIp2tP59BhSLeiripCkFiwXkc6fEPQb8vvQkexuAQVAwQZgsSi9L0YN itmqW3JP+p7XNeO7aHkkSkkR7Um2kF5WP1YSUMN5H44ISlUM4VYvKCT4oZsKaoPlZwLm Q0XMPoCfj5N8xQHKyxKYBghwGbo+fI5h3WlfAvEuQf5sl2IDxUFM3sjA/75KofDnJ7+i r65G+3DkRH+zg/IMHVqldAowXrQkd5pntp54yFwsh0+79TNADMNJQy58TcbrvOcremBN C/6A== X-Forwarded-Encrypted: i=1; AJvYcCXUS0LKf2TZN9VQEPyyOhwxeoeEhNSvB7SmREF7ajc/S9LBUlnu3Qjr+maU37IhTPxjNY4jxmvpkpwkowu//W8LQ3XL8AH45KEu03rc X-Gm-Message-State: AOJu0YyVwU6oS7k+plCYeQAbrXQX6QpWVt1Kr+Hr4hd8M3GjW7nlx0h2 gFUXgeF+sfcgFC6P+towUjvloua8MriW3lcRg2644G79FjP33agoiM08xDH4ZUY= X-Received: by 2002:a17:906:b1b:b0:a47:499b:d735 with SMTP id u27-20020a1709060b1b00b00a47499bd735mr745672ejg.14.1711539565301; Wed, 27 Mar 2024 04:39:25 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id la5-20020a170907780500b00a45621ded4bsm5395486ejc.146.2024.03.27.04.39.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 04:39:25 -0700 (PDT) Date: Wed, 27 Mar 2024 14:39:21 +0300 From: Dan Carpenter To: Marek =?iso-8859-1?Q?Beh=FAn?= Cc: Arnd Bergmann , Gregory CLEMENT , soc@kernel.org, arm@kernel.org, Hans de Goede , Matti Vaittinen , Horia =?utf-8?Q?Geant=C4=83?= , 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: References: <20240323164359.21642-1-kabel@kernel.org> <20240323164359.21642-7-kabel@kernel.org> <72bf31c3-337d-4747-8353-639492507a7b@moroto.mountain> <20240327103419.3918953a@dellmb> 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=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240327103419.3918953a@dellmb> On Wed, Mar 27, 2024 at 10:34:19AM +0100, Marek Beh?n wrote: > On Tue, 26 Mar 2024 12:00:25 +0300 > Dan Carpenter wrote: > > > On Sat, Mar 23, 2024 at 05:43:54PM +0100, Marek Beh?n wrote: > > > +/** > > > + * devm_irq_create_mapping - Resource managed version of irq_create_mapping() > > > + * @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 disposed 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 created, or > > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > > > + * 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 = irq_create_mapping(domain, hwirq); > > > + > > > + if (!virq) > > > + return 0; > > > > 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. > > > > 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. > > > > 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 = devm_irq_create_mapping(dev, mcu->gc.irq.domain, irq_idx); > + if (irq <= 0) > + return dev_err_probe(dev, irq ?: -ENXIO, > + "Cannot map MESSAGE_SIGNED IRQ\n"); > > So it handles !irq as -ENXIO. Yeah. But imagine how much easier it would be if devm_irq_create_mapping() returned -ENXIO directly. irq = devm_irq_create_mapping(); if (irq < 0) return dev_err_probe(dev, irq, "Cannot map MESSAGE_SIGNED IRQ\n"); > > I looked into several users who do > virq = irq_create_mapping() > and then reutrn errno if !virq: > > git grep -A 3 'virq = irq_create_mapping' > > Some return -ENOMEM, some -ENXIO, some -EINVAL. > > What do you think? -ENXIO is fine. regards, dan carpenter