From 92d3ab27e8fd23d1a9dc3b69d17b2afb83e5c6f5 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Mon, 28 Apr 2008 23:44:36 +0200 Subject: falconide/q40ide: add ->atapi_*put_bytes and ->ata_*put_data methods (take 2) * Add ->atapi_{in,out}put_bytes and ->ata_{in,out}put_data methods to falconide and q40ide host drivers (->ata_* methods are implemented on top of ->atapi_* methods so they also do byte-swapping now). * Cleanup atapi_{in,out}put_bytes(). v2: * Add 'struct request *rq' argument to ->ata_{in,out}put_data methods and don't byte-swap disk fs requests (we shouldn't un-swap fs requests because fs itself is stored byte-swapped on the disk) - this is how things were done before the patch (ideally device mapper should be used instead but it would break existing setups and would have some performance impact). Cc: Geert Uytterhoeven Cc: Michael Schmitz Cc: Roman Zippel Cc: Alan Cox Cc: Richard Zidlicky Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/ide/legacy/falconide.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/ide/legacy/q40ide.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) (limited to 'drivers/ide/legacy') diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c index 56cdaa0eeea5..32c044b17d45 100644 --- a/drivers/ide/legacy/falconide.c +++ b/drivers/ide/legacy/falconide.c @@ -44,6 +44,36 @@ int falconide_intr_lock; EXPORT_SYMBOL(falconide_intr_lock); +static void falconide_atapi_input_bytes(ide_drive_t *drive, void *buf, + unsigned int len) +{ + insw_swapw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2); +} + +static void falconide_atapi_output_bytes(ide_drive_t *drive, void *buf, + unsigned int len) +{ + outsw_swapw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2); +} + +static void falconide_ata_input_data(ide_drive_t *drive, struct request *rq, + void *buf, unsigned int wcount) +{ + if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS) + return insw(drive->hwif->io_ports.data_addr, buf, wcount * 2); + + falconide_atapi_input_bytes(drive, buf, wcount * 4); +} + +static void falconide_ata_output_data(ide_drive_t *drive, struct request *rq, + void *buf, unsigned int wcount) +{ + if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS) + return outsw(drive->hwif->io_ports.data_addr, buf, wcount * 2); + + falconide_atapi_output_bytes(drive, buf, wcount * 4); +} + static void __init falconide_setup_ports(hw_regs_t *hw) { int i; @@ -90,6 +120,12 @@ static int __init falconide_init(void) ide_init_port_data(hwif, index); ide_init_port_hw(hwif, &hw); + /* Atari has a byte-swapped IDE interface */ + hwif->atapi_input_bytes = falconide_atapi_input_bytes; + hwif->atapi_output_bytes = falconide_atapi_output_bytes; + hwif->ata_input_data = falconide_ata_input_data; + hwif->ata_output_data = falconide_ata_output_data; + ide_get_lock(NULL, NULL); ide_device_add(idx, NULL); ide_release_lock(); diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c index f9210458aea0..deae3d2ca65e 100644 --- a/drivers/ide/legacy/q40ide.c +++ b/drivers/ide/legacy/q40ide.c @@ -72,7 +72,35 @@ static void q40_ide_setup_ports(hw_regs_t *hw, unsigned long base, hw->ack_intr = ack_intr; } +static void q40ide_atapi_input_bytes(ide_drive_t *drive, void *buf, + unsigned int len) +{ + insw_swapw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2); +} +static void q40ide_atapi_output_bytes(ide_drive_t *drive, void *buf, + unsigned int len) +{ + outsw_swapw(drive->hwif->io_ports.data_addr, buf, (len + 1) / 2); +} + +static void q40ide_ata_input_data(ide_drive_t *drive, struct request *rq, + void *buf, unsigned int wcount) +{ + if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS) + return insw(drive->hwif->io_ports.data_addr, buf, wcount * 2); + + q40ide_atapi_input_bytes(drive, buf, wcount * 4); +} + +static void q40ide_ata_output_data(ide_drive_t *drive, struct request *rq, + void *buf, unsigned int wcount) +{ + if (drive->media == ide_disk && rq && rq->cmd_type == REQ_TYPE_FS) + return outsw(drive->hwif->io_ports.data_addr, buf, wcount * 2); + + q40ide_atapi_output_bytes(drive, buf, wcount * 4); +} /* * the static array is needed to have the name reported in /proc/ioports, @@ -123,6 +151,12 @@ static int __init q40ide_init(void) ide_init_port_data(hwif, hwif->index); ide_init_port_hw(hwif, &hw); + /* Q40 has a byte-swapped IDE interface */ + hwif->atapi_input_bytes = q40ide_atapi_input_bytes; + hwif->atapi_output_bytes = q40ide_atapi_output_bytes; + hwif->ata_input_data = q40ide_ata_input_data; + hwif->ata_output_data = q40ide_ata_output_data; + idx[i] = hwif->index; } } -- cgit v1.2.2