login
Header Space

 
 

[PATCH 20/22] ide: factor out devices setup from ide_acpi_init()

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-ide@...>
Cc: Bartlomiej Zolnierkiewicz <bzolnier@...>, <linux-kernel@...>
Date: Wednesday, January 16, 2008 - 7:28 pm

* Factor out devices setup from ide_acpi_init() to
  ide_acpi_port_init_devices().

* Call ide_acpi_port_init_devices() in ide_device_add_all().

While at it:
* Remove no longer needed 'drive' field from struct ide_acpi_drive_link.

There should be no functionality changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
 drivers/ide/ide-acpi.c  |   49 +++++++++++++++++++-----------------------------
 drivers/ide/ide-probe.c |    1 
 include/linux/ide.h     |    2 +
 3 files changed, 23 insertions(+), 29 deletions(-)

Index: b/drivers/ide/ide-acpi.c
===================================================================
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -39,7 +39,6 @@ struct GTM_buffer {
 };
 
 struct ide_acpi_drive_link {
-	ide_drive_t	*drive;
 	acpi_handle	 obj_handle;
 	u8		 idbuff[512];
 };
@@ -675,11 +674,6 @@ void ide_acpi_set_state(ide_hwif_t *hwif
  */
 void ide_acpi_init(ide_hwif_t *hwif)
 {
-	int unit;
-	int			err;
-	struct ide_acpi_drive_link	*master;
-	struct ide_acpi_drive_link	*slave;
-
 	ide_acpi_blacklist();
 
 	hwif->acpidata = kzalloc(sizeof(struct ide_acpi_hwif_link), GFP_KERNEL);
@@ -691,40 +685,38 @@ void ide_acpi_init(ide_hwif_t *hwif)
 		DEBPRINT("no ACPI object for %s found\n", hwif->name);
 		kfree(hwif->acpidata);
 		hwif->acpidata = NULL;
-		return;
 	}
+}
+
+void ide_acpi_port_init_devices(ide_hwif_t *hwif)
+{
+	ide_drive_t *drive;
+	int i, err;
+
+	if (hwif->acpidata == NULL)
+		return;
 
 	/*
 	 * The ACPI spec mandates that we send information
 	 * for both drives, regardless whether they are connected
 	 * or not.
 	 */
-	hwif->acpidata->master.drive = &hwif->drives[0];
 	hwif->drives[0].acpidata = &hwif->acpidata->master;
-	master = &hwif->acpidata->master;
-
-	hwif->acpidata->slave.drive = &hwif->drives[1];
 	hwif->drives[1].acpidata = &hwif->acpidata->slave;
-	slave = &hwif->acpidata->slave;
-
 
 	/*
 	 * Send IDENTIFY for each drive
 	 */
-	if (master->drive->present) {
-		err = taskfile_lib_get_identify(master->drive, master->idbuff);
-		if (err) {
-			DEBPRINT("identify device %s failed (%d)\n",
-				 master->drive->name, err);
-		}
-	}
+	for (i = 0; i < MAX_DRIVES; i++) {
+		drive = &hwif->drives[i];
+
+		if (!drive->present)
+			continue;
 
-	if (slave->drive->present) {
-		err = taskfile_lib_get_identify(slave->drive, slave->idbuff);
-		if (err) {
+		err = taskfile_lib_get_identify(drive, drive->acpidata->idbuff);
+		if (err)
 			DEBPRINT("identify device %s failed (%d)\n",
-				 slave->drive->name, err);
-		}
+				 drive->name, err);
 	}
 
 	if (ide_noacpionboot) {
@@ -740,12 +732,11 @@ void ide_acpi_init(ide_hwif_t *hwif)
 	ide_acpi_get_timing(hwif);
 	ide_acpi_push_timing(hwif);
 
-	for (unit = 0; unit < MAX_DRIVES; ++unit) {
-		ide_drive_t *drive = &hwif->drives[unit];
+	for (i = 0; i < MAX_DRIVES; i++) {
+		drive = &hwif->drives[i];
 
-		if (drive->present) {
+		if (drive->present)
 			/* Execute ACPI startup code */
 			ide_acpi_exec_tfs(drive);
-		}
 	}
 }
Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1430,6 +1430,7 @@ int ide_device_add_all(u8 idx[MAX_HWIFS]
 		}
 
 		ide_acpi_init(hwif);
+		ide_acpi_port_init_devices(hwif);
 	}
 
 	for (i = 0; i < MAX_HWIFS; i++) {
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1205,12 +1205,14 @@ extern int ide_acpi_exec_tfs(ide_drive_t
 extern void ide_acpi_get_timing(ide_hwif_t *hwif);
 extern void ide_acpi_push_timing(ide_hwif_t *hwif);
 extern void ide_acpi_init(ide_hwif_t *hwif);
+void ide_acpi_port_init_devices(ide_hwif_t *);
 extern void ide_acpi_set_state(ide_hwif_t *hwif, int on);
 #else
 static inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; }
 static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; }
 static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; }
 static inline void ide_acpi_init(ide_hwif_t *hwif) { ; }
+static inline void ide_acpi_port_init_devices(ide_hwif_t *hwif) { ; }
 static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {}
 #endif
 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/22] ide: even more IDE probing code rework, Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:25 pm)
[PATCH 22/22] ide: move create_proc_ide_drives() call to ide..., Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:28 pm)
[PATCH 21/22] ide: move hwif-&gt;present check out from ide_..., Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:28 pm)
[PATCH 20/22] ide: factor out devices setup from ide_acpi_in..., Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:28 pm)
[PATCH 19/22] ide-acpi: remove dead code from do_drive_get_G..., Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:28 pm)
[PATCH 15/22] ide: factor out adding drive to hwgroup from i..., Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:27 pm)
[PATCH 18/22] ide-acpi: remove needless exports, Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:28 pm)
[PATCH 17/22] ide: move ide_acpi_init() call to ide_device_a..., Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:28 pm)
[PATCH 16/22] ide: factor out devices setup from init_irq(), Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:27 pm)
[PATCH 14/22] ide: move hwif-&gt;rqsize init from ide_init_q..., Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:27 pm)
[PATCH 13/22] ide: merge init_gendisk() into hwif_register_d..., Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:27 pm)
[PATCH 12/22] ide: call init_gendisk() after ide_acpi_init(), Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:27 pm)
[PATCH 11/22] ide: move blk_register_region() call out from ..., Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:27 pm)
[PATCH 10/22] ide: skip not present devices in init_gendisk(), Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:27 pm)
[PATCH 09/22] ide: remove incorrect init_gendisk() comment, Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:27 pm)
[PATCH 08/22] ide: add -&gt;init_port_devs method to ide_hwif_t, Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:27 pm)
[PATCH 07/22] ide: add IDE_HFLAG_NO_{IO32_BIT,UNMASK_IRQS} h..., Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:26 pm)
[PATCH 06/22] ide: factor out code initializing devices from..., Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:26 pm)
[PATCH 05/22] ide: fix ide_unregister() usage in host drivers, Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:26 pm)
[PATCH 04/22] ide: add ide_deprecated_find_port() helper, Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:26 pm)
Re: [PATCH 04/22] ide: add ide_deprecated_find_port() helper, Sergei Shtylyov, (Wed May 21, 10:29 am)
Re: [PATCH 04/22] ide: add ide_deprecated_find_port() helper, Bartlomiej Zolnierkiewicz..., (Tue May 27, 2:36 pm)
[PATCH 03/22] ide: add 'init_default' and 'restore' argument..., Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:26 pm)
[PATCH 02/22] ide: remove redundant init_hwif_default() call..., Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:26 pm)
[PATCH 01/22] ide: remove redundant hwif-&gt;present check f..., Bartlomiej Zolnierkiewicz..., (Wed Jan 16, 7:26 pm)
speck-geostationary