All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adam Belay <ambx1@neo.rr.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PnP Updates for 2.6.2-rc2
Date: Thu, 29 Jan 2004 23:57:02 +0000	[thread overview]
Message-ID: <20040129235702.GD12308@neo.rr.com> (raw)
In-Reply-To: <20040129235304.GA12308@neo.rr.com>

Some PnPBIOSes do not follow the specifications with regard to disabling
devices.  This patch preserves the tag bits, while zeroing the resource 
settings.  Previously we would zero the entire buffer.  It has been tested and 
appears to correct the issue while remaining compatible with unbroken PnPBIOSes.

--- a/drivers/pnp/pnpbios/core.c	2004-01-23 15:19:25.000000000 +0000
+++ b/drivers/pnp/pnpbios/core.c	2004-01-23 20:00:45.000000000 +0000
@@ -264,19 +264,49 @@
 	return ret;
 }
 
+static void pnpbios_zero_data_stream(struct pnp_bios_node * node)
+{
+	unsigned char * p = (char *)node->data;
+	unsigned char * end = (char *)(node->data + node->size);
+	unsigned int len;
+	int i;
+	while ((char *)p < (char *)end) {
+		if(p[0] & 0x80) { /* large tag */
+			len = (p[2] << 8) | p[1];
+			p += 3;
+		} else {
+			if (((p[0]>>3) & 0x0f) == 0x0f)
+				return;
+			len = p[0] & 0x07;
+			p += 1;
+		}
+		for (i = 0; i < len; i++)
+			p[i] = 0;
+		p += len;
+	}
+	printk(KERN_ERR "PnPBIOS: Resource structure did not contain an end tag.\n");
+}
+
 static int pnpbios_disable_resources(struct pnp_dev *dev)
 {
 	struct pnp_bios_node * node;
+	u8 nodenum = dev->number;
 	int ret;
 
 	/* just in case */
 	if(dev->flags & PNPBIOS_NO_DISABLE || !pnpbios_is_dynamic(dev))
 		return -EPERM;
 
-	/* the value of this will be zero */
 	node = pnpbios_kmalloc(node_info.max_node_size, GFP_KERNEL);
 	if (!node)
 		return -ENOMEM;
+
+	if (pnp_bios_get_dev_node(&nodenum, (char )PNPMODE_DYNAMIC, node)) {
+		kfree(node);
+		return -ENODEV;
+	}
+	pnpbios_zero_data_stream(node);
+
 	ret = pnp_bios_set_dev_node(dev->number, (char)PNPMODE_DYNAMIC, node);
 	kfree(node);
 	if (ret > 0)

  parent reply	other threads:[~2004-01-30  5:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-29 23:53 [PATCH] PnP Updates for 2.6.2-rc2 Adam Belay
2004-01-29 23:55 ` Adam Belay
2004-01-29 23:56 ` Adam Belay
2004-01-29 23:57 ` Adam Belay [this message]
2004-01-29 23:57 ` Adam Belay
2004-01-29 23:59 ` Adam Belay
2004-01-29 23:59 ` Adam Belay
2004-01-30  0:00 ` Adam Belay
2004-01-30  0:01 ` Adam Belay
2004-01-30  0:02 ` Adam Belay

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=20040129235702.GD12308@neo.rr.com \
    --to=ambx1@neo.rr.com \
    --cc=akpm@osdl.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.