Commit d5e4d10f authored by Russell King's avatar Russell King Committed by Linus Torvalds

[PATCH] Fix cardbus build problem

This is a temporary patch which should get cardbus working again.
In order to use pci_remove_behind_bridge(), we need to separately
allocate the pci_dev structures.
parent 7e285bef
...@@ -90,7 +90,7 @@ static int pc_debug = PCMCIA_DEBUG; ...@@ -90,7 +90,7 @@ static int pc_debug = PCMCIA_DEBUG;
#define PCDATA_INDICATOR 0x0015 #define PCDATA_INDICATOR 0x0015
typedef struct cb_config_t { typedef struct cb_config_t {
struct pci_dev dev; struct pci_dev *dev[8];
} cb_config_t; } cb_config_t;
/*===================================================================== /*=====================================================================
...@@ -178,7 +178,7 @@ int read_cb_mem(socket_info_t * s, int space, u_int addr, u_int len, void *ptr) ...@@ -178,7 +178,7 @@ int read_cb_mem(socket_info_t * s, int space, u_int addr, u_int len, void *ptr)
if (!s->cb_config) if (!s->cb_config)
goto fail; goto fail;
dev = &s->cb_config[0].dev; dev = s->cb_config->dev[0];
/* Config space? */ /* Config space? */
if (space == 0) { if (space == 0) {
...@@ -248,14 +248,25 @@ int cb_alloc(socket_info_t * s) ...@@ -248,14 +248,25 @@ int cb_alloc(socket_info_t * s)
} }
s->functions = fn; s->functions = fn;
c = kmalloc(fn * sizeof(struct cb_config_t), GFP_ATOMIC); c = kmalloc(sizeof(struct cb_config_t), GFP_ATOMIC);
if (!c) if (!c)
return CS_OUT_OF_RESOURCE; return CS_OUT_OF_RESOURCE;
memset(c, 0, fn * sizeof(struct cb_config_t)); memset(c, 0, sizeof(struct cb_config_t));
for (i = 0; i < fn; i++) {
c->dev[i] = kmalloc(sizeof(struct pci_dev), GFP_ATOMIC);
if (!c->dev[i]) {
for (; i--; )
kfree(c->dev[i]);
kfree(c);
return CS_OUT_OF_RESOURCE;
}
memset(c->dev[i], 0, sizeof(struct pci_dev));
}
irq = s->cap.pci_irq; irq = s->cap.pci_irq;
for (i = 0; i < fn; i++) { for (i = 0; i < fn; i++) {
struct pci_dev *dev = &c[i].dev; struct pci_dev *dev = c->dev[i];
u8 irq_pin; u8 irq_pin;
int r; int r;
...@@ -309,11 +320,8 @@ void cb_free(socket_info_t * s) ...@@ -309,11 +320,8 @@ void cb_free(socket_info_t * s)
cb_config_t *c = s->cb_config; cb_config_t *c = s->cb_config;
if (c) { if (c) {
int i;
s->cb_config = NULL; s->cb_config = NULL;
for (i = 0 ; i < s->functions ; i++) pci_remove_behind_bridge(s->cap.cb_dev);
pci_remove_device(&c[i].dev);
kfree(c); kfree(c);
printk(KERN_INFO "cs: cb_free(bus %d)\n", s->cap.cb_dev->subordinate->number); printk(KERN_INFO "cs: cb_free(bus %d)\n", s->cap.cb_dev->subordinate->number);
...@@ -347,7 +355,7 @@ void cb_enable(socket_info_t * s) ...@@ -347,7 +355,7 @@ void cb_enable(socket_info_t * s)
/* Set up PCI interrupt and command registers */ /* Set up PCI interrupt and command registers */
for (i = 0; i < s->functions; i++) { for (i = 0; i < s->functions; i++) {
dev = &s->cb_config[i].dev; dev = s->cb_config->dev[i];
pci_write_config_byte(dev, PCI_COMMAND, PCI_COMMAND_MASTER | pci_write_config_byte(dev, PCI_COMMAND, PCI_COMMAND_MASTER |
PCI_COMMAND_IO | PCI_COMMAND_MEMORY); PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE,
...@@ -356,7 +364,7 @@ void cb_enable(socket_info_t * s) ...@@ -356,7 +364,7 @@ void cb_enable(socket_info_t * s)
if (s->irq.AssignedIRQ) { if (s->irq.AssignedIRQ) {
for (i = 0; i < s->functions; i++) { for (i = 0; i < s->functions; i++) {
dev = &s->cb_config[i].dev; dev = s->cb_config->dev[i];
pci_write_config_byte(dev, PCI_INTERRUPT_LINE, pci_write_config_byte(dev, PCI_INTERRUPT_LINE,
s->irq.AssignedIRQ); s->irq.AssignedIRQ);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment