From patchwork Thu Nov 23 04:03:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "David E. Box" X-Patchwork-Id: 168691 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce62:0:b0:403:3b70:6f57 with SMTP id o2csp207595vqx; Wed, 22 Nov 2023 20:05:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IEsFtypZcOi8vJUOWyIqcUttpvNeKQzRCHxBt0wCihahwmadH8o2qAiwh1LMVIVeNxNK0Sw X-Received: by 2002:a05:6a00:3926:b0:68f:a92a:8509 with SMTP id fh38-20020a056a00392600b0068fa92a8509mr2443821pfb.7.1700712322230; Wed, 22 Nov 2023 20:05:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700712322; cv=none; d=google.com; s=arc-20160816; b=zHq0/EBgKQOGTdRpBbxwcnBk6eMLSrF3Z4KHB/KPwihzMBReFyKKSCLdJVnZUkqbAx 8340iUpOSJ4ghl9izXwtLv6gkyC0SrmU/qCmU4v0PFyqNoQStM4a0+7ZIMl+0a9ZoHzi o6UDWSLZB188GDuAdG7y2mHTIB7qF7ugQYsqqJ4ZIHBU9mzEaGBI2pLjumnuUW7fGQXd SwR+UBMuxKb6BZAgQT3uY4kEm3olJ7u12TvoThJOu7onUi3B7bncYpd4mLLEgxJ0BjDy GyQh40VN5UE/TS2qqf0ykOIk+W4Dl+Voo2xaIF+i1lahKJ9IePDnmPmp9wkipxKjjUTS bAVA== 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:to:from :dkim-signature; bh=5ESILGEUPpbzOxOBRSBkGP73mDWWwhQ1lBx+97QIyNw=; fh=aBF56gt1ZIoBM/Km9IExMMgXxUSat1xZCoUaU7LtMu4=; b=QUbJdwu5soqGbXGRSjWMLkbra9urvlmX797re/KGc8d2ktjNNHXWaDRmZzuNzwXczG BeD2984w7u2YEKVCt6ayr8m/72NMb2OziI4NRPzjtYuKS9TAR3qn4yVtf5cnneodSyVE 3cVa2kwDOnBxVyejyGMKHfHN3dXfmaaB86DmI8BQhfe0BIVhwOYodHqKVtwDtMY5uLMX 3rXysOdsV11/csEuC9nI59y1B3jMTeoIgb9EOvlk/nHm6/0b9FPwnGEosQJcuGF98eOC C/xpMvk3nQcHewcD/NidmAMSch41Sn3P7ppum/JFbBbvwLLClb60bu2qWcRYBTZNWXew sqmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=asa4+sDC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id i9-20020a63e909000000b005b42f4443b7si510909pgh.653.2023.11.22.20.05.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 20:05:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=asa4+sDC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 3696B83B2E29; Wed, 22 Nov 2023 20:05:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344751AbjKWEE5 (ORCPT + 99 others); Wed, 22 Nov 2023 23:04:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233071AbjKWEDx (ORCPT ); Wed, 22 Nov 2023 23:03:53 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13B11D48; Wed, 22 Nov 2023 20:04:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700712240; x=1732248240; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=5ZZAKxI4gVSEhTRWxoAY8gcBKY1IXr9jOeKv5If/tc8=; b=asa4+sDCer8oL6EvCBvQ2oOOHS+KlIJMRg7xnBL+AE7Gf5TDURuGAmf2 Q+Zd09rPaDWaCrezuNGCylWFIwk17toqzXXRFSxJidfgS7v95ml7xwlcy KD1qQlXOEEg2IOtBrtdnHpcEsE5163bI5kIWKJ504E1CJB3JJHnPFYBlq 8LACWQzy+UQkp4N5kFLMEFzQ62aFbCXoGBSzZxRG92VOgd1MRYpMZciFd vPFAun+QljxVduibEeLvorfWZ1ovuCQwt2sT/Ju9PgcZq1pj+NKjjdIOO F7H71yPpXSqAqMzvmjXY3uFg6sWaYAI4ZKfnoa+uJ8qf1DDu8HR1/+Nyu A==; X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="5334663" X-IronPort-AV: E=Sophos;i="6.04,220,1695711600"; d="scan'208";a="5334663" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 20:03:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10902"; a="837671154" X-IronPort-AV: E=Sophos;i="6.04,220,1695711600"; d="scan'208";a="837671154" Received: from linux.intel.com ([10.54.29.200]) by fmsmga004.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Nov 2023 20:03:57 -0800 Received: from debox1-desk4.lan (snpatel1-mobl.amr.corp.intel.com [10.209.89.91]) by linux.intel.com (Postfix) with ESMTP id C57AF580CA6; Wed, 22 Nov 2023 20:03:56 -0800 (PST) From: "David E. Box" To: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, ilpo.jarvinen@linux.intel.com, rajvi.jingar@linux.intel.com, dave.hansen@linux.intel.com, peterz@infradead.org Subject: [PATCH V5 12/20] asm-generic/io.h: iounmap/ioport_unmap cleanup.h support Date: Wed, 22 Nov 2023 20:03:47 -0800 Message-Id: <20231123040355.82139-13-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231123040355.82139-1-david.e.box@linux.intel.com> References: <20231123040355.82139-1-david.e.box@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Wed, 22 Nov 2023 20:05:15 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783326124207884060 X-GMAIL-MSGID: 1783326124207884060 Add auto-release cleanups for iounmap() and ioport_unmap(). Signed-off-by: David E. Box Suggested-by: Ilpo Järvinen --- V2 - Move from linux/io.h to asm-generic/io.h. Adds iounmap cleanup if iounmap() is defined. Adds ioport_unmap cleanup if CONFIG_IOPORT_MAP is defined. include/asm-generic/io.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index bac63e874c7b..9ef0332490b1 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -8,6 +8,7 @@ #define __ASM_GENERIC_IO_H #include /* I/O is all done through memory accesses */ +#include #include /* for memset() and memcpy() */ #include #include @@ -1065,6 +1066,10 @@ static inline void __iomem *ioremap(phys_addr_t addr, size_t size) #endif #endif /* !CONFIG_MMU || CONFIG_GENERIC_IOREMAP */ +#ifdef iounmap +DEFINE_FREE(iounmap, void __iomem *, iounmap(_T)); +#endif + #ifndef ioremap_wc #define ioremap_wc ioremap #endif @@ -1127,6 +1132,7 @@ static inline void ioport_unmap(void __iomem *p) extern void __iomem *ioport_map(unsigned long port, unsigned int nr); extern void ioport_unmap(void __iomem *p); #endif /* CONFIG_GENERIC_IOMAP */ +DEFINE_FREE(ioport_unmap, void __iomem *, ioport_unmap(_T)); #endif /* CONFIG_HAS_IOPORT_MAP */ #ifndef CONFIG_GENERIC_IOMAP