2019-11-02 18:30:33 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* drivers/serial/uart_rpmsg.c
|
|
|
|
*
|
2020-08-22 18:36:57 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2019-11-02 18:30:33 +01:00
|
|
|
*
|
2020-08-22 18:36:57 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2019-11-02 18:30:33 +01:00
|
|
|
*
|
2020-08-22 18:36:57 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2019-11-02 18:30:33 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <nuttx/fs/ioctl.h>
|
|
|
|
#include <nuttx/kmalloc.h>
|
2022-09-05 11:37:31 +02:00
|
|
|
#include <nuttx/mutex.h>
|
2019-11-02 18:30:33 +01:00
|
|
|
#include <nuttx/rptun/openamp.h>
|
|
|
|
#include <nuttx/serial/serial.h>
|
|
|
|
#include <nuttx/serial/uart_rpmsg.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#define UART_RPMSG_DEV_CONSOLE "/dev/console"
|
|
|
|
#define UART_RPMSG_DEV_PREFIX "/dev/tty"
|
|
|
|
#define UART_RPMSG_EPT_PREFIX "rpmsg-tty"
|
|
|
|
|
|
|
|
#define UART_RPMSG_TTY_WRITE 0
|
|
|
|
#define UART_RPMSG_TTY_WAKEUP 1
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
begin_packed_struct struct uart_rpmsg_header_s
|
|
|
|
{
|
|
|
|
uint32_t command : 31;
|
|
|
|
uint32_t response : 1;
|
|
|
|
int32_t result;
|
|
|
|
uint64_t cookie;
|
|
|
|
} end_packed_struct;
|
|
|
|
|
|
|
|
begin_packed_struct struct uart_rpmsg_write_s
|
|
|
|
{
|
|
|
|
struct uart_rpmsg_header_s header;
|
|
|
|
uint32_t count;
|
|
|
|
uint32_t resolved;
|
|
|
|
char data[0];
|
|
|
|
} end_packed_struct;
|
|
|
|
|
|
|
|
begin_packed_struct struct uart_rpmsg_wakeup_s
|
|
|
|
{
|
|
|
|
struct uart_rpmsg_header_s header;
|
|
|
|
} end_packed_struct;
|
|
|
|
|
|
|
|
struct uart_rpmsg_priv_s
|
|
|
|
{
|
|
|
|
struct rpmsg_endpoint ept;
|
2022-09-06 08:18:45 +02:00
|
|
|
mutex_t lock;
|
2019-11-02 18:30:33 +01:00
|
|
|
FAR const char *devname;
|
|
|
|
FAR const char *cpuname;
|
|
|
|
FAR void *recv_data;
|
|
|
|
bool last_upper;
|
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int uart_rpmsg_setup(FAR struct uart_dev_s *dev);
|
|
|
|
static void uart_rpmsg_shutdown(FAR struct uart_dev_s *dev);
|
|
|
|
static int uart_rpmsg_attach(FAR struct uart_dev_s *dev);
|
|
|
|
static void uart_rpmsg_detach(FAR struct uart_dev_s *dev);
|
|
|
|
static void uart_rpmsg_rxint(FAR struct uart_dev_s *dev, bool enable);
|
|
|
|
static bool uart_rpmsg_rxflowcontrol(FAR struct uart_dev_s *dev,
|
|
|
|
unsigned int nbuffered, bool upper);
|
|
|
|
static void uart_rpmsg_dmasend(FAR struct uart_dev_s *dev);
|
|
|
|
static void uart_rpmsg_dmareceive(FAR struct uart_dev_s *dev);
|
|
|
|
static void uart_rpmsg_dmarxfree(FAR struct uart_dev_s *dev);
|
|
|
|
static void uart_rpmsg_dmatxavail(FAR struct uart_dev_s *dev);
|
|
|
|
static void uart_rpmsg_send(FAR struct uart_dev_s *dev, int ch);
|
|
|
|
static void uart_rpmsg_txint(FAR struct uart_dev_s *dev, bool enable);
|
|
|
|
static bool uart_rpmsg_txready(FAR struct uart_dev_s *dev);
|
|
|
|
static bool uart_rpmsg_txempty(FAR struct uart_dev_s *dev);
|
|
|
|
static void uart_rpmsg_device_created(FAR struct rpmsg_device *rdev,
|
|
|
|
FAR void *priv_);
|
|
|
|
static void uart_rpmsg_device_destroy(FAR struct rpmsg_device *rdev,
|
|
|
|
FAR void *priv_);
|
|
|
|
static int uart_rpmsg_ept_cb(struct rpmsg_endpoint *ept, FAR void *data,
|
|
|
|
size_t len, uint32_t src, FAR void *priv_);
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static const struct uart_ops_s g_uart_rpmsg_ops =
|
|
|
|
{
|
|
|
|
.setup = uart_rpmsg_setup,
|
|
|
|
.shutdown = uart_rpmsg_shutdown,
|
|
|
|
.attach = uart_rpmsg_attach,
|
|
|
|
.detach = uart_rpmsg_detach,
|
|
|
|
.rxint = uart_rpmsg_rxint,
|
|
|
|
.rxflowcontrol = uart_rpmsg_rxflowcontrol,
|
|
|
|
.dmasend = uart_rpmsg_dmasend,
|
|
|
|
.dmareceive = uart_rpmsg_dmareceive,
|
|
|
|
.dmarxfree = uart_rpmsg_dmarxfree,
|
|
|
|
.dmatxavail = uart_rpmsg_dmatxavail,
|
|
|
|
.send = uart_rpmsg_send,
|
|
|
|
.txint = uart_rpmsg_txint,
|
|
|
|
.txready = uart_rpmsg_txready,
|
|
|
|
.txempty = uart_rpmsg_txempty,
|
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
static int uart_rpmsg_setup(FAR struct uart_dev_s *dev)
|
|
|
|
{
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void uart_rpmsg_shutdown(FAR struct uart_dev_s *dev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static int uart_rpmsg_attach(FAR struct uart_dev_s *dev)
|
|
|
|
{
|
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void uart_rpmsg_detach(FAR struct uart_dev_s *dev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void uart_rpmsg_rxint(FAR struct uart_dev_s *dev, bool enable)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool uart_rpmsg_rxflowcontrol(FAR struct uart_dev_s *dev,
|
|
|
|
unsigned int nbuffered, bool upper)
|
|
|
|
{
|
|
|
|
FAR struct uart_rpmsg_priv_s *priv = dev->priv;
|
|
|
|
FAR struct uart_rpmsg_wakeup_s msg;
|
|
|
|
|
2023-08-29 12:43:49 +02:00
|
|
|
nxmutex_lock(&priv->lock);
|
2019-11-02 18:30:33 +01:00
|
|
|
if (!upper && upper != priv->last_upper)
|
|
|
|
{
|
|
|
|
memset(&msg, 0, sizeof(msg));
|
|
|
|
|
|
|
|
msg.header.command = UART_RPMSG_TTY_WAKEUP;
|
|
|
|
if (is_rpmsg_ept_ready(&priv->ept))
|
|
|
|
{
|
|
|
|
rpmsg_send(&priv->ept, &msg, sizeof(msg));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->last_upper = upper;
|
2023-08-29 12:43:49 +02:00
|
|
|
nxmutex_unlock(&priv->lock);
|
2019-11-02 18:30:33 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void uart_rpmsg_dmasend(FAR struct uart_dev_s *dev)
|
|
|
|
{
|
|
|
|
FAR struct uart_rpmsg_priv_s *priv = dev->priv;
|
|
|
|
FAR struct uart_dmaxfer_s *xfer = &dev->dmatx;
|
|
|
|
FAR struct uart_rpmsg_write_s *msg;
|
|
|
|
size_t len = xfer->length + xfer->nlength;
|
|
|
|
uint32_t space;
|
|
|
|
|
|
|
|
msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true);
|
|
|
|
if (!msg)
|
|
|
|
{
|
|
|
|
dev->dmatx.length = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(msg, 0, sizeof(*msg));
|
|
|
|
|
2021-12-08 05:20:35 +01:00
|
|
|
space = space - sizeof(*msg);
|
2019-11-02 18:30:33 +01:00
|
|
|
|
|
|
|
if (len > space)
|
|
|
|
{
|
|
|
|
len = space;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len > xfer->length)
|
|
|
|
{
|
2021-12-08 05:20:35 +01:00
|
|
|
memcpy(msg->data, xfer->buffer, xfer->length);
|
2021-12-31 08:22:50 +01:00
|
|
|
memcpy(msg->data + xfer->length, xfer->nbuffer, len - xfer->length);
|
2019-11-02 18:30:33 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-08 05:20:35 +01:00
|
|
|
memcpy(msg->data, xfer->buffer, len);
|
2019-11-02 18:30:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
msg->count = len;
|
|
|
|
msg->header.command = UART_RPMSG_TTY_WRITE;
|
|
|
|
msg->header.result = -ENXIO;
|
|
|
|
msg->header.cookie = (uintptr_t)dev;
|
|
|
|
|
2021-12-08 05:20:35 +01:00
|
|
|
rpmsg_send_nocopy(&priv->ept, msg, sizeof(*msg) + len);
|
2019-11-02 18:30:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void uart_rpmsg_dmareceive(FAR struct uart_dev_s *dev)
|
|
|
|
{
|
|
|
|
FAR struct uart_rpmsg_priv_s *priv = dev->priv;
|
|
|
|
FAR struct uart_dmaxfer_s *xfer = &dev->dmarx;
|
|
|
|
FAR struct uart_rpmsg_write_s *msg = priv->recv_data;
|
|
|
|
uint32_t len = msg->count;
|
|
|
|
size_t space = xfer->length + xfer->nlength;
|
|
|
|
|
|
|
|
if (len > space)
|
|
|
|
{
|
|
|
|
len = space;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (len > xfer->length)
|
|
|
|
{
|
2021-12-08 05:20:35 +01:00
|
|
|
memcpy(xfer->buffer, msg->data, xfer->length);
|
|
|
|
memcpy(xfer->nbuffer, msg->data, len - xfer->length);
|
2019-11-02 18:30:33 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-08 05:20:35 +01:00
|
|
|
memcpy(xfer->buffer, msg->data, len);
|
2019-11-02 18:30:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
xfer->nbytes = len;
|
|
|
|
uart_recvchars_done(dev);
|
|
|
|
|
|
|
|
msg->header.result = len;
|
|
|
|
|
|
|
|
if (len != msg->count)
|
|
|
|
{
|
|
|
|
uart_rpmsg_rxflowcontrol(dev, 0, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void uart_rpmsg_dmarxfree(FAR struct uart_dev_s *dev)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void uart_rpmsg_dmatxavail(FAR struct uart_dev_s *dev)
|
|
|
|
{
|
|
|
|
FAR struct uart_rpmsg_priv_s *priv = dev->priv;
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_lock(&priv->lock);
|
2022-09-05 11:37:31 +02:00
|
|
|
|
2019-11-02 18:30:33 +01:00
|
|
|
if (is_rpmsg_ept_ready(&priv->ept) && dev->dmatx.length == 0)
|
|
|
|
{
|
|
|
|
uart_xmitchars_dma(dev);
|
|
|
|
}
|
2022-09-05 11:37:31 +02:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&priv->lock);
|
2019-11-02 18:30:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void uart_rpmsg_send(FAR struct uart_dev_s *dev, int ch)
|
|
|
|
{
|
|
|
|
int nexthead;
|
|
|
|
|
|
|
|
nexthead = dev->xmit.head + 1;
|
|
|
|
if (nexthead >= dev->xmit.size)
|
|
|
|
{
|
|
|
|
nexthead = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nexthead != dev->xmit.tail)
|
|
|
|
{
|
|
|
|
/* No.. not full. Add the character to the TX buffer and return. */
|
|
|
|
|
|
|
|
dev->xmit.buffer[dev->xmit.head] = ch;
|
|
|
|
dev->xmit.head = nexthead;
|
|
|
|
}
|
|
|
|
|
|
|
|
uart_rpmsg_dmatxavail(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void uart_rpmsg_txint(FAR struct uart_dev_s *dev, bool enable)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool uart_rpmsg_txready(FAR struct uart_dev_s *dev)
|
|
|
|
{
|
|
|
|
int nexthead;
|
|
|
|
|
|
|
|
nexthead = dev->xmit.head + 1;
|
|
|
|
if (nexthead >= dev->xmit.size)
|
|
|
|
{
|
|
|
|
nexthead = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nexthead != dev->xmit.tail;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool uart_rpmsg_txempty(FAR struct uart_dev_s *dev)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void uart_rpmsg_device_created(FAR struct rpmsg_device *rdev,
|
|
|
|
FAR void *priv_)
|
|
|
|
{
|
|
|
|
FAR struct uart_dev_s *dev = priv_;
|
|
|
|
FAR struct uart_rpmsg_priv_s *priv = dev->priv;
|
|
|
|
char eptname[RPMSG_NAME_SIZE];
|
|
|
|
|
|
|
|
if (strcmp(priv->cpuname, rpmsg_get_cpuname(rdev)) == 0)
|
|
|
|
{
|
|
|
|
priv->ept.priv = dev;
|
2023-03-05 15:34:33 +01:00
|
|
|
snprintf(eptname, sizeof(eptname), "%s%s",
|
|
|
|
UART_RPMSG_EPT_PREFIX, priv->devname);
|
2019-11-02 18:30:33 +01:00
|
|
|
rpmsg_create_ept(&priv->ept, rdev, eptname,
|
|
|
|
RPMSG_ADDR_ANY, RPMSG_ADDR_ANY,
|
|
|
|
uart_rpmsg_ept_cb, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void uart_rpmsg_device_destroy(FAR struct rpmsg_device *rdev,
|
|
|
|
FAR void *priv_)
|
|
|
|
{
|
|
|
|
FAR struct uart_dev_s *dev = priv_;
|
|
|
|
FAR struct uart_rpmsg_priv_s *priv = dev->priv;
|
|
|
|
|
|
|
|
if (strcmp(priv->cpuname, rpmsg_get_cpuname(rdev)) == 0)
|
|
|
|
{
|
|
|
|
rpmsg_destroy_ept(&priv->ept);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int uart_rpmsg_ept_cb(FAR struct rpmsg_endpoint *ept, FAR void *data,
|
|
|
|
size_t len, uint32_t src, FAR void *priv_)
|
|
|
|
{
|
|
|
|
FAR struct uart_dev_s *dev = priv_;
|
2022-09-05 11:37:31 +02:00
|
|
|
FAR struct uart_rpmsg_priv_s *priv = dev->priv;
|
2019-11-02 18:30:33 +01:00
|
|
|
FAR struct uart_rpmsg_header_s *header = data;
|
|
|
|
FAR struct uart_rpmsg_write_s *msg = data;
|
|
|
|
|
|
|
|
if (header->response)
|
|
|
|
{
|
2020-02-22 19:31:14 +01:00
|
|
|
/* Get write-cmd response, this tell how many data have sent */
|
2019-11-02 18:30:33 +01:00
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_lock(&priv->lock);
|
2022-09-05 11:37:31 +02:00
|
|
|
|
2019-11-02 18:30:33 +01:00
|
|
|
dev->dmatx.nbytes = header->result;
|
|
|
|
if (header->result < 0)
|
|
|
|
{
|
|
|
|
dev->dmatx.nbytes = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
uart_xmitchars_done(dev);
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_unlock(&priv->lock);
|
2022-09-05 11:37:31 +02:00
|
|
|
|
2019-11-02 18:30:33 +01:00
|
|
|
/* If have sent some data succeed, then continue send */
|
|
|
|
|
|
|
|
if (msg->count == header->result)
|
|
|
|
{
|
|
|
|
uart_rpmsg_dmatxavail(dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (header->command == UART_RPMSG_TTY_WRITE)
|
|
|
|
{
|
|
|
|
/* Get write-cmd, there are some data, we need receive them */
|
|
|
|
|
|
|
|
priv->recv_data = data;
|
|
|
|
uart_recvchars_dma(dev);
|
|
|
|
priv->recv_data = NULL;
|
|
|
|
|
|
|
|
header->response = 1;
|
|
|
|
rpmsg_send(ept, msg, sizeof(*msg));
|
|
|
|
}
|
|
|
|
else if (header->command == UART_RPMSG_TTY_WAKEUP)
|
|
|
|
{
|
|
|
|
/* Remote core have space, then wakeup current core, continue send */
|
|
|
|
|
|
|
|
uart_rpmsg_dmatxavail(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int uart_rpmsg_init(FAR const char *cpuname, FAR const char *devname,
|
|
|
|
int buf_size, bool isconsole)
|
|
|
|
{
|
|
|
|
FAR struct uart_rpmsg_priv_s *priv;
|
|
|
|
FAR struct uart_dev_s *dev;
|
|
|
|
char dev_name[32];
|
|
|
|
int ret = -ENOMEM;
|
|
|
|
|
|
|
|
dev = kmm_zalloc(sizeof(struct uart_dev_s));
|
|
|
|
if (!dev)
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev->ops = &g_uart_rpmsg_ops;
|
2023-03-21 04:31:03 +01:00
|
|
|
dev->isconsole = isconsole;
|
2019-11-02 18:30:33 +01:00
|
|
|
dev->recv.size = buf_size;
|
|
|
|
dev->xmit.size = buf_size;
|
|
|
|
|
|
|
|
dev->recv.buffer = kmm_malloc(dev->recv.size);
|
|
|
|
if (!dev->recv.buffer)
|
|
|
|
{
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev->xmit.buffer = kmm_malloc(dev->xmit.size);
|
|
|
|
if (!dev->xmit.buffer)
|
|
|
|
{
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv = kmm_zalloc(sizeof(struct uart_rpmsg_priv_s));
|
|
|
|
if (!priv)
|
|
|
|
{
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->cpuname = cpuname;
|
|
|
|
priv->devname = devname;
|
|
|
|
|
|
|
|
dev->priv = priv;
|
|
|
|
|
|
|
|
ret = rpmsg_register_callback(dev,
|
|
|
|
uart_rpmsg_device_created,
|
|
|
|
uart_rpmsg_device_destroy,
|
2022-06-06 10:38:11 +02:00
|
|
|
NULL,
|
2019-11-02 18:30:33 +01:00
|
|
|
NULL);
|
|
|
|
if (ret < 0)
|
|
|
|
{
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2022-09-06 08:18:45 +02:00
|
|
|
nxmutex_init(&priv->lock);
|
2023-03-05 15:34:33 +01:00
|
|
|
snprintf(dev_name, sizeof(dev_name), "%s%s",
|
|
|
|
UART_RPMSG_DEV_PREFIX, devname);
|
2019-11-02 18:30:33 +01:00
|
|
|
uart_register(dev_name, dev);
|
|
|
|
|
2023-03-21 04:31:03 +01:00
|
|
|
if (dev->isconsole)
|
2019-11-02 18:30:33 +01:00
|
|
|
{
|
|
|
|
uart_register(UART_RPMSG_DEV_CONSOLE, dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
return OK;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
kmm_free(dev->recv.buffer);
|
|
|
|
kmm_free(dev->xmit.buffer);
|
|
|
|
kmm_free(dev->priv);
|
|
|
|
kmm_free(dev);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|