* [PATCH] [1/6] Remove dummy cb_config() and cb_release()
@ 2003-02-23 15:20 Russell King
2003-02-23 15:20 ` [PATCH] [2/6] Remove unused "dev" argument from cb_setup_cis_mem Russell King
0 siblings, 1 reply; 6+ messages in thread
From: Russell King @ 2003-02-23 15:20 UTC (permalink / raw)
To: LKML; +Cc: Linus Torvalds
This patch appears not to be in 2.5.62, but applies cleanly.
Subject: [1/6] Remove dummy cb_config() and cb_release()
cb_config() and cb_release() are just simple dummy functions that are
only used in the internals of the PCMCIA code. We inline them where
used.
drivers/pcmcia/cardbus.c | 32 --------------------------------
drivers/pcmcia/cs.c | 7 ++-----
drivers/pcmcia/cs_internal.h | 2 --
3 files changed, 2 insertions, 39 deletions
diff -ur orig/drivers/pcmcia/cardbus.c linux/drivers/pcmcia/cardbus.c
--- orig/drivers/pcmcia/cardbus.c Fri Jan 17 10:39:17 2003
+++ linux/drivers/pcmcia/cardbus.c Sun Feb 23 12:17:52 2003
@@ -335,38 +335,6 @@
/*=====================================================================
- cb_config() has the job of allocating all system resources that
- a Cardbus card requires. Rather than using the CIS (which seems
- to not always be present), it treats the card as an ordinary PCI
- device, and probes the base address registers to determine each
- function's IO and memory space needs.
-
- It is called from the RequestIO card service.
-
-======================================================================*/
-
-int cb_config(socket_info_t * s)
-{
- return CS_SUCCESS;
-}
-
-/*======================================================================
-
- cb_release() releases all the system resources (IO and memory
- space, and interrupt) committed for a Cardbus card by a prior call
- to cb_config().
-
- It is called from the ReleaseIO() service.
-
-======================================================================*/
-
-void cb_release(socket_info_t * s)
-{
- DEBUG(0, "cs: cb_release(bus %d)\n", s->cap.cb_dev->subordinate->number);
-}
-
-/*=====================================================================
-
cb_enable() has the job of configuring a socket for a Cardbus
card, and initializing the card's PCI configuration registers.
diff -ur orig/drivers/pcmcia/cs.c linux/drivers/pcmcia/cs.c
--- orig/drivers/pcmcia/cs.c Fri Feb 21 19:48:51 2003
+++ linux/drivers/pcmcia/cs.c Sun Feb 23 12:03:16 2003
@@ -1562,7 +1562,6 @@
#ifdef CONFIG_CARDBUS
if (handle->state & CLIENT_CARDBUS) {
- cb_release(s);
return CS_SUCCESS;
}
#endif
@@ -1804,10 +1803,8 @@
if (handle->state & CLIENT_CARDBUS) {
#ifdef CONFIG_CARDBUS
- int ret = cb_config(s);
- if (ret == CS_SUCCESS)
- handle->state |= CLIENT_IO_REQ;
- return ret;
+ handle->state |= CLIENT_IO_REQ;
+ return CS_SUCCESS;
#else
return CS_UNSUPPORTED_FUNCTION;
#endif
diff -ur orig/drivers/pcmcia/cs_internal.h linux/drivers/pcmcia/cs_internal.h
--- orig/drivers/pcmcia/cs_internal.h Wed Nov 13 16:53:30 2002
+++ linux/drivers/pcmcia/cs_internal.h Sun Feb 23 11:39:32 2003
@@ -198,8 +198,6 @@
/* In cardbus.c */
int cb_alloc(socket_info_t *s);
void cb_free(socket_info_t *s);
-int cb_config(socket_info_t *s);
-void cb_release(socket_info_t *s);
void cb_enable(socket_info_t *s);
void cb_disable(socket_info_t *s);
int read_cb_mem(socket_info_t *s, u_char fn, int space,
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH] [2/6] Remove unused "dev" argument from cb_setup_cis_mem 2003-02-23 15:20 [PATCH] [1/6] Remove dummy cb_config() and cb_release() Russell King @ 2003-02-23 15:20 ` Russell King 2003-02-23 15:20 ` [PATCH] [3/6] Remove "fn" argument from read_cb_mem() Russell King 0 siblings, 1 reply; 6+ messages in thread From: Russell King @ 2003-02-23 15:20 UTC (permalink / raw) To: LKML; +Cc: Linus Torvalds This patch appears not to be in 2.5.62, but applies cleanly. Subject: [2/6] Remove unused "dev" argument from cb_setup_cis_mem cb_setup_cis_mem doesn't reference the pci device. Remove this unused argument. drivers/pcmcia/cardbus.c | 4 ++-- 1 files changed, 2 insertions, 2 deletions diff -ur -x sa11* -x Kconfig -x Makefile orig/drivers/pcmcia/cardbus.c linux/drivers/pcmcia/cardbus.c --- orig/drivers/pcmcia/cardbus.c Sun Feb 23 12:39:27 2003 +++ linux/drivers/pcmcia/cardbus.c Sun Feb 23 12:17:52 2003 @@ -146,7 +146,7 @@ } } -static int cb_setup_cis_mem(socket_info_t * s, struct pci_dev *dev, struct resource *res) +static int cb_setup_cis_mem(socket_info_t * s, struct resource *res) { unsigned int start, size; @@ -201,7 +201,7 @@ if (!res->flags) goto fail; - if (cb_setup_cis_mem(s, dev, res) != 0) + if (cb_setup_cis_mem(s, res) != 0) goto fail; if (space == 7) { ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] [3/6] Remove "fn" argument from read_cb_mem() 2003-02-23 15:20 ` [PATCH] [2/6] Remove unused "dev" argument from cb_setup_cis_mem Russell King @ 2003-02-23 15:20 ` Russell King 2003-02-23 15:20 ` [PATCH] [4/6] Remove pci_{read,write}[bwl] Russell King 0 siblings, 1 reply; 6+ messages in thread From: Russell King @ 2003-02-23 15:20 UTC (permalink / raw) To: LKML; +Cc: Linus Torvalds This patch appears not to be in 2.5.62, but applies cleanly. Subject: [3/6] Remove "fn" argument from read_cb_mem() read_cb_mem is only ever called with its "fn" argument set to zero. We therefore do not need to pass it. drivers/pcmcia/cardbus.c | 5 ++--- drivers/pcmcia/cistpl.c | 4 ++-- drivers/pcmcia/cs_internal.h | 3 +-- 3 files changed, 5 insertions, 7 deletions diff -ur -x sa11* -x Kconfig -x Makefile orig/drivers/pcmcia/cardbus.c linux/drivers/pcmcia/cardbus.c --- orig/drivers/pcmcia/cardbus.c Sun Feb 23 12:41:54 2003 +++ linux/drivers/pcmcia/cardbus.c Sun Feb 23 12:43:55 2003 @@ -175,8 +175,7 @@ =====================================================================*/ -int read_cb_mem(socket_info_t * s, u_char fn, int space, - u_int addr, u_int len, void *ptr) +int read_cb_mem(socket_info_t * s, int space, u_int addr, u_int len, void *ptr) { struct pci_dev *dev; struct resource *res; @@ -186,7 +185,7 @@ if (!s->cb_config) goto fail; - dev = &s->cb_config[fn].dev; + dev = &s->cb_config[0].dev; /* Config space? */ if (space == 0) { diff -ur -x sa11* -x Kconfig -x Makefile orig/drivers/pcmcia/cistpl.c linux/drivers/pcmcia/cistpl.c --- orig/drivers/pcmcia/cistpl.c Sun Nov 24 10:12:25 2002 +++ linux/drivers/pcmcia/cistpl.c Sun Feb 23 10:23:58 2003 @@ -327,7 +327,7 @@ } #ifdef CONFIG_CARDBUS if (s->state & SOCKET_CARDBUS) - ret = read_cb_mem(s, 0, attr, addr, len, ptr); + ret = read_cb_mem(s, attr, addr, len, ptr); else #endif ret = read_cis_mem(s, attr, addr, len, ptr); @@ -358,7 +358,7 @@ for (i = 0; i < s->cis_used; i++) { #ifdef CONFIG_CARDBUS if (s->state & SOCKET_CARDBUS) - read_cb_mem(s, 0, s->cis_table[i].attr, s->cis_table[i].addr, + read_cb_mem(s, s->cis_table[i].attr, s->cis_table[i].addr, s->cis_table[i].len, buf); else #endif diff -ur -x sa11* -x Kconfig -x Makefile orig/drivers/pcmcia/cs_internal.h linux/drivers/pcmcia/cs_internal.h --- orig/drivers/pcmcia/cs_internal.h Sun Feb 23 12:39:27 2003 +++ linux/drivers/pcmcia/cs_internal.h Sun Feb 23 11:39:32 2003 @@ -200,8 +200,7 @@ void cb_free(socket_info_t *s); void cb_enable(socket_info_t *s); void cb_disable(socket_info_t *s); -int read_cb_mem(socket_info_t *s, u_char fn, int space, - u_int addr, u_int len, void *ptr); +int read_cb_mem(socket_info_t *s, int space, u_int addr, u_int len, void *ptr); void cb_release_cis_mem(socket_info_t *s); /* In cistpl.c */ ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] [4/6] Remove pci_{read,write}[bwl] 2003-02-23 15:20 ` [PATCH] [3/6] Remove "fn" argument from read_cb_mem() Russell King @ 2003-02-23 15:20 ` Russell King 2003-02-23 15:20 ` [PATCH] [5/6] Remove stack allocation of struct pci_dev Russell King 0 siblings, 1 reply; 6+ messages in thread From: Russell King @ 2003-02-23 15:20 UTC (permalink / raw) To: LKML; +Cc: Linus Torvalds This patch appears not to be in 2.5.62, but applies cleanly. Subject: [4/6] Remove pci_{read,write}[bwl] cardbus.c uses its own names for our PCI config space functions. Make it use our names. drivers/pcmcia/cardbus.c | 34 +++++++++++++++------------------- 1 files changed, 15 insertions, 19 deletions diff -ur -x sa11* -x Kconfig -x Makefile orig/drivers/pcmcia/cardbus.c linux/drivers/pcmcia/cardbus.c --- orig/drivers/pcmcia/cardbus.c Sun Feb 23 12:47:15 2003 +++ linux/drivers/pcmcia/cardbus.c Sun Feb 23 12:43:55 2003 @@ -75,13 +75,6 @@ #define FIND_FIRST_BIT(n) ((n) - ((n) & ((n)-1))) -#define pci_readb pci_read_config_byte -#define pci_writeb pci_write_config_byte -#define pci_readw pci_read_config_word -#define pci_writew pci_write_config_word -#define pci_readl pci_read_config_dword -#define pci_writel pci_write_config_dword - /* Offsets in the Expansion ROM Image Header */ #define ROM_SIGNATURE 0x0000 /* 2 bytes */ #define ROM_DATA_PTR 0x0018 /* 2 bytes */ @@ -192,7 +185,7 @@ if (addr + len > 0x100) goto fail; for (; len; addr++, ptr++, len--) - pci_readb(dev, addr, (u_char *) ptr); + pci_read_config_byte(dev, addr, ptr); return 0; } @@ -243,17 +236,18 @@ tmp.sysdata = bus->sysdata; tmp.devfn = 0; - pci_readw(&tmp, PCI_VENDOR_ID, &vend); - pci_readw(&tmp, PCI_DEVICE_ID, &dev); + pci_read_config_word(&tmp, PCI_VENDOR_ID, &vend); + pci_read_config_word(&tmp, PCI_DEVICE_ID, &dev); printk(KERN_INFO "cs: cb_alloc(bus %d): vendor 0x%04x, " "device 0x%04x\n", bus->number, vend, dev); - pci_readb(&tmp, PCI_HEADER_TYPE, &hdr); + pci_read_config_byte(&tmp, PCI_HEADER_TYPE, &hdr); fn = 1; if (hdr & 0x80) { do { tmp.devfn = fn; - if (pci_readw(&tmp, PCI_VENDOR_ID, &v) || !v || v == 0xffff) + if (pci_read_config_word(&tmp, PCI_VENDOR_ID, &v) || + !v || v == 0xffff) break; fn++; } while (fn < 8); @@ -278,7 +272,7 @@ dev->devfn = i; dev->vendor = vend; - pci_readw(dev, PCI_DEVICE_ID, &dev->device); + pci_read_config_word(dev, PCI_DEVICE_ID, &dev->device); dev->hdr_type = hdr & 0x7f; dev->dma_mask = 0xffffffff; dev->dev.dma_mask = &dev->dma_mask; @@ -295,7 +289,7 @@ } /* Does this function have an interrupt at all? */ - pci_readb(dev, PCI_INTERRUPT_PIN, &irq_pin); + pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &irq_pin); if (irq_pin) dev->irq = irq; @@ -305,7 +299,7 @@ continue; if (irq_pin) - pci_writeb(dev, PCI_INTERRUPT_LINE, irq); + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq); device_register(&dev->dev); pci_insert_device(dev, bus); @@ -360,15 +354,17 @@ /* Set up PCI interrupt and command registers */ for (i = 0; i < s->functions; i++) { dev = &s->cb_config[i].dev; - pci_writeb(dev, PCI_COMMAND, PCI_COMMAND_MASTER | - PCI_COMMAND_IO | PCI_COMMAND_MEMORY); - pci_writeb(dev, PCI_CACHE_LINE_SIZE, L1_CACHE_BYTES / 4); + pci_write_config_byte(dev, PCI_COMMAND, PCI_COMMAND_MASTER | + PCI_COMMAND_IO | PCI_COMMAND_MEMORY); + pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, + L1_CACHE_BYTES / 4); } if (s->irq.AssignedIRQ) { for (i = 0; i < s->functions; i++) { dev = &s->cb_config[i].dev; - pci_writeb(dev, PCI_INTERRUPT_LINE, s->irq.AssignedIRQ); + pci_write_config_byte(dev, PCI_INTERRUPT_LINE, + s->irq.AssignedIRQ); } s->socket.io_irq = s->irq.AssignedIRQ; s->ss_entry->set_socket(s->sock, &s->socket); ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] [5/6] Remove stack allocation of struct pci_dev 2003-02-23 15:20 ` [PATCH] [4/6] Remove pci_{read,write}[bwl] Russell King @ 2003-02-23 15:20 ` Russell King 2003-02-23 15:20 ` [PATCH] [6/6] Always re-read vendor for each function Russell King 0 siblings, 1 reply; 6+ messages in thread From: Russell King @ 2003-02-23 15:20 UTC (permalink / raw) To: LKML; +Cc: Linus Torvalds This patch appears not to be in 2.5.62, but applies cleanly. Subject: [5/6] 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. drivers/pcmcia/cardbus.c | 14 ++++---------- 1 files changed, 4 insertions, 10 deletions diff -ur -x sa11* -x Kconfig -x Makefile orig/drivers/pcmcia/cardbus.c linux/drivers/pcmcia/cardbus.c --- orig/drivers/pcmcia/cardbus.c Sun Feb 23 13:56:32 2003 +++ linux/drivers/pcmcia/cardbus.c Sun Feb 23 14:04:29 2003 @@ -224,29 +224,23 @@ int cb_alloc(socket_info_t * s) { struct pci_bus *bus; - struct pci_dev tmp; 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)); - tmp.bus = bus; - tmp.sysdata = bus->sysdata; - tmp.devfn = 0; - pci_read_config_word(&tmp, PCI_VENDOR_ID, &vend); - pci_read_config_word(&tmp, PCI_DEVICE_ID, &dev); + pci_bus_read_config_word(bus, 0, PCI_VENDOR_ID, &vend); + pci_bus_read_config_word(bus, 0, PCI_DEVICE_ID, &dev); printk(KERN_INFO "cs: cb_alloc(bus %d): vendor 0x%04x, " "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; if (hdr & 0x80) { do { - tmp.devfn = fn; - if (pci_read_config_word(&tmp, PCI_VENDOR_ID, &v) || + if (pci_bus_read_config_word(bus, fn, PCI_VENDOR_ID, &v) || !v || v == 0xffff) break; fn++; ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] [6/6] Always re-read vendor for each function 2003-02-23 15:20 ` [PATCH] [5/6] Remove stack allocation of struct pci_dev Russell King @ 2003-02-23 15:20 ` Russell King 0 siblings, 0 replies; 6+ messages in thread From: Russell King @ 2003-02-23 15:20 UTC (permalink / raw) To: LKML; +Cc: Linus Torvalds This patch appears not to be in 2.5.62, but applies cleanly. Subject: [6/6] Always re-read vendor for each function We should probably always read the vendor ID from each function rather than assuming that it is identical to function 0. drivers/pcmcia/cardbus.c | 4 ++-- 1 files changed, 2 insertions, 2 deletions diff -ur -x sa11* -x Kconfig -x Makefile orig/drivers/pcmcia/cardbus.c linux/drivers/pcmcia/cardbus.c --- orig/drivers/pcmcia/cardbus.c Sun Feb 23 14:12:57 2003 +++ linux/drivers/pcmcia/cardbus.c Sun Feb 23 14:15:26 2003 @@ -263,9 +263,9 @@ dev->sysdata = bus->sysdata; dev->dev.parent = bus->dev; dev->dev.bus = &pci_bus_type; - dev->devfn = i; - dev->vendor = vend; + + pci_read_config_word(dev, PCI_VENDOR_ID, &dev->vendor); pci_read_config_word(dev, PCI_DEVICE_ID, &dev->device); dev->hdr_type = hdr & 0x7f; dev->dma_mask = 0xffffffff; ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-02-23 15:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-23 15:20 [PATCH] [1/6] Remove dummy cb_config() and cb_release() Russell King
2003-02-23 15:20 ` [PATCH] [2/6] Remove unused "dev" argument from cb_setup_cis_mem Russell King
2003-02-23 15:20 ` [PATCH] [3/6] Remove "fn" argument from read_cb_mem() Russell King
2003-02-23 15:20 ` [PATCH] [4/6] Remove pci_{read,write}[bwl] Russell King
2003-02-23 15:20 ` [PATCH] [5/6] Remove stack allocation of struct pci_dev Russell King
2003-02-23 15:20 ` [PATCH] [6/6] Always re-read vendor for each function Russell King
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.