Signed-off-by: Alberto Ladron <alberto.ladron@xxxxxxxxx> --- drivers/usb/storage/shuttle_usbat.c | 83 ++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index 3b0294e..9eddc40 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c @@ -152,13 +152,13 @@ struct usbat_info { unsigned long sense_ascq; /* additional sense code qualifier */ }; -#define short_pack(LSB,MSB) ( ((u16)(LSB)) | ( ((u16)(MSB))<<8 ) ) +#define short_pack(LSB, MSB) (((u16)(LSB)) | (((u16)(MSB))<<8)) #define LSB_of(s) ((s)&0xFF) #define MSB_of(s) ((s)>>8) -static int transferred = 0; +static int transferred; -static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us); +static int usbat_flash_transport(struct scsi_cmnd *srb, struct us_data *us); static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us); static int init_usbat_cd(struct us_data *us); @@ -172,7 +172,7 @@ static int init_usbat_flash(struct us_data *us); vendorName, productName, useProtocol, useTransport, \ initFunction, flags) \ { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ - .driver_info = (flags) } +.driver_info = (flags) } static struct usb_device_id usbat_usb_ids[] = { # include "unusual_usbat.h" @@ -225,7 +225,7 @@ static void usbat_pack_ata_sector_cmd(unsigned char *buf, */ static int usbat_get_device_type(struct us_data *us) { - return ((struct usbat_info*)us->extra)->devicetype; + return ((struct usbat_info *)us->extra)->devicetype; } /* @@ -268,7 +268,7 @@ static int usbat_write(struct us_data *us, * Convenience function to perform a bulk read */ static int usbat_bulk_read(struct us_data *us, - void* buf, + void *buf, unsigned int len, int use_sg) { @@ -283,7 +283,7 @@ static int usbat_bulk_read(struct us_data *us, * Convenience function to perform a bulk write */ static int usbat_bulk_write(struct us_data *us, - void* buf, + void *buf, unsigned int len, int use_sg) { @@ -416,11 +416,11 @@ static int usbat_wait_not_busy(struct us_data *us, int minutes) * minutes! */ - for (i=0; i<1200+minutes*60; i++) { + for (i = 0; i < 1200+minutes*60; i++) { - result = usbat_get_status(us, status); + result = usbat_get_status(us, status); - if (result!=USB_STOR_XFER_GOOD) + if (result != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; if (*status & 0x01) { /* check condition */ result = usbat_read(us, USBAT_ATA, 0x10, status); @@ -429,16 +429,16 @@ static int usbat_wait_not_busy(struct us_data *us, int minutes) if (*status & 0x20) /* device fault */ return USB_STOR_TRANSPORT_FAILED; - if ((*status & 0x80)==0x00) { /* not busy */ + if ((*status & 0x80) == 0x00) { /* not busy */ usb_stor_dbg(us, "Waited not busy for %d steps\n", i); return USB_STOR_TRANSPORT_GOOD; } - if (i<500) + if (i < 500) msleep(10); /* 5 seconds */ - else if (i<700) + else if (i < 700) msleep(50); /* 10 seconds */ - else if (i<1200) + else if (i < 1200) msleep(100); /* 50 seconds */ else msleep(1000); /* X minutes */ @@ -453,7 +453,7 @@ static int usbat_wait_not_busy(struct us_data *us, int minutes) * Read block data from the data register */ static int usbat_read_block(struct us_data *us, - void* buf, + void *buf, unsigned short len, int use_sg) { @@ -486,7 +486,7 @@ static int usbat_read_block(struct us_data *us, */ static int usbat_write_block(struct us_data *us, unsigned char access, - void* buf, + void *buf, unsigned short len, int minutes, int use_sg) @@ -548,7 +548,7 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us, BUG_ON(num_registers > US_IOBUF_SIZE/2); - for (i=0; i<20; i++) { + for (i = 0; i < 20; i++) { /* * The first time we send the full command, which consists @@ -561,7 +561,7 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us, * that, we just return a failure. */ - if (i==0) { + if (i == 0) { cmdlen = 16; /* * Write to multiple registers @@ -581,9 +581,9 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us, cmdlen = 8; /* Conditionally read or write blocks */ - command[cmdlen-8] = (direction==DMA_TO_DEVICE ? 0x40 : 0xC0); + command[cmdlen-8] = (direction == DMA_TO_DEVICE ? 0x40 : 0xC0); command[cmdlen-7] = access | - (direction==DMA_TO_DEVICE ? + (direction == DMA_TO_DEVICE ? USBAT_CMD_COND_WRITE_BLOCK : USBAT_CMD_COND_READ_BLOCK); command[cmdlen-6] = data_reg; command[cmdlen-5] = status_reg; @@ -597,9 +597,9 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us, if (result != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; - if (i==0) { + if (i == 0) { - for (j=0; j<num_registers; j++) { + for (j = 0; j < num_registers; j++) { data[j<<1] = registers[j]; data[1+(j<<1)] = data_out[j]; } @@ -640,7 +640,7 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us, * the bulk output pipe only the first time. */ - if (direction==DMA_FROM_DEVICE && 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; @@ -650,12 +650,12 @@ static int usbat_hp8200e_rw_block_test(struct us_data *us, * Read status: is the device angry, or just busy? */ - result = usbat_read(us, USBAT_ATA, - direction==DMA_TO_DEVICE ? + result = usbat_read(us, USBAT_ATA, + direction == DMA_TO_DEVICE ? USBAT_ATA_STATUS : USBAT_ATA_ALTSTATUS, status); - if (result!=USB_STOR_XFER_GOOD) + if (result != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; if (*status & 0x01) /* check condition */ return USB_STOR_TRANSPORT_FAILED; @@ -717,7 +717,7 @@ static int usbat_multiple_write(struct us_data *us, return USB_STOR_TRANSPORT_ERROR; /* Create the reg/data, reg/data sequence */ - for (i=0; i<num_registers; i++) { + for (i = 0; i < num_registers; i++) { data[i<<1] = registers[i]; data[1+(i<<1)] = data_out[i]; } @@ -746,7 +746,7 @@ static int usbat_multiple_write(struct us_data *us, * other related details) are defined beforehand with _set_shuttle_features(). */ static int usbat_read_blocks(struct us_data *us, - void* buffer, + void *buffer, int len, int use_sg) { @@ -766,7 +766,7 @@ static int usbat_read_blocks(struct us_data *us, result = usbat_execute_command(us, command, 8); if (result != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_FAILED; - + /* Read the blocks we just asked for */ result = usbat_bulk_read(us, buffer, len, use_sg); if (result != USB_STOR_XFER_GOOD) @@ -788,7 +788,7 @@ static int usbat_read_blocks(struct us_data *us, * other related details) are defined beforehand with _set_shuttle_features(). */ static int usbat_write_blocks(struct us_data *us, - void* buffer, + void *buffer, int len, int use_sg) { @@ -1006,11 +1006,11 @@ static int usbat_identify_device(struct us_data *us, * CDROM drives), it should succeed. */ rc = usbat_write(us, USBAT_ATA, USBAT_ATA_CMD, 0xA1); - if (rc != USB_STOR_XFER_GOOD) - return USB_STOR_TRANSPORT_ERROR; + if (rc != USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; rc = usbat_get_status(us, &status); - if (rc != USB_STOR_XFER_GOOD) + if (rc != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; /* Check for error bit, or if the command 'fell through' */ @@ -1593,7 +1593,7 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us) data[5] = 0xB0; /* (device sel) = slave */ data[6] = 0xA0; /* (command) = ATA PACKET COMMAND */ - for (i=7; i<19; i++) { + for (i = 7; i < 19; i++) { registers[i] = 0x10; data[i] = (i-7 >= srb->cmd_len) ? 0 : srb->cmnd[i-7]; } @@ -1674,13 +1674,12 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us) return USB_STOR_TRANSPORT_ERROR; } len += ((unsigned int) *status)<<8; - } - else + } else len = *status; result = usbat_read_block(us, scsi_sglist(srb), len, - scsi_sg_count(srb)); + scsi_sg_count(srb)); } return result; @@ -1689,7 +1688,7 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us) /* * Transport for USBAT02-based CompactFlash and similar storage devices */ -static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us) +static int usbat_flash_transport(struct scsi_cmnd *srb, struct us_data *us) { int rc; struct usbat_info *info = (struct usbat_info *) (us->extra); @@ -1753,13 +1752,13 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us) * I don't think we'll ever see a READ_12 but support it anyway */ block = ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) | - ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); + ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) | - ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); + ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); usb_stor_dbg(us, "READ_12: read block 0x%04lx count %ld\n", - block, blocks); + block, blocks); return usbat_flash_read_data(us, info, block, blocks); } @@ -1782,7 +1781,7 @@ static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *us) ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); blocks = ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) | - ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); + ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); usb_stor_dbg(us, "WRITE_12: write block 0x%04lx count %ld\n", block, blocks); -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html