From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: linux-ide@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 18/50] ide: add ide_pci_remove() helper
Date: Sun, 06 Jul 2008 19:20:28 +0200 [thread overview]
Message-ID: <48710242.1ade660a.3458.6293@mx.google.com> (raw)
In-Reply-To: 20080706172010.559358957@bzolnier@gmail.com
[-- Attachment #1: ide-add-ide_pci_remove-helper.patch --]
[-- Type: text/plain, Size: 3086 bytes --]
* Add 'unsigned long host_flags' field to struct ide_host.
* Set ->host_flags in ide_host_alloc_all().
* Always set PCI dev's ->driver_data in ide_pci_init_{one,two}().
* Add ide_pci_remove() helper (the default implementation for
struct pci_driver's ->remove method).
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-probe.c | 3 +++
drivers/ide/setup-pci.c | 39 +++++++++++++++++++++++++++++++++------
include/linux/ide.h | 2 ++
3 files changed, 38 insertions(+), 6 deletions(-)
Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1613,6 +1613,9 @@ struct ide_host *ide_host_alloc_all(cons
if (hws[0])
host->dev[0] = hws[0]->dev;
+ if (d)
+ host->host_flags = d->host_flags;
+
return host;
}
EXPORT_SYMBOL_GPL(ide_host_alloc_all);
Index: b/drivers/ide/setup-pci.c
===================================================================
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -547,8 +547,7 @@ int ide_pci_init_one(struct pci_dev *dev
host->host_priv = priv;
- if (priv)
- pci_set_drvdata(dev, host);
+ pci_set_drvdata(dev, host);
ret = do_ide_setup_pci_device(dev, d, 1);
if (ret < 0)
@@ -592,10 +591,8 @@ int ide_pci_init_two(struct pci_dev *dev
host->host_priv = priv;
- if (priv) {
- pci_set_drvdata(pdev[0], host);
- pci_set_drvdata(pdev[1], host);
- }
+ pci_set_drvdata(pdev[0], host);
+ pci_set_drvdata(pdev[1], host);
for (i = 0; i < 2; i++) {
ret = do_ide_setup_pci_device(pdev[i], d, !i);
@@ -618,3 +615,33 @@ out:
return ret;
}
EXPORT_SYMBOL_GPL(ide_pci_init_two);
+
+void ide_pci_remove(struct pci_dev *dev)
+{
+ struct ide_host *host = pci_get_drvdata(dev);
+ struct pci_dev *dev2 = host->dev[1] ? to_pci_dev(host->dev[1]) : NULL;
+ int bars;
+
+ if (host->host_flags & IDE_HFLAG_SINGLE)
+ bars = (1 << 2) - 1;
+ else
+ bars = (1 << 4) - 1;
+
+ if ((host->host_flags & IDE_HFLAG_NO_DMA) == 0) {
+ if (host->host_flags & IDE_HFLAG_CS5520)
+ bars |= (1 << 2);
+ else
+ bars |= (1 << 4);
+ }
+
+ ide_host_remove(host);
+
+ if (dev2)
+ pci_release_selected_regions(dev2, bars);
+ pci_release_selected_regions(dev, bars);
+
+ if (dev2)
+ pci_disable_device(dev2);
+ pci_disable_device(dev);
+}
+EXPORT_SYMBOL_GPL(ide_pci_remove);
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -616,6 +616,7 @@ struct ide_host {
ide_hwif_t *ports[MAX_HWIFS];
unsigned int n_ports;
struct device *dev[2];
+ unsigned long host_flags;
void *host_priv;
};
@@ -1198,6 +1199,7 @@ struct ide_port_info {
int ide_pci_init_one(struct pci_dev *, const struct ide_port_info *, void *);
int ide_pci_init_two(struct pci_dev *, struct pci_dev *,
const struct ide_port_info *, void *);
+void ide_pci_remove(struct pci_dev *);
void ide_map_sg(ide_drive_t *, struct request *);
void ide_init_sg_cmd(ide_drive_t *, struct request *);
--
next prev parent reply other threads:[~2008-07-06 17:35 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080706172010.559358957@bzolnier@gmail.com>
2008-07-06 17:20 ` [PATCH 01/50] it8213: fix return value in it8213_init_one() Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 02/50] ide: always call ->init_chipset method in do_ide_setup_pci_device() Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 03/50] ide: respect dev->irq in do_ide_setup_pci_device() also if tried_config Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 04/50] ide: move ide_setup_pci_controller() call to ide_setup_pci_device() Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 05/50] ide: call ide_pci_setup_ports() before do_ide_setup_pci_device() Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 06/50] ide: add ->dev and ->host_priv fields to struct ide_host Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 07/50] ide: add ide_device_{get,put}() helpers Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 08/50] aec62xx: convert to use ->host_priv Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 09/50] hpt366: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 10/50] it821x: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 11/50] sc1200: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 12/50] siimage: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 13/50] via82cxxx: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 14/50] tc86c001: remove ->init_chipset method Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 15/50] amd74xx: cleanup " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 16/50] cmd64x: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 17/50] via82cxxx: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` Bartlomiej Zolnierkiewicz [this message]
2008-07-06 17:20 ` [PATCH 19/50] aec62xx: add ->remove method and module_exit() Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 20/50] alim15x3: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 21/50] amd74xx: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 22/50] atiixp: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 23/50] cmd64x: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 24/50] cs5530: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 25/50] cs5535: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 26/50] cy82c693: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 27/50] ide/pci/generic: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 28/50] hpt34x: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 29/50] hpt366: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 30/50] it8213: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 31/50] it821x: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 32/50] jmicron: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 33/50] ns87415: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 34/50] opti621: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 35/50] pdc202xx_new: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 36/50] pdc202xx_old: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 37/50] piix: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 38/50] rz1000: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 39/50] sc1200: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 40/50] serverworks: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 41/50] siimage: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 42/50] sis5513: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 43/50] sl82c105: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 44/50] slc90e66: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 45/50] tc86c001: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 46/50] triflex: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 47/50] trm290: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 48/50] via82cxxx: " Bartlomiej Zolnierkiewicz
2008-07-06 17:20 ` [PATCH 49/50] icside: add module_exit() Bartlomiej Zolnierkiewicz
2008-07-06 17:21 ` [PATCH 50/50] rapide: " Bartlomiej Zolnierkiewicz
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=48710242.1ade660a.3458.6293@mx.google.com \
--to=bzolnier@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).