All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
To: linux-ide@vger.kernel.org
Cc: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 03/22] ide: add 'init_default' and 'restore' arguments to ide_unregister()
Date: Thu, 17 Jan 2008 00:26:17 +0100	[thread overview]
Message-ID: <20080116232617.9166.68848.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20080116232556.9166.13457.sendpatchset@localhost.localdomain>

* Add 'init_default' (flag for calling init_hwif_default()) and 'restore'
  (flag for calling ide_hwif_restore()) arguments to ide_unregister().

* Update ide_unregister() users to set 'init_default' and 'restore' flags.

* No need to set 'init_default' flag in ide_register_hw() if the setup done
  by init_hwif_default() is going to be overridden by ide_init_port_hw().

* No need to set 'init_default' and 'restore' flags in cleanup_module().

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/arm/rapide.c          |    2 +-
 drivers/ide/ide-pnp.c             |    7 ++++---
 drivers/ide/ide.c                 |   19 ++++++++++++-------
 drivers/ide/legacy/ide-cs.c       |    2 +-
 drivers/ide/legacy/ide_platform.c |    2 +-
 drivers/ide/mips/au1xxx-ide.c     |    2 +-
 drivers/ide/pci/delkin_cb.c       |    3 ++-
 drivers/ide/pci/scc_pata.c        |    2 +-
 drivers/macintosh/mediabay.c      |    2 +-
 include/linux/ide.h               |    2 +-
 10 files changed, 25 insertions(+), 18 deletions(-)

Index: b/drivers/ide/arm/rapide.c
===================================================================
--- a/drivers/ide/arm/rapide.c
+++ b/drivers/ide/arm/rapide.c
@@ -76,7 +76,7 @@ static void __devexit rapide_remove(stru
 
 	ecard_set_drvdata(ec, NULL);
 
-	ide_unregister(hwif->index);
+	ide_unregister(hwif->index, 1, 1);
 
 	ecard_release_resources(ec);
 }
Index: b/drivers/ide/ide-pnp.c
===================================================================
--- a/drivers/ide/ide-pnp.c
+++ b/drivers/ide/ide-pnp.c
@@ -60,9 +60,10 @@ static int idepnp_probe(struct pnp_dev *
 static void idepnp_remove(struct pnp_dev * dev)
 {
 	ide_hwif_t *hwif = pnp_get_drvdata(dev);
-	if (hwif) {
-		ide_unregister(hwif->index);
-	} else
+
+	if (hwif)
+		ide_unregister(hwif->index, 1, 1);
+	else
 		printk(KERN_ERR "idepnp: Unable to remove device, please report.\n");
 }
 
Index: b/drivers/ide/ide.c
===================================================================
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -499,6 +499,8 @@ void ide_remove_port_from_hwgroup(ide_hw
 /**
  *	ide_unregister		-	free an IDE interface
  *	@index: index of interface (will change soon to a pointer)
+ *	@init_default: init default hwif flag
+ *	@restore: restore hwif flag
  *
  *	Perform the final unregister of an IDE interface. At the moment
  *	we don't refcount interfaces so this will also get split up.
@@ -518,7 +520,7 @@ void ide_remove_port_from_hwgroup(ide_hw
  *	This is raving bonkers.
  */
 
-void ide_unregister(unsigned int index)
+void ide_unregister(unsigned int index, int init_default, int restore)
 {
 	ide_drive_t *drive;
 	ide_hwif_t *hwif, *g;
@@ -602,9 +604,12 @@ void ide_unregister(unsigned int index)
 
 	/* restore hwif data to pristine status */
 	ide_init_port_data(hwif, index);
-	init_hwif_default(hwif, index);
 
-	ide_hwif_restore(hwif, &tmp_hwif);
+	if (init_default)
+		init_hwif_default(hwif, index);
+
+	if (restore)
+		ide_hwif_restore(hwif, &tmp_hwif);
 
 abort:
 	spin_unlock_irq(&ide_lock);
@@ -710,12 +715,12 @@ int ide_register_hw(hw_regs_t *hw, void 
 				goto found;
 		}
 		for (index = 0; index < MAX_HWIFS; index++)
-			ide_unregister(index);
+			ide_unregister(index, 1, 1);
 	} while (retry--);
 	return -1;
 found:
 	if (hwif->present)
-		ide_unregister(index);
+		ide_unregister(index, 0, 1);
 	else if (!hwif->hold)
 		ide_init_port_data(hwif, index);
 
@@ -1058,7 +1063,7 @@ int generic_ide_ioctl(ide_drive_t *drive
 	        case HDIO_UNREGISTER_HWIF:
 			if (!capable(CAP_SYS_RAWIO)) return -EACCES;
 			/* (arg > MAX_HWIFS) checked in function */
-			ide_unregister(arg);
+			ide_unregister(arg, 1, 1);
 			return 0;
 		case HDIO_SET_NICE:
 			if (!capable(CAP_SYS_ADMIN)) return -EACCES;
@@ -1703,7 +1708,7 @@ void __exit cleanup_module (void)
 	int index;
 
 	for (index = 0; index < MAX_HWIFS; ++index)
-		ide_unregister(index);
+		ide_unregister(index, 0, 0);
 
 	proc_ide_destroy();
 
Index: b/drivers/ide/legacy/ide-cs.c
===================================================================
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -337,7 +337,7 @@ void ide_release(struct pcmcia_device *l
     if (info->ndev) {
 	/* FIXME: if this fails we need to queue the cleanup somehow
 	   -- need to investigate the required PCMCIA magic */
-	ide_unregister(info->hd);
+	ide_unregister(info->hd, 1, 1);
     }
     info->ndev = 0;
 
Index: b/drivers/ide/legacy/ide_platform.c
===================================================================
--- a/drivers/ide/legacy/ide_platform.c
+++ b/drivers/ide/legacy/ide_platform.c
@@ -122,7 +122,7 @@ static int __devexit plat_ide_remove(str
 {
 	ide_hwif_t *hwif = pdev->dev.driver_data;
 
-	ide_unregister(hwif->index);
+	ide_unregister(hwif->index, 1, 1);
 
 	return 0;
 }
Index: b/drivers/ide/mips/au1xxx-ide.c
===================================================================
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/mips/au1xxx-ide.c
@@ -678,7 +678,7 @@ static int au_ide_remove(struct device *
 	ide_hwif_t *hwif = dev_get_drvdata(dev);
 	_auide_hwif *ahwif = &auide_hwif;
 
-	ide_unregister(hwif->index);
+	ide_unregister(hwif->index, 1, 1);
 
 	iounmap((void *)ahwif->regbase);
 
Index: b/drivers/ide/pci/delkin_cb.c
===================================================================
--- a/drivers/ide/pci/delkin_cb.c
+++ b/drivers/ide/pci/delkin_cb.c
@@ -99,7 +99,8 @@ delkin_cb_remove (struct pci_dev *dev)
 	ide_hwif_t *hwif = pci_get_drvdata(dev);
 
 	if (hwif)
-		ide_unregister(hwif->index);
+		ide_unregister(hwif->index, 1, 1);
+
 	pci_disable_device(dev);
 }
 
Index: b/drivers/ide/pci/scc_pata.c
===================================================================
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -736,7 +736,7 @@ static void __devexit scc_remove(struct 
 		hwif->dmatable_cpu = NULL;
 	}
 
-	ide_unregister(hwif->index);
+	ide_unregister(hwif->index, 1, 1);
 
 	hwif->chipset = ide_unknown;
 	iounmap((void*)ports->dma);
Index: b/drivers/macintosh/mediabay.c
===================================================================
--- a/drivers/macintosh/mediabay.c
+++ b/drivers/macintosh/mediabay.c
@@ -595,7 +595,7 @@ static void media_bay_step(int i)
     	        if (bay->cd_index >= 0) {
 			printk(KERN_DEBUG "Unregistering mb %d ide, index:%d\n", i,
 			       bay->cd_index);
-			ide_unregister(bay->cd_index);
+			ide_unregister(bay->cd_index, 1, 1);
 			bay->cd_index = -1;
 		}
 	    	if (bay->cd_retry) {
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1211,7 +1211,7 @@ static inline void ide_acpi_set_state(id
 void ide_remove_port_from_hwgroup(ide_hwif_t *);
 extern int ide_hwif_request_regions(ide_hwif_t *hwif);
 extern void ide_hwif_release_regions(ide_hwif_t* hwif);
-extern void ide_unregister (unsigned int index);
+void ide_unregister(unsigned int, int, int);
 
 void ide_register_region(struct gendisk *);
 void ide_unregister_region(struct gendisk *);

  parent reply	other threads:[~2008-01-16 23:13 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-16 23:25 [PATCH 00/22] ide: even more IDE probing code rework Bartlomiej Zolnierkiewicz
2008-01-16 23:26 ` [PATCH 01/22] ide: remove redundant hwif->present check from ide_register_hw() Bartlomiej Zolnierkiewicz
2008-01-16 23:26 ` [PATCH 02/22] ide: remove redundant init_hwif_default() call " Bartlomiej Zolnierkiewicz
2008-01-16 23:26 ` Bartlomiej Zolnierkiewicz [this message]
2008-01-16 23:26 ` [PATCH 04/22] ide: add ide_deprecated_find_port() helper Bartlomiej Zolnierkiewicz
2008-05-21 14:29   ` Sergei Shtylyov
2008-05-27 18:36     ` Bartlomiej Zolnierkiewicz
2008-01-16 23:26 ` [PATCH 05/22] ide: fix ide_unregister() usage in host drivers Bartlomiej Zolnierkiewicz
2008-01-16 23:26 ` [PATCH 06/22] ide: factor out code initializing devices from ide_init_port() Bartlomiej Zolnierkiewicz
2008-01-16 23:26 ` [PATCH 07/22] ide: add IDE_HFLAG_NO_{IO32_BIT,UNMASK_IRQS} host flags Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 08/22] ide: add ->init_port_devs method to ide_hwif_t Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 09/22] ide: remove incorrect init_gendisk() comment Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 10/22] ide: skip not present devices in init_gendisk() Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 11/22] ide: move blk_register_region() call out from init_gendisk() Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 12/22] ide: call init_gendisk() after ide_acpi_init() Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 13/22] ide: merge init_gendisk() into hwif_register_devices() Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 14/22] ide: move hwif->rqsize init from ide_init_queue() to init_irq() Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 15/22] ide: factor out adding drive to hwgroup from init_irq() Bartlomiej Zolnierkiewicz
2008-01-16 23:27 ` [PATCH 16/22] ide: factor out devices setup " Bartlomiej Zolnierkiewicz
2008-01-16 23:28 ` [PATCH 17/22] ide: move ide_acpi_init() call to ide_device_add_all() Bartlomiej Zolnierkiewicz
2008-01-16 23:28 ` [PATCH 18/22] ide-acpi: remove needless exports Bartlomiej Zolnierkiewicz
2008-01-16 23:28 ` [PATCH 19/22] ide-acpi: remove dead code from do_drive_get_GTF() Bartlomiej Zolnierkiewicz
2008-01-16 23:28 ` [PATCH 20/22] ide: factor out devices setup from ide_acpi_init() Bartlomiej Zolnierkiewicz
2008-01-16 23:28 ` [PATCH 21/22] ide: move hwif->present check out from ide_proc_register_port() Bartlomiej Zolnierkiewicz
2008-01-16 23:28 ` [PATCH 22/22] ide: move create_proc_ide_drives() call to ide_device_add_all() 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=20080116232617.9166.68848.sendpatchset@localhost.localdomain \
    --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 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.