linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PnP Updates for 2.6.4-mm2
@ 2004-03-15  0:06 Adam Belay
  2004-03-15  0:10 ` Adam Belay
  0 siblings, 1 reply; 8+ messages in thread
From: Adam Belay @ 2004-03-15  0:06 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

Hi Andrew,

This is the first of a series of PnP updates for 2.6.4.  I would appreciate if
these could be tested in your -mm tree.

Thanks,
Adam

[PNP] Resource Conflict Cleanup

This patch cleans up the resource conflict logic and was originally from Matthew
Wilcox <willy@debian.org>.

--- a/drivers/pnp/resource.c	2004-01-23 15:19:25.000000000 +0000
+++ b/drivers/pnp/resource.c	2004-02-01 20:07:41.000000000 +0000
@@ -231,15 +231,9 @@
 
 #define length(start, end) (*(end) - *(start) + 1)

-/* ranged_conflict - used to determine if two resource ranges conflict
- * condition 1: check if the start of a is within b
- * condition 2: check if the end of a is within b
- * condition 3: check if b is engulfed by a */
-
+/* Two ranges conflict if one doesn't end before the other starts */
 #define ranged_conflict(starta, enda, startb, endb) \
-((*(starta) >= *(startb) && *(starta) <= *(endb)) || \
- (*(enda) >= *(startb) && *(enda) <= *(endb)) || \
- (*(starta) < *(startb) && *(enda) > *(endb)))
+	!((*(enda) < *(startb)) || (*(endb) < *(starta)))

 #define cannot_compare(flags) \
 ((flags) & (IORESOURCE_UNSET | IORESOURCE_DISABLED))

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] PnP Updates for 2.6.4-mm2
  2004-03-15  0:06 [PATCH] PnP Updates for 2.6.4-mm2 Adam Belay
@ 2004-03-15  0:10 ` Adam Belay
  2004-03-15  0:15   ` Adam Belay
  0 siblings, 1 reply; 8+ messages in thread
From: Adam Belay @ 2004-03-15  0:10 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel

[PARPORT] Update PC Parport Detection Code

This patch updates the parport_pc driver's probing code to better detect PnP
devices.  It also removes an extra MODULE_AUTHOR etc.

--- a/drivers/parport/parport_pc.c	2004-03-11 02:55:49.000000000 +0000
+++ b/drivers/parport/parport_pc.c	2004-03-13 23:43:58.000000000 +0000
@@ -13,6 +13,7 @@
  * Many ECP bugs fixed.  Fred Barnes & Jamie Lokier, 1999
  * More PCI support now conditional on CONFIG_PCI, 03/2001, Paul G. 
  * Various hacks, Fred Barnes, 04/2001
+ * Updated probing logic - Adam Belay <ambx1@neo.rr.com>
  */
 
 /* This driver should work with any hardware that is broadly compatible
@@ -98,7 +99,8 @@
        (defined(CONFIG_PARPORT_1284) && defined(CONFIG_PARPORT_PC_FIFO))
 static int verbose_probing;
 #endif
-static int registered_parport;
+static int pci_registered_parport;
+static int pnp_registered_parport;
 
 /* frob_control, but for ECR */
 static void frob_econtrol (struct parport *pb, unsigned char m,
@@ -2771,10 +2773,11 @@
 };
 MODULE_DEVICE_TABLE(pci,parport_pc_pci_tbl);
 
-static int __devinit parport_pc_pci_probe (struct pci_dev *dev,
+static int parport_pc_pci_probe (struct pci_dev *dev,
 					   const struct pci_device_id *id)
 {
 	int err, count, n, i = id->driver_data;
+
 	if (i < last_sio)
 		/* This is an onboard Super-IO and has already been probed */
 		return 0;
@@ -2847,23 +2850,72 @@
 static int __init parport_pc_init_superio(int autoirq, int autodma) {return 0;}
 #endif /* CONFIG_PCI */
 
-#ifdef CONFIG_PNP
-static const struct pnp_device_id pnp_dev_table[] = {
+
+static const struct pnp_device_id parport_pc_pnp_tbl[] = {
 	/* Standard LPT Printer Port */
 	{.id = "PNP0400", .driver_data = 0},
 	/* ECP Printer Port */
 	{.id = "PNP0401", .driver_data = 0},
-	{.id = ""}
+	{ }
 };
 
+MODULE_DEVICE_TABLE(pnp,parport_pc_pnp_tbl);
+
+static int parport_pc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *id)
+{
+	struct parport *pdata;
+	unsigned long io_lo, io_hi;
+	int dma, irq;
+
+	if (pnp_port_valid(dev,0) &&
+		!(pnp_port_flags(dev,0) & IORESOURCE_DISABLED)) {
+		io_lo = pnp_port_start(dev,0);
+	} else
+		return -EINVAL;
+
+	if (pnp_port_valid(dev,1) &&
+		!(pnp_port_flags(dev,1) & IORESOURCE_DISABLED)) {
+		io_hi = pnp_port_start(dev,1);
+	} else
+		io_hi = 0;
+
+	if (pnp_irq_valid(dev,0) &&
+		!(pnp_irq_flags(dev,0) & IORESOURCE_DISABLED)) {
+		irq = pnp_irq(dev,0);
+	} else
+		irq = PARPORT_IRQ_NONE;
+
+	if (pnp_dma_valid(dev,0) &&
+		!(pnp_dma_flags(dev,0) & IORESOURCE_DISABLED)) {
+		dma = pnp_dma(dev,0);
+	} else
+		dma = PARPORT_DMA_NONE;
+
+	printk(KERN_INFO "parport: PnPBIOS parport detected.\n");
+	if (!(pdata = parport_pc_probe_port (io_lo, io_hi, irq, dma, NULL)))
+		return -ENODEV;
+
+	pnp_set_drvdata(dev,pdata);
+	return 0;
+}
+
+static void parport_pc_pnp_remove(struct pnp_dev *dev)
+{
+	struct parport *pdata = (struct parport *)pnp_get_drvdata(dev);
+	if (!pdata)
+		return;
+
+	parport_pc_unregister_port(pdata);
+}
+
 /* we only need the pnp layer to activate the device, at least for now */
 static struct pnp_driver parport_pc_pnp_driver = {
 	.name		= "parport_pc",
-	.id_table	= pnp_dev_table,
+	.id_table	= parport_pc_pnp_tbl,
+	.probe		= parport_pc_pnp_probe,
+	.remove		= parport_pc_pnp_remove,
 };
-#else
-static struct pnp_driver parport_pc_pnp_driver;
-#endif
+
 
 /* This is called by parport_pc_find_nonpci_ports (in asm/parport.h) */
 static int __init __attribute__((unused))
@@ -2903,12 +2955,18 @@
 	/* Onboard SuperIO chipsets that show themselves on the PCI bus. */
 	count += parport_pc_init_superio (autoirq, autodma);
 
+	r = pnp_register_driver (&parport_pc_pnp_driver);
+	if (r >= 0) {
+		pnp_registered_parport = 1;
+		count += r;
+	}
+
 	/* ISA ports and whatever (see asm/parport.h). */
 	count += parport_pc_find_nonpci_ports (autoirq, autodma);
 
 	r = pci_register_driver (&parport_pc_pci_driver);
 	if (r >= 0) {
-		registered_parport = 1;
+		pci_registered_parport = 1;
 		count += r;
 	}
 
@@ -3104,9 +3162,6 @@
 	if (parse_parport_params())
 		return -EINVAL;
 
-	/* try to activate any PnP parports first */
-	pnp_register_driver(&parport_pc_pnp_driver);
-
 	if (io[0]) {
 		int i;
 		/* Only probe the ports we were given. */
@@ -3120,24 +3175,18 @@
 						  irqval[i], dmaval[i], NULL))
 				count++;
 		}
-	} else {
+	} else
 		count += parport_pc_find_ports (irqval[0], dmaval[0]);
-		if (!count && registered_parport)
-			pci_unregister_driver (&parport_pc_pci_driver);
-	}
-
-	if (!count) {
-		pnp_unregister_driver (&parport_pc_pnp_driver);
-		return -ENODEV;
-	}
 
 	return 0;
 }
 
 static void __exit parport_pc_exit(void)
 {
-	if (registered_parport)
+	if (pci_registered_parport)
 		pci_unregister_driver (&parport_pc_pci_driver);
+	if (pnp_registered_parport)
+		pnp_unregister_driver (&parport_pc_pnp_driver);
 
 	spin_lock(&ports_lock);
 	while (!list_empty(&ports_list)) {
@@ -3151,13 +3200,8 @@
 		spin_lock(&ports_lock);
 	}
 	spin_unlock(&ports_lock);
-	pnp_unregister_driver (&parport_pc_pnp_driver);
 }
 
-
-MODULE_AUTHOR("Phil Blundell, Tim Waugh, others");
-MODULE_DESCRIPTION("PC-style parallel port driver");
-MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Phil Blundell, Tim Waugh, others");
 MODULE_DESCRIPTION("PC-style parallel port driver");
 MODULE_LICENSE("GPL");

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] PnP Updates for 2.6.4-mm2
  2004-03-15  0:10 ` Adam Belay
@ 2004-03-15  0:15   ` Adam Belay
  2004-03-15  0:21     ` Adam Belay
  0 siblings, 1 reply; 8+ messages in thread
From: Adam Belay @ 2004-03-15  0:15 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel

[ISAPNP] Fix Device Detection Issue

Some isapnp devices were not getting detected as a result of a bug in the isapnp 
driver.  It was not following the specifications and calculating a checksum when
it was not reliable.  This problem was originally discovered by Paul L. Rogers
<rogerspl@datasync.com>.  He made an initial patch.  This release has some small 
modifications, including a check to see if we run out of CSNs.

--- a/drivers/pnp/isapnp/core.c	2004-03-11 02:55:28.000000000 +0000
+++ b/drivers/pnp/isapnp/core.c	2004-03-14 21:55:12.000000000 +0000
@@ -99,6 +99,7 @@
 static unsigned char isapnp_checksum_value;
 static DECLARE_MUTEX(isapnp_cfg_mutex);
 static int isapnp_detected;
+static int isapnp_csn_count;

 /* some prototypes */
 
@@ -371,11 +372,14 @@
 			break;
 		}
 	      __next:
+		if (csn == 255)
+			break;
 		checksum = 0x6a;
 		chksum = 0x00;
 		bit = 0x00;
 	}
 	isapnp_wait();
+	isapnp_csn_count = csn;
 	return csn;
 }
 
@@ -880,7 +884,7 @@
 
 	isapnp_wait();
 	isapnp_key();
-	for (csn = 1; csn <= 10; csn++) {
+	for (csn = 1; csn <= isapnp_csn_count; csn++) {
 		isapnp_wake(csn);
 		isapnp_peek(header, 9);
 		checksum = isapnp_checksum(header);
@@ -890,12 +894,6 @@
 			header[4], header[5], header[6], header[7], header[8]);
 		printk(KERN_DEBUG "checksum = 0x%x\n", checksum);
 #endif
-		/* Don't be strict on the checksum, here !
-                   e.g. 'SCM SwapBox Plug and Play' has header[8]==0 (should be: b7)*/
-		if (header[8] == 0)
-			;
-		else if (checksum == 0x00 || checksum != header[8])	/* not valid CSN */
-			continue;
 		if ((card = isapnp_alloc(sizeof(struct pnp_card))) == NULL)
 			continue;

@@ -932,7 +930,7 @@

 int isapnp_cfg_begin(int csn, int logdev)
 {
-	if (csn < 1 || csn > 10 || logdev > 10)
+	if (csn < 1 || csn > isapnp_csn_count || logdev > 10)
 		return -EINVAL;
 	MOD_INC_USE_COUNT;
 	down(&isapnp_cfg_mutex);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] PnP Updates for 2.6.4-mm2
  2004-03-15  0:15   ` Adam Belay
@ 2004-03-15  0:21     ` Adam Belay
  2004-03-15  0:23       ` Adam Belay
  0 siblings, 1 reply; 8+ messages in thread
From: Adam Belay @ 2004-03-15  0:21 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel

[PNP] remove __init from system.c

This patch is from "Randy.Dunlap" <rddunlap@osdl.org>

// Linux 2.6.4-rc2
// These 2 functions shouldn't be __init for general PNP use.

diffstat:=
 drivers/pnp/system.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


diff -Naurp ./drivers/pnp/system.c~pnp_init ./drivers/pnp/system.c
--- ./drivers/pnp/system.c~pnp_init	2004-02-17 19:59:59.000000000 -0800
+++ ./drivers/pnp/system.c	2004-03-07 15:14:30.000000000 -0800
@@ -21,7 +21,7 @@ static const struct pnp_device_id pnp_de
 	{	"",			0	}
 };

-static void __init reserve_ioport_range(char *pnpid, int start, int end)
+static void reserve_ioport_range(char *pnpid, int start, int end)
 {
 	struct resource *res;
 	char *regionid;
@@ -49,7 +49,7 @@ static void __init reserve_ioport_range(
 	return;
 }

-static void __init reserve_resources_of_dev( struct pnp_dev *dev )
+static void reserve_resources_of_dev( struct pnp_dev *dev )
 {
 	int i;
 

 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] PnP Updates for 2.6.4-mm2
  2004-03-15  0:21     ` Adam Belay
@ 2004-03-15  0:23       ` Adam Belay
  2004-03-15  0:26         ` Adam Belay
  0 siblings, 1 reply; 8+ messages in thread
From: Adam Belay @ 2004-03-15  0:23 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel

[ISAPNP] Remove uneeded MOD_INC/DEC_USE_COUNT

From: Christoph Hellwig <hch@lst.de>

isapnp_cfg_begin and isapnp_cfg_end are exported symbols, so if any
module using them is loaded isapnp.o can't be unloaded anyway.


--- 1.43/drivers/pnp/isapnp/core.c	Sun Sep 21 21:10:18 2003
+++ edited/drivers/pnp/isapnp/core.c	Sun Oct  5 16:17:52 2003
@@ -934,7 +934,6 @@
 {
 	if (csn < 1 || csn > 10 || logdev > 10)
 		return -EINVAL;
-	MOD_INC_USE_COUNT;
 	down(&isapnp_cfg_mutex);
 	isapnp_wait();
 	isapnp_key();
@@ -962,7 +961,6 @@
 {
 	isapnp_wait();
 	up(&isapnp_cfg_mutex);
-	MOD_DEC_USE_COUNT;
 	return 0;
 }

 #undef SPRINTF


 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] PnP Updates for 2.6.4-mm2
  2004-03-15  0:23       ` Adam Belay
@ 2004-03-15  0:26         ` Adam Belay
  2004-03-15  0:27           ` Adam Belay
  0 siblings, 1 reply; 8+ messages in thread
From: Adam Belay @ 2004-03-15  0:26 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel

[SERIAL] Add a few ids

This patch adds a few pnp ids I've been collecting for a while.

--- a/drivers/serial/8250_pnp.c	2004-03-14 23:42:34.000000000 +0000
+++ b/drivers/serial/8250_pnp.c	2004-03-14 23:43:23.000000000 +0000
@@ -266,6 +266,8 @@
 	{	"RSS00A0",		0	},
 	/* Viking 56K FAX INT */
 	{	"RSS0262",		0	},
+	/* K56 par,VV,Voice,Speakphone,AudioSpan,PnP */
+	{       "RSS0250",              0       },
 	/* SupraExpress 28.8 Data/Fax PnP modem */
 	{	"SUP1310",		0	},
 	/* SupraExpress 33.6 Data/Fax PnP modem */
@@ -283,6 +285,8 @@
 	/* 3Com Corp. */
 	/* Gateway Telepath IIvi 33.6 */
 	{	"USR0000",		0	},
+	/* U.S. Robotics Sporster 33.6K Fax INT PnP */
+	{	"USR0002",		0	},
 	/*  Sportster Vi 14.4 PnP FAX Voicemail */
 	{	"USR0004",		0	},
 	/* U.S. Robotics 33.6K Voice INT PnP */
@@ -315,6 +319,8 @@
 	{	"USR9180",		0	},
 	/* U.S. Robotics 56K Voice INT PnP*/
 	{	"USR9190",		0	},
+	/* Rockwell's (PORALiNK) 33600 INT PNP */
+	{	"WCI0003",		0	},
 	/* Unkown PnP modems */
 	{	"PNPCXXX",		UNKNOWN_DEV	},
 	/* More unkown PnP modems */

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] PnP Updates for 2.6.4-mm2
  2004-03-15  0:26         ` Adam Belay
@ 2004-03-15  0:27           ` Adam Belay
  2004-03-15  0:33             ` Adam Belay
  0 siblings, 1 reply; 8+ messages in thread
From: Adam Belay @ 2004-03-15  0:27 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel

[ISAPNP] Remove Experimental Status

isapnp has been stable for a while in the new pnp layer.  This patch
unmarks it from experimental.

--- b/drivers/pnp/isapnp/Kconfig	2004-03-12 22:25:17.000000000 +0000
+++ a/drivers/pnp/isapnp/Kconfig	2004-03-14 23:32:23.000000000 +0000
@@ -2,8 +2,8 @@
 # ISA Plug and Play configuration
 #
 config ISAPNP
-	bool "ISA Plug and Play support (EXPERIMENTAL)"
-	depends on PNP && EXPERIMENTAL
+	bool "ISA Plug and Play support"
+	depends on PNP
 	help
 	  Say Y here if you would like support for ISA Plug and Play devices.
 	  Some information is in <file:Documentation/isapnp.txt>.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] PnP Updates for 2.6.4-mm2
  2004-03-15  0:27           ` Adam Belay
@ 2004-03-15  0:33             ` Adam Belay
  0 siblings, 0 replies; 8+ messages in thread
From: Adam Belay @ 2004-03-15  0:33 UTC (permalink / raw)
  To: Andrew Morton, linux-kernel

[ISAPNP] MEM Config Fix

This patch fixes a bug in the resource configuration function.  If there is
more than one memory range, the isapnp driver will write into the incorrect
configuration register.  I'm in the process of rewritting the configuration
code, but I think it's better to send this now rather than waiting to send
it all at once.

--- a/drivers/pnp/isapnp/core.c	2004-03-14 23:09:29.000000000 +0000
+++ b/drivers/pnp/isapnp/core.c	2004-03-14 23:08:46.000000000 +0000
@@ -1048,7 +1048,7 @@
 	for (tmp = 0; tmp < PNP_MAX_DMA && (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 && (res->mem_resource[tmp].flags & (IORESOURCE_MEM | IORESOURCE_UNSET)) == IORESOURCE_MEM; tmp++)
-		isapnp_write_word(ISAPNP_CFG_MEM+(tmp<<2), (res->mem_resource[tmp].start >> 8) & 0xffff);
+		isapnp_write_word(ISAPNP_CFG_MEM+(tmp<<3), (res->mem_resource[tmp].start >> 8) & 0xffff);
 	/* FIXME: We aren't handling 32bit mems properly here */
 	isapnp_activate(dev->number);
 	isapnp_cfg_end();

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-03-15  5:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-15  0:06 [PATCH] PnP Updates for 2.6.4-mm2 Adam Belay
2004-03-15  0:10 ` Adam Belay
2004-03-15  0:15   ` Adam Belay
2004-03-15  0:21     ` Adam Belay
2004-03-15  0:23       ` Adam Belay
2004-03-15  0:26         ` Adam Belay
2004-03-15  0:27           ` Adam Belay
2004-03-15  0:33             ` Adam Belay

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).