File: io.c

package info (click to toggle)
qdl 2.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 388 kB
  • sloc: ansic: 4,810; makefile: 87; xml: 75; sh: 70
file content (69 lines) | stat: -rw-r--r-- 1,558 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// SPDX-License-Identifier: BSD-3-Clause
/*
 * Copyright (c) 2025, Qualcomm Innovation Center, Inc. All rights reserved.
 */
#include <stdlib.h>

#include "qdl.h"

struct qdl_device *qdl_init(enum QDL_DEVICE_TYPE type)
{
	if (type == QDL_DEVICE_USB)
		return usb_init();

	if (type == QDL_DEVICE_SIM)
		return sim_init();

	return NULL;
}

void qdl_deinit(struct qdl_device *qdl)
{
	if (qdl)
		free(qdl);
}

void qdl_set_out_chunk_size(struct qdl_device *qdl, long size)
{
	qdl->set_out_chunk_size(qdl, size);
}

int qdl_open(struct qdl_device *qdl, const char *serial)
{
	return qdl->open(qdl, serial);
}

void qdl_close(struct qdl_device *qdl)
{
	qdl->close(qdl);
}

/**
 * qdl_read() - Read a message from the device
 * @qdl: device handle
 * @buf: buffer to write the data into
 * @len: maximum length of data to be read
 * @timeout: timeout for the read, in milliseconds
 *
 * Returns: number of bytes read, might be zero for a ZLP
 *	    negative errno on failure (notably -ETIMEDOUT)
 */
int qdl_read(struct qdl_device *qdl, void *buf, size_t len, unsigned int timeout)
{
	return qdl->read(qdl, buf, len, timeout);
}

/**
 * qdl_write() - Write a message from the device
 * @qdl: device handle
 * @buf: buffer with data to be written
 * @len: length of data to be written
 * @timeout: timeout for write, in milliseconds
 *
 * Returns: number of bytes read
 *	    negative errno on failure (notably -ETIMEDOUT)
 */
int qdl_write(struct qdl_device *qdl, const void *buf, size_t len, unsigned int timeout)
{
	return qdl->write(qdl, buf, len, timeout);
}