Commit 760053b6 authored by Boaz Harrosh's avatar Boaz Harrosh Committed by Chris Wright

USB: fix USB_STORAGE_CYPRESS_ATACB

upstream commit: 1f4159c1

commit 64a87b24: [SCSI] Let scsi_cmnd->cmnd use request->cmd buffer
changed the scsi_eh_prep_cmnd logic by making it clear
the ->cmnd buffer. But the sat to cypress atacb translation supposed
the ->cmnd buffer wasn't modified.

This patch makes it set the ->cmnd buffer after scsi_eh_prep_cmnd call.
The problem and a fix was reported by Matthieu CASTET <castet.matthieu@free.fr>

It also removes all the hackery fiddling of scsi_cmnd and scsi_eh_save by
requesting from scsi_eh_prep_cmnd to prepare a read into ->sense_buffer,
which is much more suitable a buffer for HW transfers, then after the command
execution the regs read is copied into regs buffer before actual preparation
of sense_buffer.

Also fix an alien comment character to my utf-8 editor.
Signed-off-by: default avatarBoaz Harrosh <bharrosh@panasas.com>
Signed-off-by: default avatarMatthieu CASTET <castet.matthieu@free.fr>
Cc: stable <stable@kernel.org>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Matthew Dharm <mdharm-kernel@one-eyed-alien.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarChris Wright <chrisw@sous-sol.org>
parent 39f8c8a3
...@@ -133,19 +133,18 @@ void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us) ...@@ -133,19 +133,18 @@ void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
/* build the command for /* build the command for
* reading the ATA registers */ * reading the ATA registers */
scsi_eh_prep_cmnd(srb, &ses, NULL, 0, 0); scsi_eh_prep_cmnd(srb, &ses, NULL, 0, sizeof(regs));
srb->sdb.length = sizeof(regs);
sg_init_one(&ses.sense_sgl, regs, srb->sdb.length);
srb->sdb.table.sgl = &ses.sense_sgl;
srb->sc_data_direction = DMA_FROM_DEVICE;
srb->sdb.table.nents = 1;
/* we use the same command as before, but we set /* we use the same command as before, but we set
* the read taskfile bit, for not executing atacb command, * the read taskfile bit, for not executing atacb command,
* but reading register selected in srb->cmnd[4] * but reading register selected in srb->cmnd[4]
*/ */
srb->cmd_len = 16;
srb->cmnd = ses.cmnd;
srb->cmnd[2] = 1; srb->cmnd[2] = 1;
usb_stor_transparent_scsi_command(srb, us); usb_stor_transparent_scsi_command(srb, us);
memcpy(regs, srb->sense_buffer, sizeof(regs));
tmp_result = srb->result; tmp_result = srb->result;
scsi_eh_restore_cmnd(srb, &ses); scsi_eh_restore_cmnd(srb, &ses);
/* we fail to get registers, report invalid command */ /* we fail to get registers, report invalid command */
...@@ -162,8 +161,8 @@ void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us) ...@@ -162,8 +161,8 @@ void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us)
/* XXX we should generate sk, asc, ascq from status and error /* XXX we should generate sk, asc, ascq from status and error
* regs * regs
* (see 11.1 Error translation ATA device error to SCSI error map) * (see 11.1 Error translation ATA device error to SCSI error
* and ata_to_sense_error from libata. * map, and ata_to_sense_error from libata.)
*/ */
/* Sense data is current and format is descriptor. */ /* Sense data is current and format is descriptor. */
......
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