From patchwork Fri Sep 6 14:24:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 2854554 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 A62D79F499 for ; Fri, 6 Sep 2013 16:46:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E6D2A20108 for ; Fri, 6 Sep 2013 16:46:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B674820121 for ; Fri, 6 Sep 2013 16:46:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754308Ab3IFO0e (ORCPT ); Fri, 6 Sep 2013 10:26:34 -0400 Received: from mga09.intel.com ([134.134.136.24]:35985 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752069Ab3IFO0e (ORCPT ); Fri, 6 Sep 2013 10:26:34 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 06 Sep 2013 07:23:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.90,854,1371106800"; d="scan'208";a="374430298" Received: from unknown (HELO localhost) ([10.255.20.213]) by orsmga001.jf.intel.com with ESMTP; 06 Sep 2013 07:26:29 -0700 From: Lan Tianyu To: tianyu.lan@intel.com, lenb@kernel.org, rjw@sisk.pl, yinghai@kernel.org, bhelgaas@google.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 3/4] ACPI: Add new acpi_dev_resource_address_space_with_addr() function Date: Fri, 6 Sep 2013 10:24:45 -0400 Message-Id: <1378477486-8758-4-git-send-email-tianyu.lan@intel.com> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1378477486-8758-1-git-send-email-tianyu.lan@intel.com> References: <1378477486-8758-1-git-send-email-tianyu.lan@intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-9.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 Make acpi_dev_resource_address_space() to accept struct acpi_resource_address64 as param and rename it to *_with_addr. This is for some cases that acpi address info is also needed after convert from acpi resouce to generic resource. Add acpi_devi_resource_addres_space() again as a wrapper of new function for original users. Signed-off-by: Lan Tianyu --- drivers/acpi/resource.c | 53 ++++++++++++++++++++++++++++++++++--------------- include/linux/acpi.h | 3 +++ 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c index 84bc3db..76da28b 100644 --- a/drivers/acpi/resource.c +++ b/drivers/acpi/resource.c @@ -162,19 +162,21 @@ bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res) EXPORT_SYMBOL_GPL(acpi_dev_resource_io); /** - * acpi_dev_resource_address_space - Extract ACPI address space information. + * acpi_dev_resource_address_space_with_addr - Extract ACPI address space information. * @ares: Input ACPI resource object. + * @addr: Output ACPI resource address64 space object. * @res: Output generic resource object. * * Check if the given ACPI resource object represents an address space resource - * and if that's the case, use the information in it to populate the generic - * resource object pointed to by @res. + * and if that's the case, convert it to ACPI resource address64 space object + * pointed to by @addr and use the information to populate the generic resource + * object pointed to by @re. */ -bool acpi_dev_resource_address_space(struct acpi_resource *ares, +bool acpi_dev_resource_address_space_with_addr(struct acpi_resource *ares, + struct acpi_resource_address64 *addr, struct resource *res) { acpi_status status; - struct acpi_resource_address64 addr; bool window; u64 len; u8 io_decode; @@ -188,29 +190,29 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares, return false; } - status = acpi_resource_to_address64(ares, &addr); + status = acpi_resource_to_address64(ares, addr); if (ACPI_FAILURE(status)) return true; - res->start = addr.minimum + addr.translation_offset; - res->end = addr.maximum + addr.translation_offset; - window = addr.producer_consumer == ACPI_PRODUCER; + res->start = addr->minimum + addr->translation_offset; + res->end = addr->maximum + addr->translation_offset; + window = addr->producer_consumer == ACPI_PRODUCER; - switch(addr.resource_type) { + switch (addr->resource_type) { case ACPI_MEMORY_RANGE: - len = addr.maximum - addr.minimum + 1; + len = addr->maximum - addr->minimum + 1; res->flags = acpi_dev_memresource_flags(len, - addr.info.mem.write_protect, + addr->info.mem.write_protect, window); - if (addr.info.mem.caching == ACPI_PREFETCHABLE_MEMORY) + if (addr->info.mem.caching == ACPI_PREFETCHABLE_MEMORY) res->flags |= IORESOURCE_PREFETCH; break; case ACPI_IO_RANGE: - io_decode = addr.granularity == 0xfff ? + io_decode = addr->granularity == 0xfff ? ACPI_DECODE_10 : ACPI_DECODE_16; - res->flags = acpi_dev_ioresource_flags(addr.minimum, - addr.maximum, + res->flags = acpi_dev_ioresource_flags(addr->minimum, + addr->maximum, io_decode, window); break; case ACPI_BUS_NUMBER_RANGE: @@ -222,6 +224,25 @@ bool acpi_dev_resource_address_space(struct acpi_resource *ares, return true; } +EXPORT_SYMBOL_GPL(acpi_dev_resource_address_space_with_addr); + +/** + * acpi_dev_resource_address_space - Extract ACPI address space information. + * @ares: Input ACPI resource object. + * @res: Output generic resource object. + * + * Check if the given ACPI resource object represents an address space resource + * and if that's the case, use the information in it to populate the generic + * resource object pointed to by @res. + */ +bool acpi_dev_resource_address_space(struct acpi_resource *ares, + struct resource *res) +{ + struct acpi_resource_address64 addr; + + return acpi_dev_resource_address_space_with_addr(ares, &addr, + res); +} EXPORT_SYMBOL_GPL(acpi_dev_resource_address_space); /** diff --git a/include/linux/acpi.h b/include/linux/acpi.h index a5db4ae..9f5c0d5 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -260,6 +260,9 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res); bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res); bool acpi_dev_resource_address_space(struct acpi_resource *ares, struct resource *res); +bool acpi_dev_resource_address_space_with_addr(struct acpi_resource *ares, + struct acpi_resource_address64 *addr, + struct resource *res); bool acpi_dev_resource_ext_address_space(struct acpi_resource *ares, struct resource *res); unsigned long acpi_dev_irq_flags(u8 triggering, u8 polarity, u8 shareable);