From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rcsinet15.oracle.com ([148.87.113.117]:29856 "EHLO rcsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030649Ab2CSFpa (ORCPT ); Mon, 19 Mar 2012 01:45:30 -0400 From: Yinghai Lu To: Jesse Barnes , Benjamin Herrenschmidt , Tony Luck , David Miller , x86 Cc: Bjorn Helgaas , Dominik Brodowski , Andrew Morton , Linus Torvalds , Greg Kroah-Hartman , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Yinghai Lu Subject: [PATCH -v11 18/30] resources: Replace registered resource in tree. Date: Sun, 18 Mar 2012 22:42:49 -0700 Message-Id: <1332135781-13695-19-git-send-email-yinghai@kernel.org> In-Reply-To: <1332135781-13695-1-git-send-email-yinghai@kernel.org> References: <1332135781-13695-1-git-send-email-yinghai@kernel.org> Sender: linux-pci-owner@vger.kernel.org List-ID: We could have one resource inserted in tree at first during proble. Later we need to put real resource into the tree. So try to hold the lock to swap them. Signed-off-by: Yinghai Lu Cc: Andrew Morton --- include/linux/ioport.h | 1 + kernel/resource.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 20a30df..62af212 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -163,6 +163,7 @@ int probe_resource(struct resource *b_res, struct device *dev, struct resource *busn_res, resource_size_t needed_size, struct resource **p, int skip_nr, int limit, char *name); +void resource_replace(struct resource *old_res, struct resource *new_res); struct resource *lookup_resource(struct resource *root, resource_size_t start); int adjust_resource(struct resource *res, resource_size_t start, resource_size_t size); diff --git a/kernel/resource.c b/kernel/resource.c index 0c9616f..ea96dcf 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -1112,6 +1112,21 @@ reduce_needed_size: return ret; } +/* replace old with new in the resource tree */ +void resource_replace(struct resource *old, struct resource *new) +{ + struct resource *parent; + + write_lock(&resource_lock); + parent = old->parent; + new->start = old->start; + new->end = old->end; + new->flags = old->flags; + __release_resource(old); + __request_resource(parent, new); + write_unlock(&resource_lock); +} + /* * Managed region resource */ -- 1.7.7