patch-2.3.39 linux/drivers/pcmcia/cardbus.c
Next file: linux/drivers/pcmcia/cs.c
Previous file: linux/drivers/pci/proc.c
Back to the patch index
Back to the overall index
- Lines: 178
- Date:
Sun Jan 9 16:36:02 2000
- Orig file:
v2.3.38/linux/drivers/pcmcia/cardbus.c
- Orig date:
Fri Jan 7 19:13:22 2000
diff -u --recursive --new-file v2.3.38/linux/drivers/pcmcia/cardbus.c linux/drivers/pcmcia/cardbus.c
@@ -99,11 +99,6 @@
#define PCDATA_CODE_TYPE 0x0014
#define PCDATA_INDICATOR 0x0015
-#ifndef CONFIG_PROC_FS
-#define pci_proc_attach_device(dev) do { } while (0)
-#define pci_proc_detach_device(dev) do { } while (0)
-#endif
-
typedef struct cb_config_t {
struct pci_dev dev;
} cb_config_t;
@@ -261,6 +256,21 @@
=====================================================================*/
+static int cb_assign_irq(u32 mask)
+{
+ int irq, try;
+
+ for (try = 0; try < 2; try++) {
+ for (irq = 1; irq < 32; irq++) {
+ if ((mask >> irq) & 1) {
+ if (try_irq(IRQ_TYPE_EXCLUSIVE, irq, try) == 0)
+ return irq;
+ }
+ }
+ }
+ return 0;
+}
+
int cb_alloc(socket_info_t * s)
{
struct pci_bus *bus;
@@ -268,6 +278,7 @@
u_short vend, v, dev;
u_char i, hdr, fn;
cb_config_t *c;
+ int irq;
bus = s->cap.cb_dev->subordinate;
memset(&tmp, 0, sizeof(tmp));
@@ -297,8 +308,10 @@
return CS_OUT_OF_RESOURCE;
memset(c, 0, fn * sizeof(struct cb_config_t));
+ irq = s->cap.pci_irq;
for (i = 0; i < fn; i++) {
struct pci_dev *dev = &c[i].dev;
+ u8 irq_pin;
int r;
dev->bus = bus;
@@ -306,9 +319,10 @@
dev->devfn = i;
dev->vendor = vend;
pci_readw(dev, PCI_DEVICE_ID, &dev->device);
- dev->hdr_type = hdr;
+ dev->hdr_type = hdr & 0x7f;
pci_setup_device(dev);
+
/* FIXME: Do we need to enable the expansion ROM? */
for (r = 0; r < 7; r++) {
struct resource *res = dev->resource + r;
@@ -319,28 +333,25 @@
pci_assign_resource(dev, r);
}
}
-
- list_add_tail(&dev->bus_list, &bus->devices);
- list_add_tail(&dev->global_list, &pci_devices);
- pci_proc_attach_device(dev);
pci_enable_device(dev);
+
+ /* Does this function have an interrupt at all? */
+ pci_readb(dev, PCI_INTERRUPT_PIN, &irq_pin);
+ if (irq_pin) {
+ if (!irq)
+ irq = cb_assign_irq(s->cap.irq_mask);
+ dev->irq = irq;
+ pci_writeb(dev, PCI_INTERRUPT_LINE, irq);
+ }
+
+ pci_insert_device(dev, bus);
}
s->cb_config = c;
+ s->irq.AssignedIRQ = irq;
return CS_SUCCESS;
}
-static void free_resources(struct pci_dev *dev)
-{
- int i;
-
- for (i = 0; i < 7; i++) {
- struct resource *res = dev->resource + i;
- if (res->parent)
- release_resource(res);
- }
-}
-
void cb_free(socket_info_t * s)
{
cb_config_t *c = s->cb_config;
@@ -349,14 +360,9 @@
int i;
s->cb_config = NULL;
- for(i=0; i<s->functions; i++) {
- struct pci_dev *dev = &c[i].dev;
+ for (i = 0 ; i < s->functions ; i++)
+ pci_remove_device(&c[i].dev);
- list_del(&dev->bus_list);
- list_del(&dev->global_list);
- free_resources(dev);
- pci_proc_detach_device(dev);
- }
kfree(c);
printk(KERN_INFO "cs: cb_free(bus %d)\n", s->cap.cb_dev->subordinate->number);
}
@@ -374,54 +380,8 @@
======================================================================*/
-static int cb_assign_irq(u32 mask)
-{
- int irq, try;
-
- for (try = 0; try < 2; try++) {
- for (irq = 1; irq < 32; irq++) {
- if ((mask >> irq) & 1) {
- if (try_irq(IRQ_TYPE_EXCLUSIVE, irq, try) == 0)
- return irq;
- }
- }
- }
- return 0;
-}
-
int cb_config(socket_info_t * s)
{
- cb_config_t *c = s->cb_config;
- u_char fn = s->functions;
- int i, irq;
-
- printk(KERN_INFO "cs: cb_config(bus %d)\n", s->cap.cb_dev->subordinate->number);
-
- /*
- * If we have a PCI interrupt for the bridge,
- * then use that..
- */
- irq = s->cap.pci_irq;
-
- for (i = 0; i < fn; i++) {
- struct pci_dev *dev = &c[i].dev;
- u8 irq_pin;
-
- /* Does this function have an interrupt at all? */
- pci_readb(dev, PCI_INTERRUPT_PIN, &irq_pin);
- if (!irq_pin)
- continue;
-
- if (!irq) {
- irq = cb_assign_irq(s->cap.irq_mask);
- if (!irq)
- return CS_OUT_OF_RESOURCE;
- }
-
- dev->irq = irq;
- pci_writeb(dev, PCI_INTERRUPT_LINE, irq);
- }
- s->irq.AssignedIRQ = irq;
return CS_SUCCESS;
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)