From patchwork Thu Oct 23 02:12:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lv Zheng X-Patchwork-Id: 5137771 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E5E289F349 for ; Thu, 23 Oct 2014 02:14:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F1BE72025A for ; Thu, 23 Oct 2014 02:14:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E166820221 for ; Thu, 23 Oct 2014 02:14:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932230AbaJWCM0 (ORCPT ); Wed, 22 Oct 2014 22:12:26 -0400 Received: from mga11.intel.com ([192.55.52.93]:24403 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932090AbaJWCMR (ORCPT ); Wed, 22 Oct 2014 22:12:17 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 22 Oct 2014 19:12:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,773,1406617200"; d="scan'208";a="609713928" Received: from lvzheng-z530.sh.intel.com ([10.239.37.17]) by fmsmga001.fm.intel.com with ESMTP; 22 Oct 2014 19:12:15 -0700 From: Lv Zheng To: "Rafael J. Wysocki" , Len Brown Cc: Lv Zheng , Lv Zheng , , linux-acpi@vger.kernel.org Subject: [PATCH 2/6] ACPI/OSL: Rename system memory functions. Date: Thu, 23 Oct 2014 10:12:10 +0800 Message-Id: <6e1b8d2d369d84a27d4b15f6edde8810118be33f.1414029477.git.lv.zheng@intel.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: References: Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch cleans up system memory functions to make it easier to understand the meaning of such functions. No functional cleanup. Signed-off-by: Lv Zheng Tested-by: Fei Yang --- drivers/acpi/mem.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/acpi/mem.c b/drivers/acpi/mem.c index 722241e..defd317 100644 --- a/drivers/acpi/mem.c +++ b/drivers/acpi/mem.c @@ -33,15 +33,23 @@ struct acpi_ioremap { static LIST_HEAD(acpi_ioremaps); static DEFINE_MUTEX(acpi_ioremap_lock); -static void acpi_os_drop_map_ref(struct acpi_ioremap *map) +/* + * The following functions must be called with 'acpi_ioremap_lock' or RCU + * read lock held. + */ +static inline void acpi_map_get(struct acpi_ioremap *map) +{ + map->refcount++; +} + +static inline void acpi_map_put(struct acpi_ioremap *map) { if (!--map->refcount) list_del_rcu(&map->list); } -/* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ static struct acpi_ioremap * -acpi_map_lookup(acpi_physical_address phys, acpi_size size) +acpi_map_lookup_phys(acpi_physical_address phys, acpi_size size) { struct acpi_ioremap *map; @@ -53,7 +61,6 @@ acpi_map_lookup(acpi_physical_address phys, acpi_size size) return NULL; } -/* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ static struct acpi_ioremap * acpi_map_lookup_virt(void __iomem *virt, acpi_size size) { @@ -67,13 +74,12 @@ acpi_map_lookup_virt(void __iomem *virt, acpi_size size) return NULL; } -/* Must be called with 'acpi_ioremap_lock' or RCU read lock held. */ static void __iomem * acpi_map_vaddr_lookup(acpi_physical_address phys, unsigned int size) { struct acpi_ioremap *map; - map = acpi_map_lookup(phys, size); + map = acpi_map_lookup_phys(phys, size); if (map) return map->virt + (phys - map->phys); @@ -111,7 +117,7 @@ static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr) iounmap(vaddr); } -static void acpi_os_map_cleanup(struct acpi_ioremap *map) +static void acpi_map_cleanup(struct acpi_ioremap *map) { if (!map->refcount) { synchronize_rcu(); @@ -126,10 +132,10 @@ void __iomem *acpi_os_get_iomem(acpi_physical_address phys, unsigned int size) void __iomem *virt = NULL; mutex_lock(&acpi_ioremap_lock); - map = acpi_map_lookup(phys, size); + map = acpi_map_lookup_phys(phys, size); if (map) { virt = map->virt + (phys - map->phys); - map->refcount++; + acpi_map_get(map); } mutex_unlock(&acpi_ioremap_lock); @@ -155,9 +161,9 @@ acpi_os_map_iomem(acpi_physical_address phys, acpi_size size) mutex_lock(&acpi_ioremap_lock); /* Check if there's a suitable mapping already. */ - map = acpi_map_lookup(phys, size); + map = acpi_map_lookup_phys(phys, size); if (map) { - map->refcount++; + acpi_map_get(map); goto out; } @@ -204,10 +210,10 @@ void __ref acpi_os_unmap_iomem(void __iomem *virt, acpi_size size) WARN(true, PREFIX "%s: bad address %p\n", __func__, virt); return; } - acpi_os_drop_map_ref(map); + acpi_map_put(map); mutex_unlock(&acpi_ioremap_lock); - acpi_os_map_cleanup(map); + acpi_map_cleanup(map); } EXPORT_SYMBOL_GPL(acpi_os_unmap_iomem); @@ -265,15 +271,15 @@ void acpi_os_unmap_generic_address(struct acpi_generic_address *gas) return; mutex_lock(&acpi_ioremap_lock); - map = acpi_map_lookup(addr, gas->bit_width / 8); + map = acpi_map_lookup_phys(addr, gas->bit_width / 8); if (!map) { mutex_unlock(&acpi_ioremap_lock); return; } - acpi_os_drop_map_ref(map); + acpi_map_put(map); mutex_unlock(&acpi_ioremap_lock); - acpi_os_map_cleanup(map); + acpi_map_cleanup(map); } EXPORT_SYMBOL(acpi_os_unmap_generic_address);