From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PNP driver changes for 2.5.44
Date: Tue, 29 Oct 2002 10:44:53 -0800 [thread overview]
Message-ID: <20021029184453.GD27082@kroah.com> (raw)
In-Reply-To: <20021029184419.GC27082@kroah.com>
ChangeSet 1.808.4.3, 2002/10/24 00:25:49-07:00, ambx1@neo.rr.com
[PATCH] PnPBIOS changes - 2.5.44 (2/4)
This patch adds compatible PnP ID support to the PnPBIOS protocol. None of my
test systems take advantage of this feature but it is included in the
specifications so it makes sense to support it. If anyone does get a compatible
ID listed for the PnPBIOS I'd be interested to hear about it (if more than 1 id
is listed when viewing the driverfs file 'id' within the PnPBIOS protocol). Also
it fixes the dma and mem resource problem.
diff -Nru a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
--- a/drivers/pnp/pnpbios/core.c Tue Oct 29 10:38:46 2002
+++ b/drivers/pnp/pnpbios/core.c Tue Oct 29 10:38:46 2002
@@ -680,7 +680,7 @@
static void add_dmaresource(struct pnp_dev *dev, int dma)
{
- int i = 8;
+ int i = 0;
while (!(dev->dma_resource[i].flags & IORESOURCE_UNSET) && i < DEVICE_COUNT_DMA) i++;
if (i < DEVICE_COUNT_DMA) {
dev->dma_resource[i].start = (unsigned long) dma;
@@ -701,7 +701,7 @@
static void add_memresource(struct pnp_dev *dev, int mem, int len)
{
- int i = 0;
+ int i = 8;
while (!(dev->resource[i].flags & IORESOURCE_UNSET) && i < DEVICE_COUNT_RESOURCE) i++;
if (i < DEVICE_COUNT_RESOURCE) {
dev->resource[i].start = (unsigned long) mem;
@@ -816,6 +816,7 @@
} /* while */
end:
if ((dev->resource[0].start == 0) &&
+ (dev->resource[8].start == 0) &&
(dev->irq_resource[0].start == -1) &&
(dev->dma_resource[0].start == -1))
dev->active = 0;
@@ -927,7 +928,6 @@
static unsigned char *node_possible_resource_data_to_dev(unsigned char *p, struct pnp_bios_node *node, struct pnp_dev *dev)
{
- unsigned char *lastp = NULL;
int len, depnum, dependent;
if ((char *)p == NULL)
@@ -963,8 +963,7 @@
break;
}
} /* switch */
- lastp = p+3;
- p = p + p[1] + p[2]*256 + 3;
+ p += len + 3;
continue;
}
len = p[0] & 0x07;
@@ -1030,6 +1029,70 @@
return NULL;
}
+/* pnp EISA ids */
+
+#define HEX(id,a) hex[((id)>>a) & 15]
+#define CHAR(id,a) (0x40 + (((id)>>a) & 31))
+//
+
+static void inline pnpid32_to_pnpid(u32 id, char *str)
+{
+ const char *hex = "0123456789abcdef";
+
+ id = be32_to_cpu(id);
+ str[0] = CHAR(id, 26);
+ str[1] = CHAR(id, 21);
+ str[2] = CHAR(id,16);
+ str[3] = HEX(id, 12);
+ str[4] = HEX(id, 8);
+ str[5] = HEX(id, 4);
+ str[6] = HEX(id, 0);
+ str[7] = '\0';
+
+ return;
+}
+//
+#undef CHAR
+#undef HEX
+
+static void node_id_data_to_dev(unsigned char *p, struct pnp_bios_node *node, struct pnp_dev *dev)
+{
+ int len;
+ struct pnp_id *dev_id;
+
+ if ((char *)p == NULL)
+ return;
+ while ( (char *)p < ((char *)node->data + node->size )) {
+
+ if( p[0] & 0x80 ) {// large item
+ len = (p[2] << 8) | p[1];
+ p += len + 3;
+ continue;
+ }
+ len = p[0] & 0x07;
+ switch ((p[0]>>3) & 0x0f) {
+ case 0x0f:
+ {
+ return;
+ break;
+ }
+ case 0x03: // compatible ID
+ {
+ if (len != 4)
+ goto __skip;
+ dev_id = pnpbios_kmalloc(sizeof (struct pnp_id), GFP_KERNEL);
+ if (!dev_id)
+ return;
+ pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] << 24,dev_id->id);
+ pnp_add_id(dev_id, dev);
+ break;
+ }
+ } /* switch */
+ __skip:
+ p += len + 1;
+
+ } /* while */
+}
/* pnp resource writing functions */
@@ -1314,31 +1377,6 @@
return 0;
}
-#define HEX(id,a) hex[((id)>>a) & 15]
-#define CHAR(id,a) (0x40 + (((id)>>a) & 31))
-//
-
-static void inline pnpid32_to_pnpid(u32 id, char *str)
-{
- const char *hex = "0123456789abcdef";
-
- id = be32_to_cpu(id);
- str[0] = CHAR(id, 26);
- str[1] = CHAR(id, 21);
- str[2] = CHAR(id,16);
- str[3] = HEX(id, 12);
- str[4] = HEX(id, 8);
- str[5] = HEX(id, 4);
- str[6] = HEX(id, 0);
- str[7] = '\0';
-
- return;
-}
-//
-#undef CHAR
-#undef HEX
-
-
static void __init build_devlist(void)
{
u8 nodenum;
@@ -1386,7 +1424,8 @@
memcpy(dev_id->id,id,8);
pnp_add_id(dev_id, dev);
pos = node_current_resource_data_to_dev(node,dev);
- node_possible_resource_data_to_dev(pos,node,dev);
+ pos = node_possible_resource_data_to_dev(pos,node,dev);
+ node_id_data_to_dev(pos,node,dev);
dev->protocol = &pnpbios_protocol;
next prev parent reply other threads:[~2002-10-29 18:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-29 18:40 [BK PATCH] PNP driver changes for 2.5.44 Greg KH
2002-10-29 18:43 ` [PATCH] " Greg KH
2002-10-29 18:44 ` Greg KH
2002-10-29 18:44 ` Greg KH [this message]
2002-10-29 18:45 ` Greg KH
2002-10-29 18:47 ` Greg KH
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=20021029184453.GD27082@kroah.com \
--to=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
/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