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

[PATCH] Remove stack allocation of struct pci_dev

cb_alloc() allocated a pci_dev on the stack to access PCI space.  This
is unnecessary since we have pci_bus_*_config_* functions.  Use these
functions instead.
parent 3b88f1f7
...@@ -224,29 +224,23 @@ int read_cb_mem(socket_info_t * s, int space, u_int addr, u_int len, void *ptr) ...@@ -224,29 +224,23 @@ int read_cb_mem(socket_info_t * s, int space, u_int addr, u_int len, void *ptr)
int cb_alloc(socket_info_t * s) int cb_alloc(socket_info_t * s)
{ {
struct pci_bus *bus; struct pci_bus *bus;
struct pci_dev tmp;
u_short vend, v, dev; u_short vend, v, dev;
u_char i, hdr, fn; u_char i, hdr, fn;
cb_config_t *c; cb_config_t *c;
int irq; int irq;
bus = s->cap.cb_dev->subordinate; bus = s->cap.cb_dev->subordinate;
memset(&tmp, 0, sizeof(tmp));
tmp.bus = bus;
tmp.sysdata = bus->sysdata;
tmp.devfn = 0;
pci_read_config_word(&tmp, PCI_VENDOR_ID, &vend); pci_bus_read_config_word(bus, 0, PCI_VENDOR_ID, &vend);
pci_read_config_word(&tmp, PCI_DEVICE_ID, &dev); pci_bus_read_config_word(bus, 0, PCI_DEVICE_ID, &dev);
printk(KERN_INFO "cs: cb_alloc(bus %d): vendor 0x%04x, " printk(KERN_INFO "cs: cb_alloc(bus %d): vendor 0x%04x, "
"device 0x%04x\n", bus->number, vend, dev); "device 0x%04x\n", bus->number, vend, dev);
pci_read_config_byte(&tmp, PCI_HEADER_TYPE, &hdr); pci_bus_read_config_byte(bus, 0, PCI_HEADER_TYPE, &hdr);
fn = 1; fn = 1;
if (hdr & 0x80) { if (hdr & 0x80) {
do { do {
tmp.devfn = fn; if (pci_bus_read_config_word(bus, fn, PCI_VENDOR_ID, &v) ||
if (pci_read_config_word(&tmp, PCI_VENDOR_ID, &v) ||
!v || v == 0xffff) !v || v == 0xffff)
break; break;
fn++; fn++;
......
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