2025-06-11 22:53:28 +02:00
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
2025-04-22 16:34:18 +02:00
|
|
|
/*
|
|
|
|
|
* 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();
|
|
|
|
|
|
2025-04-22 16:37:28 +02:00
|
|
|
if (type == QDL_DEVICE_SIM)
|
|
|
|
|
return sim_init();
|
|
|
|
|
|
2025-04-22 16:34:18 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-16 19:55:45 -05:00
|
|
|
/**
|
|
|
|
|
* 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)
|
|
|
|
|
*/
|
2025-04-22 16:34:18 +02:00
|
|
|
int qdl_read(struct qdl_device *qdl, void *buf, size_t len, unsigned int timeout)
|
|
|
|
|
{
|
|
|
|
|
return qdl->read(qdl, buf, len, timeout);
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-16 20:04:50 -05:00
|
|
|
/**
|
|
|
|
|
* 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
|
2025-10-23 21:40:29 +02:00
|
|
|
* @timeout: timeout for write, in milliseconds
|
2025-09-16 20:04:50 -05:00
|
|
|
*
|
|
|
|
|
* Returns: number of bytes read
|
|
|
|
|
* negative errno on failure (notably -ETIMEDOUT)
|
|
|
|
|
*/
|
2025-10-23 21:40:29 +02:00
|
|
|
int qdl_write(struct qdl_device *qdl, const void *buf, size_t len, unsigned int timeout)
|
2025-04-22 16:34:18 +02:00
|
|
|
{
|
2025-10-23 21:40:29 +02:00
|
|
|
return qdl->write(qdl, buf, len, timeout);
|
2025-04-22 16:34:18 +02:00
|
|
|
}
|