* [PATCH 1/8] ide: remove superfluous check from ide_proc_port_register_devices()
@ 2009-01-11 19:11 Bartlomiej Zolnierkiewicz
2009-01-11 19:11 ` [PATCH 2/8] ide-acpi: no need to zero ->acpidata for devices Bartlomiej Zolnierkiewicz
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-11 19:11 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: remove superfluous check from ide_proc_port_register_devices()
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
just few cleanup patches for pata-2.6 tree (mainly IDE ACPI related)
drivers/ide/ide-proc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: b/drivers/ide/ide-proc.c
===================================================================
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -600,7 +600,7 @@ void ide_proc_port_register_devices(ide_
int i;
ide_port_for_each_dev(i, drive, hwif) {
- if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0 || drive->proc)
+ if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
continue;
drive->proc = proc_mkdir(drive->name, parent);
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/8] ide-acpi: no need to zero ->acpidata for devices
2009-01-11 19:11 [PATCH 1/8] ide: remove superfluous check from ide_proc_port_register_devices() Bartlomiej Zolnierkiewicz
@ 2009-01-11 19:11 ` Bartlomiej Zolnierkiewicz
2009-01-11 19:11 ` [PATCH 3/8] ide-acpi: init ACPI handles early " Bartlomiej Zolnierkiewicz
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-11 19:11 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide-acpi: no need to zero ->acpidata for devices
ide_acpi_init() takes care of it.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-acpi.c | 2 --
1 file changed, 2 deletions(-)
Index: b/drivers/ide/ide-acpi.c
===================================================================
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -718,8 +718,6 @@ void ide_acpi_port_init_devices(ide_hwif
* Send IDENTIFY for each drive
*/
ide_port_for_each_dev(i, drive, hwif) {
- memset(drive->acpidata, 0, sizeof(*drive->acpidata));
-
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
continue;
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/8] ide-acpi: init ACPI handles early for devices
2009-01-11 19:11 [PATCH 1/8] ide: remove superfluous check from ide_proc_port_register_devices() Bartlomiej Zolnierkiewicz
2009-01-11 19:11 ` [PATCH 2/8] ide-acpi: no need to zero ->acpidata for devices Bartlomiej Zolnierkiewicz
@ 2009-01-11 19:11 ` Bartlomiej Zolnierkiewicz
2009-01-11 19:11 ` [PATCH 4/8] ide: add ide_for_each_present_dev() iterator Bartlomiej Zolnierkiewicz
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-11 19:11 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide-acpi: init ACPI handles early for devices
Init ACPI handles for devices in ide_acpi_port_init_devices()
and remove no longer needed ide_acpi_drive_get_handle().
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-acpi.c | 65 +++++++++++++++----------------------------------
1 file changed, 21 insertions(+), 44 deletions(-)
Index: b/drivers/ide/ide-acpi.c
===================================================================
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -208,40 +208,6 @@ static acpi_handle ide_acpi_hwif_get_han
}
/**
- * ide_acpi_drive_get_handle - Get ACPI object handle for a given drive
- * @drive: device to locate
- *
- * Retrieves the object handle of a given drive. According to the ACPI
- * spec the drive is a child of the hwif.
- *
- * Returns handle on success, 0 on error.
- */
-static acpi_handle ide_acpi_drive_get_handle(ide_drive_t *drive)
-{
- ide_hwif_t *hwif = drive->hwif;
- int port;
- acpi_handle drive_handle;
-
- if (!hwif->acpidata)
- return NULL;
-
- if (!hwif->acpidata->obj_handle)
- return NULL;
-
- port = hwif->channel ? drive->dn - 2: drive->dn;
-
- DEBPRINT("ENTER: %s at channel#: %d port#: %d\n",
- drive->name, hwif->channel, port);
-
-
- /* TBD: could also check ACPI object VALID bits */
- drive_handle = acpi_get_child(hwif->acpidata->obj_handle, port);
- DEBPRINT("drive %s handle 0x%p\n", drive->name, drive_handle);
-
- return drive_handle;
-}
-
-/**
* do_drive_get_GTF - get the drive bootup default taskfile settings
* @drive: the drive for which the taskfile settings should be retrieved
* @gtf_length: number of bytes of _GTF data returned at @gtf_address
@@ -296,14 +262,9 @@ static int do_drive_get_GTF(ide_drive_t
goto out;
}
- /* Get this drive's _ADR info. if not already known. */
if (!drive->acpidata->obj_handle) {
- drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive);
- if (!drive->acpidata->obj_handle) {
- DEBPRINT("No ACPI object found for %s\n",
- drive->name);
- goto out;
- }
+ DEBPRINT("No ACPI object found for %s\n", drive->name);
+ goto out;
}
/* Setting up output buffer */
@@ -658,9 +619,6 @@ void ide_acpi_set_state(ide_hwif_t *hwif
acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0);
ide_port_for_each_dev(i, drive, hwif) {
- if (!drive->acpidata->obj_handle)
- drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive);
-
if (drive->acpidata->obj_handle &&
(drive->dev_flags & IDE_DFLAG_PRESENT)) {
acpi_bus_set_power(drive->acpidata->obj_handle,
@@ -714,6 +672,25 @@ void ide_acpi_port_init_devices(ide_hwif
hwif->devices[0]->acpidata = &hwif->acpidata->master;
hwif->devices[1]->acpidata = &hwif->acpidata->slave;
+ /* get _ADR info for each device */
+ ide_port_for_each_dev(i, drive, hwif) {
+ acpi_handle dev_handle;
+
+ if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
+ continue;
+
+ DEBPRINT("ENTER: %s at channel#: %d port#: %d\n",
+ drive->name, hwif->channel, drive->dn & 1);
+
+ /* TBD: could also check ACPI object VALID bits */
+ dev_handle = acpi_get_child(hwif->acpidata->obj_handle,
+ drive->dn & 1);
+
+ DEBPRINT("drive %s handle 0x%p\n", drive->name, dev_handle);
+
+ drive->acpidata->obj_handle = dev_handle;
+ }
+
/*
* Send IDENTIFY for each drive
*/
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/8] ide: add ide_for_each_present_dev() iterator
2009-01-11 19:11 [PATCH 1/8] ide: remove superfluous check from ide_proc_port_register_devices() Bartlomiej Zolnierkiewicz
2009-01-11 19:11 ` [PATCH 2/8] ide-acpi: no need to zero ->acpidata for devices Bartlomiej Zolnierkiewicz
2009-01-11 19:11 ` [PATCH 3/8] ide-acpi: init ACPI handles early " Bartlomiej Zolnierkiewicz
@ 2009-01-11 19:11 ` Bartlomiej Zolnierkiewicz
2009-01-11 19:11 ` [PATCH 5/8] ide: sanitize ACPI initialization Bartlomiej Zolnierkiewicz
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-11 19:11 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: add ide_for_each_present_dev() iterator
* Add ide_for_each_present_dev() iterator and convert IDE code to use it.
* Do some drive-by CodingStyle fixups in ide-acpi.c while at it.
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-acpi.c | 30 ++++++++++--------------------
drivers/ide/ide-iops.c | 5 ++---
drivers/ide/ide-probe.c | 38 +++++++++++++-------------------------
include/linux/ide.h | 4 ++++
4 files changed, 29 insertions(+), 48 deletions(-)
Index: b/drivers/ide/ide-acpi.c
===================================================================
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -614,17 +614,17 @@ void ide_acpi_set_state(ide_hwif_t *hwif
DEBPRINT("no ACPI data for %s\n", hwif->name);
return;
}
+
/* channel first and then drives for power on and verse versa for power off */
if (on)
acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0);
- ide_port_for_each_dev(i, drive, hwif) {
- if (drive->acpidata->obj_handle &&
- (drive->dev_flags & IDE_DFLAG_PRESENT)) {
+ ide_port_for_each_present_dev(i, drive, hwif) {
+ if (drive->acpidata->obj_handle)
acpi_bus_set_power(drive->acpidata->obj_handle,
- on? ACPI_STATE_D0: ACPI_STATE_D3);
- }
+ on ? ACPI_STATE_D0 : ACPI_STATE_D3);
}
+
if (!on)
acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D3);
}
@@ -673,12 +673,9 @@ void ide_acpi_port_init_devices(ide_hwif
hwif->devices[1]->acpidata = &hwif->acpidata->slave;
/* get _ADR info for each device */
- ide_port_for_each_dev(i, drive, hwif) {
+ ide_port_for_each_present_dev(i, drive, hwif) {
acpi_handle dev_handle;
- if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
- continue;
-
DEBPRINT("ENTER: %s at channel#: %d port#: %d\n",
drive->name, hwif->channel, drive->dn & 1);
@@ -691,13 +688,8 @@ void ide_acpi_port_init_devices(ide_hwif
drive->acpidata->obj_handle = dev_handle;
}
- /*
- * Send IDENTIFY for each drive
- */
- ide_port_for_each_dev(i, drive, hwif) {
- if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
- continue;
-
+ /* send IDENTIFY for each device */
+ ide_port_for_each_present_dev(i, drive, hwif) {
err = taskfile_lib_get_identify(drive, drive->acpidata->idbuff);
if (err)
DEBPRINT("identify device %s failed (%d)\n",
@@ -717,9 +709,7 @@ void ide_acpi_port_init_devices(ide_hwif
ide_acpi_get_timing(hwif);
ide_acpi_push_timing(hwif);
- ide_port_for_each_dev(i, drive, hwif) {
- if (drive->dev_flags & IDE_DFLAG_PRESENT)
- /* Execute ACPI startup code */
- ide_acpi_exec_tfs(drive);
+ ide_port_for_each_present_dev(i, drive, hwif) {
+ ide_acpi_exec_tfs(drive);
}
}
Index: b/drivers/ide/ide-iops.c
===================================================================
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -1101,9 +1101,8 @@ static ide_startstop_t do_reset1 (ide_dr
prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE);
timeout = jiffies;
- ide_port_for_each_dev(i, tdrive, hwif) {
- if (tdrive->dev_flags & IDE_DFLAG_PRESENT &&
- tdrive->dev_flags & IDE_DFLAG_PARKED &&
+ ide_port_for_each_present_dev(i, tdrive, hwif) {
+ if ((tdrive->dev_flags & IDE_DFLAG_PARKED) &&
time_after(tdrive->sleep, timeout))
timeout = tdrive->sleep;
}
Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -824,22 +824,18 @@ static void ide_port_tune_devices(ide_hw
ide_drive_t *drive;
int i;
- ide_port_for_each_dev(i, drive, hwif) {
- if (drive->dev_flags & IDE_DFLAG_PRESENT) {
- if (port_ops && port_ops->quirkproc)
- port_ops->quirkproc(drive);
- }
+ ide_port_for_each_present_dev(i, drive, hwif) {
+ if (port_ops && port_ops->quirkproc)
+ port_ops->quirkproc(drive);
}
- ide_port_for_each_dev(i, drive, hwif) {
- if (drive->dev_flags & IDE_DFLAG_PRESENT) {
- ide_set_max_pio(drive);
+ ide_port_for_each_present_dev(i, drive, hwif) {
+ ide_set_max_pio(drive);
- drive->dev_flags |= IDE_DFLAG_NICE1;
+ drive->dev_flags |= IDE_DFLAG_NICE1;
- if (hwif->dma_ops)
- ide_set_dma(drive);
- }
+ if (hwif->dma_ops)
+ ide_set_dma(drive);
}
}
@@ -910,10 +906,7 @@ static int ide_port_setup_devices(ide_hw
int i, j = 0;
mutex_lock(&ide_cfg_mtx);
- ide_port_for_each_dev(i, drive, hwif) {
- if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
- continue;
-
+ ide_port_for_each_present_dev(i, drive, hwif) {
if (ide_init_queue(drive)) {
printk(KERN_ERR "ide: failed to init %s\n",
drive->name);
@@ -1125,13 +1118,10 @@ static void hwif_register_devices(ide_hw
ide_drive_t *drive;
unsigned int i;
- ide_port_for_each_dev(i, drive, hwif) {
+ ide_port_for_each_present_dev(i, drive, hwif) {
struct device *dev = &drive->gendev;
int ret;
- if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
- continue;
-
dev_set_name(dev, "%u.%u", hwif->index, i);
dev->parent = &hwif->gendev;
dev->bus = &ide_bus_type;
@@ -1574,11 +1564,9 @@ static void __ide_port_unregister_device
ide_drive_t *drive;
int i;
- ide_port_for_each_dev(i, drive, hwif) {
- if (drive->dev_flags & IDE_DFLAG_PRESENT) {
- device_unregister(&drive->gendev);
- wait_for_completion(&drive->gendev_rel_comp);
- }
+ ide_port_for_each_present_dev(i, drive, hwif) {
+ device_unregister(&drive->gendev);
+ wait_for_completion(&drive->gendev_rel_comp);
}
}
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1607,6 +1607,10 @@ static inline ide_drive_t *ide_get_pair_
#define ide_port_for_each_dev(i, dev, port) \
for ((i) = 0; ((dev) = (port)->devices[i]) || (i) < MAX_DRIVES; (i)++)
+#define ide_port_for_each_present_dev(i, dev, port) \
+ for ((i) = 0; ((dev) = (port)->devices[i]) || (i) < MAX_DRIVES; (i)++) \
+ if ((dev)->dev_flags & IDE_DFLAG_PRESENT)
+
#define ide_host_for_each_port(i, port, host) \
for ((i) = 0; ((port) = (host)->ports[i]) || (i) < MAX_HOST_PORTS; (i)++)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 5/8] ide: sanitize ACPI initialization
2009-01-11 19:11 [PATCH 1/8] ide: remove superfluous check from ide_proc_port_register_devices() Bartlomiej Zolnierkiewicz
` (2 preceding siblings ...)
2009-01-11 19:11 ` [PATCH 4/8] ide: add ide_for_each_present_dev() iterator Bartlomiej Zolnierkiewicz
@ 2009-01-11 19:11 ` Bartlomiej Zolnierkiewicz
2009-01-11 19:11 ` [PATCH 6/8] ide-acpi: cleanup do_drive_get_GTF() Bartlomiej Zolnierkiewicz
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-11 19:11 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: sanitize ACPI initialization
* ide_acpi_init() -> ide_acpi_init_port()
* ide_acpi_blacklist() -> ide_acpi_init()
* Call ide_acpi_init() only once (do it during IDE core
initialization) and cleanup the function accordingly.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-acpi.c | 12 +++---------
drivers/ide/ide-probe.c | 2 +-
drivers/ide/ide.c | 2 ++
include/linux/ide.h | 6 ++++--
4 files changed, 10 insertions(+), 12 deletions(-)
Index: b/drivers/ide/ide-acpi.c
===================================================================
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -95,12 +95,8 @@ static const struct dmi_system_id ide_ac
{ } /* terminate list */
};
-static int ide_acpi_blacklist(void)
+int ide_acpi_init(void)
{
- static int done;
- if (done)
- return 0;
- done = 1;
dmi_check_system(ide_acpi_dmi_table);
return 0;
}
@@ -630,7 +626,7 @@ void ide_acpi_set_state(ide_hwif_t *hwif
}
/**
- * ide_acpi_init - initialize the ACPI link for an IDE interface
+ * ide_acpi_init_port - initialize the ACPI link for an IDE interface
* @hwif: target IDE interface (channel)
*
* The ACPI spec is not quite clear when the drive identify buffer
@@ -640,10 +636,8 @@ void ide_acpi_set_state(ide_hwif_t *hwif
* So we get the information during startup; but this means that
* any changes during run-time will be lost after resume.
*/
-void ide_acpi_init(ide_hwif_t *hwif)
+void ide_acpi_init_port(ide_hwif_t *hwif)
{
- ide_acpi_blacklist();
-
hwif->acpidata = kzalloc(sizeof(struct ide_acpi_hwif_link), GFP_KERNEL);
if (!hwif->acpidata)
return;
Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1507,7 +1507,7 @@ int ide_host_register(struct ide_host *h
j++;
- ide_acpi_init(hwif);
+ ide_acpi_init_port(hwif);
if (hwif->present)
ide_acpi_port_init_devices(hwif);
Index: b/drivers/ide/ide.c
===================================================================
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -522,6 +522,8 @@ static int __init ide_init(void)
goto out_port_class;
}
+ ide_acpi_init();
+
proc_ide_create();
return 0;
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1482,17 +1482,19 @@ static inline void ide_release_dma_engin
#endif /* CONFIG_BLK_DEV_IDEDMA */
#ifdef CONFIG_BLK_DEV_IDEACPI
+int ide_acpi_init(void);
extern int ide_acpi_exec_tfs(ide_drive_t *drive);
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_init_port(ide_hwif_t *);
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_init(void) { return 0; }
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_init_port(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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 6/8] ide-acpi: cleanup do_drive_get_GTF()
2009-01-11 19:11 [PATCH 1/8] ide: remove superfluous check from ide_proc_port_register_devices() Bartlomiej Zolnierkiewicz
` (3 preceding siblings ...)
2009-01-11 19:11 ` [PATCH 5/8] ide: sanitize ACPI initialization Bartlomiej Zolnierkiewicz
@ 2009-01-11 19:11 ` Bartlomiej Zolnierkiewicz
2009-01-11 19:12 ` [PATCH 7/8] ide-acpi: cleanup do_drive_set_taskfiles() Bartlomiej Zolnierkiewicz
2009-01-11 19:12 ` [PATCH 8/8] ide-acpi: remove taskfile_load_raw() Bartlomiej Zolnierkiewicz
6 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-11 19:11 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide-acpi: cleanup do_drive_get_GTF()
* ide_noacpi is already checked by ide_acpi_exec_tfs()
which is the only user of do_drive_get_GTF().
* ide_acpi_exec_tfs() prints sufficient debug info about the
device so no need to have excessive data about port/host.
* It is sufficient to check for drive->acpidata->obj_handle
as it will be NULL if dev == NULL or hwif->acpidata == NULL
or device is not present.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-acpi.c | 27 ---------------------------
1 file changed, 27 deletions(-)
Index: b/drivers/ide/ide-acpi.c
===================================================================
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -225,39 +225,12 @@ static int do_drive_get_GTF(ide_drive_t
acpi_status status;
struct acpi_buffer output;
union acpi_object *out_obj;
- ide_hwif_t *hwif = drive->hwif;
- struct device *dev = hwif->gendev.parent;
int err = -ENODEV;
- int port;
*gtf_length = 0;
*gtf_address = 0UL;
*obj_loc = 0UL;
- if (ide_noacpi)
- return 0;
-
- if (!dev) {
- DEBPRINT("no PCI device for %s\n", hwif->name);
- goto out;
- }
-
- if (!hwif->acpidata) {
- DEBPRINT("no ACPI data for %s\n", hwif->name);
- goto out;
- }
-
- port = hwif->channel ? drive->dn - 2: drive->dn;
-
- DEBPRINT("ENTER: %s at %s, port#: %d, hard_port#: %d\n",
- hwif->name, dev->bus_id, port, hwif->channel);
-
- if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) {
- DEBPRINT("%s drive %d:%d not present\n",
- hwif->name, hwif->channel, port);
- goto out;
- }
-
if (!drive->acpidata->obj_handle) {
DEBPRINT("No ACPI object found for %s\n", drive->name);
goto out;
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 7/8] ide-acpi: cleanup do_drive_set_taskfiles()
2009-01-11 19:11 [PATCH 1/8] ide: remove superfluous check from ide_proc_port_register_devices() Bartlomiej Zolnierkiewicz
` (4 preceding siblings ...)
2009-01-11 19:11 ` [PATCH 6/8] ide-acpi: cleanup do_drive_get_GTF() Bartlomiej Zolnierkiewicz
@ 2009-01-11 19:12 ` Bartlomiej Zolnierkiewicz
2009-01-11 19:12 ` [PATCH 8/8] ide-acpi: remove taskfile_load_raw() Bartlomiej Zolnierkiewicz
6 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-11 19:12 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide-acpi: cleanup do_drive_set_taskfiles()
* ide_noacpi is already checked by ide_acpi_exec_tfs()
which is the only user of do_drive_set_taskfiles().
* ide_acpi_exec_tfs() prints sufficient debug info about the
device so no need to do it again.
* do_drive_get_GTF() + ide_acpi_exec_tfs() make sure that this
function will never be called with incorrect gtf_length argument
or if device is not present.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-acpi.c | 21 +--------------------
1 file changed, 1 insertion(+), 20 deletions(-)
Index: b/drivers/ide/ide-acpi.c
===================================================================
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -340,32 +340,14 @@ static int do_drive_set_taskfiles(ide_dr
unsigned int gtf_length,
unsigned long gtf_address)
{
- int rc = -ENODEV, err;
+ int rc = 0, err;
int gtf_count = gtf_length / REGS_PER_GTF;
int ix;
struct taskfile_array *gtf;
- if (ide_noacpi)
- return 0;
-
- DEBPRINT("ENTER: %s, hard_port#: %d\n", drive->name, drive->dn);
-
- if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
- goto out;
-
- if (!gtf_count) /* shouldn't be here */
- goto out;
-
DEBPRINT("total GTF bytes=%u (0x%x), gtf_count=%d, addr=0x%lx\n",
gtf_length, gtf_length, gtf_count, gtf_address);
- if (gtf_length % REGS_PER_GTF) {
- printk(KERN_ERR "%s: unexpected GTF length (%d)\n",
- __func__, gtf_length);
- goto out;
- }
-
- rc = 0;
for (ix = 0; ix < gtf_count; ix++) {
gtf = (struct taskfile_array *)
(gtf_address + ix * REGS_PER_GTF);
@@ -376,7 +358,6 @@ static int do_drive_set_taskfiles(ide_dr
rc = err;
}
-out:
return rc;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 8/8] ide-acpi: remove taskfile_load_raw()
2009-01-11 19:11 [PATCH 1/8] ide: remove superfluous check from ide_proc_port_register_devices() Bartlomiej Zolnierkiewicz
` (5 preceding siblings ...)
2009-01-11 19:12 ` [PATCH 7/8] ide-acpi: cleanup do_drive_set_taskfiles() Bartlomiej Zolnierkiewicz
@ 2009-01-11 19:12 ` Bartlomiej Zolnierkiewicz
6 siblings, 0 replies; 8+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-11 19:12 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide-acpi: remove taskfile_load_raw()
* taskfile_load_raw() is used only by do_drive_set_taskfiles()
so inline it there.
While at it:
- rename 'args' variable to 'task'
- remove struct taskfile_array
- do ide_acpigtf check early
- use REGS_PER_GTF
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-acpi.c | 69 ++++++++++++++++---------------------------------
1 file changed, 23 insertions(+), 46 deletions(-)
Index: b/drivers/ide/ide-acpi.c
===================================================================
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -26,9 +26,6 @@
#include <acpi/actypes.h>
#define REGS_PER_GTF 7
-struct taskfile_array {
- u8 tfa[REGS_PER_GTF]; /* regs. 0x1f1 - 0x1f7 */
-};
struct GTM_buffer {
u32 PIO_speed0;
@@ -291,43 +288,6 @@ out:
}
/**
- * taskfile_load_raw - send taskfile registers to drive
- * @drive: drive to which output is sent
- * @gtf: raw ATA taskfile register set (0x1f1 - 0x1f7)
- *
- * Outputs IDE taskfile to the drive.
- */
-static int taskfile_load_raw(ide_drive_t *drive,
- const struct taskfile_array *gtf)
-{
- ide_task_t args;
- int err = 0;
-
- DEBPRINT("(0x1f1-1f7): hex: "
- "%02x %02x %02x %02x %02x %02x %02x\n",
- gtf->tfa[0], gtf->tfa[1], gtf->tfa[2],
- gtf->tfa[3], gtf->tfa[4], gtf->tfa[5], gtf->tfa[6]);
-
- memset(&args, 0, sizeof(ide_task_t));
-
- /* convert gtf to IDE Taskfile */
- memcpy(&args.tf_array[7], >f->tfa, 7);
- args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
-
- if (!ide_acpigtf) {
- DEBPRINT("_GTF execution disabled\n");
- return err;
- }
-
- err = ide_no_data_taskfile(drive, &args);
- if (err)
- printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n",
- __func__, err);
-
- return err;
-}
-
-/**
* do_drive_set_taskfiles - write the drive taskfile settings from _GTF
* @drive: the drive to which the taskfile command should be sent
* @gtf_length: total number of bytes of _GTF taskfiles
@@ -343,19 +303,36 @@ static int do_drive_set_taskfiles(ide_dr
int rc = 0, err;
int gtf_count = gtf_length / REGS_PER_GTF;
int ix;
- struct taskfile_array *gtf;
DEBPRINT("total GTF bytes=%u (0x%x), gtf_count=%d, addr=0x%lx\n",
gtf_length, gtf_length, gtf_count, gtf_address);
+ /* send all taskfile registers (0x1f1-0x1f7) *in*that*order* */
for (ix = 0; ix < gtf_count; ix++) {
- gtf = (struct taskfile_array *)
- (gtf_address + ix * REGS_PER_GTF);
+ u8 *gtf = (u8 *)(gtf_address + ix * REGS_PER_GTF);
+ ide_task_t task;
- /* send all TaskFile registers (0x1f1-0x1f7) *in*that*order* */
- err = taskfile_load_raw(drive, gtf);
- if (err)
+ DEBPRINT("(0x1f1-1f7): "
+ "hex: %02x %02x %02x %02x %02x %02x %02x\n",
+ gtf[0], gtf[1], gtf[2],
+ gtf[3], gtf[4], gtf[5], gtf[6]);
+
+ if (!ide_acpigtf) {
+ DEBPRINT("_GTF execution disabled\n");
+ continue;
+ }
+
+ /* convert GTF to taskfile */
+ memset(&task, 0, sizeof(ide_task_t));
+ memcpy(&task.tf_array[7], gtf, REGS_PER_GTF);
+ task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
+
+ err = ide_no_data_taskfile(drive, &task);
+ if (err) {
+ printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n",
+ __func__, err);
rc = err;
+ }
}
return rc;
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-01-11 19:11 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-11 19:11 [PATCH 1/8] ide: remove superfluous check from ide_proc_port_register_devices() Bartlomiej Zolnierkiewicz
2009-01-11 19:11 ` [PATCH 2/8] ide-acpi: no need to zero ->acpidata for devices Bartlomiej Zolnierkiewicz
2009-01-11 19:11 ` [PATCH 3/8] ide-acpi: init ACPI handles early " Bartlomiej Zolnierkiewicz
2009-01-11 19:11 ` [PATCH 4/8] ide: add ide_for_each_present_dev() iterator Bartlomiej Zolnierkiewicz
2009-01-11 19:11 ` [PATCH 5/8] ide: sanitize ACPI initialization Bartlomiej Zolnierkiewicz
2009-01-11 19:11 ` [PATCH 6/8] ide-acpi: cleanup do_drive_get_GTF() Bartlomiej Zolnierkiewicz
2009-01-11 19:12 ` [PATCH 7/8] ide-acpi: cleanup do_drive_set_taskfiles() Bartlomiej Zolnierkiewicz
2009-01-11 19:12 ` [PATCH 8/8] ide-acpi: remove taskfile_load_raw() Bartlomiej Zolnierkiewicz
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).