ide: factor out debugging code from ide_tf_load()
PATCH 1/9 ide: factor out debugging code from ide_tf_load()
Factor out debugging code from ide_tf_load() to ide_tf_dump() helper and update ide_tf_load() users accordingly.
--- drivers/ide/ide-io.c | 1 + drivers/ide/ide-taskfile.c | 29 +++++++++++++++++------------ include/linux/ide.h | 2 ++ 3 files changed, 20 insertions(+), 12 deletions(-)
drivers/ide/ide-io.c +1 -0
@@ -1680,6 +1680,7 @@ void ide_pktcmd_tf_load(ide_drive_t *dri task.tf.lbam = bcount &0xff ; task.tf.lbah = (bcount >>8 ) &0xff ; +ide_tf_dump (drive->name, &task.tf);ide_tf_load (drive, &task); }
drivers/ide/ide-taskfile.c +17 -12
@@ -33,26 +33,29 @@#include <asm/uaccess.h> #include <asm/io.h> -void ide_tf_load (ide_drive_t *drive,ide_task_t *task) +void ide_tf_dump (const char *s,struct ide_taskfile *tf) { -ide_hwif_t *hwif = drive->hwif; -struct ide_io_ports *io_ports = &hwif->io_ports; -struct ide_taskfile *tf = &task->tf; -u8 HIHI = (task->tf_flags &IDE_TFLAG_LBA48 ) ?0xE0 :0xEF ; - -if (task->tf_flags &IDE_TFLAG_FLAGGED ) -HIHI =0xFF ; -#ifdef DEBUG printk ("%s: tf: feat 0x%02x nsect 0x%02x lbal 0x%02x " "lbam 0x%02x lbah 0x%02x dev 0x%02x cmd 0x%02x\n" , - drive->name, tf->feature, tf->nsect, tf->lbal, + s, tf->feature, tf->nsect, tf->lbal, tf->lbam, tf->lbah, tf->device, tf->command);printk ("%s: hob: nsect 0x%02x lbal 0x%02x " "lbam 0x%02x lbah 0x%02x\n" , - drive->name, tf->hob_nsect, tf->hob_lbal, + s, tf->hob_nsect, tf->hob_lbal, tf->hob_lbam, tf->hob_lbah);#endif +} + +void ide_tf_load (ide_drive_t *drive,ide_task_t *task) +{ +ide_hwif_t *hwif = drive->hwif; +struct ide_io_ports *io_ports = &hwif->io_ports; +struct ide_taskfile *tf = &task->tf; +u8 HIHI = (task->tf_flags &IDE_TFLAG_LBA48 ) ?0xE0 :0xEF ; + +if (task->tf_flags &IDE_TFLAG_FLAGGED ) +HIHI =0xFF ;ide_set_irq (drive,1 );
@@ -149,8 +152,10 @@ ide_startstop_t do_rw_taskfile (ide_drivif (task->tf_flags &IDE_TFLAG_FLAGGED ) task->tf_flags |=IDE_TFLAG_FLAGGED_SET_IN_FLAGS ; -if ((task->tf_flags &IDE_TFLAG_DMA_PIO_FALLBACK ) ==0 ) +if ((task->tf_flags &IDE_TFLAG_DMA_PIO_FALLBACK ) ==0 ) { +ide_tf_dump (drive->name, tf);ide_tf_load (drive, task); + }switch (task->data_phase) {case TASKFILE_MULTI_OUT :
include/linux/ide.h +2 -0
@@ -949,6 +949,8 @@ typedef struct ide_task_s {void *special;/* valid_t generally */ } ide_task_t; +void ide_tf_dump (const char *,struct ide_taskfile *); +void ide_tf_load (ide_drive_t *,ide_task_t *);void ide_tf_read (ide_drive_t *,ide_task_t *);
PATCH 2/9 ide: move ide_tf_{load,read} to ide-iops.c
--- drivers/ide/ide-io.c | 43 --------------------- drivers/ide/ide-iops.c | 88 +++++++++++++++++++++++++++++++++++++++++++++ drivers/ide/ide-taskfile.c | 45 ----------------------- 3 files changed, 88 insertions(+), 88 deletions(-)
drivers/ide/ide-io.c +0 -43
@@ -295,49 +295,6 @@ static void ide_complete_pm_request (idespin_unlock_irqrestore (&ide_lock, flags); } -void ide_tf_read (ide_drive_t *drive,ide_task_t *task) -{ -ide_hwif_t *hwif = drive->hwif; -struct ide_io_ports *io_ports = &hwif->io_ports; -struct ide_taskfile *tf = &task->tf; - -if (task->tf_flags &IDE_TFLAG_IN_DATA ) { -u16 data = hwif->INW (io_ports->data_addr); - - tf->data = data &0xff ; - tf->hob_data = (data >>8 ) &0xff ; - } - -/* be sure we're looking at the low order bits */ - hwif->OUTB (drive->ctl & ~0x80 , io_ports->ctl_addr); - -if (task->tf_flags &IDE_TFLAG_IN_NSECT ) - tf->nsect = hwif->INB (io_ports->nsect_addr); -if (task->tf_flags &IDE_TFLAG_IN_LBAL ) - tf->lbal = hwif->INB (io_ports->lbal_addr); -if (task->tf_flags &IDE_TFLAG_IN_LBAM ) - tf->lbam = hwif->INB (io_ports->lbam_addr); -if (task->tf_flags &IDE_TFLAG_IN_LBAH ) - tf->lbah = hwif->INB (io_ports->lbah_addr); -if (task->tf_flags &IDE_TFLAG_IN_DEVICE ) - tf->device = hwif->INB (io_ports->device_addr); - -if (task->tf_flags &IDE_TFLAG_LBA48 ) { - hwif->OUTB (drive->ctl |0x80 , io_ports->ctl_addr); - -if (task->tf_flags &IDE_TFLAG_IN_HOB_FEATURE ) - tf->hob_feature = hwif->INB (io_ports->feature_addr); -if (task->tf_flags &IDE_TFLAG_IN_HOB_NSECT ) - tf->hob_nsect = hwif->INB (io_ports->nsect_addr); -if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAL ) - tf->hob_lbal = hwif->INB (io_ports->lbal_addr); -if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAM ) - tf->hob_lbam = hwif->INB (io_ports->lbam_addr); -if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAH ) - tf->hob_lbah = hwif->INB (io_ports->lbah_addr); - } -} -/** * ide_end_drive_cmd - end an explicit drive command * @drive: command
drivers/ide/ide-iops.c +88 -0
94 lines not on this page · raw message
drivers/ide/ide-taskfile.c +0 -45
51 lines not on this page · raw message
PATCH 3/9 ide: add ->tf_load and ->tf_read methods
In reply to Bartlomiej Zolnierkiewicz* Add ->tf_load and ->tf_read methods to ide_hwif_t and set the default methods in default_hwif_transport().
* Use ->tf_{load,read} instead o calling ide_tf_{load,read}() directly.
* Make ide_tf_{load,read}() static.
There should be no functional changes caused by this patch.
--- drivers/ide/ide-io.c | 4 ++-- drivers/ide/ide-iops.c | 7 +++++-- drivers/ide/ide-lib.c | 2 +- drivers/ide/ide-taskfile.c | 2 +- include/linux/ide.h | 8 +++++--- 5 files changed, 14 insertions(+), 9 deletions(-)
drivers/ide/ide-io.c +2 -2
@@ -330,7 +330,7 @@ void ide_end_drive_cmd (ide_drive_t *dri tf->error = err; tf->status = stat; -ide_tf_read (drive, task); + drive->hwif->tf_read (drive, task);if (task->tf_flags &IDE_TFLAG_DYN )kfree (task);
@@ -1638,7 +1638,7 @@ void ide_pktcmd_tf_load(ide_drive_t *dri task.tf.lbah = (bcount >>8 ) &0xff ;ide_tf_dump (drive->name, &task.tf); -ide_tf_load (drive, &task); + drive->hwif->tf_load (drive, &task); }EXPORT_SYMBOL_GPL (ide_pktcmd_tf_load);
drivers/ide/ide-iops.c +5 -2
@@ -127,7 +127,7 @@ void SELECT_MASK (ide_drive_t *drive, in port_ops->maskproc (drive, mask); } -void ide_tf_load (ide_drive_t *drive,ide_task_t *task) +static void ide_tf_load (ide_drive_t *drive,ide_task_t *task) {ide_hwif_t *hwif = drive->hwif;struct ide_io_ports *io_ports = &hwif->io_ports;
@@ -172,7 +172,7 @@ void ide_tf_load(ide_drive_t *drive, ide io_ports->device_addr); } -void ide_tf_read (ide_drive_t *drive,ide_task_t *task) +static void ide_tf_read (ide_drive_t *drive,ide_task_t *task) {ide_hwif_t *hwif = drive->hwif;struct ide_io_ports *io_ports = &hwif->io_ports;
@@ -323,6 +323,9 @@ static void ata_output_data(ide_drive_tvoid default_hwif_transport (ide_hwif_t *hwif) { + hwif->tf_load = ide_tf_load; + hwif->tf_read = ide_tf_read; + hwif->input_data = ata_input_data; hwif->output_data = ata_output_data; }
drivers/ide/ide-lib.c +1 -1
@@ -487,7 +487,7 @@ static void ide_dump_sector(ide_drive_telse task.tf_flags =IDE_TFLAG_IN_LBA |IDE_TFLAG_IN_DEVICE ; -ide_tf_read (drive, &task); + drive->hwif->tf_read (drive, &task);if (lba48 || (tf->device &ATA_LBA )) printk(", LBAsect=%llu",
drivers/ide/ide-taskfile.c +1 -1
@@ -109,7 +109,7 @@ ide_startstop_t do_rw_taskfile (ide_drivif ((task->tf_flags &IDE_TFLAG_DMA_PIO_FALLBACK ) ==0 ) {ide_tf_dump (drive->name, tf); -ide_tf_load (drive, task); + hwif->tf_load (drive, task); }switch (task->data_phase) {
include/linux/ide.h +5 -3
@@ -429,6 +429,8 @@ struct ide_dma_ops {void (*dma_timeout)(struct ide_drive_s *); }; +struct ide_task_s ; + typedef struct hwif_s { struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ struct hwif_s *mate; /* other hwif from same PCI chip */
@@ -469,6 +471,9 @@ typedef struct hwif_s {const struct ide_port_ops *port_ops;const struct ide_dma_ops *dma_ops; +void (*tf_load)(ide_drive_t *,struct ide_task_s *); +void (*tf_read)(ide_drive_t *,struct ide_task_s *); +void (*input_data)(ide_drive_t *,struct request *,void *,unsigned );void (*output_data)(ide_drive_t *,struct request *,void *,unsigned );
@@ -951,9 +956,6 @@ typedef struct ide_task_s {void ide_tf_dump (const char *,struct ide_taskfile *); -void ide_tf_load (ide_drive_t *,ide_task_t *); -void ide_tf_read (ide_drive_t *,ide_task_t *); -extern void SELECT_DRIVE (ide_drive_t *);extern void SELECT_MASK (ide_drive_t *,int );
Re: [PATCH 3/9] ide: add ->tf_load and ->tf_read methods
Quoted 2 lines · Bartlomiej Zolnierkiewicz
* Add ->tf_load and ->tf_read methods to
ide_hwif_tand set the default methods indefault_hwif_transport().
It's not clear to me what do we gain with addign such methods...
Quoted 7 lines
* Use ->tf_{load,read} instead o calling ide_tf_{load,read}() directly.
* Make ide_tf_{load,read}() static.
There should be no functional changes caused by this patch.
Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>
MBR, Sergei
Re: [PATCH 3/9] ide: add ->tf_load and ->tf_read methods
Quoted 6 lines · Sergei Shtylyov
Quoted 2 lines · Bartlomiej Zolnierkiewicz
* Add ->tf_load and ->tf_read methods to
ide_hwif_tand set the default methods indefault_hwif_transport().It's not clear to me what do we gain with addign such methods...
in short-term not much besides a nice optimization
in long-term it should enable us to remove ->IN*/OUT* methods completely
Quoted 9 lines
Quoted 7 lines
* Use ->tf_{load,read} instead o calling ide_tf_{load,read}() directly.
* Make ide_tf_{load,read}() static.
There should be no functional changes caused by this patch.
Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>Acked-by Sergei Shtylyov <[email protected]>
PATCH 4/9 ide-cris: add ->tf_{load,read} methods
In reply to Bartlomiej ZolnierkiewiczAdd ->tf_{load,read} methods so cris_ide_{outb,outw,inb,inw}() can be used directly.
There should be no functional changes caused by this patch.
--- drivers/ide/cris/ide-cris.c | 87 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+)
drivers/ide/cris/ide-cris.c +87 -0
@@ -775,6 +775,90 @@ static void __init cris_setup_ports(hw_r hw->ack_intr = cris_ide_ack_intr; } +static void cris_tf_load (ide_drive_t *drive,ide_task_t *task) +{ +struct ide_io_ports *io_ports = &drive->hwif->io_ports; +struct ide_taskfile *tf = &task->tf; +u8 HIHI = (task->tf_flags &IDE_TFLAG_LBA48 ) ?0xE0 :0xEF ; + +if (task->tf_flags &IDE_TFLAG_FLAGGED ) +HIHI =0xFF ; + +ide_set_irq (drive,1 ); + +if (task->tf_flags &IDE_TFLAG_OUT_DATA ) +cris_ide_outw ((tf->hob_data <<8 ) | tf->data, + io_ports->data_addr); + +if (task->tf_flags &IDE_TFLAG_OUT_HOB_FEATURE ) +cris_ide_outb (tf->hob_feature, io_ports->feature_addr); +if (task->tf_flags &IDE_TFLAG_OUT_HOB_NSECT ) +cris_ide_outb (tf->hob_nsect, io_ports->nsect_addr); +if (task->tf_flags &IDE_TFLAG_OUT_HOB_LBAL ) +cris_ide_outb (tf->hob_lbal, io_ports->lbal_addr); +if (task->tf_flags &IDE_TFLAG_OUT_HOB_LBAM ) +cris_ide_outb (tf->hob_lbam, io_ports->lbam_addr); +if (task->tf_flags &IDE_TFLAG_OUT_HOB_LBAH ) +cris_ide_outb (tf->hob_lbah, io_ports->lbah_addr); + +if (task->tf_flags &IDE_TFLAG_OUT_FEATURE ) +cris_ide_outb (tf->feature, io_ports->feature_addr); +if (task->tf_flags &IDE_TFLAG_OUT_NSECT ) +cris_ide_outb (tf->nsect, io_ports->nsect_addr); +if (task->tf_flags &IDE_TFLAG_OUT_LBAL ) +cris_ide_outb (tf->lbal, io_ports->lbal_addr); +if (task->tf_flags &IDE_TFLAG_OUT_LBAM ) +cris_ide_outb (tf->lbam, io_ports->lbam_addr); +if (task->tf_flags &IDE_TFLAG_OUT_LBAH ) +cris_ide_outb (tf->lbah, io_ports->lbah_addr); + +if (task->tf_flags &IDE_TFLAG_OUT_DEVICE ) +cris_ide_outb ((tf->device &HIHI ) | drive->select.all, + io_ports->device_addr); +} + +static void cris_tf_read (ide_drive_t *drive,ide_task_t *task) +{ +struct ide_io_ports *io_ports = &drive->hwif->io_ports; +struct ide_taskfile *tf = &task->tf; + +if (task->tf_flags &IDE_TFLAG_IN_DATA ) { +u16 data =cris_ide_inw (io_ports->data_addr); + + tf->data = data &0xff ; + tf->hob_data = (data >>8 ) &0xff ; + } + +/* be sure we're looking at the low order bits */ +cris_ide_outb (drive->ctl & ~0x80 , io_ports->ctl_addr); + +if (task->tf_flags &IDE_TFLAG_IN_NSECT ) + tf->nsect =cris_ide_inb (io_ports->nsect_addr); +if (task->tf_flags &IDE_TFLAG_IN_LBAL ) + tf->lbal =cris_ide_inb (io_ports->lbal_addr); +if (task->tf_flags &IDE_TFLAG_IN_LBAM ) + tf->lbam =cris_ide_inb (io_ports->lbam_addr); +if (task->tf_flags &IDE_TFLAG_IN_LBAH ) + tf->lbah =cris_ide_inb (io_ports->lbah_addr); +if (task->tf_flags &IDE_TFLAG_IN_DEVICE ) + tf->device =cris_ide_inb (io_ports->device_addr); + +if (task->tf_flags &IDE_TFLAG_LBA48 ) { +cris_ide_outb (drive->ctl |0x80 , io_ports->ctl_addr); + +if (task->tf_flags &IDE_TFLAG_IN_HOB_FEATURE ) + tf->hob_feature =cris_ide_inb (io_ports->feature_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_NSECT ) + tf->hob_nsect =cris_ide_inb (io_ports->nsect_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAL ) + tf->hob_lbal =cris_ide_inb (io_ports->lbal_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAM ) + tf->hob_lbam =cris_ide_inb (io_ports->lbam_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAH ) + tf->hob_lbah =cris_ide_inb (io_ports->lbah_addr); + } +} +static const struct ide_port_ops cris_port_ops = { .set_pio_mode = cris_set_pio_mode, .set_dma_mode = cris_set_dma_mode,
@@ -812,6 +896,9 @@ static int __init init_e100_ide(void)ide_init_port_hw (hwif, &hw); + hwif->tf_load = cris_tf_load; + hwif->tf_read = cris_tf_read; + hwif->input_data = cris_input_data; hwif->output_data = cris_output_data;
PATCH 5/9 ide-h8300: add ->tf_{load,read} methods
In reply to Bartlomiej ZolnierkiewiczAdd ->tf_{load,read} methods so outb()/inb() and mm_outw()/mm_inw() can be used directly.
There should be no functional changes caused by this patch.
--- drivers/ide/h8300/ide-h8300.c | 88 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+)
drivers/ide/h8300/ide-h8300.c +88 -0
@@ -42,6 +42,91 @@ static u16 mm_inw(unsigned long a)return r; } +static void h8300_tf_load (ide_drive_t *drive,ide_task_t *task) +{ +ide_hwif_t *hwif = drive->hwif; +struct ide_io_ports *io_ports = &hwif->io_ports; +struct ide_taskfile *tf = &task->tf; +u8 HIHI = (task->tf_flags &IDE_TFLAG_LBA48 ) ?0xE0 :0xEF ; + +if (task->tf_flags &IDE_TFLAG_FLAGGED ) +HIHI =0xFF ; + +ide_set_irq (drive,1 ); + +if (task->tf_flags &IDE_TFLAG_OUT_DATA ) +mm_outw ((tf->hob_data <<8 ) | tf->data, io_ports->data_addr); + +if (task->tf_flags &IDE_TFLAG_OUT_HOB_FEATURE ) +outb (tf->hob_feature, io_ports->feature_addr); +if (task->tf_flags &IDE_TFLAG_OUT_HOB_NSECT ) +outb (tf->hob_nsect, io_ports->nsect_addr); +if (task->tf_flags &IDE_TFLAG_OUT_HOB_LBAL ) +outb (tf->hob_lbal, io_ports->lbal_addr); +if (task->tf_flags &IDE_TFLAG_OUT_HOB_LBAM ) +outb (tf->hob_lbam, io_ports->lbam_addr); +if (task->tf_flags &IDE_TFLAG_OUT_HOB_LBAH ) +outb (tf->hob_lbah, io_ports->lbah_addr); + +if (task->tf_flags &IDE_TFLAG_OUT_FEATURE ) +outb (tf->feature, io_ports->feature_addr); +if (task->tf_flags &IDE_TFLAG_OUT_NSECT ) +outb (tf->nsect, io_ports->nsect_addr); +if (task->tf_flags &IDE_TFLAG_OUT_LBAL ) +outb (tf->lbal, io_ports->lbal_addr); +if (task->tf_flags &IDE_TFLAG_OUT_LBAM ) +outb (tf->lbam, io_ports->lbam_addr); +if (task->tf_flags &IDE_TFLAG_OUT_LBAH ) +outb (tf->lbah, io_ports->lbah_addr); + +if (task->tf_flags &IDE_TFLAG_OUT_DEVICE ) +outb ((tf->device &HIHI ) | drive->select.all, + io_ports->device_addr); +} + +static void h8300_tf_read (ide_drive_t *drive,ide_task_t *task) +{ +ide_hwif_t *hwif = drive->hwif; +struct ide_io_ports *io_ports = &hwif->io_ports; +struct ide_taskfile *tf = &task->tf; + +if (task->tf_flags &IDE_TFLAG_IN_DATA ) { +u16 data =mm_inw (io_ports->data_addr); + + tf->data = data &0xff ; + tf->hob_data = (data >>8 ) &0xff ; + } + +/* be sure we're looking at the low order bits */ +outb (drive->ctl & ~0x80 , io_ports->ctl_addr); + +if (task->tf_flags &IDE_TFLAG_IN_NSECT ) + tf->nsect =inb (io_ports->nsect_addr); +if (task->tf_flags &IDE_TFLAG_IN_LBAL ) + tf->lbal =inb (io_ports->lbal_addr); +if (task->tf_flags &IDE_TFLAG_IN_LBAM ) + tf->lbam =inb (io_ports->lbam_addr); +if (task->tf_flags &IDE_TFLAG_IN_LBAH ) + tf->lbah =inb (io_ports->lbah_addr); +if (task->tf_flags &IDE_TFLAG_IN_DEVICE ) + tf->device =inb (io_ports->device_addr); + +if (task->tf_flags &IDE_TFLAG_LBA48 ) { +outb (drive->ctl |0x80 , io_ports->ctl_addr); + +if (task->tf_flags &IDE_TFLAG_IN_HOB_FEATURE ) + tf->hob_feature =inb (io_ports->feature_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_NSECT ) + tf->hob_nsect =inb (io_ports->nsect_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAL ) + tf->hob_lbal =inb (io_ports->lbal_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAM ) + tf->hob_lbam =inb (io_ports->lbam_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAH ) + tf->hob_lbah =inb (io_ports->lbah_addr); + } +} +static void mm_outsw (unsigned long addr,void *buf,u32 len) {unsigned short *bp = (unsigned short *)buf;
@@ -84,6 +169,9 @@ static inline void hwif_setup(ide_hwif_t {default_hwif_iops (hwif); + hwif->tf_load = h8300_tf_load; + hwif->tf_read = h8300_tf_read; + hwif->input_data = h8300_input_data; hwif->output_data = h8300_output_data;
PATCH 6/9 scc_pata: add ->tf_{load,read} methods
In reply to Bartlomiej ZolnierkiewiczAdd ->tf_{load,read} methods so scc_ide_{outb,outw,inb,inw}() can be used directly.
There should be no functional changes caused by this patch.
--- drivers/ide/pci/scc_pata.c | 87 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+)
drivers/ide/pci/scc_pata.c +87 -0
@@ -574,6 +574,90 @@ static int __devinit init_setup_scc(strureturn ide_setup_pci_device (dev, d); } +static void scc_tf_load (ide_drive_t *drive,ide_task_t *task) +{ +struct ide_io_ports *io_ports = &drive->hwif->io_ports; +struct ide_taskfile *tf = &task->tf; +u8 HIHI = (task->tf_flags &IDE_TFLAG_LBA48 ) ?0xE0 :0xEF ; + +if (task->tf_flags &IDE_TFLAG_FLAGGED ) +HIHI =0xFF ; + +ide_set_irq (drive,1 ); + +if (task->tf_flags &IDE_TFLAG_OUT_DATA ) +scc_ide_outw ((tf->hob_data <<8 ) | tf->data, + io_ports->data_addr); + +if (task->tf_flags &IDE_TFLAG_OUT_HOB_FEATURE ) +scc_ide_outb (tf->hob_feature, io_ports->feature_addr); +if (task->tf_flags &IDE_TFLAG_OUT_HOB_NSECT ) +scc_ide_outb (tf->hob_nsect, io_ports->nsect_addr); +if (task->tf_flags &IDE_TFLAG_OUT_HOB_LBAL ) +scc_ide_outb (tf->hob_lbal, io_ports->lbal_addr); +if (task->tf_flags &IDE_TFLAG_OUT_HOB_LBAM ) +scc_ide_outb (tf->hob_lbam, io_ports->lbam_addr); +if (task->tf_flags &IDE_TFLAG_OUT_HOB_LBAH ) +scc_ide_outb (tf->hob_lbah, io_ports->lbah_addr); + +if (task->tf_flags &IDE_TFLAG_OUT_FEATURE ) +scc_ide_outb (tf->feature, io_ports->feature_addr); +if (task->tf_flags &IDE_TFLAG_OUT_NSECT ) +scc_ide_outb (tf->nsect, io_ports->nsect_addr); +if (task->tf_flags &IDE_TFLAG_OUT_LBAL ) +scc_ide_outb (tf->lbal, io_ports->lbal_addr); +if (task->tf_flags &IDE_TFLAG_OUT_LBAM ) +scc_ide_outb (tf->lbam, io_ports->lbam_addr); +if (task->tf_flags &IDE_TFLAG_OUT_LBAH ) +scc_ide_outb (tf->lbah, io_ports->lbah_addr); + +if (task->tf_flags &IDE_TFLAG_OUT_DEVICE ) +scc_ide_outb ((tf->device &HIHI ) | drive->select.all, + io_ports->device_addr); +} + +static void scc_tf_read (ide_drive_t *drive,ide_task_t *task) +{ +struct ide_io_ports *io_ports = &drive->hwif->io_ports; +struct ide_taskfile *tf = &task->tf; + +if (task->tf_flags &IDE_TFLAG_IN_DATA ) { +u16 data =scc_ide_inw (io_ports->data_addr); + + tf->data = data &0xff ; + tf->hob_data = (data >>8 ) &0xff ; + } + +/* be sure we're looking at the low order bits */ +scc_ide_outb (drive->ctl & ~0x80 , io_ports->ctl_addr); + +if (task->tf_flags &IDE_TFLAG_IN_NSECT ) + tf->nsect =scc_ide_inb (io_ports->nsect_addr); +if (task->tf_flags &IDE_TFLAG_IN_LBAL ) + tf->lbal =scc_ide_inb (io_ports->lbal_addr); +if (task->tf_flags &IDE_TFLAG_IN_LBAM ) + tf->lbam =scc_ide_inb (io_ports->lbam_addr); +if (task->tf_flags &IDE_TFLAG_IN_LBAH ) + tf->lbah =scc_ide_inb (io_ports->lbah_addr); +if (task->tf_flags &IDE_TFLAG_IN_DEVICE ) + tf->device =scc_ide_inb (io_ports->device_addr); + +if (task->tf_flags &IDE_TFLAG_LBA48 ) { +scc_ide_outb (drive->ctl |0x80 , io_ports->ctl_addr); + +if (task->tf_flags &IDE_TFLAG_IN_HOB_FEATURE ) + tf->hob_feature =scc_ide_inb (io_ports->feature_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_NSECT ) + tf->hob_nsect =scc_ide_inb (io_ports->nsect_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAL ) + tf->hob_lbal =scc_ide_inb (io_ports->lbal_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAM ) + tf->hob_lbam =scc_ide_inb (io_ports->lbam_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAH ) + tf->hob_lbah =scc_ide_inb (io_ports->lbah_addr); + } +} +static void scc_input_data (ide_drive_t *drive,void *buf,unsigned int len) {unsigned long data_addr = drive->hwif->io_ports.data_addr;
@@ -619,6 +703,9 @@ static void __devinit init_mmio_iops_sccide_set_hwifdata (hwif, ports); + hwif->tf_load = scc_tf_load; + hwif->tf_read = scc_tf_read; + hwif->input_data = scc_input_data; hwif->output_data = scc_output_data;
PATCH 7/9 ns87415: add ->tf_read method
In reply to Bartlomiej ZolnierkiewiczAdd ->tf_read method so out{b,w}(), in{b,w}() and superio_ide_inb() can be used directly.
There should be no functional changes caused by this patch.
--- drivers/ide/pci/ns87415.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
drivers/ide/pci/ns87415.c +44 -0
@@ -63,6 +63,48 @@ static u8 superio_ide_inb (unsigned longreturn inb (port); } +static void superio_tf_read (ide_drive_t *drive,ide_task_t *task) +{ +struct ide_io_ports *io_ports = &drive->hwif->io_ports; +struct ide_taskfile *tf = &task->tf; + +if (task->tf_flags &IDE_TFLAG_IN_DATA ) { +u16 data =inw (io_ports->data_addr); + + tf->data = data &0xff ; + tf->hob_data = (data >>8 ) &0xff ; + } + +/* be sure we're looking at the low order bits */ +outb (drive->ctl & ~0x80 , io_ports->ctl_addr); + +if (task->tf_flags &IDE_TFLAG_IN_NSECT ) + tf->nsect =inb (io_ports->nsect_addr); +if (task->tf_flags &IDE_TFLAG_IN_LBAL ) + tf->lbal =inb (io_ports->lbal_addr); +if (task->tf_flags &IDE_TFLAG_IN_LBAM ) + tf->lbam =inb (io_ports->lbam_addr); +if (task->tf_flags &IDE_TFLAG_IN_LBAH ) + tf->lbah =inb (io_ports->lbah_addr); +if (task->tf_flags &IDE_TFLAG_IN_DEVICE ) + tf->device =superio_ide_inb (io_ports->device_addr); + +if (task->tf_flags &IDE_TFLAG_LBA48 ) { +outb (drive->ctl |0x80 , io_ports->ctl_addr); + +if (task->tf_flags &IDE_TFLAG_IN_HOB_FEATURE ) + tf->hob_feature =inb (io_ports->feature_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_NSECT ) + tf->hob_nsect =inb (io_ports->nsect_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAL ) + tf->hob_lbal =inb (io_ports->lbal_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAM ) + tf->hob_lbam =inb (io_ports->lbam_addr); +if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAH ) + tf->hob_lbah =inb (io_ports->lbah_addr); + } +} +static void __devinit superio_ide_init_iops (struct hwif_s *hwif) {struct pci_dev *pdev =to_pci_dev (hwif->dev);
@@ -80,6 +122,8 @@ static void __devinit superio_ide_init_i tmp =superio_ide_inb (superio_ide_dma_status[port]);outb (tmp |0x66 , superio_ide_dma_status[port]); + hwif->tf_read = superio_tf_read; +/* We need to override inb to workaround a SuperIO errata */ hwif->INB = superio_ide_inb; }
PATCH 8/9 ide: use IDE I/O helpers directly in ide_tf_{load,read}()
In reply to Bartlomiej ZolnierkiewiczThere should be no functional changes caused by this patch.
--- drivers/ide/ide-iops.c | 83 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 27 deletions(-)
drivers/ide/ide-iops.c +56 -27
@@ -132,8 +132,15 @@ static void ide_tf_load(ide_drive_t *driide_hwif_t *hwif = drive->hwif;struct ide_io_ports *io_ports = &hwif->io_ports;struct ide_taskfile *tf = &task->tf; +void (*tf_outb)(u8 addr,unsigned long port); +u8 mmio = (hwif->host_flags &IDE_HFLAG_MMIO ) ?1 :0 ;u8 HIHI = (task->tf_flags &IDE_TFLAG_LBA48 ) ?0xE0 :0xEF ; +if (mmio) + tf_outb = ide_mm_outb; +else + tf_outb = ide_outb; +if (task->tf_flags &IDE_TFLAG_FLAGGED )HIHI =0xFF ;
@@ -142,34 +149,40 @@ static void ide_tf_load(ide_drive_t *driif ((task->tf_flags &IDE_TFLAG_NO_SELECT_MASK ) ==0 )SELECT_MASK (drive,0 ); -if (task->tf_flags &IDE_TFLAG_OUT_DATA ) - hwif->OUTW ((tf->hob_data <<8 ) | tf->data, io_ports->data_addr); +if (task->tf_flags &IDE_TFLAG_OUT_DATA ) { +u16 data = (tf->hob_data <<8 ) | tf->data; + +if (mmio) +writew (data, (void __iomem *)io_ports->data_addr); +else +outw (data, io_ports->data_addr); + }if (task->tf_flags &IDE_TFLAG_OUT_HOB_FEATURE ) - hwif->OUTB (tf->hob_feature, io_ports->feature_addr); +tf_outb (tf->hob_feature, io_ports->feature_addr);if (task->tf_flags &IDE_TFLAG_OUT_HOB_NSECT ) - hwif->OUTB (tf->hob_nsect, io_ports->nsect_addr); +tf_outb (tf->hob_nsect, io_ports->nsect_addr);if (task->tf_flags &IDE_TFLAG_OUT_HOB_LBAL ) - hwif->OUTB (tf->hob_lbal, io_ports->lbal_addr); +tf_outb (tf->hob_lbal, io_ports->lbal_addr);if (task->tf_flags &IDE_TFLAG_OUT_HOB_LBAM ) - hwif->OUTB (tf->hob_lbam, io_ports->lbam_addr); +tf_outb (tf->hob_lbam, io_ports->lbam_addr);if (task->tf_flags &IDE_TFLAG_OUT_HOB_LBAH ) - hwif->OUTB (tf->hob_lbah, io_ports->lbah_addr); +tf_outb (tf->hob_lbah, io_ports->lbah_addr);if (task->tf_flags &IDE_TFLAG_OUT_FEATURE ) - hwif->OUTB (tf->feature, io_ports->feature_addr); +tf_outb (tf->feature, io_ports->feature_addr);if (task->tf_flags &IDE_TFLAG_OUT_NSECT ) - hwif->OUTB (tf->nsect, io_ports->nsect_addr); +tf_outb (tf->nsect, io_ports->nsect_addr);if (task->tf_flags &IDE_TFLAG_OUT_LBAL ) - hwif->OUTB (tf->lbal, io_ports->lbal_addr); +tf_outb (tf->lbal, io_ports->lbal_addr);if (task->tf_flags &IDE_TFLAG_OUT_LBAM ) - hwif->OUTB (tf->lbam, io_ports->lbam_addr); +tf_outb (tf->lbam, io_ports->lbam_addr);if (task->tf_flags &IDE_TFLAG_OUT_LBAH ) - hwif->OUTB (tf->lbah, io_ports->lbah_addr); +tf_outb (tf->lbah, io_ports->lbah_addr);if (task->tf_flags &IDE_TFLAG_OUT_DEVICE ) - hwif->OUTB ((tf->device &HIHI ) | drive->select.all, - io_ports->device_addr); +tf_outb ((tf->device &HIHI ) | drive->select.all, + io_ports->device_addr); }static void ide_tf_read (ide_drive_t *drive,ide_task_t *task)
@@ -177,41 +190,57 @@ static void ide_tf_read(ide_drive_t *driide_hwif_t *hwif = drive->hwif;struct ide_io_ports *io_ports = &hwif->io_ports;struct ide_taskfile *tf = &task->tf; +void (*tf_outb)(u8 addr,unsigned long port); +u8 (*tf_inb)(unsigned long port); +u8 mmio = (hwif->host_flags &IDE_HFLAG_MMIO ) ?1 :0 ; + +if (mmio) { + tf_outb = ide_mm_outb; + tf_inb = ide_mm_inb; + }else { + tf_outb = ide_outb; + tf_inb = ide_inb; + }if (task->tf_flags &IDE_TFLAG_IN_DATA ) { -u16 data = hwif->INW (io_ports->data_addr); +u16 data; + +if (mmio) + data =readw ((void __iomem *)io_ports->data_addr); +else + data =inw (io_ports->data_addr); tf->data = data &0xff ; tf->hob_data = (data >>8 ) &0xff ; }/* be sure we're looking at the low order bits */ - hwif->OUTB (drive->ctl & ~0x80 , io_ports->ctl_addr); +tf_outb (drive->ctl & ~0x80 , io_ports->ctl_addr);if (task->tf_flags &IDE_TFLAG_IN_NSECT ) - tf->nsect = hwif->INB (io_ports->nsect_addr); + tf->nsect =tf_inb (io_ports->nsect_addr);if (task->tf_flags &IDE_TFLAG_IN_LBAL ) - tf->lbal = hwif->INB (io_ports->lbal_addr); + tf->lbal =tf_inb (io_ports->lbal_addr);if (task->tf_flags &IDE_TFLAG_IN_LBAM ) - tf->lbam = hwif->INB (io_ports->lbam_addr); + tf->lbam =tf_inb (io_ports->lbam_addr);if (task->tf_flags &IDE_TFLAG_IN_LBAH ) - tf->lbah = hwif->INB (io_ports->lbah_addr); + tf->lbah =tf_inb (io_ports->lbah_addr);if (task->tf_flags &IDE_TFLAG_IN_DEVICE ) - tf->device = hwif->INB (io_ports->device_addr); + tf->device =tf_inb (io_ports->device_addr);if (task->tf_flags &IDE_TFLAG_LBA48 ) { - hwif->OUTB (drive->ctl |0x80 , io_ports->ctl_addr); +tf_outb (drive->ctl |0x80 , io_ports->ctl_addr);if (task->tf_flags &IDE_TFLAG_IN_HOB_FEATURE ) - tf->hob_feature = hwif->INB (io_ports->feature_addr); + tf->hob_feature =tf_inb (io_ports->feature_addr);if (task->tf_flags &IDE_TFLAG_IN_HOB_NSECT ) - tf->hob_nsect = hwif->INB (io_ports->nsect_addr); + tf->hob_nsect =tf_inb (io_ports->nsect_addr);if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAL ) - tf->hob_lbal = hwif->INB (io_ports->lbal_addr); + tf->hob_lbal =tf_inb (io_ports->lbal_addr);if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAM ) - tf->hob_lbam = hwif->INB (io_ports->lbam_addr); + tf->hob_lbam =tf_inb (io_ports->lbam_addr);if (task->tf_flags &IDE_TFLAG_IN_HOB_LBAH ) - tf->hob_lbah = hwif->INB (io_ports->lbah_addr); + tf->hob_lbah =tf_inb (io_ports->lbah_addr); } }
PATCH 9/9 ide: remove ->INW and ->OUTW methods
In reply to Bartlomiej Zolnierkiewicz* Remove no longer used ->INW and ->OUTW methods.
While at it:
* scc_pata.c: scc_ide_{out,in}w() is called only in scc_tf_{load,read}() so inline it there.
--- drivers/ide/cris/ide-cris.c | 2 -- drivers/ide/h8300/ide-h8300.c | 3 --- drivers/ide/ide-iops.c | 24 ------------------------ drivers/ide/pci/scc_pata.c | 19 +++---------------- include/linux/ide.h | 2 -- 5 files changed, 3 insertions(+), 47 deletions(-)
drivers/ide/cris/ide-cris.c +0 -2
@@ -903,10 +903,8 @@ static int __init init_e100_ide(void) hwif->output_data = cris_output_data; hwif->OUTB = &cris_ide_outb; - hwif->OUTW = &cris_ide_outw; hwif->OUTBSYNC = &cris_ide_outbsync; hwif->INB = &cris_ide_inb; - hwif->INW = &cris_ide_inw; hwif->cbl =ATA_CBL_PATA40 ; idx[h] = hwif->index;
drivers/ide/h8300/ide-h8300.c +0 -3
@@ -174,9 +174,6 @@ static inline void hwif_setup(ide_hwif_t hwif->input_data = h8300_input_data; hwif->output_data = h8300_output_data; - - hwif->OUTW = mm_outw; - hwif->INW = mm_inw; }static int __init h8300_ide_init (void )
drivers/ide/ide-iops.c +0 -24
@@ -37,11 +37,6 @@ static u8 ide_inb (unsigned long port)return (u8 )inb (port); } -static u16 ide_inw (unsigned long port) -{ -return (u16 )inw (port); -} -static void ide_outb (u8 val,unsigned long port) {outb (val, port);
@@ -52,18 +47,11 @@ static void ide_outbsync (ide_drive_t *doutb (addr, port); } -static void ide_outw (u16 val,unsigned long port) -{ -outw (val, port); -} -void default_hwif_iops (ide_hwif_t *hwif) { hwif->OUTB = ide_outb; hwif->OUTBSYNC = ide_outbsync; - hwif->OUTW = ide_outw; hwif->INB = ide_inb; - hwif->INW = ide_inw; }/*
@@ -75,11 +63,6 @@ static u8 ide_mm_inb (unsigned long portreturn (u8 )readb ((void __iomem *) port); } -static u16 ide_mm_inw (unsigned long port) -{ -return (u16 )readw ((void __iomem *) port); -} -static void ide_mm_outb (u8 value,unsigned long port) {writeb (value, (void __iomem *) port);
@@ -90,20 +73,13 @@ static void ide_mm_outbsync (ide_drive_twriteb (value, (void __iomem *) port); } -static void ide_mm_outw (u16 value,unsigned long port) -{ -writew (value, (void __iomem *) port); -} -void default_hwif_mmiops (ide_hwif_t *hwif) { hwif->OUTB = ide_mm_outb;/* Most systems will need to override OUTBSYNC, alas however this one is controller specific! */ hwif->OUTBSYNC = ide_mm_outbsync; - hwif->OUTW = ide_mm_outw; hwif->INB = ide_mm_inb; - hwif->INW = ide_mm_inw; }EXPORT_SYMBOL (default_hwif_mmiops);
drivers/ide/pci/scc_pata.c +3 -16
@@ -126,12 +126,6 @@ static u8 scc_ide_inb(unsigned long portreturn (u8 )data; } -static u16 scc_ide_inw (unsigned long port) -{ -u32 data =in_be32 ((void *)port); -return (u16 )data; -} -static void scc_ide_insw (unsigned long port,void *addr,u32 count) {u16 *ptr = (u16 *)addr;
@@ -154,11 +148,6 @@ static void scc_ide_outb(u8 addr, unsignout_be32 ((void *)port, addr); } -static void scc_ide_outw (u16 addr,unsigned long port) -{ -out_be32 ((void *)port, addr); -} -static void scc_ide_outbsync (ide_drive_t * drive,u8 addr,unsigned long port) {
@@ -586,8 +575,8 @@ static void scc_tf_load(ide_drive_t *driide_set_irq (drive,1 );if (task->tf_flags &IDE_TFLAG_OUT_DATA ) -scc_ide_outw ((tf->hob_data <<8 ) | tf->data, - io_ports->data_addr); +out_be32 ((void *)io_ports->data_addr, + (tf->hob_data <<8 ) | tf->data);if (task->tf_flags &IDE_TFLAG_OUT_HOB_FEATURE )scc_ide_outb (tf->hob_feature, io_ports->feature_addr);
@@ -622,7 +611,7 @@ static void scc_tf_read(ide_drive_t *dristruct ide_taskfile *tf = &task->tf;if (task->tf_flags &IDE_TFLAG_IN_DATA ) { -u16 data =scc_ide_inw (io_ports->data_addr); +u16 data = (u16 )in_be32 ((void *)io_ports->data_addr); tf->data = data &0xff ; tf->hob_data = (data >>8 ) &0xff ;
@@ -710,10 +699,8 @@ static void __devinit init_mmio_iops_scc hwif->output_data = scc_output_data; hwif->INB = scc_ide_inb; - hwif->INW = scc_ide_inw; hwif->OUTB = scc_ide_outb; hwif->OUTBSYNC = scc_ide_outbsync; - hwif->OUTW = scc_ide_outw; io_ports->data_addr = dma_base +0x20 ; io_ports->error_addr = dma_base +0x24 ;
include/linux/ide.h +0 -2
@@ -484,10 +484,8 @@ typedef struct hwif_s {void (*OUTB )(u8 addr,unsigned long port);void (*OUTBSYNC )(ide_drive_t *drive,u8 addr,unsigned long port); -void (*OUTW )(u16 addr,unsigned long port);u8 (*INB )(unsigned long port); -u16 (*INW )(unsigned long port);/* dma physical region descriptor table (cpu view) */ unsigned int *dmatable_cpu;