if (us->fflags & US_FL_CAPACITY_HEURISTICS)
sdev->guess_capacity = 1;
if (sdev->scsi_level > SCSI_2)
- sdev->sdev_target->scsi_level = sdev->scsi_level = SCSI_2;
+ sdev->sdev_target->scsi_level = sdev->scsi_level
+ = SCSI_2;
sdev->retry_hwerror = 1;
sdev->allow_restart = 1;
sdev->last_sector_bug = 1;
return -EINVAL;
}
-static DEVICE_ATTR(max_sectors, S_IRUGO | S_IWUSR, show_max_sectors, store_max_sectors);
-static struct device_attribute *sysfs_device_attr_list[] = {&dev_attr_max_sectors, NULL, };
+static DEVICE_ATTR(max_sectors, S_IRUGO | S_IWUSR, show_max_sectors,
+ store_max_sectors);
+static struct device_attribute *sysfs_device_attr_list[] =
+ {&dev_attr_max_sectors, NULL, };
/* this defines our host template, with which we'll allocate hosts */
/*
* usb_stor_access_xfer_buf()
*/
-unsigned int usb_stor_access_xfer_buf(struct us_data *us, unsigned char *buffer,
- unsigned int buflen, struct scsi_cmnd *srb, struct scatterlist **sgptr,
+unsigned int usb_stor_access_xfer_buf(struct us_data *us,
+ unsigned char *buffer, unsigned int buflen,
+ struct scsi_cmnd *srb, struct scatterlist **sgptr,
unsigned int *offset, enum xfer_buf_dir dir)
{
unsigned int cnt;
while (sglen > 0) {
unsigned int plen = min(sglen,
- (unsigned int)PAGE_SIZE - poff);
+ (unsigned int)PAGE_SIZE - poff);
unsigned char *ptr = kmap(page);
if (dir == TO_XFER_BUF)
err = ErrCode;
for (retry = 0; retry < 2; retry++) {
- if (Copy_D_BlockAll(us, (err == ERR_EccReadErr) ? REQ_FAIL : REQ_ERASE)) {
+ if (Copy_D_BlockAll(us,
+ (err == ERR_EccReadErr) ? REQ_FAIL : REQ_ERASE)) {
if (ErrCode == ERR_HwError)
return ERROR;
continue;
if (mode == REQ_FAIL)
SectCopyMode = REQ_FAIL;
- for (Media.Sector = 0; Media.Sector < Ssfdc.MaxSectors; Media.Sector++) {
+ for (Media.Sector = 0; Media.Sector < Ssfdc.MaxSectors;
+ Media.Sector++) {
if (Copy_D_PhyOneSect(us)) {
if (ErrCode == ERR_HwError)
return ERROR;
{
ReadBlock = Media.PhyBlock;
- for (WriteBlock = AssignStart[Media.Zone]; WriteBlock < Ssfdc.MaxBlocks; WriteBlock++) {
+ for (WriteBlock = AssignStart[Media.Zone];
+ WriteBlock < Ssfdc.MaxBlocks; WriteBlock++) {
if (!Chk_D_Bit(Assign[Media.Zone], WriteBlock)) {
Set_D_Bit(Assign[Media.Zone], WriteBlock);
AssignStart[Media.Zone] = WriteBlock + 1;
}
}
- for (WriteBlock = 0; WriteBlock < AssignStart[Media.Zone]; WriteBlock++) {
+ for (WriteBlock = 0;
+ WriteBlock < AssignStart[Media.Zone]; WriteBlock++) {
if (!Chk_D_Bit(Assign[Media.Zone], WriteBlock)) {
Set_D_Bit(Assign[Media.Zone], WriteBlock);
AssignStart[Media.Zone] = WriteBlock + 1;
for (retry = 0; retry < 2; retry++) {
if (retry != 0) {
Ssfdc_D_Reset(us);
- if (Ssfdc_D_ReadCisSect(us, WorkBuf, WorkRedund)) {
+ if (Ssfdc_D_ReadCisSect(us, WorkBuf,
+ WorkRedund)) {
ErrCode = ERR_HwError;
MediaChange = ERROR;
return ERROR;
Media.Zone = 0;
Media.Sector = 0;
- for (Media.PhyBlock = 0; Media.PhyBlock < (Ssfdc.MaxBlocks - Ssfdc.MaxLogBlocks - 1); Media.PhyBlock++) {
+ for (Media.PhyBlock = 0;
+ Media.PhyBlock < (Ssfdc.MaxBlocks - Ssfdc.MaxLogBlocks - 1);
+ Media.PhyBlock++) {
if (Ssfdc_D_ReadRedtData(us, Redundant)) {
Ssfdc_D_Reset(us);
return ERROR;
WORD phyblock, logblock;
if (Log2Phy[Media.Zone] == NULL) {
- Log2Phy[Media.Zone] = kmalloc(MAX_LOGBLOCK * sizeof(WORD), GFP_KERNEL);
+ Log2Phy[Media.Zone] = kmalloc(MAX_LOGBLOCK * sizeof(WORD),
+ GFP_KERNEL);
/* pr_info("ExAllocatePool Zone = %x, Addr = %x\n",
Media.Zone, Log2Phy[Media.Zone]); */
if (Log2Phy[Media.Zone] == NULL)
{
/* pr_info("Make_D_LogTable --- MediaZone = 0x%x\n",
Media.Zone); */
- for (Media.LogBlock = 0; Media.LogBlock < Ssfdc.MaxLogBlocks; Media.LogBlock++)
+ for (Media.LogBlock = 0; Media.LogBlock < Ssfdc.MaxLogBlocks;
+ Media.LogBlock++)
Log2Phy[Media.Zone][Media.LogBlock] = NO_ASSIGN;
- for (Media.PhyBlock = 0; Media.PhyBlock < (MAX_BLOCKNUM / 8); Media.PhyBlock++)
+ for (Media.PhyBlock = 0; Media.PhyBlock < (MAX_BLOCKNUM / 8);
+ Media.PhyBlock++)
Assign[Media.Zone][Media.PhyBlock] = 0x00;
- for (Media.PhyBlock = 0; Media.PhyBlock < Ssfdc.MaxBlocks; Media.PhyBlock++) {
- if ((!Media.Zone) && (Media.PhyBlock <= CisArea.PhyBlock)) {
+ for (Media.PhyBlock = 0; Media.PhyBlock < Ssfdc.MaxBlocks;
+ Media.PhyBlock++) {
+ if ((!Media.Zone) &&
+ (Media.PhyBlock <= CisArea.PhyBlock)) {
Set_D_Bit(Assign[Media.Zone], Media.PhyBlock);
continue;
}
continue;
if (Log2Phy[Media.Zone][Media.LogBlock] == NO_ASSIGN) {
- Log2Phy[Media.Zone][Media.LogBlock] = Media.PhyBlock;
+ Log2Phy[Media.Zone][Media.LogBlock] =
+ Media.PhyBlock;
continue;
}
if (!Load_D_LogBlockAddr(Redundant)) {
if (Media.LogBlock == logblock) {
- Media.PhyBlock = Log2Phy[Media.Zone][logblock];
+ Media.PhyBlock =
+ Log2Phy[Media.Zone][logblock];
- if (Ssfdc_D_ReadRedtData(us, Redundant)) {
+ if (Ssfdc_D_ReadRedtData(us,
+ Redundant)) {
Ssfdc_D_Reset(us);
return ERROR;
}
sect = Media.Sector;
Set_D_FailBlock(WorkRedund);
- for (Media.Sector = 0; Media.Sector < Ssfdc.MaxSectors; Media.Sector++) {
+ for (Media.Sector = 0; Media.Sector < Ssfdc.MaxSectors;
+ Media.Sector++) {
if (Ssfdc_D_WriteRedtData(us, WorkRedund)) {
Ssfdc_D_Reset(us);
Media.Sector = sect;
{
WORD addr1, addr2;
- addr1 = (WORD)*(redundant + REDT_ADDR1H)*0x0100 + (WORD)*(redundant + REDT_ADDR1L);
- addr2 = (WORD)*(redundant + REDT_ADDR2H)*0x0100 + (WORD)*(redundant + REDT_ADDR2L);
+ addr1 = (WORD)*(redundant + REDT_ADDR1H)*0x0100 +
+ (WORD)*(redundant + REDT_ADDR1L);
+ addr2 = (WORD)*(redundant + REDT_ADDR2H)*0x0100 +
+ (WORD)*(redundant + REDT_ADDR2L);
if (addr1 == addr2)
if ((addr1 & 0xF000) == 0x1000) {
if ((hweight16(addr) % 2))
addr++;
- *(redundant + REDT_ADDR1H) = *(redundant + REDT_ADDR2H) = (BYTE)(addr / 0x0100);
+ *(redundant + REDT_ADDR1H) = *(redundant + REDT_ADDR2H) =
+ (BYTE)(addr / 0x0100);
*(redundant + REDT_ADDR1L) = *(redundant + REDT_ADDR2L) = (BYTE)addr;
}
Media.Sector = CisArea.Sector;
if (Ssfdc_D_ReadSect(us, buf, redundant)) {
- Media.Zone = zone; Media.PhyBlock = block; Media.Sector = sector;
+ Media.Zone = zone;
+ Media.PhyBlock = block;
+ Media.Sector = sector;
return ERROR;
}
}
/* ----- Ssfdc_D_ReadBlock() --------------------------------------------- */
-int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf, BYTE *redundant)
+int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf,
+ BYTE *redundant)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
/* ----- Ssfdc_D_CopyBlock() -------------------------------------------- */
-int Ssfdc_D_CopyBlock(struct us_data *us, WORD count, BYTE *buf, BYTE *redundant)
+int Ssfdc_D_CopyBlock(struct us_data *us, WORD count, BYTE *buf,
+ BYTE *redundant)
{
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
int result;
return result;
}
-/* ----- SM_SCSI_Test_Unit_Ready() -------------------------------------------------- */
+/* ----- SM_SCSI_Test_Unit_Ready() ------------------------------------- */
int SM_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb)
{
if (us->SM_Status.Insert && us->SM_Status.Ready)
return USB_STOR_TRANSPORT_GOOD;
}
-/* ----- SM_SCSI_Inquiry() -------------------------------------------------- */
+/* ----- SM_SCSI_Inquiry() --------------------------------------------- */
int SM_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb)
{
- BYTE data_ptr[36] = {0x00, 0x80, 0x02, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x55, 0x53, 0x42, 0x32, 0x2E, 0x30, 0x20, 0x20, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x31, 0x30, 0x30};
+ BYTE data_ptr[36] = {0x00, 0x80, 0x02, 0x00, 0x1F, 0x00, 0x00, 0x00,
+ 0x55, 0x53, 0x42, 0x32, 0x2E, 0x30, 0x20,
+ 0x20, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65,
+ 0x61, 0x64, 0x65, 0x72, 0x20, 0x20, 0x20,
+ 0x20, 0x20, 0x20, 0x30, 0x31, 0x30, 0x30};
usb_stor_set_xfer_buf(us, data_ptr, 36, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
-/* ----- SM_SCSI_Mode_Sense() -------------------------------------------------- */
+/* ----- SM_SCSI_Mode_Sense() ------------------------------------------ */
int SM_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb)
{
- BYTE mediaNoWP[12] = {0x0b, 0x00, 0x00, 0x08, 0x00, 0x00, 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00};
- BYTE mediaWP[12] = {0x0b, 0x00, 0x80, 0x08, 0x00, 0x00, 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00};
+ BYTE mediaNoWP[12] = {0x0b, 0x00, 0x00, 0x08, 0x00, 0x00,
+ 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00};
+ BYTE mediaWP[12] = {0x0b, 0x00, 0x80, 0x08, 0x00, 0x00,
+ 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00};
if (us->SM_Status.WtP)
usb_stor_set_xfer_buf(us, mediaWP, 12, srb, TO_XFER_BUF);
return USB_STOR_TRANSPORT_GOOD;
}
-/* ----- SM_SCSI_Read_Capacity() -------------------------------------------------- */
+/* ----- SM_SCSI_Read_Capacity() --------------------------------------- */
int SM_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb)
{
unsigned int offset = 0;
{
int result = 0;
PBYTE Cdb = srb->cmnd;
- DWORD bn = ((Cdb[2] << 24) & 0xff000000) | ((Cdb[3] << 16) & 0x00ff0000) |
- ((Cdb[4] << 8) & 0x0000ff00) | ((Cdb[5] << 0) & 0x000000ff);
+ DWORD bn = ((Cdb[2] << 24) & 0xff000000) |
+ ((Cdb[3] << 16) & 0x00ff0000) |
+ ((Cdb[4] << 8) & 0x0000ff00) |
+ ((Cdb[5] << 0) & 0x000000ff);
WORD blen = ((Cdb[7] << 8) & 0xff00) | ((Cdb[8] << 0) & 0x00ff);
DWORD blenByte = blen * 0x200;
void *buf;
{
int result = 0;
PBYTE Cdb = srb->cmnd;
- DWORD bn = ((Cdb[2] << 24) & 0xff000000) | ((Cdb[3] << 16) & 0x00ff0000) |
- ((Cdb[4] << 8) & 0x0000ff00) | ((Cdb[5] << 0) & 0x000000ff);
+ DWORD bn = ((Cdb[2] << 24) & 0xff000000) |
+ ((Cdb[3] << 16) & 0x00ff0000) |
+ ((Cdb[4] << 8) & 0x0000ff00) |
+ ((Cdb[5] << 0) & 0x000000ff);
WORD blen = ((Cdb[7] << 8) & 0xff00) | ((Cdb[8] << 0) & 0x00ff);
DWORD blenByte = blen * 0x200;
void *buf;
return 0;
}
-void fill_inquiry_response(struct us_data *us, unsigned char *data, unsigned int data_len)
+void fill_inquiry_response(struct us_data *us, unsigned char *data,
+ unsigned int data_len)
{
pr_info("usb --- fill_inquiry_response\n");
if (data_len < 36) /* You lose. */
if (data[0]&0x20) {
memset(data+8, 0, 28);
} else {
- u16 bcdDevice = le16_to_cpu(us->pusb_dev->descriptor.bcdDevice);
+ u16 bcdDevice =
+ le16_to_cpu(us->pusb_dev->descriptor.bcdDevice);
memcpy(data+8, us->unusual_dev->vendorName,
strlen(us->unusual_dev->vendorName) > 8 ? 8 :
strlen(us->unusual_dev->vendorName));
us->srb->result = DID_BAD_TARGET << 16;
} else if ((us->srb->cmnd[0] == INQUIRY)
&& (us->fflags & US_FL_FIX_INQUIRY)) {
- unsigned char data_ptr[36] = {0x00, 0x80, 0x02, 0x02, 0x1F, 0x00, 0x00, 0x00};
+ unsigned char data_ptr[36] = {0x00, 0x80, 0x02, 0x02,
+ 0x1F, 0x00, 0x00, 0x00};
fill_inquiry_response(us, data_ptr, 36);
us->srb->result = SAM_STAT_GOOD;
usb_set_intfdata(intf, us);
/* Allocate the device-related DMA-mapped buffers */
- us->cr = usb_alloc_coherent(us->pusb_dev, sizeof(*us->cr), GFP_KERNEL, &us->cr_dma);
+ us->cr = usb_alloc_coherent(us->pusb_dev, sizeof(*us->cr), GFP_KERNEL,
+ &us->cr_dma);
if (!us->cr) {
pr_info("usb_ctrlrequest allocation failed\n");
return -ENOMEM;
}
- us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE, GFP_KERNEL, &us->iobuf_dma);
+ us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE, GFP_KERNEL,
+ &us->iobuf_dma);
if (!us->iobuf) {
pr_info("I/O buffer allocation failed\n");
return -ENOMEM;
static int get_device_info(struct us_data *us, const struct usb_device_id *id)
{
struct usb_device *dev = us->pusb_dev;
- struct usb_interface_descriptor *idesc = &us->pusb_intf->cur_altsetting->desc;
+ struct usb_interface_descriptor *idesc =
+ &us->pusb_intf->cur_altsetting->desc;
pr_info("usb --- get_device_info\n");
/* Calculate and store the pipe values */
us->send_ctrl_pipe = usb_sndctrlpipe(us->pusb_dev, 0);
us->recv_ctrl_pipe = usb_rcvctrlpipe(us->pusb_dev, 0);
- us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev, ep_out->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
- us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev, ep_in->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
+ us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev,
+ ep_out->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
+ us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev,
+ ep_in->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
if (ep_int) {
- us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev, ep_int->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
+ us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev,
+ ep_int->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
us->ep_bInterval = ep_int->bInterval;
}
return 0;
/* Free the device-related DMA-mapped buffers */
if (us->cr)
- usb_free_coherent(us->pusb_dev, sizeof(*us->cr), us->cr, us->cr_dma);
+ usb_free_coherent(us->pusb_dev, sizeof(*us->cr), us->cr,
+ us->cr_dma);
if (us->iobuf)
- usb_free_coherent(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, us->iobuf_dma);
+ usb_free_coherent(us->pusb_dev, US_IOBUF_SIZE, us->iobuf,
+ us->iobuf_dma);
/* Remove our private data from the interface */
usb_set_intfdata(us->pusb_intf, NULL);
complete_and_exit(&us->scanning_done, 0);
}
-static int eucr_probe(struct usb_interface *intf, const struct usb_device_id *id)
+static int eucr_probe(struct usb_interface *intf,
+ const struct usb_device_id *id)
{
struct Scsi_Host *host;
struct us_data *us;