Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932432AbYCZRS1 (ORCPT ); Wed, 26 Mar 2008 13:18:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756012AbYCZRJ3 (ORCPT ); Wed, 26 Mar 2008 13:09:29 -0400 Received: from g1t0027.austin.hp.com ([15.216.28.34]:22200 "EHLO g1t0027.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761104AbYCZRJK (ORCPT ); Wed, 26 Mar 2008 13:09:10 -0400 Message-Id: <20080326171228.962706020@ldl.fc.hp.com> References: <20080326171058.099442579@ldl.fc.hp.com> User-Agent: quilt/0.46-1 Date: Wed, 26 Mar 2008 11:11:26 -0600 From: Bjorn Helgaas To: Len Brown Cc: linux-acpi@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Adam Belay Cc: Li Shaohua Cc: Matthieu Castet Cc: Thomas Renninger Cc: Rene Herman Cc: Jaroslav Kysela Cc: Andrew Morton Subject: [patch 28/37] PNP: add pnp_get_resource() interface Content-Disposition: inline; filename=pnp-add-get-resource Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2169 Lines: 68 This adds a pnp_get_resource() that works the same way as platform_get_resource(). This will enable us to consolidate many pnp_resource_table references in one place, which will make it easier to make the table dynamic. Signed-off-by: Bjorn Helgaas --- include/linux/pnp.h | 1 + drivers/pnp/resource.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) Index: work7/include/linux/pnp.h =================================================================== --- work7.orig/include/linux/pnp.h 2008-03-24 15:26:03.000000000 -0600 +++ work7/include/linux/pnp.h 2008-03-24 15:39:26.000000000 -0600 @@ -25,6 +25,7 @@ /* * Resource Management */ +struct resource *pnp_get_resource(struct pnp_dev *, unsigned int, unsigned int); /* Use these instead of directly reading pnp_dev to get resource information */ #define pnp_port_start(dev,bar) ((dev)->res.port_resource[(bar)].start) Index: work7/drivers/pnp/resource.c =================================================================== --- work7.orig/drivers/pnp/resource.c 2008-03-24 15:26:03.000000000 -0600 +++ work7/drivers/pnp/resource.c 2008-03-24 15:40:25.000000000 -0600 @@ -560,6 +560,32 @@ return 0; } +struct resource *pnp_get_resource(struct pnp_dev *dev, + unsigned int type, unsigned int num) +{ + struct pnp_resource_table *res = &dev->res; + + switch (type) { + case IORESOURCE_IO: + if (num >= PNP_MAX_PORT) + return NULL; + return &res->port_resource[num]; + case IORESOURCE_MEM: + if (num >= PNP_MAX_MEM) + return NULL; + return &res->mem_resource[num]; + case IORESOURCE_IRQ: + if (num >= PNP_MAX_IRQ) + return NULL; + return &res->irq_resource[num]; + case IORESOURCE_DMA: + if (num >= PNP_MAX_DMA) + return NULL; + return &res->dma_resource[num]; + } + return NULL; +} + /* format is: pnp_reserve_irq=irq1[,irq2] .... */ static int __init pnp_setup_reserve_irq(char *str) { -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/