All of lore.kernel.org
 help / color / mirror / Atom feed
From: Russell King <rmk@arm.linux.org.uk>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Linus Torvalds <torvalds@transmeta.com>
Subject: [PATCH] [5/6] Remove stack allocation of struct pci_dev
Date: Sun, 23 Feb 2003 15:20:26 +0000	[thread overview]
Message-ID: <20020223151805@raistlin.arm.linux.org.uk> (raw)
In-Reply-To: <20020223151804@raistlin.arm.linux.org.uk>

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++;

  reply	other threads:[~2003-02-23 15:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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       ` Russell King [this message]
2003-02-23 15:20         ` [PATCH] [6/6] Always re-read vendor for each function Russell King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020223151805@raistlin.arm.linux.org.uk \
    --to=rmk@arm.linux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.