From patchwork Tue Sep 12 08:55:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 138208 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9ecd:0:b0:3f2:4152:657d with SMTP id t13csp440559vqx; Tue, 12 Sep 2023 07:19:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFh8zuEjOIzQh3wn6KQpiGDB8K3ga0LxuRA9CsAViVEBj6dDFtjZim48Jo2ZhBS/9aihEqS X-Received: by 2002:a17:902:c945:b0:1bf:25a0:f874 with SMTP id i5-20020a170902c94500b001bf25a0f874mr15895891pla.65.1694528345228; Tue, 12 Sep 2023 07:19:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694528345; cv=none; d=google.com; s=arc-20160816; b=DahEbN2Ei6KspFOT48kCfu+Qi7DWYekUulrvcmQxVST5Sf0mzqAqhFeY66IFlJ1p+6 eFOdeCpZ0pIERPx45aR+p0Mwr1chzy+2gp0xH60PtWEdrfES/fTCicGoAnYrOZTOSI5c JH6QK0fqrP0L8bFtowLJ5UY8fk6D8KuVfxbQ4fnB0+Vh3U/kid9r2hF5YOQFWoEkw/qe Pr9TSadaShg6PQ/24MpxSAvfuLzFs0V7Caw+/s5BH+ZTzETIHQ6axTSBGI6cTHMSyukY hcnn6Ypp+arfJbRay+8w/lLC9MDEA1TnLttlZ5jq7PdAgvbGmAWhc5x+3pq93kbewATr Ww0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P0GSkSsBN1wyMRXDMHKAiDApaGJ4YO7Sk/7sv4md1Ps=; fh=jelMaxxYL7iVN5WTJYLdEcOSQCZkPWCTA7Z8F6/jemw=; b=KTHhrojGaI5VB7i39raXDCJEaiwhZIfh1SgZ+NsghmzQtpRJhy3DkAEugRbKRTK4pa o2a7NZiQp+6oJslfNWjKvGMA7uVGczZTPHy9ic//nAafCteIhJDoh6pGIjMEXQFseBsn 4Bf2Q0hijNcsJcNCmHBd2N0FTT4dkv0d2Syxg5EWHDTKXJkSWuG++1ubSJqNOKmfdCUW BVBsWDnQmpHtJNYtjv+IEMZDH9wd4nXUfVQHKVdK8g87qxE2f4/bUcxsw0weik26VCi5 VZEPSXoad2SarW33l4r7H/42jf4SLg0JcIwo5ly0cXS1xPJ3LwYZEsh447YSWjdTgrop IWlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=AxLuEctB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id z11-20020a170903018b00b001b894687ec9si8443903plg.462.2023.09.12.07.19.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 07:19:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=AxLuEctB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id DDC3381F34FC; Tue, 12 Sep 2023 01:56:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233137AbjILI4X (ORCPT + 38 others); Tue, 12 Sep 2023 04:56:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233093AbjILI4I (ORCPT ); Tue, 12 Sep 2023 04:56:08 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A567CAA for ; Tue, 12 Sep 2023 01:56:04 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-31f737b8b69so4880601f8f.3 for ; Tue, 12 Sep 2023 01:56:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694508963; x=1695113763; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P0GSkSsBN1wyMRXDMHKAiDApaGJ4YO7Sk/7sv4md1Ps=; b=AxLuEctBWuoOz0QPbt5I6ffnds/54T799jnlbiT7SzW7JS6qbBcaVZJ47hxwcctuFc lypQrNhpC+BcxCqM3g1j25Vx6x8jSaWqzHaEPUc2IIWyM9wnIJQwmQqIGzQkcbJR0302 GPjX4OwXyL49io6wl/El1mAgPei4bq+pruDf+Gf+0I6SHAy/TqvthrPzIUiLZ4Ex+WkJ mxY84AmixdbPewKtXwuD3UTxJxNCALr7e0+VaMJhxjE2yScD83u5NAppWSD0lUtTNFLu 6jtt/oML0RMhoJhzmIhodPxNrffpPBSJSUNhW4WbTcB1OvwWNOCxXJuAYlCD53r4Oe7s v+kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694508963; x=1695113763; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P0GSkSsBN1wyMRXDMHKAiDApaGJ4YO7Sk/7sv4md1Ps=; b=php4qpirTkeJzbMFDNMOBG2xS3uABVN3Fq1BLT5GKi5fAK9JjF5zLiSC8R9UPHAHEx HEdaPsRKsRTiZt1lb+23VWykaq0/Pmi+wUCKHmGl90PE0/AnMut4rqCPwph8CipdBiuD 0o4PJl6CtqgbihTr/So1bNKe2E9DTyxSOWxDBgg2ZdR8gLrRA0IWrD1+nZ9JqLI10J9y ChJQlsPnJKTBVzn3wmSdyfKBmdbsCdHFKSKe2QAh2E2qgF6npxkT2oFYOxbltEb3qJUz yM2rt51F1mWk8gIzf0pJUNTZ7xEPJKwuOTuPT+damOuPcIVMvPcWdjWHMC4bIr+aXR39 RnTw== X-Gm-Message-State: AOJu0YzptXpoxs53Z2TvdtHvD1sPGnT8wYViKiWjlvistgyP8Ee1o85Y 4pk3nFowX/mNqHjJ+dGPbxwjx89/mf1qiICltAQ= X-Received: by 2002:adf:e743:0:b0:31f:651f:f850 with SMTP id c3-20020adfe743000000b0031f651ff850mr9470113wrn.36.1694508963002; Tue, 12 Sep 2023 01:56:03 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:907f:4cd7:f0ae:6b2a]) by smtp.gmail.com with ESMTPSA id d6-20020adfef86000000b00317ddccb0d1sm12310028wro.24.2023.09.12.01.56.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 01:56:02 -0700 (PDT) From: Bartosz Golaszewski To: Yury Norov , Andy Shevchenko , Rasmus Villemoes , Thomas Gleixner , Marc Zyngier Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 4/4] genirq/irq_sim: shrink code by using cleanup helpers Date: Tue, 12 Sep 2023 10:55:41 +0200 Message-Id: <20230912085541.13682-5-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230912085541.13682-1-brgl@bgdev.pl> References: <20230912085541.13682-1-brgl@bgdev.pl> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 12 Sep 2023 01:56:43 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776841754205575334 X-GMAIL-MSGID: 1776841754205575334 From: Bartosz Golaszewski Use the new __free helper from linux/cleanup.h to remove all gotos and simplify the error paths. Signed-off-by: Bartosz Golaszewski --- kernel/irq/irq_sim.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/kernel/irq/irq_sim.c b/kernel/irq/irq_sim.c index b0d50b48dbd1..24d10267f582 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,28 @@ 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) = NULL; + unsigned long *pending __free(bitmap) = NULL; 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; + pending = 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);