Commit e07a6a66 authored by Martin Dalecki's avatar Martin Dalecki Committed by Linus Torvalds

[PATCH] 2.5.7 IDE 25

- Replace the task_io_reg_t with the simple u8. There is no need to obfuscate
   the code more then necessary.

- kill some unnecessary type definitions out from hdreg.h.

- Add proper attributes to register files in hdreg.h.

- Don't use raw arrays for tfRegister and hobRegister in ide_task_s.  Use out
   nice global structures describing the fields in them.  This allows to kill
   the following defines:

     IDE_DATA_OFFSET
     IDE_FEATURE_OFFSET
     IDE_NSECTOR_OFFSET
     IDE_SECTOR_OFFSET
     IDE_LCYL_OFFSET
     IDE_HCYL_OFFSET
     IDE_SELECT_OFFSET
     IDE_COMMAND_OFFSET

   and many many others.

- Please have a look at the following in pdc4030.c. It couldn't have worked!
   This has been fixed in one go with the above change:

   memcpy(args.hobRegister, NULL, sizeof(struct hd_drive_hob_hdr));

- Kill the redundant *_REG_HOB definitions. They don't help readability in any
   way.
parent 4772b236
This diff is collapsed.
......@@ -592,7 +592,7 @@ int ide_dmaproc (ide_dma_action_t func, ide_drive_t *drive)
if ((HWGROUP(drive)->rq->flags & REQ_DRIVE_TASKFILE) &&
(drive->addressing == 1)) {
ide_task_t *args = HWGROUP(drive)->rq->special;
OUT_BYTE(args->tfRegister[IDE_COMMAND_OFFSET], IDE_COMMAND_REG);
OUT_BYTE(args->taskfile.command, IDE_COMMAND_REG);
} else if (drive->addressing) {
OUT_BYTE(reading ? WIN_READDMA_EXT : WIN_WRITEDMA_EXT, IDE_COMMAND_REG);
} else {
......
......@@ -186,9 +186,9 @@ int ide_driveid_update (ide_drive_t *drive)
*/
int ide_ata66_check (ide_drive_t *drive, ide_task_t *args)
{
if ((args->tfRegister[IDE_COMMAND_OFFSET] == WIN_SETFEATURES) &&
(args->tfRegister[IDE_SECTOR_OFFSET] > XFER_UDMA_2) &&
(args->tfRegister[IDE_FEATURE_OFFSET] == SETFEATURES_XFER)) {
if ((args->taskfile.command == WIN_SETFEATURES) &&
(args->taskfile.sector_number > XFER_UDMA_2) &&
(args->taskfile.feature == SETFEATURES_XFER)) {
if (!HWIF(drive)->udma_four) {
printk("%s: Speed warnings UDMA 3/4/5 is not functional.\n", HWIF(drive)->name);
return 1;
......@@ -213,9 +213,9 @@ int ide_ata66_check (ide_drive_t *drive, ide_task_t *args)
*/
int set_transfer (ide_drive_t *drive, ide_task_t *args)
{
if ((args->tfRegister[IDE_COMMAND_OFFSET] == WIN_SETFEATURES) &&
(args->tfRegister[IDE_SECTOR_OFFSET] >= XFER_SW_DMA_0) &&
(args->tfRegister[IDE_FEATURE_OFFSET] == SETFEATURES_XFER) &&
if ((args->taskfile.command == WIN_SETFEATURES) &&
(args->taskfile.sector_number >= XFER_SW_DMA_0) &&
(args->taskfile.feature == SETFEATURES_XFER) &&
(drive->id->dma_ultra ||
drive->id->dma_mword ||
drive->id->dma_1word))
......
......@@ -7,6 +7,7 @@
*/
#include <linux/config.h>
#include <linux/types.h>
#include <linux/ide.h>
#include <linux/mc146818rtc.h>
#include <asm/io.h>
......
......@@ -534,8 +534,8 @@ static ide_startstop_t pre_task_out_intr (ide_drive_t *drive, struct request *rq
}
/* (ks/hs): Fixed Multi Write */
if ((args->tfRegister[IDE_COMMAND_OFFSET] != WIN_MULTWRITE) &&
(args->tfRegister[IDE_COMMAND_OFFSET] != WIN_MULTWRITE_EXT)) {
if ((args->taskfile.command != WIN_MULTWRITE) &&
(args->taskfile.command != WIN_MULTWRITE_EXT)) {
unsigned long flags;
char *buf = ide_map_rq(rq, &flags);
/* For Write_sectors we need to stuff the first sector */
......@@ -741,12 +741,12 @@ static ide_startstop_t task_mulin_intr(ide_drive_t *drive)
/* Called by ioctl to feature out type of command being called */
void ide_cmd_type_parser(ide_task_t *args)
{
struct hd_drive_task_hdr *taskfile = (struct hd_drive_task_hdr *) args->tfRegister;
struct hd_drive_task_hdr *taskfile = &args->taskfile;
args->prehandler = NULL;
args->handler = NULL;
switch(args->tfRegister[IDE_COMMAND_OFFSET]) {
switch(args->taskfile.command) {
case WIN_IDENTIFY:
case WIN_PIDENTIFY:
args->handler = task_in_intr;
......@@ -797,9 +797,11 @@ void ide_cmd_type_parser(ide_task_t *args)
case WIN_SMART:
if (taskfile->feature == SMART_WRITE_LOG_SECTOR)
args->prehandler = pre_task_out_intr;
args->tfRegister[IDE_LCYL_OFFSET] = SMART_LCYL_PASS;
args->tfRegister[IDE_HCYL_OFFSET] = SMART_HCYL_PASS;
switch(args->tfRegister[IDE_FEATURE_OFFSET]) {
args->taskfile.low_cylinder = SMART_LCYL_PASS;
args->taskfile.high_cylinder = SMART_HCYL_PASS;
switch(args->taskfile.feature) {
case SMART_READ_VALUES:
case SMART_READ_THRESHOLDS:
case SMART_READ_LOG_SECTOR:
......@@ -837,7 +839,7 @@ void ide_cmd_type_parser(ide_task_t *args)
#endif
case WIN_SETFEATURES:
args->handler = task_no_data_intr;
switch(args->tfRegister[IDE_FEATURE_OFFSET]) {
switch(args->taskfile.feature) {
case SETFEATURES_XFER:
args->command_type = IDE_DRIVE_TASK_SET_XFER;
return;
......@@ -944,27 +946,13 @@ static void init_taskfile_request(struct request *rq)
int ide_wait_taskfile(ide_drive_t *drive, struct hd_drive_task_hdr *taskfile, struct hd_drive_hob_hdr *hobfile, byte *buf)
{
struct request rq;
/* FIXME: This is on stack! */
ide_task_t args;
memset(&args, 0, sizeof(ide_task_t));
args.tfRegister[IDE_DATA_OFFSET] = taskfile->data;
args.tfRegister[IDE_FEATURE_OFFSET] = taskfile->feature;
args.tfRegister[IDE_NSECTOR_OFFSET] = taskfile->sector_count;
args.tfRegister[IDE_SECTOR_OFFSET] = taskfile->sector_number;
args.tfRegister[IDE_LCYL_OFFSET] = taskfile->low_cylinder;
args.tfRegister[IDE_HCYL_OFFSET] = taskfile->high_cylinder;
args.tfRegister[IDE_SELECT_OFFSET] = taskfile->device_head;
args.tfRegister[IDE_COMMAND_OFFSET] = taskfile->command;
args.hobRegister[IDE_DATA_OFFSET_HOB] = hobfile->data;
args.hobRegister[IDE_FEATURE_OFFSET_HOB] = hobfile->feature;
args.hobRegister[IDE_NSECTOR_OFFSET_HOB] = hobfile->sector_count;
args.hobRegister[IDE_SECTOR_OFFSET_HOB] = hobfile->sector_number;
args.hobRegister[IDE_LCYL_OFFSET_HOB] = hobfile->low_cylinder;
args.hobRegister[IDE_HCYL_OFFSET_HOB] = hobfile->high_cylinder;
args.hobRegister[IDE_SELECT_OFFSET_HOB] = hobfile->device_head;
args.hobRegister[IDE_CONTROL_OFFSET_HOB] = hobfile->control;
args.taskfile = *taskfile;
args.hobfile = *hobfile;
init_taskfile_request(&rq);
......@@ -986,7 +974,9 @@ int ide_raw_taskfile(ide_drive_t *drive, ide_task_t *args, byte *buf)
rq.buffer = buf;
if (args->command_type != IDE_DRIVE_TASK_NO_DATA)
rq.current_nr_sectors = rq.nr_sectors = (args->hobRegister[IDE_NSECTOR_OFFSET_HOB] << 8) | args->tfRegister[IDE_NSECTOR_OFFSET];
rq.current_nr_sectors = rq.nr_sectors
= (args->hobfile.sector_count << 8)
| args->taskfile.sector_count;
rq.special = args;
......@@ -1032,13 +1022,13 @@ int ide_cmd_ioctl(ide_drive_t *drive, struct inode *inode, struct file *file, un
if (copy_from_user(args, (void *)arg, 4))
return -EFAULT;
tfargs.tfRegister[IDE_FEATURE_OFFSET] = args[2];
tfargs.tfRegister[IDE_NSECTOR_OFFSET] = args[3];
tfargs.tfRegister[IDE_SECTOR_OFFSET] = args[1];
tfargs.tfRegister[IDE_LCYL_OFFSET] = 0x00;
tfargs.tfRegister[IDE_HCYL_OFFSET] = 0x00;
tfargs.tfRegister[IDE_SELECT_OFFSET] = 0x00;
tfargs.tfRegister[IDE_COMMAND_OFFSET] = args[0];
tfargs.taskfile.feature = args[2];
tfargs.taskfile.sector_count = args[3];
tfargs.taskfile.sector_number = args[1];
tfargs.taskfile.low_cylinder = 0x00;
tfargs.taskfile.high_cylinder = 0x00;
tfargs.taskfile.device_head = 0x00;
tfargs.taskfile.command = args[0];
if (args[3]) {
argsize = 4 + (SECTOR_WORDS * 4 * args[3]);
......
......@@ -737,22 +737,25 @@ void ide_end_drive_cmd (ide_drive_t *drive, byte stat, byte err)
ide_task_t *args = (ide_task_t *) rq->special;
rq->errors = !OK_STAT(stat,READY_STAT,BAD_STAT);
if (args) {
args->tfRegister[IDE_ERROR_OFFSET] = err;
args->tfRegister[IDE_NSECTOR_OFFSET] = IN_BYTE(IDE_NSECTOR_REG);
args->tfRegister[IDE_SECTOR_OFFSET] = IN_BYTE(IDE_SECTOR_REG);
args->tfRegister[IDE_LCYL_OFFSET] = IN_BYTE(IDE_LCYL_REG);
args->tfRegister[IDE_HCYL_OFFSET] = IN_BYTE(IDE_HCYL_REG);
args->tfRegister[IDE_SELECT_OFFSET] = IN_BYTE(IDE_SELECT_REG);
args->tfRegister[IDE_STATUS_OFFSET] = stat;
args->taskfile.feature = err;
args->taskfile.sector_count = IN_BYTE(IDE_NSECTOR_REG);
args->taskfile.sector_number = IN_BYTE(IDE_SECTOR_REG);
args->taskfile.low_cylinder = IN_BYTE(IDE_LCYL_REG);
args->taskfile.high_cylinder = IN_BYTE(IDE_HCYL_REG);
args->taskfile.device_head = IN_BYTE(IDE_SELECT_REG);
args->taskfile.command = stat;
if ((drive->id->command_set_2 & 0x0400) &&
(drive->id->cfs_enable_2 & 0x0400) &&
(drive->addressing == 1)) {
OUT_BYTE(drive->ctl|0x80, IDE_CONTROL_REG_HOB);
args->hobRegister[IDE_FEATURE_OFFSET_HOB] = IN_BYTE(IDE_FEATURE_REG);
args->hobRegister[IDE_NSECTOR_OFFSET_HOB] = IN_BYTE(IDE_NSECTOR_REG);
args->hobRegister[IDE_SECTOR_OFFSET_HOB] = IN_BYTE(IDE_SECTOR_REG);
args->hobRegister[IDE_LCYL_OFFSET_HOB] = IN_BYTE(IDE_LCYL_REG);
args->hobRegister[IDE_HCYL_OFFSET_HOB] = IN_BYTE(IDE_HCYL_REG);
/* The following command goes to the hob file! */
OUT_BYTE(drive->ctl|0x80, IDE_CONTROL_REG);
args->hobfile.feature = IN_BYTE(IDE_FEATURE_REG);
args->hobfile.sector_count = IN_BYTE(IDE_NSECTOR_REG);
args->hobfile.sector_number = IN_BYTE(IDE_SECTOR_REG);
args->hobfile.low_cylinder = IN_BYTE(IDE_LCYL_REG);
args->hobfile.high_cylinder = IN_BYTE(IDE_HCYL_REG);
}
}
}
......@@ -1081,8 +1084,8 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
goto args_error;
ata_taskfile(drive,
(struct hd_drive_task_hdr *)&args->tfRegister,
(struct hd_drive_hob_hdr *)&args->hobRegister,
&args->taskfile,
&args->hobfile,
args->handler, NULL, NULL);
if (((args->command_type == IDE_DRIVE_TASK_RAW_WRITE) ||
......
......@@ -550,7 +550,7 @@ static ide_startstop_t promise_write (ide_drive_t *drive)
ide_startstop_t do_pdc4030_io (ide_drive_t *drive, ide_task_t *task)
{
struct request *rq = HWGROUP(drive)->rq;
task_struct_t *taskfile = (task_struct_t *) task->tfRegister;
struct hd_drive_task_hdr *taskfile = &task->taskfile;
unsigned long timeout;
byte stat;
......@@ -652,8 +652,9 @@ ide_startstop_t promise_rw_disk (ide_drive_t *drive, struct request *rq, unsigne
taskfile.device_head = ((block>>8)&0x0f)|drive->select.all;
taskfile.command = (rq_data_dir(rq)==READ)?PROMISE_READ:PROMISE_WRITE;
memcpy(args.tfRegister, &taskfile, sizeof(struct hd_drive_task_hdr));
memcpy(args.hobRegister, NULL, sizeof(struct hd_drive_hob_hdr));
args.taskfile = taskfile;
memset(&args.hobfile, 0, sizeof(struct hd_drive_hob_hdr));
ide_cmd_type_parser(&args);
/* We don't use the generic inerrupt handlers here? */
args.prehandler = NULL;
......
......@@ -54,16 +54,9 @@
* HDIO_DRIVE_CMD and HDIO_DRIVE_TASK
*/
#if 0
#include <asm/hdreg.h>
typedef ide_ioreg_t task_ioreg_t;
#else
typedef unsigned char task_ioreg_t;
#endif
#define HDIO_DRIVE_CMD_HDR_SIZE 4*sizeof(task_ioreg_t)
#define HDIO_DRIVE_TASK_HDR_SIZE 8*sizeof(task_ioreg_t)
#define HDIO_DRIVE_HOB_HDR_SIZE 8*sizeof(task_ioreg_t)
#define HDIO_DRIVE_CMD_HDR_SIZE (4 * sizeof(u8))
#define HDIO_DRIVE_TASK_HDR_SIZE (8 * sizeof(u8))
#define HDIO_DRIVE_HOB_HDR_SIZE (8 * sizeof(u8))
#define IDE_DRIVE_TASK_INVALID -1
#define IDE_DRIVE_TASK_NO_DATA 0
......@@ -74,57 +67,27 @@ typedef unsigned char task_ioreg_t;
#define IDE_DRIVE_TASK_OUT 3
#define IDE_DRIVE_TASK_RAW_WRITE 4
struct hd_drive_cmd_hdr {
task_ioreg_t command;
task_ioreg_t sector_number;
task_ioreg_t feature;
task_ioreg_t sector_count;
};
typedef struct hd_drive_task_hdr {
task_ioreg_t data;
task_ioreg_t feature;
task_ioreg_t sector_count;
task_ioreg_t sector_number;
task_ioreg_t low_cylinder;
task_ioreg_t high_cylinder;
task_ioreg_t device_head;
task_ioreg_t command;
} task_struct_t;
typedef struct hd_drive_hob_hdr {
task_ioreg_t data;
task_ioreg_t feature;
task_ioreg_t sector_count;
task_ioreg_t sector_number;
task_ioreg_t low_cylinder;
task_ioreg_t high_cylinder;
task_ioreg_t device_head;
task_ioreg_t control;
} hob_struct_t;
typedef union ide_reg_valid_s {
unsigned all : 16;
struct {
unsigned data : 1;
unsigned error_feature : 1;
unsigned sector : 1;
unsigned nsector : 1;
unsigned lcyl : 1;
unsigned hcyl : 1;
unsigned select : 1;
unsigned status_command : 1;
unsigned data_hob : 1;
unsigned error_feature_hob : 1;
unsigned sector_hob : 1;
unsigned nsector_hob : 1;
unsigned lcyl_hob : 1;
unsigned hcyl_hob : 1;
unsigned select_hob : 1;
unsigned control_hob : 1;
} b;
} ide_reg_valid_t;
struct hd_drive_task_hdr {
u8 data;
u8 feature;
u8 sector_count;
u8 sector_number;
u8 low_cylinder;
u8 high_cylinder;
u8 device_head;
u8 command;
} __attribute__((packed));
struct hd_drive_hob_hdr {
u8 data;
u8 feature;
u8 sector_count;
u8 sector_number;
u8 low_cylinder;
u8 high_cylinder;
u8 device_head;
u8 control;
} __attribute__((packed));
/*
* Define standard taskfile in/out register
......@@ -134,23 +97,6 @@ typedef union ide_reg_valid_s {
#define IDE_HOB_STD_OUT_FLAGS 0xC0
#define IDE_HOB_STD_IN_FLAGS 0xC0
typedef struct ide_task_request_s {
task_ioreg_t io_ports[8];
task_ioreg_t hob_ports[8];
ide_reg_valid_t out_flags;
ide_reg_valid_t in_flags;
int data_phase;
int req_cmd;
unsigned long out_size;
unsigned long in_size;
} ide_task_request_t;
typedef struct ide_ioctl_request_s {
ide_task_request_t *task_request;
unsigned char *out_buffer;
unsigned char *in_buffer;
} ide_ioctl_request_t;
#define TASKFILE_INVALID 0x7fff
#define TASKFILE_48 0x8000
......
......@@ -90,17 +90,6 @@ typedef unsigned char byte; /* used everywhere */
#define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET
#define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET
#define IDE_DATA_OFFSET_HOB (0)
#define IDE_ERROR_OFFSET_HOB (1)
#define IDE_NSECTOR_OFFSET_HOB (2)
#define IDE_SECTOR_OFFSET_HOB (3)
#define IDE_LCYL_OFFSET_HOB (4)
#define IDE_HCYL_OFFSET_HOB (5)
#define IDE_SELECT_OFFSET_HOB (6)
#define IDE_CONTROL_OFFSET_HOB (7)
#define IDE_FEATURE_OFFSET_HOB IDE_ERROR_OFFSET_HOB
#define IDE_DATA_REG (HWIF(drive)->io_ports[IDE_DATA_OFFSET])
#define IDE_ERROR_REG (HWIF(drive)->io_ports[IDE_ERROR_OFFSET])
#define IDE_NSECTOR_REG (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET])
......@@ -112,16 +101,6 @@ typedef unsigned char byte; /* used everywhere */
#define IDE_CONTROL_REG (HWIF(drive)->io_ports[IDE_CONTROL_OFFSET])
#define IDE_IRQ_REG (HWIF(drive)->io_ports[IDE_IRQ_OFFSET])
#define IDE_DATA_REG_HOB (HWIF(drive)->io_ports[IDE_DATA_OFFSET])
#define IDE_ERROR_REG_HOB (HWIF(drive)->io_ports[IDE_ERROR_OFFSET])
#define IDE_NSECTOR_REG_HOB (HWIF(drive)->io_ports[IDE_NSECTOR_OFFSET])
#define IDE_SECTOR_REG_HOB (HWIF(drive)->io_ports[IDE_SECTOR_OFFSET])
#define IDE_LCYL_REG_HOB (HWIF(drive)->io_ports[IDE_LCYL_OFFSET])
#define IDE_HCYL_REG_HOB (HWIF(drive)->io_ports[IDE_HCYL_OFFSET])
#define IDE_SELECT_REG_HOB (HWIF(drive)->io_ports[IDE_SELECT_OFFSET])
#define IDE_STATUS_REG_HOB (HWIF(drive)->io_ports[IDE_STATUS_OFFSET])
#define IDE_CONTROL_REG_HOB (HWIF(drive)->io_ports[IDE_CONTROL_OFFSET])
#define IDE_FEATURE_REG IDE_ERROR_REG
#define IDE_COMMAND_REG IDE_STATUS_REG
#define IDE_ALTSTATUS_REG IDE_CONTROL_REG
......@@ -785,8 +764,8 @@ extern int ide_do_drive_cmd(ide_drive_t *drive, struct request *rq, ide_action_t
void ide_end_drive_cmd (ide_drive_t *drive, byte stat, byte err);
typedef struct ide_task_s {
task_ioreg_t tfRegister[8];
task_ioreg_t hobRegister[8];
struct hd_drive_task_hdr taskfile;
struct hd_drive_hob_hdr hobfile;
int command_type;
ide_pre_handler_t *prehandler;
ide_handler_t *handler;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment