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

[PATCH] 2.5.16 IDE 68

 - Make the different ATAPI device type drivers use a unified packet command
   structure. We have to start to push them together.

This patch is rather trivial in itself, but the plentora of code duplication it
is trying to fight against is making it unfortunately rather big...
parent 14cfb6a6
......@@ -130,6 +130,13 @@ if [ "$CONFIG_BLK_DEV_IDE" != "n" ]; then
"$CONFIG_BLK_DEV_IDEDMA_ICS" = "y" ]; then
bool ' IGNORE word93 Validation BITS' CONFIG_IDEDMA_IVB
fi
if [ "$CONFIG_BLK_DEV_IDECD" != "n" -o \
"$CONFIG_BLK_DEV_IDETAPE" != "n" -o \
"$CONFIG_BLK_DEV_IDEFLOPPY" != "n" -o \
"$CONFIG_BLK_DEV_IDESCSI" != "n" ]; then
define_bool CONFIG_ATAPI y
fi
else
bool 'Old hard disk (MFM/RLL/IDE) driver' CONFIG_BLK_DEV_HD_ONLY
define_bool CONFIG_BLK_DEV_HD $CONFIG_BLK_DEV_HD_ONLY
......
......@@ -10,7 +10,8 @@
O_TARGET := idedriver.o
export-objs := ide-taskfile.o ide.o ide-features.o ide-probe.o quirks.o pcidma.o tcq.o ataraid.o
export-objs := ide-taskfile.o ide.o ide-features.o ide-probe.o quirks.o pcidma.o tcq.o \
atapi.o ataraid.o
obj-y :=
obj-m :=
......@@ -20,6 +21,7 @@ obj-$(CONFIG_BLK_DEV_HD) += hd.o
obj-$(CONFIG_BLK_DEV_IDE) += ide-mod.o
obj-$(CONFIG_BLK_DEV_IDECS) += ide-cs.o
obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.o
obj-$(CONFIG_ATAPI) += atapi.o
obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd.o
obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o
obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o
......
/**** vi:set ts=8 sts=8 sw=8:************************************************
*
* Copyright (C) 2002 Marcin Dalecki <martin@dalecki.de>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*/
/*
* Code common among all the ATAPI device drivers.
*
* Ideally this should evolve in to a unified driver.
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/string.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/ioport.h>
#include <linux/blkdev.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/cdrom.h>
#include <linux/hdreg.h>
#include <linux/ide.h>
#include <linux/atapi.h>
#include <asm/byteorder.h>
#include <asm/io.h>
#include <asm/bitops.h>
#include <asm/uaccess.h>
/*
* Too bad. The drive wants to send us data which we are not ready to accept.
* Just throw it away.
*/
void atapi_discard_data(struct ata_device *drive, unsigned int bcount)
{
while (bcount--)
IN_BYTE(IDE_DATA_REG);
}
void atapi_write_zeros(struct ata_device *drive, unsigned int bcount)
{
while (bcount--)
OUT_BYTE(0, IDE_DATA_REG);
}
/*
* Initializes a packet command. Used by tape and floppy driver.
*/
void atapi_init_pc(struct atapi_packet_command *pc)
{
memset(pc->c, 0, 12);
pc->retries = 0;
pc->flags = 0;
pc->request_transfer = 0;
pc->buffer = pc->pc_buffer;
pc->buffer_size = IDEFLOPPY_PC_BUFFER_SIZE;
pc->b_data = NULL;
pc->bio = NULL;
}
EXPORT_SYMBOL(atapi_discard_data);
EXPORT_SYMBOL(atapi_write_zeros);
EXPORT_SYMBOL(atapi_init_pc);
MODULE_LICENSE("GPL");
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/**** vi:set ts=8 sts=8 sw=8:************************************************
*
* Copyright (C) 2002 Marcin Dalecki <martin@dalecki.de>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*/
/*
* With each packet command, we allocate a buffer.
* This is used for several packet
* commands (Not for READ/WRITE commands).
*/
#define IDEFLOPPY_PC_BUFFER_SIZE 256
#define IDETAPE_PC_BUFFER_SIZE 256
/* This struct get's shared between different drivers.
*/
struct atapi_packet_command {
u8 c[12]; /* Actual packet bytes */
char *buffer; /* Data buffer */
int buffer_size; /* Size of our data buffer */
char *current_position; /* Pointer into the above buffer */
int request_transfer; /* Bytes to transfer */
int actually_transferred; /* Bytes actually transferred */
unsigned long flags; /* Status/Action bit flags: long for set_bit */
/* FIXME: the following is ugly as hell, but the only way we can start
* actually to unify the code.
*/
/* driver specific data. */
/* floppy/tape */
int retries; /* On each retry, we increment retries */
int error; /* Error code */
char *b_data; /* Pointer which runs on the buffers */
unsigned int b_count; /* Missing/Available data on the current buffer */
u8 pc_buffer[IDEFLOPPY_PC_BUFFER_SIZE]; /* Temporary buffer */
/* Called when this packet command is completed */
void (*callback) (struct ata_device *, struct request *);
/* only tape */
struct bio *bio;
/* only scsi */
struct {
unsigned int b_count; /* Bytes transferred from current entry */
struct scatterlist *sg; /* Scatter gather table */
struct scsi_cmnd *scsi_cmd; /* SCSI command */
void (*done)(struct scsi_cmnd *); /* Scsi completion routine */
unsigned long timeout; /* Command timeout */
} s;
};
extern void atapi_discard_data(struct ata_device *drive, unsigned int bcount);
extern void atapi_write_zeros(struct ata_device *drive, unsigned int bcount);
extern void atapi_init_pc(struct atapi_packet_command *pc);
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