@@ -1580,11 +1580,19 @@ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing)
static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
{
- int retries, res;
struct scsi_device *sdp = sdkp->device;
const int timeout = sdp->request_queue->rq_timeout
* SD_FLUSH_TIMEOUT_MULTIPLIER;
struct scsi_sense_hdr my_sshdr;
+ struct scsi_failure failures[] = {
+ {
+ .allowed = 3,
+ .result = SCMD_FAILURE_RESULT_ANY,
+ },
+ {},
+ };
+ static const u8 cmd[10] = { SYNCHRONIZE_CACHE };
+ int res;
if (!scsi_device_online(sdp))
return -ENODEV;
@@ -1593,26 +1601,18 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)
if (!sshdr)
sshdr = &my_sshdr;
- for (retries = 3; retries > 0; --retries) {
- unsigned char cmd[10] = { 0 };
-
- cmd[0] = SYNCHRONIZE_CACHE;
- /*
- * Leave the rest of the command zero to indicate
- * flush everything.
- */
- res = scsi_exec_req(((struct scsi_exec_args) {
- .sdev = sdp,
- .cmd = cmd,
- .data_dir = DMA_NONE,
- .sshdr = sshdr,
- .timeout = timeout,
- .retries = sdkp->max_retries,
- .req_flags = RQF_PM }));
- if (res == 0)
- break;
- }
-
+ /*
+ * Leave the rest of the command zero to indicate flush everything.
+ */
+ res = scsi_exec_req(((struct scsi_exec_args) {
+ .sdev = sdp,
+ .cmd = cmd,
+ .data_dir = DMA_NONE,
+ .sshdr = sshdr,
+ .timeout = timeout,
+ .retries = sdkp->max_retries,
+ .req_flags = RQF_PM,
+ .failures = failures }));
if (res) {
sd_print_result(sdkp, "Synchronize Cache(10) failed", res);