LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Thomas Renninger <trenn@suse.de>
To: Rene Herman <rene.herman@keyaccess.nl>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>,
	linux-acpi@vger.kernel.org, Len Brown <lenb@kernel.org>,
	Bjorn Helgaas <bjorn.helgaas@hp.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Jean Delvare <khali@linux-fr.org>,
	Jaroslav Kysela <perex@perex.cz>
Subject: Re: [PATCH] Allocate pnp resources dynamically via krealloc	- working version - Addon patch 2
Date: Mon, 28 Jan 2008 17:04:49 +0100	[thread overview]
Message-ID: <1201536289.20940.425.camel@queen.suse.de> (raw)
In-Reply-To: <479DEE10.6060203@keyaccess.nl>

On Mon, 2008-01-28 at 16:00 +0100, Rene Herman wrote:
> On 28-01-08 15:21, Thomas Renninger wrote:
> 
> > I think I know what is going on.
> > While pnpbios and pnpacpi theoretically do not have limits, isapnp has
> > spec restrictions (AFAIK, I have not read this up, but taken over from
> > previous implementation...).
> > Therefore in isapnp I wanted to stay with:
> > #define PNP_MAX_PORT            8
> > #define PNP_MAX_MEM             4
> > #define PNP_MAX_IRQ             2
> > #define PNP_MAX_DMA             2
> > but I have forgotten to malloc one portion for each at init time, or
> > even better one portion as soon as one is needed.
> 
> Yup.
> 
> > As said, isapnp is more or less untested, thanks a lot for trying out.
> > I will send an updated version soon.
> 
> I"m not sure of the flow of things by the way but if it makes better/nicer 
> code to just pretend that ISAPnP is also unlimited then I'd say to simply do 
> so. ISAPnP is getting obsolete anyway, not anything to optimise for...

Also go the dynamic way in isapnp layer

Signed-off-by: Thomas Renninger <trenn@suse.de>

---
 drivers/pnp/isapnp/core.c |   25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

Index: linux-2.6.23/drivers/pnp/isapnp/core.c
===================================================================
--- linux-2.6.23.orig/drivers/pnp/isapnp/core.c
+++ linux-2.6.23/drivers/pnp/isapnp/core.c
@@ -953,7 +953,7 @@ static int isapnp_read_resources(struct 
 
 	dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE);
 	if (dev->active) {
-		for (tmp = 0; tmp < PNP_MAX_PORT; tmp++) {
+		for (tmp = 0; pnp_port_ok(dev, tmp); tmp++) {
 			ret = isapnp_read_word(ISAPNP_CFG_PORT + (tmp << 1));
 			if (!ret)
 				continue;
@@ -961,8 +961,10 @@ static int isapnp_read_resources(struct 
 			new_res.flags = IORESOURCE_IO;
 			if (pnp_assign_resource(res, &new_res))
 				pnp_err("Bug in %s", __FUNCTION__);
+			if (tmp > PNP_MAX_PORT)
+				pnp_warn("ISA exceeds spec max port");
 		}
-		for (tmp = 0; tmp < PNP_MAX_MEM; tmp++) {
+		for (tmp = 0; pnp_mem_ok(dev, tmp); tmp++) {
 			ret =
 			    isapnp_read_word(ISAPNP_CFG_MEM + (tmp << 3)) << 8;
 			if (!ret)
@@ -971,8 +973,10 @@ static int isapnp_read_resources(struct 
 			new_res.flags = IORESOURCE_MEM;
 			if (pnp_assign_resource(res, &new_res))
 				pnp_err("Bug in %s", __FUNCTION__);
+			if (tmp > PNP_MAX_MEM)
+				pnp_warn("ISA exceeds spec max mem");
 		}
-		for (tmp = 0; tmp < PNP_MAX_IRQ; tmp++) {
+		for (tmp = 0; pnp_irq_ok(dev, tmp); tmp++) {
 			ret =
 			    (isapnp_read_word(ISAPNP_CFG_IRQ + (tmp << 1)) >>
 			     8);
@@ -982,8 +986,11 @@ static int isapnp_read_resources(struct 
 			new_res.flags = IORESOURCE_IRQ;
 			if (pnp_assign_resource(res, &new_res))
 				pnp_err("Bug in %s", __FUNCTION__);
+			if (tmp > PNP_MAX_IRQ)
+				pnp_warn("ISA exceeds spec max irq");
+
 		}
-		for (tmp = 0; tmp < PNP_MAX_DMA; tmp++) {
+		for (tmp = 0; pnp_dma_ok(dev, tmp); tmp++) {
 			ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp);
 			if (ret == 4)
 				continue;
@@ -992,6 +999,8 @@ static int isapnp_read_resources(struct 
 			new_res.flags = IORESOURCE_DMA;
 			if (pnp_assign_resource(res, &new_res))
 				pnp_err("Bug in %s", __FUNCTION__);
+			if (tmp > PNP_MAX_DMA)
+				pnp_warn("ISA exceeds spec max dma");
 		}
 	}
 	return 0;
@@ -1017,14 +1026,14 @@ static int isapnp_set_resources(struct p
 	isapnp_cfg_begin(dev->card->number, dev->number);
 	dev->active = 1;
 	for (tmp = 0;
-	     tmp < PNP_MAX_PORT
+	     pnp_port_ok(dev, tmp)
 	     && (res->port_resource[tmp].
 		 flags & (IORESOURCE_IO | IORESOURCE_UNSET)) == IORESOURCE_IO;
 	     tmp++)
 		isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1),
 				  res->port_resource[tmp].start);
 	for (tmp = 0;
-	     tmp < PNP_MAX_IRQ
+	     pnp_irq_ok(dev, tmp)
 	     && (res->irq_resource[tmp].
 		 flags & (IORESOURCE_IRQ | IORESOURCE_UNSET)) == IORESOURCE_IRQ;
 	     tmp++) {
@@ -1034,14 +1043,14 @@ static int isapnp_set_resources(struct p
 		isapnp_write_byte(ISAPNP_CFG_IRQ + (tmp << 1), irq);
 	}
 	for (tmp = 0;
-	     tmp < PNP_MAX_DMA
+	     pnp_dma_ok(dev, tmp)
 	     && (res->dma_resource[tmp].
 		 flags & (IORESOURCE_DMA | IORESOURCE_UNSET)) == IORESOURCE_DMA;
 	     tmp++)
 		isapnp_write_byte(ISAPNP_CFG_DMA + tmp,
 				  res->dma_resource[tmp].start);
 	for (tmp = 0;
-	     tmp < PNP_MAX_MEM
+	     pnp_mem_ok(dev, tmp)
 	     && (res->mem_resource[tmp].
 		 flags & (IORESOURCE_MEM | IORESOURCE_UNSET)) == IORESOURCE_MEM;
 	     tmp++)



  parent reply	other threads:[~2008-01-28 16:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-19 20:00 [PATCH] Allocate pnp resources dynamically via krealloc Thomas Renninger
2008-01-20  0:23 ` Pekka Enberg
2008-01-20 11:04   ` Thomas Renninger
2008-01-23 17:38   ` [PATCH] Allocate pnp resources dynamically via krealloc - working version Thomas Renninger
2008-01-27 19:19     ` Rene Herman
2008-01-28 14:21       ` Thomas Renninger
2008-01-28 15:00         ` Rene Herman
2008-01-28 16:04           ` [PATCH] Allocate pnp resources dynamically via krealloc - working version - Addon patch 1 Thomas Renninger
2008-01-28 18:07             ` Rene Herman
2008-01-28 19:12               ` [PATCH] Allocate pnp resources dynamically via krealloc - working version - Addon patch 3 Thomas Renninger
2008-01-28 21:12                 ` Rene Herman
2008-01-29 14:18                   ` [PATCH] Allocate pnp resources dynamically via krealloc - working version - Addon debug patch 4 Thomas Renninger
2008-02-05 18:20                   ` [PATCH] Allocate pnp resources dynamically via krealloc - Yet another Version Thomas Renninger
2008-02-06 14:38                     ` Thomas Renninger
2008-02-06 15:22                       ` Rene Herman
2008-01-28 16:04           ` Thomas Renninger [this message]
2008-01-27 21:03     ` [PATCH] Allocate pnp resources dynamically via krealloc - working version Pekka Enberg

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=1201536289.20940.425.camel@queen.suse.de \
    --to=trenn@suse.de \
    --cc=bjorn.helgaas@hp.com \
    --cc=khali@linux-fr.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=perex@perex.cz \
    --cc=rene.herman@keyaccess.nl \
    --subject='Re: [PATCH] Allocate pnp resources dynamically via krealloc	- working version - Addon patch 2' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).