- /*
- * The end of qc->sg is reached and the device expects
- * more data to transfer. In order not to overrun qc->sg
- * and fulfill length specified in the byte count register,
- * - for read case, discard trailing data from the device
- * - for write case, padding zero data to the device
- */
- u16 pad_buf[1] = { 0 };
-
- if (qc->curbytes + bytes > qc->nbytes + ATAPI_MAX_DRAIN) {
- ata_ehi_push_desc(ehi, "too much trailing data "
- "buf=%u cur=%u bytes=%u",
- qc->nbytes, qc->curbytes, bytes);
- return -1;
- }
-
- /* allow overflow only for misc ATAPI commands */
- if (!atapi_qc_may_overflow(qc)) {
- ata_ehi_push_desc(ehi, "unexpected trailing data "
- "%u bytes", bytes);
- return -1;
- }
-
- consumed = 0;
- while (consumed < bytes)
- consumed += ap->ops->data_xfer(dev,
- (unsigned char *)pad_buf, 2, rw);
-
- qc->curbytes += bytes;
- return 0;
+ ata_ehi_push_desc(ehi, "unexpected or too much trailing data "
+ "buf=%u cur=%u bytes=%u",
+ qc->nbytes, qc->curbytes, bytes);
+ return -1;