From patchwork Mon Jan 29 10:16:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 193386 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp469660dyb; Mon, 29 Jan 2024 02:17:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXTrMGO4SQSbm5ByzjEYVkoI6BXjvzGL9+b4KQHvv8Cj80Rp1rwi/E1oPwbBo1dvCpy4YA X-Received: by 2002:a17:906:560a:b0:a35:74c1:272d with SMTP id f10-20020a170906560a00b00a3574c1272dmr2584136ejq.73.1706523440538; Mon, 29 Jan 2024 02:17:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706523440; cv=pass; d=google.com; s=arc-20160816; b=SXDo52BMIfzkEh/p5k+XYRJvBbbuHpOEDPsUD2QZZWOUcjcEMy8IO5T+aAkazw3Bjg q+esxobneke79ikn5DfSakyPQnri9M8mh/KBttKluAO6HtfxphhRRajhvMFyVDo5owQA 1uUr/cojHgs9qHzywO7ywt40K5dRM9Xct8CEUKMt1pGPP3XmgM1Wzjy/rRhpVGqQTdJw y04/yleB2SQ4E/WlaSEoHEGmwAkN54XEXPfH49JtPis3dZg8g0JztJcObnPVmya0goAz H3bYPg5TvRKasg/5052PtXxwzVLXT0RcggsNHKtoYOI6K1/67c08nw3Mgc3eekP5+giC PqHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=6k+lQZriCq0HWtXwAcVFYcKM+F9ivNEC2bp4CEGAbA4=; fh=R5BFd4r1kPzKk+3LVRWc8sNJU8jvYGHmUZune8FkLC8=; b=mn9HfTU8PphcQdqobP4nR7LRI1fawZRKfH+uw1Qc+1cNCvdUXrOgvea/Pz/gevCChc 25iHtmfdfjTU0yYmnN7kOJmOetdwWBLeSC5L9Z33PnmW1Ld6gLEaTt+3b9tcVrTAecbx YdKFt+TpAq9ADNJ9RTHlV6xnovGrS8nhxOioRPInviu1CjNl9qpSrm76x1kX6J+1Csfx pRa3h/JBNIOibQqvKiltPQHC7zvl6HbWsLz+RzAC7eMLS22Eo2qPCiwJbmF/3f53f+nC b7dzn71bucFmOsbts5qyPjZ1m7b8U8u+uy9B/PNFryGM9b0vLta0Y59d55TFkPDQIdqa Ozfw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Q7zCIc8K; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-42525-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42525-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z6-20020a1709060f0600b00a31619d6350si3239540eji.493.2024.01.29.02.17.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 02:17:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42525-ouuuleilei=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=pass header.i=@linutronix.de header.s=2020 header.b=Q7zCIc8K; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-42525-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42525-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 056261F22BB0 for ; Mon, 29 Jan 2024 10:17:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88BE258105; Mon, 29 Jan 2024 10:16:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Q7zCIc8K"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0oR/7VUd" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 05A6757867; Mon, 29 Jan 2024 10:16:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706523409; cv=none; b=h1BcOdkplkPnzsnhRTsI/iyYTTvHaueUqhco5JVUoJftJ9HGK0Vha6cIrYj5BfwmcCuAFGH2W03q2f1qO7ZpVSe10iu5GQJNmqyMmIdMhpHpw/zxfkGMS/lIzn7jsGnvh6Wauj/7hyrVEE1uv1wgEZ6JPtZ+2UI/9zD3imCfPF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706523409; c=relaxed/simple; bh=MMDGCwc+FSOicV5E+PeIAyDklNGTkpiv2XznQeMswrw=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=JxUGgptoqvjvrpbjZvNBnjCBVDwMFk9Tk7eRMzTmPHJndHHb4RUXL4n7FddpzAYbsmoBCwN4nMHblFTorrbT83xnrLi7dCr0xF1DRKuiznrVsZaj49+bQEiZQ20AkGLRm31dfKGAhYupnmTsTR03KjX/xISqCh60Qt75mq1N4LI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=Q7zCIc8K; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=0oR/7VUd; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Mon, 29 Jan 2024 10:16:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1706523405; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6k+lQZriCq0HWtXwAcVFYcKM+F9ivNEC2bp4CEGAbA4=; b=Q7zCIc8KWm1il92nA5SDg11i5odaPU3F9mNB15aE/XVHkl8k/1WXnnQYjjsie1FZnuNBp3 sZ2A2hb6s9BDUygWMBXzGK5apr3p+SD+TkOwrMDAptQF6iu/8ej0gKuMq2L14hGOAuB+dU xAFCKsLkJcSW+6Fk7eTnm0oGH/PwFQq5dQitJIrmjwHGGVH/W7t83IvUv3WcJB4HB5v4Wp cRMwfK8ybRZu+eOWs608uftZp5BRriQrUHih7C93ZBgNCwgLyym38mtFHrtT1e1zfy8yIo gf9ckbtIImhbkK5fgoW0KIDIp5qiG3FqwcKHbs2W3W2TcWyKX8Ey+1vu/v2BGw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1706523405; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6k+lQZriCq0HWtXwAcVFYcKM+F9ivNEC2bp4CEGAbA4=; b=0oR/7VUdjSKLdHHxSYYISUIc4RIkG1L2JyaPTQXGbb+oUJOmLiuJqagz3MMouSpIf3GC/z gYWlExnGSWjytICA== From: "tip-bot2 for Bartosz Golaszewski" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] genirq/irq_sim: Shrink code by using helpers Cc: Bartosz Golaszewski , Ingo Molnar , Thomas Gleixner , Nathan Chancellor , x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20240122124243.44002-5-brgl@bgdev.pl> References: <20240122124243.44002-5-brgl@bgdev.pl> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170652340477.398.6421562413831650962.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789419522941100632 X-GMAIL-MSGID: 1789419522941100632 The following commit has been merged into the irq/core branch of tip: Commit-ID: aafd753555c0ecb9c7ce11ff14429a34c8c0a14b Gitweb: https://git.kernel.org/tip/aafd753555c0ecb9c7ce11ff14429a34c8c0a14b Author: Bartosz Golaszewski AuthorDate: Mon, 22 Jan 2024 13:42:43 +01:00 Committer: Ingo Molnar CommitterDate: Mon, 29 Jan 2024 11:07:57 +01:00 genirq/irq_sim: Shrink code by using helpers Use the new __free() mechanism to remove all gotos and simplify the error paths. Signed-off-by: Bartosz Golaszewski Signed-off-by: Ingo Molnar Cc: Thomas Gleixner Cc: Nathan Chancellor Link: https://lore.kernel.org/r/20240122124243.44002-5-brgl@bgdev.pl --- kernel/irq/irq_sim.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c index b0d50b4..38d6ae6 100644 --- a/kernel/irq/irq_sim.c +++ b/kernel/irq/irq_sim.c @@ -4,6 +4,7 @@ * Copyright (C) 2020 Bartosz Golaszewski */ +#include #include #include #include @@ -163,33 +164,27 @@ static const struct irq_domain_ops irq_sim_domain_ops = { struct irq_domain *irq_domain_create_sim(struct fwnode_handle *fwnode, unsigned int num_irqs) { - struct irq_sim_work_ctx *work_ctx; + struct irq_sim_work_ctx *work_ctx __free(kfree) = + kmalloc(sizeof(*work_ctx), GFP_KERNEL); - work_ctx = kmalloc(sizeof(*work_ctx), GFP_KERNEL); if (!work_ctx) - goto err_out; + return ERR_PTR(-ENOMEM); - work_ctx->pending = bitmap_zalloc(num_irqs, GFP_KERNEL); - if (!work_ctx->pending) - goto err_free_work_ctx; + unsigned long *pending __free(bitmap) = bitmap_zalloc(num_irqs, GFP_KERNEL); + if (!pending) + return ERR_PTR(-ENOMEM); work_ctx->domain = irq_domain_create_linear(fwnode, num_irqs, &irq_sim_domain_ops, work_ctx); if (!work_ctx->domain) - goto err_free_bitmap; + return ERR_PTR(-ENOMEM); work_ctx->irq_count = num_irqs; work_ctx->work = IRQ_WORK_INIT_HARD(irq_sim_handle_irq); + work_ctx->pending = no_free_ptr(pending); - return work_ctx->domain; - -err_free_bitmap: - bitmap_free(work_ctx->pending); -err_free_work_ctx: - kfree(work_ctx); -err_out: - return ERR_PTR(-ENOMEM); + return no_free_ptr(work_ctx)->domain; } EXPORT_SYMBOL_GPL(irq_domain_create_sim);