/* The qualifier defined here is not the value that is masked, it defines conditions for the write to take place. The actual masked qualifier (and other related details) are defined beforehand with _set_shuttle_features().  */
static int usbat_write_blocks(struct us_data *us, void *buffer, int len, int use_sg)
/* The qualifier defined here is not the value that is masked, it defines conditions for the write to take place. The actual masked qualifier (and other related details) are defined beforehand with _set_shuttle_features().  */
static int usbat_write_blocks(struct us_data *us, void *buffer, int len, int use_sg)
{
	int result;
	unsigned char *command = us->iobuf;
	command[0] = 0x40;
	command[1] = USBAT_ATA | USBAT_CMD_COND_WRITE_BLOCK;
	command[2] = USBAT_ATA_DATA;
	command[3] = USBAT_ATA_STATUS;
	command[4] = 0xFD;
	command[5] = USBAT_QUAL_FCQ;
	command[6] = LSB_of(len);
	command[7] = MSB_of(len);
	result = usbat_execute_command(us, command, 8);
	if (result != USB_STOR_XFER_GOOD)
		return USB_STOR_TRANSPORT_FAILED;
	result = usbat_bulk_write(us, buffer, len, use_sg);
	if (result != USB_STOR_XFER_GOOD)
		return USB_STOR_TRANSPORT_FAILED;
	return USB_STOR_TRANSPORT_GOOD;
}