1/*
2 * Copyright 2007, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Bruno Albuquerque, bga@bug-br.org.br
7 *
8 * Copyright 2004-2006 yellowTAB GMbH. This file is
9 * based on work I did for ZETA while employed by
10 * yellowTAB and is used under permission.
11 */
12
13
14#include "scsi_periph_int.h"
15
16#include <scsi_cmds.h>
17
18#include <string.h>
19
20
21err_res
22periph_synchronize_cache(scsi_periph_device_info *device, scsi_ccb *request)
23{
24	scsi_cmd_sync_cache* cmd = (scsi_cmd_sync_cache*)request->cdb;
25
26	request->flags = SCSI_DIR_NONE;
27
28	request->data = NULL;
29	request->sg_list = NULL;
30	request->data_length = 0;
31	request->timeout = device->std_timeout;
32	request->sort = -1;
33
34	memset(cmd, 0, sizeof(*cmd));
35
36	cmd->opcode	= SCSI_OP_SYNCHRONIZE_CACHE;
37	cmd->immediately = 0;
38
39	// TODO: Maybe we will actually want to set this one day...
40	cmd->block_count = 0;
41
42	request->cdb_length = sizeof(*cmd);
43
44	device->scsi->sync_io(request);
45
46	return periph_check_error(device, request);
47}
48