* 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <linux/sched.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/cdrom.h>
+
+#include <scsi/scsi.h>
+#include <scsi/scsi_cmnd.h>
+
#include "transport.h"
#include "protocol.h"
#include "usb.h"
#include "debug.h"
#include "shuttle_usbat.h"
-#include <linux/sched.h>
-#include <linux/errno.h>
-#include <linux/slab.h>
-
#define short_pack(LSB,MSB) ( ((u16)(LSB)) | ( ((u16)(MSB))<<8 ) )
#define LSB_of(s) ((s)&0xFF)
#define MSB_of(s) ((s)>>8)
int transferred = 0;
-int usbat_read(struct us_data *us,
- unsigned char access,
- unsigned char reg,
- unsigned char *content) {
-
+static int usbat_read(struct us_data *us,
+ unsigned char access,
+ unsigned char reg,
+ unsigned char *content)
+{
int result;
result = usb_stor_ctrl_transfer(us,
return result;
}
-int usbat_write(struct us_data *us,
- unsigned char access,
- unsigned char reg,
- unsigned char content) {
-
+static int usbat_write(struct us_data *us,
+ unsigned char access,
+ unsigned char reg,
+ unsigned char content)
+{
int result;
result = usb_stor_ctrl_transfer(us,
return result;
}
-int usbat_set_shuttle_features(struct us_data *us,
- unsigned char external_trigger,
- unsigned char epp_control,
- unsigned char mask_byte,
- unsigned char test_pattern,
- unsigned char subcountH,
- unsigned char subcountL) {
-
+static int usbat_set_shuttle_features(struct us_data *us,
+ unsigned char external_trigger,
+ unsigned char epp_control,
+ unsigned char mask_byte,
+ unsigned char test_pattern,
+ unsigned char subcountH,
+ unsigned char subcountL)
+{
int result;
unsigned char *command = us->iobuf;
return result;
}
-int usbat_read_block(struct us_data *us,
- unsigned char access,
- unsigned char reg,
- unsigned char *content,
- unsigned short len,
- int use_sg) {
-
+static int usbat_read_block(struct us_data *us,
+ unsigned char access,
+ unsigned char reg,
+ unsigned char *content,
+ unsigned short len,
+ int use_sg)
+{
int result;
unsigned char *command = us->iobuf;
* an error condition.
*/
-int usbat_wait_not_busy(struct us_data *us, int minutes) {
-
+static int usbat_wait_not_busy(struct us_data *us, int minutes)
+{
int i;
int result;
unsigned char *status = us->iobuf;
}
if (i<500)
- wait_ms(10); // 5 seconds
+ msleep(10); // 5 seconds
else if (i<700)
- wait_ms(50); // 10 seconds
+ msleep(50); // 10 seconds
else if (i<1200)
- wait_ms(100); // 50 seconds
+ msleep(100); // 50 seconds
else
- wait_ms(1000); // X minutes
+ msleep(1000); // X minutes
}
US_DEBUGP("Waited not busy for %d minutes, timing out.\n",
return USB_STOR_TRANSPORT_FAILED;
}
-int usbat_write_block(struct us_data *us,
- unsigned char access,
- unsigned char reg,
- unsigned char *content,
- unsigned short len,
- int use_sg,
- int minutes) {
-
+static int usbat_write_block(struct us_data *us,
+ unsigned char access,
+ unsigned char reg,
+ unsigned char *content,
+ unsigned short len,
+ int use_sg, int minutes)
+{
int result;
unsigned char *command = us->iobuf;
return usbat_wait_not_busy(us, minutes);
}
-int usbat_rw_block_test(struct us_data *us,
- unsigned char access,
- unsigned char *registers,
- unsigned char *data_out,
- unsigned short num_registers,
- unsigned char data_reg,
- unsigned char status_reg,
- unsigned char timeout,
- unsigned char qualifier,
- int direction,
- unsigned char *content,
- unsigned short len,
- int use_sg,
- int minutes) {
-
+static int usbat_rw_block_test(struct us_data *us,
+ unsigned char access,
+ unsigned char *registers,
+ unsigned char *data_out,
+ unsigned short num_registers,
+ unsigned char data_reg,
+ unsigned char status_reg,
+ unsigned char timeout,
+ unsigned char qualifier,
+ int direction,
+ unsigned char *content,
+ unsigned short len,
+ int use_sg,
+ int minutes)
+{
int result;
- unsigned int pipe = (direction == SCSI_DATA_READ) ?
+ unsigned int pipe = (direction == DMA_FROM_DEVICE) ?
us->recv_bulk_pipe : us->send_bulk_pipe;
// Not really sure the 0x07, 0x17, 0xfc, 0xe7 is necessary here,
} else
cmdlen = 8;
- command[cmdlen-8] = (direction==SCSI_DATA_WRITE ? 0x40 : 0xC0);
+ command[cmdlen-8] = (direction==DMA_TO_DEVICE ? 0x40 : 0xC0);
command[cmdlen-7] = access |
- (direction==SCSI_DATA_WRITE ? 0x05 : 0x04);
+ (direction==DMA_TO_DEVICE ? 0x05 : 0x04);
command[cmdlen-6] = data_reg;
command[cmdlen-5] = status_reg;
command[cmdlen-4] = timeout;
//US_DEBUGP("Transfer %s %d bytes, sg buffers %d\n",
- // direction == SCSI_DATA_WRITE ? "out" : "in",
+ // direction == DMA_TO_DEVICE ? "out" : "in",
// len, use_sg);
result = usb_stor_bulk_transfer_sg(us,
* the bulk output pipe only the first time.
*/
- if (direction==SCSI_DATA_READ && i==0) {
+ if (direction==DMA_FROM_DEVICE && i==0) {
if (usb_stor_clear_halt(us,
us->send_bulk_pipe) < 0)
return USB_STOR_TRANSPORT_ERROR;
*/
result = usbat_read(us, USBAT_ATA,
- direction==SCSI_DATA_WRITE ? 0x17 : 0x0E,
+ direction==DMA_TO_DEVICE ? 0x17 : 0x0E,
status);
if (result!=USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_FAILED;
US_DEBUGP("Redoing %s\n",
- direction==SCSI_DATA_WRITE ? "write" : "read");
+ direction==DMA_TO_DEVICE ? "write" : "read");
} else if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
}
US_DEBUGP("Bummer! %s bulk data 20 times failed.\n",
- direction==SCSI_DATA_WRITE ? "Writing" : "Reading");
+ direction==DMA_TO_DEVICE ? "Writing" : "Reading");
return USB_STOR_TRANSPORT_FAILED;
}
* transfers of data!
*/
-int usbat_multiple_write(struct us_data *us,
- unsigned char access,
- unsigned char *registers,
- unsigned char *data_out,
- unsigned short num_registers) {
-
+static int usbat_multiple_write(struct us_data *us,
+ unsigned char access,
+ unsigned char *registers,
+ unsigned char *data_out,
+ unsigned short num_registers)
+{
int result;
unsigned char *data = us->iobuf;
int i;
return usbat_wait_not_busy(us, 0);
}
-int usbat_read_user_io(struct us_data *us,
- unsigned char *data_flags) {
-
+static int usbat_read_user_io(struct us_data *us, unsigned char *data_flags)
+{
int result;
result = usb_stor_ctrl_transfer(us,
return result;
}
-int usbat_write_user_io(struct us_data *us,
- unsigned char enable_flags,
- unsigned char data_flags) {
-
+static int usbat_write_user_io(struct us_data *us,
+ unsigned char enable_flags,
+ unsigned char data_flags)
+{
int result;
result = usb_stor_ctrl_transfer(us,
* a little ( <= 65535 byte) ATAPI pipe
*/
-int usbat_handle_read10(struct us_data *us,
- unsigned char *registers,
- unsigned char *data,
- Scsi_Cmnd *srb) {
-
+static int usbat_handle_read10(struct us_data *us,
+ unsigned char *registers,
+ unsigned char *data,
+ struct scsi_cmnd *srb)
+{
int result = USB_STOR_TRANSPORT_GOOD;
unsigned char *buffer;
unsigned int len;
result = usbat_rw_block_test(us, USBAT_ATA,
registers, data, 19,
0x10, 0x17, 0xFD, 0x30,
- SCSI_DATA_READ,
+ DMA_FROM_DEVICE,
srb->request_buffer,
srb->request_bufflen, srb->use_sg, 1);
result = usbat_rw_block_test(us, USBAT_ATA,
registers, data, 19,
0x10, 0x17, 0xFD, 0x30,
- SCSI_DATA_READ,
+ DMA_FROM_DEVICE,
buffer,
len, 0, 1);
return result;
}
-static int hp_8200e_select_and_test_registers(struct us_data *us) {
-
+static int hp_8200e_select_and_test_registers(struct us_data *us)
+{
int selector;
unsigned char *status = us->iobuf;
return USB_STOR_TRANSPORT_GOOD;
}
-int init_8200e(struct us_data *us) {
-
+int init_8200e(struct us_data *us)
+{
int result;
unsigned char *status = us->iobuf;
US_DEBUGP("INIT 1\n");
- wait_ms(2000);
+ msleep(2000);
if (usbat_read_user_io(us, status) !=
USB_STOR_XFER_GOOD)
US_DEBUGP("INIT 5\n");
- wait_ms(250);
+ msleep(250);
// Write 0x80 to ISA port 0x3F
US_DEBUGP("INIT 12\n");
- wait_ms(1400);
+ msleep(1400);
if (usbat_read_user_io(us, status) !=
USB_STOR_XFER_GOOD)
/*
* Transport for the HP 8200e
*/
-int hp8200e_transport(Scsi_Cmnd *srb, struct us_data *us)
+int hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
{
int result;
unsigned char *status = us->iobuf;
if (srb->cmnd[0] == TEST_UNIT_READY)
transferred = 0;
- if (srb->sc_data_direction == SCSI_DATA_WRITE) {
+ if (srb->sc_data_direction == DMA_TO_DEVICE) {
result = usbat_rw_block_test(us, USBAT_ATA,
registers, data, 19,
0x10, 0x17, 0xFD, 0x30,
- SCSI_DATA_WRITE,
+ DMA_TO_DEVICE,
srb->request_buffer,
len, srb->use_sg, 10);
// If there is response data to be read in
// then do it here.
- if (len != 0 && (srb->sc_data_direction == SCSI_DATA_READ)) {
+ if (len != 0 && (srb->sc_data_direction == DMA_FROM_DEVICE)) {
// How many bytes to read in? Check cylL register