* Convenience function to perform a bulk read
*/
static int usbat_bulk_read(struct us_data *us,
- unsigned char *data,
- unsigned int len,
- int use_sg)
+ unsigned char *data,
+ unsigned int len)
{
if (len == 0)
return USB_STOR_XFER_GOOD;
US_DEBUGP("usbat_bulk_read: len = %d\n", len);
- return usb_stor_bulk_transfer_sg(us, us->recv_bulk_pipe, data, len, use_sg, NULL);
+ return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, data, len, NULL);
}
/*
* Convenience function to perform a bulk write
*/
static int usbat_bulk_write(struct us_data *us,
- unsigned char *data,
- unsigned int len,
- int use_sg)
+ unsigned char *data,
+ unsigned int len)
{
if (len == 0)
return USB_STOR_XFER_GOOD;
US_DEBUGP("usbat_bulk_write: len = %d\n", len);
- return usb_stor_bulk_transfer_sg(us, us->send_bulk_pipe, data, len, use_sg, NULL);
+ return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe, data, len, NULL);
}
/*
*/
static int usbat_read_block(struct us_data *us,
unsigned char *content,
- unsigned short len,
- int use_sg)
+ unsigned short len)
{
int result;
unsigned char *command = us->iobuf;
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
- result = usbat_bulk_read(us, content, len, use_sg);
+ result = usbat_bulk_read(us, content, len);
return (result == USB_STOR_XFER_GOOD ?
USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
}
unsigned char access,
unsigned char *content,
unsigned short len,
- int minutes,
- int use_sg)
+ int minutes)
{
int result;
unsigned char *command = us->iobuf;
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
- result = usbat_bulk_write(us, content, len, use_sg);
+ result = usbat_bulk_write(us, content, len);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
data[1+(j<<1)] = data_out[j];
}
- result = usbat_bulk_write(us, data, num_registers*2, 0);
+ result = usbat_bulk_write(us, data, num_registers*2);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
}
/* Send the data */
- result = usbat_bulk_write(us, data, num_registers*2, 0);
+ result = usbat_bulk_write(us, data, num_registers*2);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_ERROR;
* other related details) are defined beforehand with _set_shuttle_features().
*/
static int usbat_read_blocks(struct us_data *us,
- unsigned char *buffer,
- int len,
- int use_sg)
+ unsigned char *buffer,
+ int len)
{
int result;
unsigned char *command = us->iobuf;
return USB_STOR_TRANSPORT_FAILED;
/* Read the blocks we just asked for */
- result = usbat_bulk_read(us, buffer, len, use_sg);
+ result = usbat_bulk_read(us, buffer, len);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_FAILED;
*/
static int usbat_write_blocks(struct us_data *us,
unsigned char *buffer,
- int len,
- int use_sg)
+ int len)
{
int result;
unsigned char *command = us->iobuf;
return USB_STOR_TRANSPORT_FAILED;
/* Write the data */
- result = usbat_bulk_write(us, buffer, len, use_sg);
+ result = usbat_bulk_write(us, buffer, len);
if (result != USB_STOR_XFER_GOOD)
return USB_STOR_TRANSPORT_FAILED;
* Set the transport function based on the device type
*/
static int usbat_set_transport(struct us_data *us,
- struct usbat_info *info,
- int devicetype)
+ struct usbat_info *info)
{
+ int rc;
- if (!info->devicetype)
- info->devicetype = devicetype;
-
- if (!info->devicetype)
- usbat_identify_device(us, info);
-
- switch (info->devicetype) {
- default:
- return USB_STOR_TRANSPORT_ERROR;
+ if (!info->devicetype) {
+ rc = usbat_identify_device(us, info);
+ if (rc != USB_STOR_TRANSPORT_GOOD) {
+ US_DEBUGP("usbat_set_transport: Could not identify device\n");
+ return 1;
+ }
+ }
- case USBAT_DEV_HP8200:
+ if (usbat_get_device_type(us) == USBAT_DEV_HP8200)
us->transport = usbat_hp8200e_transport;
- break;
-
- case USBAT_DEV_FLASH:
+ else if (usbat_get_device_type(us) == USBAT_DEV_FLASH)
us->transport = usbat_flash_transport;
- break;
- }
return 0;
}
msleep(100);
/* Read the device identification data */
- rc = usbat_read_block(us, reply, 512, 0);
+ rc = usbat_read_block(us, reply, 512);
if (rc != USB_STOR_TRANSPORT_GOOD)
goto leave;
goto leave;
/* Read the data we just requested */
- result = usbat_read_blocks(us, buffer, len, 0);
+ result = usbat_read_blocks(us, buffer, len);
if (result != USB_STOR_TRANSPORT_GOOD)
goto leave;
goto leave;
/* Write the data */
- result = usbat_write_blocks(us, buffer, len, 0);
+ result = usbat_write_blocks(us, buffer, len);
if (result != USB_STOR_TRANSPORT_GOOD)
goto leave;
/*
* Initialize the USBAT processor and the storage device
*/
-static int init_usbat(struct us_data *us, int devicetype)
+int init_usbat(struct us_data *us)
{
int rc;
struct usbat_info *info;
US_DEBUGP("INIT 9\n");
/* At this point, we need to detect which device we are using */
- if (usbat_set_transport(us, info, devicetype))
+ if (usbat_set_transport(us, info))
return USB_STOR_TRANSPORT_ERROR;
US_DEBUGP("INIT 10\n");
* AT SPEED 4 IS UNRELIABLE!!!
*/
- if ((result = usbat_write_block(us,
+ if ( (result = usbat_write_block(us,
USBAT_ATA, srb->cmnd, 12,
- (srb->cmnd[0]==GPCMD_BLANK ? 75 : 10), 0) !=
- USB_STOR_TRANSPORT_GOOD)) {
+ srb->cmnd[0]==GPCMD_BLANK ? 75 : 10)) !=
+ USB_STOR_TRANSPORT_GOOD) {
return result;
}
len = *status;
- result = usbat_read_block(us, srb->request_buffer, len, srb->use_sg);
+ result = usbat_read_block(us, srb->request_buffer, len);
/* Debug-print the first 32 bytes of the transfer */
return USB_STOR_TRANSPORT_FAILED;
}
-int init_usbat_cd(struct us_data *us)
-{
- return init_usbat(us, USBAT_DEV_HP8200);
-}
-
-
-int init_usbat_flash(struct us_data *us)
-{
- return init_usbat(us, USBAT_DEV_FLASH);
-}
-
-int init_usbat_probe(struct us_data *us)
-{
- return init_usbat(us, 0);
-}
-
/*
* Default transport function. Attempts to detect which transport function
* should be called, makes it the new default, and calls it.
{
struct usbat_info *info = (struct usbat_info*) (us->extra);
- if (usbat_set_transport(us, info, 0))
+ if (usbat_set_transport(us, info))
return USB_STOR_TRANSPORT_ERROR;
return us->transport(srb, us);
}
+