Skip to contentSkip to conversation

pnp - preparations and cleanups (1/13)

PATCH New Adam Belay 1 participant 1 message Feb 17, 2003 Pnp support

lore
Share & tools
lore

Adam Belay

author
#0 lore raw

PATCH 1/1 pnp - preparations and cleanups (1/13)

This patch contains several small changes and is necessary for the remaining patches in the series.

Please apply,
Adam

drivers/pnp/Makefile +1 -2
diff -urN a/drivers/pnp/Makefile b/drivers/pnp/Makefile
@@ -4,8 +4,7 @@
 
 pnp-card-$(CONFIG_PNP_CARD) = card.o
 
-obj-y		:= core.o driver.o resource.o interface.o quirks.o names.o system.o $(pnp-card-y)
+obj-y		:= core.o driver.o resource.o manager.o support.o interface.o quirks.o names.o system.o $(pnp-card-y)
 
 obj-$(CONFIG_PNPBIOS)		+= pnpbios/
 obj-$(CONFIG_ISAPNP)		+= isapnp/
-
drivers/pnp/base.h +30 -7
diff -urN a/drivers/pnp/base.h b/drivers/pnp/base.h
@@ -1,9 +1,32 @@
 extern struct bus_type pnp_bus_type;
 extern spinlock_t pnp_lock;
-extern void *pnp_alloc(long size);
-extern int pnp_interface_attach_device(struct pnp_dev *dev);
-extern void pnp_name_device(struct pnp_dev *dev);
-extern void pnp_fixup_device(struct pnp_dev *dev);
-extern void pnp_free_resources(struct pnp_resources *resources);
-extern int __pnp_add_device(struct pnp_dev *dev);
-extern void __pnp_remove_device(struct pnp_dev *dev);
+void *pnp_alloc(long size);
+int pnp_interface_attach_device(struct pnp_dev *dev);
+void pnp_name_device(struct pnp_dev *dev);
+void pnp_fixup_device(struct pnp_dev *dev);
+void pnp_free_resources(struct pnp_resources *resources);
+int __pnp_add_device(struct pnp_dev *dev);
+void __pnp_remove_device(struct pnp_dev *dev);
+
+/* resource conflict types */
+#define CONFLICT_TYPE_NONE	0x0000	/* there are no conflicts, other than those in the link */
+#define CONFLICT_TYPE_RESERVED	0x0001	/* the resource requested was reserved */
+#define CONFLICT_TYPE_IN_USE	0x0002	/* there is a conflict because the resource is in use */
+#define CONFLICT_TYPE_PCI	0x0004	/* there is a conflict with a pci device */
+#define CONFLICT_TYPE_INVALID	0x0008	/* the resource requested is invalid */
+#define CONFLICT_TYPE_INTERNAL	0x0010	/* resources within the device conflict with each ohter */
+#define CONFLICT_TYPE_PNP_WARM	0x0020	/* there is a conflict with a pnp device that is active */
+#define CONFLICT_TYPE_PNP_COLD	0x0040	/* there is a conflict with a pnp device that is disabled */
+
+/* conflict search modes */
+#define SEARCH_WARM 1	/* check for conflicts with active devices */
+#define SEARCH_COLD 0	/* check for conflicts with disabled devices */
+
+struct pnp_dev * pnp_check_port_conflicts(struct pnp_dev * dev, int idx, int mode);
+int pnp_check_port(struct pnp_dev * dev, int idx);
+struct pnp_dev * pnp_check_mem_conflicts(struct pnp_dev * dev, int idx, int mode);
+int pnp_check_mem(struct pnp_dev * dev, int idx);
+struct pnp_dev * pnp_check_irq_conflicts(struct pnp_dev * dev, int idx, int mode);
+int pnp_check_irq(struct pnp_dev * dev, int idx);
+struct pnp_dev * pnp_check_dma_conflicts(struct pnp_dev * dev, int idx, int mode);
+int pnp_check_dma(struct pnp_dev * dev, int idx);
drivers/pnp/card.c +4 -5
diff -urN a/drivers/pnp/card.c b/drivers/pnp/card.c
@@ -22,9 +22,9 @@
 
 LIST_HEAD(pnp_cards);
 
-static const struct pnp_card_device_id * match_card(struct pnpc_driver *drv, struct pnp_card *card)
+static const struct pnp_card_id * match_card(struct pnpc_driver *drv, struct pnp_card *card)
 {
-	const struct pnp_card_device_id *drv_id = drv->id_table;
+	const struct pnp_card_id *drv_id = drv->id_table;
 	while (*drv_id->id){
 		if (compare_pnp_id(card->id,drv_id->id))
 			return drv_id;
@@ -106,7 +106,6 @@
 		return -EINVAL;
 	sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number, card->number);
 	INIT_LIST_HEAD(&card->rdevs);
-	strcpy(card->dev.name,card->name);
 	card->dev.parent = &card->protocol->dev;
 	card->dev.bus = &pnpc_bus_type;
 	card->dev.release = &pnp_release_card;
@@ -221,7 +220,7 @@
 	cdrv = to_pnpc_driver(card->dev.driver);
 	if (dev->active == 0) {
 		if (!(cdrv->flags & PNPC_DRIVER_DO_NOT_ACTIVATE)) {
-			if(pnp_activate_dev(dev,NULL)<0) {
+			if(pnp_activate_dev(dev)<0) {
 				pnp_device_detach(dev);
 				return NULL;
 			}
@@ -286,7 +285,7 @@
 	int error = 0;
 	struct pnpc_driver *drv = to_pnpc_driver(dev->driver);
 	struct pnp_card *card = to_pnp_card(dev);
-	const struct pnp_card_device_id *card_id = NULL;
+	const struct pnp_card_id *card_id = NULL;
 
 	pnp_dbg("pnp: match found with the PnP card '%s' and the driver '%s'", dev->bus_id,drv->name);
 
drivers/pnp/core.c +12 -14
diff -urN a/drivers/pnp/core.c b/drivers/pnp/core.c
@@ -104,31 +104,29 @@
 static void pnp_release_device(struct device *dmdev)
 {
 	struct pnp_dev * dev = to_pnp_dev(dmdev);
-	if (dev->res)
-		pnp_free_resources(dev->res);
+	if (dev->possible)
+		pnp_free_resources(dev->possible);
 	pnp_free_ids(dev);
 	kfree(dev);
 }
 
 int __pnp_add_device(struct pnp_dev *dev)
 {
-	int error = 0;
+	int ret;
 	pnp_name_device(dev);
 	pnp_fixup_device(dev);
-	strncpy(dev->dev.name,dev->name,DEVICE_NAME_SIZE-1);
-	dev->dev.name[DEVICE_NAME_SIZE-1] = '\0';
 	dev->dev.bus = &pnp_bus_type;
 	dev->dev.release = &pnp_release_device;
 	dev->status = PNP_READY;
-	error = device_register(&dev->dev);
-	if (error == 0){
-		spin_lock(&pnp_lock);
-		list_add_tail(&dev->global_list, &pnp_global);
-		list_add_tail(&dev->protocol_list, &dev->protocol->devices);
-		spin_unlock(&pnp_lock);
+	spin_lock(&pnp_lock);
+	list_add_tail(&dev->global_list, &pnp_global);
+	list_add_tail(&dev->protocol_list, &dev->protocol->devices);
+	spin_unlock(&pnp_lock);
+	pnp_auto_config_dev(dev);
+	ret = device_register(&dev->dev);
+	if (ret == 0)
 		pnp_interface_attach_device(dev);
-	}
-	return error;
+	return ret;
 }
 
 /*
@@ -172,7 +170,7 @@
 
 static int __init pnp_init(void)
 {
-	printk(KERN_INFO "Linux Plug and Play Support v0.94 (c) Adam Belay\n");
+	printk(KERN_INFO "Linux Plug and Play Support v0.95 (c) Adam Belay\n");
 	return bus_register(&pnp_bus_type);
 }
 
drivers/pnp/driver.c +2 -2
diff -urN a/drivers/pnp/driver.c b/drivers/pnp/driver.c
@@ -95,7 +95,7 @@
 	pnp_dev = to_pnp_dev(dev);
 	pnp_drv = to_pnp_driver(dev->driver);
 
-	pnp_dbg("pnp: match found with the PnP device '%s' and the driver '%s'", dev->bus_id,pnp_drv->name);
+	pnp_dbg("match found with the PnP device '%s' and the driver '%s'", dev->bus_id,pnp_drv->name);
 
 	error = pnp_device_attach(pnp_dev);
 	if (error < 0)
@@ -103,7 +103,7 @@
 
 	if (pnp_dev->active == 0) {
 		if (!(pnp_drv->flags & PNP_DRIVER_DO_NOT_ACTIVATE)) {
-			error = pnp_activate_dev(pnp_dev, NULL);
+			error = pnp_activate_dev(pnp_dev);
 			if (error < 0)
 				return error;
 		}
drivers/pnp/names.c +1 -1
diff -urN a/drivers/pnp/names.c b/drivers/pnp/names.c
@@ -30,7 +30,7 @@
 pnp_name_device(struct pnp_dev *dev)
 {
 	int i;
-	char *name = dev->name;
+	char *name = dev->dev.name;
 	for(i=0; i<sizeof(pnp_id_eisaid)/sizeof(pnp_id_eisaid[0]); i++){
 		if (compare_pnp_id(dev->id,pnp_id_eisaid[i])){
 			sprintf(name, "%s", pnp_id_names[i]);
drivers/pnp/quirks.c +4 -4
diff -urN a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c
@@ -29,7 +29,7 @@
 static void quirk_awe32_resources(struct pnp_dev *dev)
 {
 	struct pnp_port *port, *port2, *port3;
-	struct pnp_resources *res = dev->res->dep;
+	struct pnp_resources *res = dev->possible->dep;
 
 	/*
 	 * Unfortunately the isapnp_add_port_resource is too tightly bound
@@ -57,7 +57,7 @@
 
 static void quirk_cmi8330_resources(struct pnp_dev *dev)
 {
-	struct pnp_resources *res = dev->res->dep;
+	struct pnp_resources *res = dev->possible->dep;
 
 	for ( ; res ; res = res->dep ) {
 
@@ -77,7 +77,7 @@
 static void quirk_sb16audio_resources(struct pnp_dev *dev)
 {
 	struct pnp_port *port;
-	struct pnp_resources *res = dev->res->dep;
+	struct pnp_resources *res = dev->possible->dep;
 	int    changed = 0;
 
 	/*
@@ -115,7 +115,7 @@
 	 */
 	struct pnp_resources *res;
 	int max;
-	res = dev->res;
+	res = dev->possible;
 	max = 0;
 	for (res = res->dep; res; res = res->dep) {
 		if (res->dma->map > max)
drivers/pnp/resource.c +328 -549

1,108 lines not on this page · raw message

drivers/pnp/system.c +1 -1
diff -urN a/drivers/pnp/system.c b/drivers/pnp/system.c
@@ -53,7 +53,7 @@
 {
 	int i;
 
-	for (i=0;i<DEVICE_COUNT_IO;i++) {
+	for (i=0;i<PNP_MAX_PORT;i++) {
 		if (pnp_port_valid(dev, i))
 			/* end of resources */
 			continue;
drivers/serial/8250_pnp.c +3 -3
diff -urN a/drivers/serial/8250_pnp.c b/drivers/serial/8250_pnp.c
@@ -317,7 +317,7 @@
 {
 	unsigned int map = 0x1FF8;
 	struct pnp_irq *irq;
-	struct pnp_resources *res = dev->res;
+	struct pnp_resources *res = dev->possible;
 
 	serial8250_get_irq_map(&map);
 
@@ -357,10 +357,10 @@
  */
 static int serial_pnp_guess_board(struct pnp_dev *dev, int *flags)
 {
-	struct pnp_resources *res = dev->res;
+	struct pnp_resources *res = dev->possible;
 	struct pnp_resources *resa;
 
-	if (!(check_name(dev->name) || (dev->card && check_name(dev->card->name))))
+	if (!(check_name(dev->dev.name) || (dev->card && check_name(dev->card->dev.name))))
 		return -ENODEV;
 
 	if (!res)
include/linux/ioport.h +1 -0
diff -urN a/include/linux/ioport.h b/include/linux/ioport.h
@@ -77,6 +77,7 @@
 #define IORESOURCE_MEM_8BIT		(0<<3)
 #define IORESOURCE_MEM_16BIT		(1<<3)
 #define IORESOURCE_MEM_8AND16BIT	(2<<3)
+#define IORESOURCE_MEM_32BIT		(3<<3)
 #define IORESOURCE_MEM_SHADOWABLE	(1<<5)	/* dup: IORESOURCE_SHADOWABLE */
 #define IORESOURCE_MEM_EXPANSIONROM	(1<<6)
 
include/linux/pnp.h +200 -192

553 lines not on this page · raw message