From: Bjorn Helgaas <bjorn.helgaas@hp.com>
To: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
Adam Belay <ambx1@neo.rr.com>, Li Shaohua <shaohua.li@intel.com>,
Matthieu Castet <castet.matthieu@free.fr>,
Thomas Renninger <trenn@suse.de>,
Rene Herman <rene.herman@keyaccess.nl>,
Jaroslav Kysela <perex@perex.cz>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [patch 21/37] PNP: make generic pnp_add_dma_resource()
Date: Wed, 26 Mar 2008 11:11:19 -0600 [thread overview]
Message-ID: <20080326171227.539502349@ldl.fc.hp.com> (raw)
In-Reply-To: 20080326171058.099442579@ldl.fc.hp.com
[-- Attachment #1: pnp-common-add-dma-resource --]
[-- Type: text/plain, Size: 6185 bytes --]
Add a pnp_add_dma_resource() that can be used by all the PNP
backends. This consolidates a little more pnp_resource_table
knowledge into one place.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
---
drivers/pnp/base.h | 1 +
drivers/pnp/isapnp/core.c | 4 +---
drivers/pnp/pnpacpi/rsparser.c | 34 ++++------------------------------
drivers/pnp/pnpbios/rsparser.c | 21 +--------------------
drivers/pnp/resource.c | 24 ++++++++++++++++++++++++
5 files changed, 31 insertions(+), 53 deletions(-)
Index: work7/drivers/pnp/base.h
===================================================================
--- work7.orig/drivers/pnp/base.h 2008-03-25 14:48:51.000000000 -0600
+++ work7/drivers/pnp/base.h 2008-03-25 14:48:54.000000000 -0600
@@ -16,3 +16,4 @@
int pnp_check_dma(struct pnp_dev * dev, int idx);
int pnp_add_irq_resource(struct pnp_dev *dev, int irq, int flags);
+int pnp_add_dma_resource(struct pnp_dev *dev, int dma, int flags);
Index: work7/drivers/pnp/resource.c
===================================================================
--- work7.orig/drivers/pnp/resource.c 2008-03-25 14:48:51.000000000 -0600
+++ work7/drivers/pnp/resource.c 2008-03-25 14:48:54.000000000 -0600
@@ -487,6 +487,30 @@
return 0;
}
+int pnp_add_dma_resource(struct pnp_dev *dev, int dma, int flags)
+{
+ struct pnp_resource_table *res = &dev->res;
+ int i = 0;
+ static unsigned char warned;
+
+ while (set(res->dma_resource[i].flags) && i < PNP_MAX_DMA)
+ i++;
+ if (i >= PNP_MAX_DMA && !warned) {
+ dev_err(&dev->dev, "too many DMAs (max %d)\n", PNP_MAX_DMA);
+ warned = 1;
+ return -ENOSPC;
+ }
+
+ res->dma_resource[i].flags = IORESOURCE_DMA | flags;
+ if (dma < 0) {
+ res->dma_resource[i].flags |= IORESOURCE_DISABLED;
+ return -EINVAL;
+ }
+ res->dma_resource[i].start = dma;
+ res->dma_resource[i].end = dma;
+ return 0;
+}
+
/* format is: pnp_reserve_irq=irq1[,irq2] .... */
static int __init pnp_setup_reserve_irq(char *str)
{
Index: work7/drivers/pnp/isapnp/core.c
===================================================================
--- work7.orig/drivers/pnp/isapnp/core.c 2008-03-25 14:48:51.000000000 -0600
+++ work7/drivers/pnp/isapnp/core.c 2008-03-25 14:48:54.000000000 -0600
@@ -968,9 +968,7 @@
ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp);
if (ret == 4)
continue;
- res->dma_resource[tmp].start =
- res->dma_resource[tmp].end = ret;
- res->dma_resource[tmp].flags = IORESOURCE_DMA;
+ pnp_add_dma_resource(dev, ret, 0);
}
}
return 0;
Index: work7/drivers/pnp/pnpacpi/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpacpi/rsparser.c 2008-03-25 14:48:51.000000000 -0600
+++ work7/drivers/pnp/pnpacpi/rsparser.c 2008-03-25 14:48:54.000000000 -0600
@@ -153,32 +153,6 @@
return flags;
}
-static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev,
- u32 dma, int flags)
-{
- struct pnp_resource_table *res = &dev->res;
- int i = 0;
- static unsigned char warned;
-
- while (i < PNP_MAX_DMA &&
- !(res->dma_resource[i].flags & IORESOURCE_UNSET))
- i++;
- if (i < PNP_MAX_DMA) {
- res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
- res->dma_resource[i].flags |= flags;
- if (dma == -1) {
- res->dma_resource[i].flags |= IORESOURCE_DISABLED;
- return;
- }
- res->dma_resource[i].start = dma;
- res->dma_resource[i].end = dma;
- } else if (!warned) {
- printk(KERN_ERR "pnpacpi: exceeded the max number of DMA "
- "resources: %d \n", PNP_MAX_DMA);
- warned = 1;
- }
-}
-
static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev,
u64 io, u64 len, int io_decode)
{
@@ -295,10 +269,10 @@
case ACPI_RESOURCE_TYPE_DMA:
dma = &res->data.dma;
if (dma->channel_count > 0)
- pnpacpi_parse_allocated_dmaresource(dev,
- dma->channels[0],
- dma_flags(dma->type, dma->bus_master,
- dma->transfer));
+ pnp_add_dma_resource(dev, dma->channels[0],
+ dma_flags(dma->type,
+ dma->bus_master,
+ dma->transfer));
break;
case ACPI_RESOURCE_TYPE_IO:
Index: work7/drivers/pnp/pnpbios/rsparser.c
===================================================================
--- work7.orig/drivers/pnp/pnpbios/rsparser.c 2008-03-25 14:48:51.000000000 -0600
+++ work7/drivers/pnp/pnpbios/rsparser.c 2008-03-25 14:48:54.000000000 -0600
@@ -54,25 +54,6 @@
* Allocated Resources
*/
-static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma)
-{
- struct pnp_resource_table *res = &dev->res;
- int i = 0;
-
- while (i < PNP_MAX_DMA &&
- !(res->dma_resource[i].flags & IORESOURCE_UNSET))
- i++;
- if (i < PNP_MAX_DMA) {
- res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
- if (dma == -1) {
- res->dma_resource[i].flags |= IORESOURCE_DISABLED;
- return;
- }
- res->dma_resource[i].start =
- res->dma_resource[i].end = (unsigned long)dma;
- }
-}
-
static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev,
int io, int len)
{
@@ -190,7 +171,7 @@
for (i = 0; i < 8; i++, mask = mask >> 1)
if (mask & 0x01)
io = i;
- pnpbios_parse_allocated_dmaresource(dev, io);
+ pnp_add_dma_resource(dev, io, 0);
break;
case SMALL_TAG_PORT:
Index: work7/drivers/pnp/interface.c
===================================================================
--- work7.orig/drivers/pnp/interface.c 2008-03-25 14:48:51.000000000 -0600
+++ work7/drivers/pnp/interface.c 2008-03-25 14:48:54.000000000 -0600
@@ -370,7 +370,7 @@
goto done;
}
if (!strnicmp(buf, "set", 3)) {
- int nport = 0, nmem = 0, ndma = 0;
+ int nport = 0, nmem = 0;
if (dev->active)
goto done;
buf += 3;
@@ -439,14 +439,8 @@
buf += 3;
while (isspace(*buf))
++buf;
- dev->res.dma_resource[ndma].start =
- dev->res.dma_resource[ndma].end =
- simple_strtoul(buf, &buf, 0);
- dev->res.dma_resource[ndma].flags =
- IORESOURCE_DMA;
- ndma++;
- if (ndma >= PNP_MAX_DMA)
- break;
+ start = simple_strtoul(buf, &buf, 0);
+ pnp_add_dma_resource(dev, start, 0);
continue;
}
break;
--
next prev parent reply other threads:[~2008-03-26 17:08 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-26 17:10 [patch 00/37] PNP resource_table cleanups Bjorn Helgaas
2008-03-26 17:10 ` [patch 01/37] ISAPNP: move config register addresses out of isapnp.h Bjorn Helgaas
2008-03-26 17:11 ` [patch 02/37] PNPACPI: continue after _CRS and _PRS errors Bjorn Helgaas
2008-03-26 17:11 ` [patch 03/37] PNP: make pnp_add_id() internal to PNP core Bjorn Helgaas
2008-03-26 17:11 ` [patch 04/37] PNP: change pnp_add_id() to allocate its own pnp_id structures Bjorn Helgaas
2008-03-26 17:11 ` [patch 05/37] ISAPNP: pull pnp_add_id() out of isapnp_parse_id() Bjorn Helgaas
2008-03-26 17:11 ` [patch 06/37] PNP: add pnp_alloc_dev() Bjorn Helgaas
2008-03-26 17:11 ` [patch 07/37] PNP: make pnp_add_card_id() internal to PNP core Bjorn Helgaas
2008-03-26 17:11 ` [patch 08/37] PNP: change pnp_add_card_id() to allocate its own pnp_id structures Bjorn Helgaas
2008-03-26 17:11 ` [patch 09/37] ISAPNP: pull pnp_add_card_id() out of isapnp_parse_card_id() Bjorn Helgaas
2008-03-26 17:11 ` [patch 10/37] PNP: add pnp_alloc_card() Bjorn Helgaas
2008-03-26 17:11 ` [patch 11/37] PNPACPI: pnpacpi_encode_ext_irq() wrongly set "irq" instead of "extended_irq" Bjorn Helgaas
2008-03-26 17:11 ` [patch 12/37] PNPACPI: use temporaries to reduce repetition Bjorn Helgaas
2008-03-26 17:11 ` [patch 13/37] PNPACPI: hoist dma_flags() out of pnpacpi_parse_allocated_dmaresource() Bjorn Helgaas
2008-03-26 17:11 ` [patch 14/37] PNPACPI: extend irq_flags() to set IORESOURCE_IRQ_SHAREABLE when appropriate Bjorn Helgaas
2008-03-26 17:11 ` [patch 15/37] PNPACPI: pass pnp_dev instead of acpi_handle Bjorn Helgaas
2008-03-26 17:11 ` [patch 16/37] PNP: remove pnp_resource_table from internal get/set interfaces Bjorn Helgaas
2008-03-26 17:11 ` [patch 17/37] PNP: remove more pnp_resource_table arguments Bjorn Helgaas
2008-03-26 17:11 ` [patch 18/37] PNP: add pnp_init_resources(struct pnp_dev *) interface Bjorn Helgaas
2008-03-26 17:11 ` [patch 19/37] PNP: remove pnp_resource_table from internal pnp_clean_resource_table interface Bjorn Helgaas
2008-03-26 17:11 ` [patch 20/37] PNP: make generic pnp_add_irq_resource() Bjorn Helgaas
2008-03-26 17:11 ` Bjorn Helgaas [this message]
2008-03-26 17:11 ` [patch 22/37] PNP: make generic pnp_add_io_resource() Bjorn Helgaas
2008-03-26 17:11 ` [patch 23/37] PNP: make generic pnp_add_mem_resource() Bjorn Helgaas
2008-03-26 17:11 ` [patch 24/37] PNP: use dev_printk when possible Bjorn Helgaas
2008-03-26 17:11 ` [patch 25/37] PNPACPI: remove redundant warnings about _CRS/_PRS failures Bjorn Helgaas
2008-03-26 17:11 ` [patch 26/37] PNPACPI: remove some pnp_dbg calls Bjorn Helgaas
2008-03-26 17:11 ` [patch 27/37] PNP: use conventional "i" for loop indices Bjorn Helgaas
2008-03-26 17:11 ` [patch 28/37] PNP: add pnp_get_resource() interface Bjorn Helgaas
2008-03-26 23:15 ` Bjorn Helgaas
2008-03-26 17:11 ` [patch 29/37] PNP: convert encoders to use pnp_get_resource(), not pnp_resource_table Bjorn Helgaas
2008-03-26 17:11 ` [patch 30/37] PNP: convert resource accessors " Bjorn Helgaas
2008-03-26 17:11 ` [patch 31/37] PNP: convert resource checks " Bjorn Helgaas
2008-03-26 17:11 ` [patch 32/37] PNP: convert resource assign functions " Bjorn Helgaas
2008-03-26 17:11 ` [patch 33/37] PNP: remove PNP_MAX_* uses Bjorn Helgaas
2008-03-26 17:11 ` [patch 34/37] PNP: remove unused interfaces using pnp_resource_table Bjorn Helgaas
2008-03-26 17:11 ` [patch 35/37] rtc: dont reference pnp_resource_table directly Bjorn Helgaas
2008-03-26 17:11 ` [patch 36/37] PNP: make pnp_resource_table private to PNP core Bjorn Helgaas
2008-03-26 17:11 ` [patch 37/37] PNP: make interfaces private to the " Bjorn Helgaas
2008-03-26 22:42 ` [patch 00/37] PNP resource_table cleanups Len Brown
2008-03-26 23:13 ` Bjorn Helgaas
2008-03-27 0:30 ` Rene Herman
2008-03-27 17:50 ` Bjorn Helgaas
2008-03-31 19:40 ` Rene Herman
2008-03-31 19:48 ` Rene Herman
2008-03-31 20:51 ` Bjorn Helgaas
2008-03-31 21:38 ` Rene Herman
2008-04-01 10:16 ` Rene Herman
2008-04-01 14:52 ` Bjorn Helgaas
-- strict thread matches above, loose matches on Subject: below --
2008-04-01 15:16 [patch 00/37] PNP resource_table cleanups, v2 Bjorn Helgaas
2008-04-01 15:16 ` [patch 21/37] PNP: make generic pnp_add_dma_resource() Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080326171227.539502349@ldl.fc.hp.com \
--to=bjorn.helgaas@hp.com \
--cc=akpm@linux-foundation.org \
--cc=ambx1@neo.rr.com \
--cc=castet.matthieu@free.fr \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=rene.herman@keyaccess.nl \
--cc=shaohua.li@intel.com \
--cc=trenn@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox