Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp238351lqh; Mon, 6 May 2024 18:29:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVNmO2OinnytQlUGSSH3KOf8BJviE6gB4PnlMIivIJeJLPrt8S58x30jwE/UXlrqcLwPBomP7+GHJynTN6wBzlT12bsWhr7tSqQg/RqUQ== X-Google-Smtp-Source: AGHT+IGHIHc6L9SnvRBu2h7n/qOteLca1uLi+GD+FRDbo53VAcF0z3/q29TkXLlzJIvejGRav3r6 X-Received: by 2002:a17:90a:c687:b0:2ab:8e59:9da9 with SMTP id n7-20020a17090ac68700b002ab8e599da9mr1913592pjt.6.1715045356521; Mon, 06 May 2024 18:29:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715045356; cv=pass; d=google.com; s=arc-20160816; b=A0IlqdftVlIxeP4C9DyXsOnjCNhHF/mx3Ya6CpqTrEWMVIOGiraynNN348psRGaDjo qV4ZgDlXiMml14xCw/ISa18t9l9IPdbt5vwoe+rxeWwTf+F7FKoa2qSM3IrR+DIrUzay bpp8xNbAybFO/2hxNdHeeW9azkzJugNkpclPtkZTw25cU3zeHGMo/rlbOF7j4wcLI7vf +oVXwCqtYP1fL8wjATj6r5Bb2C7E92ecqn4fc+7FKeA24AKTQfgc5/T/hXUeeShWMlmU bhS7TNk1rplYNZKZqmaHmPYs39ttV71PVQFx8RlfA/tHri+PSkpaHcgN5VeUuZDoptAT NW3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=K2bojeD9uRKoLXe7tPcnggryO2ahglKu+H+NttyDYEg=; fh=0lz/aKQe52PRv4nb1E8kpzDsCn7RqKY2nm7XDwxV3/E=; b=WRzQBprnxjvMDij06kwl9iLdIw/8BCWwdc6QM9pTdt2ZdHVIo0DSoj6TXz8QBR4czK 8NC0KzgvgDcGbV/d5xMxbma5KVrJImELyRwhqzF3uQ/vnBuoPKUB7Ep1eY67DXN5fxQB m9mw8PwcS3ah5jwZFSol4on5oIhu38OWevnecjlylX2YVBNNVueVtWv9ifu1H5dkp3JD 8s7wp+NwyqQjnFyLUBsDa5dI1Z0reCsMlApuRbhaRDLmDbu2q06T1gQCH7u+edT/7BeB aj9F1KUp8S4dI2sHtdlGEZY2pK+mTqNw5bX4sxZ2bVin61mTROvz7NYXK1jFnQPPgpB5 dpWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-170542-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170542-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ca6-20020a17090af30600b002b21c83ddc9si5419722pjb.150.2024.05.06.18.29.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 18:29:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170542-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; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-170542-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170542-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com 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 39EDD285B95 for ; Tue, 7 May 2024 01:22:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49AD91C32; Tue, 7 May 2024 01:22:42 +0000 (UTC) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (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 4E06015D1 for ; Tue, 7 May 2024 01:22:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715044961; cv=none; b=O3ljUWm2OUUsm2F/TrjI5c/lovEx+GauEml6O3lRDPBVnmk0KOeIzgCY0GxAABT9aV8GqeFOid2BXukoN5X13fYahD+swmhpwO0z1sJgFK94y9KpaLpFddMa/WQEC051TOm/R4NfTxf31U3dJpXkNJnU3DJQfwvAiaIzmVlnsU4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715044961; c=relaxed/simple; bh=msMXKZ8d4w9YCR4MZDFG1QzZzGho5rw0uxxE32K+YXE=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=bd7XRx87QW7FofifHAtfk3sIMh4tuQiWoxx376n42qRqRbWsZjdXl8637rW6qXhfVLjif+7vHe6ygsEr6flDUsNAJFY97A3vEqmaYtnIood3OM63hS6/pTXKovwxAqFFm6CXqp0ODxJyiuTRyedvJQA5Xffo0Vi4GknvS+6KUTI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.255 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4VYL5y3HnVz1RCNY for ; Tue, 7 May 2024 09:19:18 +0800 (CST) Received: from kwepemi500008.china.huawei.com (unknown [7.221.188.139]) by mail.maildlp.com (Postfix) with ESMTPS id 6C0721403D1 for ; Tue, 7 May 2024 09:22:36 +0800 (CST) Received: from [10.67.109.254] (10.67.109.254) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 7 May 2024 09:22:36 +0800 Message-ID: <887d424c-c6b5-e5c7-21d3-9b920272fbc3@huawei.com> Date: Tue, 7 May 2024 09:22:35 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH] genirq/irqdomain: Clean code for __irq_domain_create() Content-Language: en-US To: Thomas Gleixner , References: <20240430093353.1919862-1-ruanjinjie@huawei.com> <87pltyrf9l.ffs@tglx> From: Jinjie Ruan In-Reply-To: <87pltyrf9l.ffs@tglx> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500008.china.huawei.com (7.221.188.139) On 2024/5/7 2:01, Thomas Gleixner wrote: > On Tue, Apr 30 2024 at 17:33, Jinjie Ruan wrote: >> Introduce irq_domain_alloc_name() function to handle name allocation for >> the irq domain, add "out_free_domain" label to free the irq domain, and >> when "is_fwnode_irqchip(fwnode)" is true, "domain->fwnode = fwnode" is >> the common action, so do it outside the switch, which can make the code >> more clearer. > > First of all changelogs should describe the reason for the change and > not enumerate a list of things which the patch does. The latter can be > seen from the patch itself. Thanks for the good advice,subsequent patches will learn from the experience. > >> +static int irq_domain_alloc_name(struct fwnode_handle *fwnode, >> + struct irq_domain *domain, >> + int unknown_domains, char *in_name) >> +{ >> + char *name; >> + >> + if (fwnode == NULL) { >> + if (unknown_domains) >> + domain->name = kasprintf(GFP_KERNEL, "unknown-%d", >> + unknown_domains); >> + else >> + domain->name = kstrdup(in_name, GFP_KERNEL); >> + if (!domain->name) >> + return -ENOMEM; >> + goto out; >> + } >> + >> + /* >> + * fwnode paths contain '/', which debugfs is legitimately >> + * unhappy about. Replace them with ':', which does >> + * the trick and is not as offensive as '\'... >> + */ >> + name = kasprintf(GFP_KERNEL, "%pfw", fwnode); >> + if (!name) >> + return -ENOMEM; >> + >> + domain->name = strreplace(name, '/', ':'); >> + >> +out: >> + domain->flags |= IRQ_DOMAIN_NAME_ALLOCATED; >> + return 0; > > This function is horrible. The only shared thing here is the > domain->flags manipulation. I'm not seeing how this is an improvement. Yes, the IRQ_DOMAIN_NAME_ALLOCATED flag is shared, the purpose of this change is to make the code that allocates the domain name in the __irq_domain_create() function look like it doesn't take up too much space, so it looks cleaner. > > Thanks, > > tglx