2002-12-29 11:25:14

by Jaroslav Kysela

[permalink] [raw]
Subject: [PATCH] pnp & pci structure cleanups

Hi,

this is my second pnp cleanup. It removes ISA PnP variables from
PCI structures, cleans isapnp.h header file and adds the compatibility
routines. Also, i82365 pcmcia driver is updated to latest PnP API
(in compatibility mode). This patch will cause that all unconverted
ISA PnP code will fail to compile, but it's better than silent failure
(like the current kernel tree does).

Jaroslav

You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.

===================================================================


[email protected], 2002-12-26 19:42:08+01:00, [email protected]
PnP update
- removed ISAPnP members from PCI structures
- isapnp.h cleanups (removal of duplicates)
- added compatible functions (pnp_find_dev and pnp_find_card)
- i82365 (pcmcia driver) - ported to new PnP layer


drivers/pcmcia/i82365.c | 26 +++-----
drivers/pnp/isapnp/Makefile | 4 -
drivers/pnp/isapnp/compat.c | 27 ++++----
drivers/pnp/isapnp/core.c | 54 ++++++++---------
drivers/pnp/isapnp/proc.c | 1
include/linux/isapnp.h | 138 --------------------------------------------
include/linux/pci.h | 19 ------
include/linux/pnp.h | 12 ++-
8 files changed, 66 insertions(+), 215 deletions(-)


diff -Nru a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
--- a/drivers/pcmcia/i82365.c Thu Dec 26 19:45:48 2002
+++ b/drivers/pcmcia/i82365.c Thu Dec 26 19:45:48 2002
@@ -814,7 +814,7 @@

#ifdef CONFIG_ISA

-#ifdef __ISAPNP__
+#ifdef CONFIG_PNP
static struct isapnp_device_id id_table[] __initdata = {
{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, ISAPNP_VENDOR('P', 'N', 'P'),
ISAPNP_FUNCTION(0x0e00), (unsigned long) "Intel 82365-Compatible" },
@@ -826,32 +826,28 @@
};
MODULE_DEVICE_TABLE(isapnp, id_table);

-static struct pci_dev *i82365_pnpdev;
+static struct pnp_dev *i82365_pnpdev;
#endif

static void __init isa_probe(void)
{
int i, j, sock, k, ns, id;
ioaddr_t port;
-#ifdef __ISAPNP__
+#ifdef CONFIG_PNP
struct isapnp_device_id *devid;
- struct pci_dev *dev;
+ struct pnp_dev *dev;

for (devid = id_table; devid->vendor; devid++) {
- if ((dev = isapnp_find_dev(NULL, devid->vendor, devid->function, NULL))) {
- printk("ISAPNP ");
+ if ((dev = pnp_find_dev(NULL, devid->vendor, devid->function, NULL))) {
+ printk("PNP ");

- if (dev->prepare && dev->prepare(dev) < 0) {
- printk("prepare failed\n");
- break;
- }
-
- if (dev->activate && dev->activate(dev) < 0) {
+ if (pnp_activate_dev(dev, NULL) < 0) {
printk("activate failed\n");
break;
}

- if ((i365_base = pci_resource_start(dev, 0))) {
+ i365_base = pnp_port_start(dev, 0);
+ if (i365_base) {
printk("no resources ?\n");
break;
}
@@ -1644,8 +1640,8 @@
release_region(socket[i].ioaddr, 2);
}
#if defined(CONFIG_ISA) && defined(__ISAPNP__)
- if (i82365_pnpdev && i82365_pnpdev->deactivate)
- i82365_pnpdev->deactivate(i82365_pnpdev);
+ if (i82365_pnpdev)
+ pnp_disable_dev(i82365_pnpdev);
#endif
} /* exit_i82365 */

diff -Nru a/drivers/pnp/isapnp/Makefile b/drivers/pnp/isapnp/Makefile
--- a/drivers/pnp/isapnp/Makefile Thu Dec 26 19:45:48 2002
+++ b/drivers/pnp/isapnp/Makefile Thu Dec 26 19:45:48 2002
@@ -2,8 +2,8 @@
# Makefile for the kernel ISAPNP driver.
#

-export-objs := core.o
+export-objs := core.o compat.o

isapnp-proc-$(CONFIG_PROC_FS) = proc.o

-obj-y := core.o $(isapnp-proc-y)
+obj-y := core.o compat.o $(isapnp-proc-y)
diff -Nru a/drivers/pnp/isapnp/compat.c b/drivers/pnp/isapnp/compat.c
--- a/drivers/pnp/isapnp/compat.c Thu Dec 26 19:45:48 2002
+++ b/drivers/pnp/isapnp/compat.c Thu Dec 26 19:45:48 2002
@@ -26,21 +26,20 @@
}

struct pnp_card *pnp_find_card(unsigned short vendor,
- unsigned short device,
- struct pnp_card *from)
+ unsigned short device,
+ struct pnp_card *from)
{
char id[7];
char any[7];
struct list_head *list;
pnp_convert_id(id, vendor, device);
pnp_convert_id(any, ISAPNP_ANY_ID, ISAPNP_ANY_ID);
- list = isapnp_cards.next;
- if (from)
- list = from->node.next;
-
- while (list != &isapnp_cards) {
- struct pnp_card *card = to_pnp_card(list);
- if (compare_pnp_id(&card->ids,id) || (memcmp(id,any,7)==0))
+
+ list = from ? from->global_list.next : pnp_cards.next;
+
+ while (list != &pnp_cards) {
+ struct pnp_card *card = global_to_pnp_card(list);
+ if (compare_pnp_id(card->id,id) || (memcmp(id,any,7)==0))
return card;
list = list->next;
}
@@ -48,9 +47,9 @@
}

struct pnp_dev *pnp_find_dev(struct pnp_card *card,
- unsigned short vendor,
- unsigned short function,
- struct pnp_dev *from)
+ unsigned short vendor,
+ unsigned short function,
+ struct pnp_dev *from)
{
char id[7];
char any[7];
@@ -65,7 +64,7 @@

while (list != &pnp_global) {
struct pnp_dev *dev = global_to_pnp_dev(list);
- if (compare_pnp_id(&dev->ids,id) || (memcmp(id,any,7)==0))
+ if (compare_pnp_id(dev->id,id) || (memcmp(id,any,7)==0))
return dev;
list = list->next;
}
@@ -80,7 +79,7 @@
}
while (list != &card->devices) {
struct pnp_dev *dev = card_to_pnp_dev(list);
- if (compare_pnp_id(&dev->ids,id))
+ if (compare_pnp_id(dev->id,id))
return dev;
list = list->next;
}
diff -Nru a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
--- a/drivers/pnp/isapnp/core.c Thu Dec 26 19:45:48 2002
+++ b/drivers/pnp/isapnp/core.c Thu Dec 26 19:45:48 2002
@@ -42,12 +42,8 @@
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/isapnp.h>
-#include <linux/pnp.h>
#include <asm/io.h>

-LIST_HEAD(isapnp_cards);
-LIST_HEAD(isapnp_devices);
-
#if 0
#define ISAPNP_REGION_OK
#endif
@@ -106,6 +102,8 @@
/* some prototypes */

static int isapnp_config_prepare(struct pnp_dev *dev);
+extern struct pnp_protocol isapnp_card_protocol;
+extern struct pnp_protocol isapnp_protocol;

static inline void write_data(unsigned char x)
{
@@ -521,7 +519,7 @@
port->max = (tmp[4] << 8) | tmp[3];
port->align = tmp[5];
port->size = tmp[6];
- port->flags = tmp[0] ? ISAPNP_PORT_FLAG_16BITADDR : 0;
+ port->flags = tmp[0] ? PNP_PORT_FLAG_16BITADDR : 0;
pnp_add_port_resource(dev,depnum,port);
return;
}
@@ -543,7 +541,7 @@
port->min = port->max = (tmp[1] << 8) | tmp[0];
port->size = tmp[2];
port->align = 0;
- port->flags = ISAPNP_PORT_FLAG_FIXED;
+ port->flags = PNP_PORT_FLAG_FIXED;
pnp_add_port_resource(dev,depnum,port);
return;
}
@@ -686,7 +684,7 @@
case _STAG_STARTDEP:
if (size > 1)
goto __skip;
- dependent = 0x100 | ISAPNP_RES_PRIORITY_ACCEPTABLE;
+ dependent = 0x100 | PNP_RES_PRIORITY_ACCEPTABLE;
if (size > 0) {
isapnp_peek(tmp, size);
dependent = 0x100 | tmp[0];
@@ -891,7 +889,7 @@
if (isapnp_checksum_value != 0x00)
printk(KERN_ERR "isapnp: checksum for device %i is not valid (0x%x)\n", csn, isapnp_checksum_value);
card->checksum = isapnp_checksum_value;
- card->protocol = &isapnp_protocol;
+ card->protocol = &isapnp_card_protocol;
pnpc_add_card(card);
}
return 0;
@@ -903,7 +901,12 @@

int isapnp_present(void)
{
- return !list_empty(&isapnp_devices);
+ struct pnp_card *card;
+ pnp_for_each_card(card) {
+ if (card->protocol == &isapnp_card_protocol)
+ return 1;
+ }
+ return 0;
}

int isapnp_cfg_begin(int csn, int logdev)
@@ -970,24 +973,11 @@
return 0;
}

-void isapnp_resource_change(struct resource *resource,
- unsigned long start,
- unsigned long size)
-{
- if (resource == NULL)
- return;
- resource->flags &= ~IORESOURCE_AUTO;
- resource->start = start;
- resource->end = start + size - 1;
-}
-
/*
* Inititialization.
*/


-EXPORT_SYMBOL(isapnp_cards);
-EXPORT_SYMBOL(isapnp_devices);
EXPORT_SYMBOL(isapnp_present);
EXPORT_SYMBOL(isapnp_cfg_begin);
EXPORT_SYMBOL(isapnp_cfg_end);
@@ -999,7 +989,6 @@
EXPORT_SYMBOL(isapnp_write_dword);
EXPORT_SYMBOL(isapnp_wake);
EXPORT_SYMBOL(isapnp_device);
-EXPORT_SYMBOL(isapnp_resource_change);

static int isapnp_get_resources(struct pnp_dev *dev)
{
@@ -1053,8 +1042,15 @@
return 0;
}

+struct pnp_protocol isapnp_card_protocol = {
+ .name = "ISA Plug and Play - card",
+ .get = NULL,
+ .set = NULL,
+ .disable = NULL,
+};
+
struct pnp_protocol isapnp_protocol = {
- .name = "ISA Plug and Play",
+ .name = "ISA Plug and Play - device",
.get = isapnp_get_resources,
.set = isapnp_set_resources,
.disable = isapnp_disable_resources,
@@ -1064,6 +1060,7 @@
{
int cards;
struct pnp_card *card;
+ struct pnp_dev *dev;

if (isapnp_disable) {
isapnp_detected = 0;
@@ -1084,6 +1081,9 @@
return -EBUSY;
}

+ if(pnp_register_protocol(&isapnp_card_protocol)<0)
+ return -EBUSY;
+
if(pnp_register_protocol(&isapnp_protocol)<0)
return -EBUSY;

@@ -1126,13 +1126,11 @@
protocol_for_each_card(&isapnp_protocol,card) {
cards++;
if (isapnp_verbose) {
- struct list_head *devlist;
printk(KERN_INFO "isapnp: Card '%s'\n", card->name[0]?card->name:"Unknown");
if (isapnp_verbose < 2)
continue;
- for (devlist = card->devices.next; devlist != &card->devices; devlist = devlist->next) {
- struct pci_dev *dev = pci_dev_b(devlist);
- printk(KERN_INFO "isapnp: Device '%s'\n", dev->dev.name[0]?card->name:"Unknown");
+ pnp_card_for_each_dev(card,dev) {
+ printk(KERN_INFO "isapnp: Device '%s'\n", dev->name[0]?dev->name:"Unknown");
}
}
}
diff -Nru a/drivers/pnp/isapnp/proc.c b/drivers/pnp/isapnp/proc.c
--- a/drivers/pnp/isapnp/proc.c Thu Dec 26 19:45:48 2002
+++ b/drivers/pnp/isapnp/proc.c Thu Dec 26 19:45:48 2002
@@ -28,6 +28,7 @@
#include <linux/smp_lock.h>
#include <asm/uaccess.h>

+extern struct pnp_protocol isapnp_protocol;

static struct proc_dir_entry *isapnp_proc_bus_dir = NULL;

diff -Nru a/include/linux/isapnp.h b/include/linux/isapnp.h
--- a/include/linux/isapnp.h Thu Dec 26 19:45:48 2002
+++ b/include/linux/isapnp.h Thu Dec 26 19:45:48 2002
@@ -24,6 +24,7 @@

#include <linux/config.h>
#include <linux/errno.h>
+#include <linux/pnp.h>

/*
* Configuration registers (TODO: change by specification)
@@ -54,79 +55,7 @@

#ifdef __KERNEL__

-#include <linux/pci.h>
-
-#define ISAPNP_PORT_FLAG_16BITADDR (1<<0)
-#define ISAPNP_PORT_FLAG_FIXED (1<<1)
-
-struct isapnp_port {
- unsigned short min; /* min base number */
- unsigned short max; /* max base number */
- unsigned char align; /* align boundary */
- unsigned char size; /* size of range */
- unsigned char flags; /* port flags */
- unsigned char pad; /* pad */
- struct isapnp_resources *res; /* parent */
- struct isapnp_port *next; /* next port */
-};
-
-struct isapnp_irq {
- unsigned short map; /* bitmaks for IRQ lines */
- unsigned char flags; /* IRQ flags */
- unsigned char pad; /* pad */
- struct isapnp_resources *res; /* parent */
- struct isapnp_irq *next; /* next IRQ */
-};
-
-struct isapnp_dma {
- unsigned char map; /* bitmask for DMA channels */
- unsigned char flags; /* DMA flags */
- struct isapnp_resources *res; /* parent */
- struct isapnp_dma *next; /* next port */
-};
-
-struct isapnp_mem {
- unsigned int min; /* min base number */
- unsigned int max; /* max base number */
- unsigned int align; /* align boundary */
- unsigned int size; /* size of range */
- unsigned char flags; /* memory flags */
- unsigned char pad; /* pad */
- struct isapnp_resources *res; /* parent */
- struct isapnp_mem *next; /* next memory resource */
-};
-
-struct isapnp_mem32 {
- /* TODO */
- unsigned char data[17];
- struct isapnp_resources *res; /* parent */
- struct isapnp_mem32 *next; /* next 32-bit memory resource */
-};
-
-struct isapnp_fixup {
- unsigned short vendor; /* matching vendor */
- unsigned short device; /* matching device */
- void (*quirk_function)(struct pci_dev *dev); /* fixup function */
-};
-
-
-#define ISAPNP_RES_PRIORITY_PREFERRED 0
-#define ISAPNP_RES_PRIORITY_ACCEPTABLE 1
-#define ISAPNP_RES_PRIORITY_FUNCTIONAL 2
-#define ISAPNP_RES_PRIORITY_INVALID 65535
-
-struct isapnp_resources {
- unsigned short priority; /* priority */
- unsigned short dependent; /* dependent resources */
- struct isapnp_port *port; /* first port */
- struct isapnp_irq *irq; /* first IRQ */
- struct isapnp_dma *dma; /* first DMA */
- struct isapnp_mem *mem; /* first memory resource */
- struct isapnp_mem32 *mem32; /* first 32-bit memory */
- struct pci_dev *dev; /* parent */
- struct isapnp_resources *alt; /* alternative resource (aka dependent resources) */
- struct isapnp_resources *next; /* next resource */
-};
+#define DEVICE_COUNT_COMPATIBLE 4

#define ISAPNP_ANY_ID 0xffff
#define ISAPNP_CARD_DEVS 8
@@ -162,14 +91,6 @@
unsigned long driver_data; /* data private to the driver */
};

-struct isapnp_driver {
- struct list_head node;
- char *name;
- const struct isapnp_device_id *id_table; /* NULL if wants all devices */
- int (*probe) (struct pci_dev *dev, const struct isapnp_device_id *id); /* New device inserted */
- void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
-};
-
#if defined(CONFIG_ISAPNP) || (defined(CONFIG_ISAPNP_MODULE) && defined(MODULE))

#define __ISAPNP__
@@ -188,7 +109,6 @@
void isapnp_device(unsigned char device);
void isapnp_activate(unsigned char device);
void isapnp_deactivate(unsigned char device);
-void isapnp_fixup_device(struct pci_dev *dev);
void *isapnp_alloc(long size);

#ifdef CONFIG_PROC_FS
@@ -199,40 +119,8 @@
static inline isapnp_proc_done(void) { return 0; }
#endif

-/* misc */
-void isapnp_resource_change(struct resource *resource,
- unsigned long start,
- unsigned long size);
/* init/main.c */
int isapnp_init(void);
-/* manager */
-static inline struct pci_bus *isapnp_find_card(unsigned short vendor,
- unsigned short device,
- struct pci_bus *from) { return NULL; }
-static inline struct pci_dev *isapnp_find_dev(struct pci_bus *card,
- unsigned short vendor,
- unsigned short function,
- struct pci_dev *from) { return NULL; }
-static inline int isapnp_probe_cards(const struct isapnp_card_id *ids,
- int (*probe)(struct pci_bus *card,
- const struct isapnp_card_id *id)) { return -ENODEV; }
-static inline int isapnp_probe_devs(const struct isapnp_device_id *ids,
- int (*probe)(struct pci_dev *dev,
- const struct isapnp_device_id *id)) { return -ENODEV; }
-static inline int isapnp_activate_dev(struct pci_dev *dev, const char *name) { return -ENODEV; }
-
-static inline int isapnp_register_driver(struct isapnp_driver *drv) { return 0; }
-
-static inline void isapnp_unregister_driver(struct isapnp_driver *drv) { }
-
-extern struct list_head isapnp_cards;
-extern struct list_head isapnp_devices;
-extern struct pnp_protocol isapnp_protocol;
-
-#define isapnp_for_each_card(card) \
- for(card = to_pnp_card(isapnp_cards.next); card != to_pnp_card(&isapnp_cards); card = to_pnp_card(card->node.next))
-#define isapnp_for_each_dev(dev) \
- for(dev = protocol_to_pnp_dev(isapnp_protocol.devices.next); dev != protocol_to_pnp_dev(&isapnp_protocol.devices); dev = protocol_to_pnp_dev(dev->dev_list.next))

#else /* !CONFIG_ISAPNP */

@@ -250,28 +138,6 @@
static inline void isapnp_device(unsigned char device) { ; }
static inline void isapnp_activate(unsigned char device) { ; }
static inline void isapnp_deactivate(unsigned char device) { ; }
-/* manager */
-static inline struct pci_bus *isapnp_find_card(unsigned short vendor,
- unsigned short device,
- struct pci_bus *from) { return NULL; }
-static inline struct pci_dev *isapnp_find_dev(struct pci_bus *card,
- unsigned short vendor,
- unsigned short function,
- struct pci_dev *from) { return NULL; }
-static inline int isapnp_probe_cards(const struct isapnp_card_id *ids,
- int (*probe)(struct pci_bus *card,
- const struct isapnp_card_id *id)) { return -ENODEV; }
-static inline int isapnp_probe_devs(const struct isapnp_device_id *ids,
- int (*probe)(struct pci_dev *dev,
- const struct isapnp_device_id *id)) { return -ENODEV; }
-static inline void isapnp_resource_change(struct resource *resource,
- unsigned long start,
- unsigned long size) { ; }
-static inline int isapnp_activate_dev(struct pci_dev *dev, const char *name) { return -ENODEV; }
-
-static inline int isapnp_register_driver(struct isapnp_driver *drv) { return 0; }
-
-static inline void isapnp_unregister_driver(struct isapnp_driver *drv) { }

#endif /* CONFIG_ISAPNP */

diff -Nru a/include/linux/pci.h b/include/linux/pci.h
--- a/include/linux/pci.h Thu Dec 26 19:45:48 2002
+++ b/include/linux/pci.h Thu Dec 26 19:45:48 2002
@@ -362,7 +362,7 @@
#define PCI_ANY_ID (~0)

/*
- * The pci_dev structure is used to describe both PCI and ISAPnP devices.
+ * The pci_dev structure is used to describe PCI devices.
*/
struct pci_dev {
struct list_head global_list; /* node in list of all PCI devices */
@@ -410,16 +410,9 @@
struct resource irq_resource[DEVICE_COUNT_IRQ];

char slot_name[8]; /* slot name */
- int active; /* ISAPnP: device is active */
- int ro; /* ISAPnP: read only */
- unsigned short regs; /* ISAPnP: supported registers */

/* These fields are used by common fixups */
- unsigned short transparent:1; /* Transparent PCI bridge */
-
- int (*prepare)(struct pci_dev *dev); /* ISAPnP hooks */
- int (*activate)(struct pci_dev *dev);
- int (*deactivate)(struct pci_dev *dev);
+ unsigned int transparent:1; /* Transparent PCI bridge */
};

#define pci_dev_g(n) list_entry(n, struct pci_dev, global_list)
@@ -463,13 +456,7 @@
unsigned char subordinate; /* max number of subordinate buses */

char name[48];
- unsigned short vendor;
- unsigned short device;
- unsigned int serial; /* serial number */
- unsigned char pnpver; /* Plug & Play version */
- unsigned char productver; /* product version */
- unsigned char checksum; /* if zero - checksum passed */
- unsigned char pad1;
+
struct device * dev;
};

diff -Nru a/include/linux/pnp.h b/include/linux/pnp.h
--- a/include/linux/pnp.h Thu Dec 26 19:45:48 2002
+++ b/include/linux/pnp.h Thu Dec 26 19:45:48 2002
@@ -51,11 +51,15 @@

#define global_to_pnp_card(n) list_entry(n, struct pnp_card, global_list)
#define protocol_to_pnp_card(n) list_entry(n, struct pnp_card, protocol_list)
-#define to_pnp_card(n) list_entry(n, struct pnp_card, dev)
+#define to_pnp_card(n) container_of(n, struct pnp_card, dev)
#define pnp_for_each_card(card) \
- for(dev = global_to_pnp_card(pnp_cards.next); \
- dev != global_to_pnp_card(&cards); \
- dev = global_to_pnp_card(card>global_list.next))
+ for((card) = global_to_pnp_card(pnp_cards.next); \
+ (card) != global_to_pnp_card(&pnp_cards); \
+ (card) = global_to_pnp_card((card)->global_list.next))
+#define pnp_card_for_each_dev(card,dev) \
+ for((dev) = card_to_pnp_dev((card)->devices.next); \
+ (dev) != card_to_pnp_dev(&(card)->devices); \
+ (dev) = card_to_pnp_dev((dev)->card_list.next))

static inline void *pnpc_get_drvdata (struct pnp_card *pcard)
{

===================================================================


This BitKeeper patch contains the following changesets:
1.902
## Wrapped with gzip_uu ##


begin 664 bkpatch896
M'XL(`%Q."SX``[4:_7/:./9G_%>HZ=TN=`-(\C<IV:0A[3';39@TN;F==H<1
MMISX`C9CFS2Y9?_W>T_&Q!!"@-VDC57+3T_O^T/J6W*5RJ15&<M$WFMOR;_B
M-&M5TDDJ&][_X/TBCN&]>1./9%/!-`>WS6$83>[K:3R)_.;W.+G5`+`G,N^&
MW,DD;5580Y_/9`]CV:I<G'ZZ^GQ\H6GM-CFY$=&U_"(STFYK69S<B:&?'HGL
M9AA'C2P143J2F6AX\6@Z!YUR2CG\,9FM4].:,HL:]M1C/F/"8-*GW'`L0U,4
M'LVH7UK-.+>8:5K,G7+78K;6(:SA4DXH;S+>Y!9A;LO@+>K\1%F+4K*`C/SD
MD#K5/I"_E^`3S2.]J$<F8U]D$EX(J9-$CN([Z9/NEV/\-I*C`8B5!$D\(KV3
M+DFS9.)EDT2FLP5A*L;1N'%#O*$4T62<DJK"(88D#H@_&0]##]"GM1F\\'U`
M#_2.118.AI($D\C+PCB"A8"H'X21W_?E'1&13^83GDC\`D/H<-TR`=H;>:$@
M?A*"YFOP81PG&>#.8A+)[XJUH7B0B?8+X5QGAM9[5+]6W_)'TZB@VN$+*@@C
M;SCQ96ZDS4(T97VX!I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#Y-:YE!C`JDL);
MNO`V"S&DF/D3VV`@RK1G1.&X?I^\YH"=`-Q2MK`RX*-98Q$'DE21%VIUJ#V@
M[BM8JJX6YGN*\IP)L'[ZX>K+;SF-3"6M#K9?RFL@_>>'"2_57ZA.@,J3Q"^G
M%V?][MG'<[*7;]^"\-M1+)$?_YG^^"W:4PFG?H@R`+_X>?[2VKN*;J/X>[3W
M?#S.SR!WB<=;'89NT2<OG(I2BYK<A.ALP3O-RR:Z<=GT6G<VB[$9XB^>V+X<
M?7/.=HB^>`S%MHJ?3[O2^2W1BZK^*U<HFO!&$JKD2*JZ!?$U!DFI2EYWJ<(H
MU,C<-?0I=1S'4MJVMSBR8+KU^NI&9QM*K)F+B[K'ZS,,.M`EJ"[++UW4J7,.
M=4^TMHLMI+&+A?"\V,WQD?>EMO@0,J%-;(Q`*B`576#G]-_=D]/^R?G5V24\
M?^T=7W8AB1$#ZT"3.#"X#`,82`DG.69]F.6F3CA?=>Z!1_3;FM<6]P,:AHRC
MVR06-VL1,41E4U>=9=MF?I8-_?F&AH1GV:]C1Q>+-[MI-@D"5;WA+<;Z\PUD
M;I>R#:]I(4_F`WE'+F^@_?="E?;F]@GA@P#WJ@OT9>HEX4"JJ^:BPX?"CV$.
M@\$AIM:%B(YI='Z8"XFJHL2#)ZE1UF('E2;L]3BCL`V2T+^6Y%T3\$`>QO-P
?&_%\>_P/!-Z-]&[3R:BM#W0V<*BC_1]F440XHB``````
`
end

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs


2002-12-30 22:08:46

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] pnp & pci structure cleanups

On Sun, Dec 29, 2002 at 12:33:03PM +0100, Jaroslav Kysela wrote:
> Hi,
>
> this is my second pnp cleanup. It removes ISA PnP variables from
> PCI structures, cleans isapnp.h header file and adds the compatibility
> routines. Also, i82365 pcmcia driver is updated to latest PnP API
> (in compatibility mode). This patch will cause that all unconverted
> ISA PnP code will fail to compile, but it's better than silent failure
> (like the current kernel tree does).

Yeah! Thanks for taking these fields out of pci.h, I really appreciate
it. I'll send this on to Linus in a bit.

thanks,

greg k-h

2002-12-30 22:22:43

by Alan

[permalink] [raw]
Subject: Re: [PATCH] pnp & pci structure cleanups

On Mon, 2002-12-30 at 22:12, Greg KH wrote:
> Yeah! Thanks for taking these fields out of pci.h, I really appreciate
> it. I'll send this on to Linus in a bit.

Argh I was using those to implement a test "pci_compatible" driver so
that you could feed new pci idents to old drivers. Oh well

2002-12-30 22:41:54

by Jeff Garzik

[permalink] [raw]
Subject: Re: [PATCH] pnp & pci structure cleanups

On Mon, Dec 30, 2002 at 11:12:40PM +0000, Alan Cox wrote:
> On Mon, 2002-12-30 at 22:12, Greg KH wrote:
> > Yeah! Thanks for taking these fields out of pci.h, I really appreciate
> > it. I'll send this on to Linus in a bit.
>
> Argh I was using those to implement a test "pci_compatible" driver so
> that you could feed new pci idents to old drivers. Oh well

Note that we need a way to do field replacement of PCI id tables.

I've been harping on that to various ears for years :)

<tangent>
I also want to add PCI revision id and mask to struct pci_device_id.
</tangent>

Jeff



2002-12-30 22:48:08

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] pnp & pci structure cleanups

On Mon, Dec 30, 2002 at 05:50:12PM -0500, Jeff Garzik wrote:
> On Mon, Dec 30, 2002 at 11:12:40PM +0000, Alan Cox wrote:
> > On Mon, 2002-12-30 at 22:12, Greg KH wrote:
> > > Yeah! Thanks for taking these fields out of pci.h, I really appreciate
> > > it. I'll send this on to Linus in a bit.
> >
> > Argh I was using those to implement a test "pci_compatible" driver so
> > that you could feed new pci idents to old drivers. Oh well
>
> Note that we need a way to do field replacement of PCI id tables.
>
> I've been harping on that to various ears for years :)

And USB id tables. A number of usb drivers are slowly adding module
paramater hacks to get around this, but it would be really nice to do
this "correctly" for all drivers. Somehow...

> <tangent>
> I also want to add PCI revision id and mask to struct pci_device_id.
> </tangent>

Do any drivers need that today? It shouldn't be that hard to do it, and
now is the time :)

thanks,

greg k-h

2002-12-30 23:06:19

by Jeff Garzik

[permalink] [raw]
Subject: Re: [PATCH] pnp & pci structure cleanups

On Mon, Dec 30, 2002 at 02:51:34PM -0800, Greg KH wrote:
> On Mon, Dec 30, 2002 at 05:50:12PM -0500, Jeff Garzik wrote:
> > On Mon, Dec 30, 2002 at 11:12:40PM +0000, Alan Cox wrote:
> > > On Mon, 2002-12-30 at 22:12, Greg KH wrote:
> > > > Yeah! Thanks for taking these fields out of pci.h, I really appreciate
> > > > it. I'll send this on to Linus in a bit.
> > >
> > > Argh I was using those to implement a test "pci_compatible" driver so
> > > that you could feed new pci idents to old drivers. Oh well
> >
> > Note that we need a way to do field replacement of PCI id tables.
> >
> > I've been harping on that to various ears for years :)
>
> And USB id tables. A number of usb drivers are slowly adding module
> paramater hacks to get around this, but it would be really nice to do
> this "correctly" for all drivers. Somehow...

Surely there is a sysfs path we can devise to do

echo "add <pci_device_id line>" > /sys/pci/driver/tulip

(or replace that with a file-oriented interface that inputs an entire
table)

and internally just refer to, and update, a kmalloc'd copy of the
original driver's pci (or usb) table.


> > <tangent>
> > I also want to add PCI revision id and mask to struct pci_device_id.
> > </tangent>
>
> Do any drivers need that today? It shouldn't be that hard to do it, and
> now is the time :)

Yes. tulip driver could find this useful, but that's currently a small
case worked around in the driver.

The big and annoying case is 8139C+ (8139cp.c), which has the same
PCI id as old 8139 boards, but additionally includes dramatically new
and better functionality. The distinguishing characteristic at the
probe phase is the PCI revision id, as the PCI id is the same as another
driver.

Jeff


2002-12-30 23:56:12

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] pnp & pci structure cleanups

On Mon, Dec 30, 2002 at 06:14:36PM -0500, Jeff Garzik wrote:
> On Mon, Dec 30, 2002 at 02:51:34PM -0800, Greg KH wrote:
> > On Mon, Dec 30, 2002 at 05:50:12PM -0500, Jeff Garzik wrote:
> > > Note that we need a way to do field replacement of PCI id tables.
> > >
> > > I've been harping on that to various ears for years :)
> >
> > And USB id tables. A number of usb drivers are slowly adding module
> > paramater hacks to get around this, but it would be really nice to do
> > this "correctly" for all drivers. Somehow...
>
> Surely there is a sysfs path we can devise to do
>
> echo "add <pci_device_id line>" > /sys/pci/driver/tulip
>
> (or replace that with a file-oriented interface that inputs an entire
> table)
>
> and internally just refer to, and update, a kmalloc'd copy of the
> original driver's pci (or usb) table.

Yes, that would be a good thing to have, I sure would like that.

(hint, hint, hint, for anyone wanting a way to contribute...)

> > > <tangent>
> > > I also want to add PCI revision id and mask to struct pci_device_id.
> > > </tangent>
> >
> > Do any drivers need that today? It shouldn't be that hard to do it, and
> > now is the time :)
>
> Yes. tulip driver could find this useful, but that's currently a small
> case worked around in the driver.
>
> The big and annoying case is 8139C+ (8139cp.c), which has the same
> PCI id as old 8139 boards, but additionally includes dramatically new
> and better functionality. The distinguishing characteristic at the
> probe phase is the PCI revision id, as the PCI id is the same as another
> driver.

Ok, sounds like a good enough reason to add these fields :)

thanks,

greg k-h

2002-12-31 01:00:30

by Alan

[permalink] [raw]
Subject: Re: [PATCH] pnp & pci structure cleanups

Ok. Suggestion for how to handle this (not yet tried). Change the
assumption about the end marker. Right now the end marker only uses the
first fields and the user data happens to always be zero. If we change
the pci matching code to interpret end markers with a non zero userdata
as a pointer to the next table it all seems to come out in the wash,
although there are some tricky details to consider - who frees up the
extra tables on a module unload (if anyone), and how do we manage
multiple modules with chains of tables (or do we just disallow that
case).

I think it also means we need to be able to go pci table -> owner ?

Alan



2002-12-31 01:39:11

by Jeff Garzik

[permalink] [raw]
Subject: Re: [PATCH] pnp & pci structure cleanups

On Tue, Dec 31, 2002 at 01:50:26AM +0000, Alan Cox wrote:
> Ok. Suggestion for how to handle this (not yet tried). Change the
> assumption about the end marker. Right now the end marker only uses the
> first fields and the user data happens to always be zero. If we change
> the pci matching code to interpret end markers with a non zero userdata
> as a pointer to the next table it all seems to come out in the wash,

I like it


> although there are some tricky details to consider - who frees up the
> extra tables on a module unload (if anyone), and how do we manage
> multiple modules with chains of tables (or do we just disallow that
> case).

There will definitely be cases where people will want to black out
existing entries too.
Or would that open up to too much potential vendor abuse?


> I think it also means we need to be able to go pci table -> owner ?

I don't really see why. If you wanted to be terribly correct have
these things as refcounting kobjects or similar... But really, with all
those other wonderfully unlocked PCI lists in the core, why starting
doing it The Right Way now? ;-)

Jeff




2002-12-31 01:58:05

by Alan

[permalink] [raw]
Subject: Re: [PATCH] pnp & pci structure cleanups

On Tue, 2002-12-31 at 01:47, Jeff Garzik wrote:
> There will definitely be cases where people will want to black out
> existing entries too.
> Or would that open up to too much potential vendor abuse?

I'm not sure. At the point this occurs the end user has either directly
chosen to replace a driver, or indirectly installed software they want
which does so. It probably should log that an alternative driver setup
has been configured so the user can figure out wtf is going on when
debugging weirdness.

Its providing the same facilities as rm /lib/modules/... at a finer
granularity - if I want to force e100 not eepro100 for a given card for
example.

> > I think it also means we need to be able to go pci table -> owner ?
>
> I don't really see why. If you wanted to be terribly correct have
> these things as refcounting kobjects or similar... But really, with all
> those other wonderfully unlocked PCI lists in the core, why starting
> doing it The Right Way now? ;-)

PCI list locking is easy to fix.

1. Take a list walking semaphore before scanning internally
2. Refcount up the pci device before calling the device inserted method
Refcount down the pci device before calling the device removed method
3. Add pci_lock/unlock functions, and pci_get/put functions
4. Add pci_device_present(vendor, device). Swap the ab-users of pci_
for this to it
5. Clean up drivers as we go along

Almost all the hotplug horrors are zapped at the point #1 and #2 are
done. Its also easy to assert the lock must be taken in pci_find_* when
debugging to squish the rest

Alan
--
It ain't over until the vax server pings..