+static int idedisk_issue_flush(request_queue_t *q, struct gendisk *disk,
+ sector_t *error_sector)
+{
+ ide_drive_t *drive = q->queuedata;
+ struct request *rq;
+ int ret;
+
+ if (!drive->wcache)
+ return 0;
+
+ rq = blk_get_request(q, WRITE, __GFP_WAIT);
+
+ memset(rq->cmd, 0, sizeof(rq->cmd));
+
+ if (ide_id_has_flush_cache_ext(drive->id) &&
+ (drive->capacity64 >= (1UL << 28)))
+ rq->cmd[0] = WIN_FLUSH_CACHE_EXT;
+ else
+ rq->cmd[0] = WIN_FLUSH_CACHE;
+
+
+ rq->flags |= REQ_DRIVE_TASK | REQ_SOFTBARRIER;
+ rq->buffer = rq->cmd;
+
+ ret = blk_execute_rq(q, disk, rq);
+
+ /*
+ * if we failed and caller wants error offset, get it
+ */
+ if (ret && error_sector)
+ *error_sector = ide_get_error_location(drive, rq->cmd);
+
+ blk_put_request(rq);
+ return ret;
+}
+