提交 f6f06834 编写于 作者: A aqxyjay

fix #I1US8P, rename the driver, host and deivce method names

上级 485286c5
......@@ -30,8 +30,8 @@ extern "C" {
/* baudrate config */
#define UART_CFG_BAUDRATE _IO(UART_IOC_MAGIC, 1)
void UartSampleAddDev(struct UartHost *host);
void UartSampleRemoveDev(struct UartHost *host);
void AddUartDevice(struct UartHost *host);
void RemoveUartDevice(struct UartHost *host);
#ifdef __cplusplus
#if __cplusplus
......
......@@ -157,7 +157,7 @@ const struct file_operations_vfs g_uartSampleDevFops = {
};
#define MAX_DEV_NAME_SIZE 32
static void UartSampleAddRemoveDev(struct UartHost *host, bool add)
static void AddRemoveUartDev(struct UartHost *host, bool add)
{
int32_t ret;
char *devName = NULL;
......@@ -193,12 +193,12 @@ static void UartSampleAddRemoveDev(struct UartHost *host, bool add)
OsalMemFree(devName);
}
void UartSampleAddDev(struct UartHost *host)
void AddUartDevice(struct UartHost *host)
{
UartSampleAddRemoveDev(host, true);
AddRemoveUartDev(host, true);
}
void UartSampleRemoveDev(struct UartHost *host)
void RemoveUartDevice(struct UartHost *host)
{
UartSampleAddRemoveDev(host, false);
AddRemoveUartDev(host, false);
}
......@@ -31,44 +31,44 @@
static uint8_t g_fifoBuffer[UART_RX_FIFO_SIZE] = {0};
/* HdfDriverEntry method definitions */
static int32_t HdfUartSampleBind(struct HdfDeviceObject *device);
static int32_t HdfUartSampleInit(struct HdfDeviceObject *device);
static void HdfUartSampleRelease(struct HdfDeviceObject *device);
static int32_t SampleUartDriverBind(struct HdfDeviceObject *device);
static int32_t SampleUartDriverInit(struct HdfDeviceObject *device);
static void SampleUartDriverRelease(struct HdfDeviceObject *device);
/* HdfDriverEntry definitions */
struct HdfDriverEntry g_hdfUartSample = {
struct HdfDriverEntry g_sampleUartDriverEntry = {
.moduleVersion = 1,
.moduleName = "UART_SAMPLE",
.Bind = HdfUartSampleBind,
.Init = HdfUartSampleInit,
.Release = HdfUartSampleRelease,
.Bind = SampleUartDriverBind,
.Init = SampleUartDriverInit,
.Release = SampleUartDriverRelease,
};
// Initialize HdfDriverEntry
HDF_INIT(g_hdfUartSample);
HDF_INIT(g_sampleUartDriverEntry);
/* UartHostMethod method definitions */
static int32_t SampleInit(struct UartHost *host);
static int32_t SampleDeinit(struct UartHost *host);
static int32_t SampleWrite(struct UartHost *host, uint8_t *data, uint32_t size);
static int32_t SampleSetBaud(struct UartHost *host, uint32_t baudRate);
static int32_t SampleGetBaud(struct UartHost *host, uint32_t *baudRate);
static int32_t SampleUartHostInit(struct UartHost *host);
static int32_t SampleUartHostDeinit(struct UartHost *host);
static int32_t SampleUartHostWrite(struct UartHost *host, uint8_t *data, uint32_t size);
static int32_t SampleUartHostSetBaud(struct UartHost *host, uint32_t baudRate);
static int32_t SampleUartHostGetBaud(struct UartHost *host, uint32_t *baudRate);
/* UartHostMethod definitions */
struct UartHostMethod g_uartSampleHostMethod = {
.Init = SampleInit,
.Deinit = SampleDeinit,
struct UartHostMethod g_sampleUartHostMethod = {
.Init = SampleUartHostInit,
.Deinit = SampleUartHostDeinit,
.Read = NULL,
.Write = SampleWrite,
.SetBaud = SampleSetBaud,
.GetBaud = SampleGetBaud,
.Write = SampleUartHostWrite,
.SetBaud = SampleUartHostSetBaud,
.GetBaud = SampleUartHostGetBaud,
.SetAttribute = NULL,
.GetAttribute = NULL,
.SetTransMode = NULL,
};
/* UartHostMethod implementations */
static int32_t SampleInit(struct UartHost *host)
static int32_t SampleUartHostInit(struct UartHost *host)
{
HDF_LOGI("%s: Enter", __func__);
if (host == NULL) {
......@@ -78,7 +78,7 @@ static int32_t SampleInit(struct UartHost *host)
return HDF_SUCCESS;
}
static int32_t SampleDeinit(struct UartHost *host)
static int32_t SampleUartHostDeinit(struct UartHost *host)
{
HDF_LOGI("%s: Enter", __func__);
if (host == NULL) {
......@@ -88,7 +88,7 @@ static int32_t SampleDeinit(struct UartHost *host)
return HDF_SUCCESS;
}
static int32_t SampleWrite(struct UartHost *host, uint8_t *data, uint32_t size)
static int32_t SampleUartHostWrite(struct UartHost *host, uint8_t *data, uint32_t size)
{
HDF_LOGI("%s: Enter", __func__);
uint32_t idx;
......@@ -111,7 +111,7 @@ static int32_t SampleWrite(struct UartHost *host, uint8_t *data, uint32_t size)
return HDF_SUCCESS;
}
static int32_t SampleSetBaud(struct UartHost *host, uint32_t baudRate)
static int32_t SampleUartHostSetBaud(struct UartHost *host, uint32_t baudRate)
{
HDF_LOGI("%s: Enter", __func__);
struct UartDevice *device = NULL;
......@@ -141,7 +141,7 @@ static int32_t SampleSetBaud(struct UartHost *host, uint32_t baudRate)
return err;
}
static int32_t SampleGetBaud(struct UartHost *host, uint32_t *baudRate)
static int32_t SampleUartHostGetBaud(struct UartHost *host, uint32_t *baudRate)
{
HDF_LOGI("%s: Enter", __func__);
struct UartDevice *device = NULL;
......@@ -159,7 +159,7 @@ static int32_t SampleGetBaud(struct UartHost *host, uint32_t *baudRate)
return HDF_SUCCESS;
}
static int UartDeviceInit(struct UartDevice *device)
static int InitUartDevice(struct UartDevice *device)
{
UartPl011Error err;
struct UartResource *resource = &device->resource;
......@@ -187,7 +187,7 @@ static int UartDeviceInit(struct UartDevice *device)
return HDF_SUCCESS;
}
static uint32_t UartDeviceGetResource(
static uint32_t GetUartDeviceResource(
struct UartDevice *device, const struct DeviceResourceNode *resourceNode)
{
struct UartResource *resource = &device->resource;
......@@ -199,11 +199,11 @@ static uint32_t UartDeviceGetResource(
}
if (dri->GetUint32(resourceNode, "num", &resource->num, 0) != HDF_SUCCESS) {
HDF_LOGE("uart config read num fail");
HDF_LOGE("uart config read num fail");
return HDF_FAILURE;
}
if (dri->GetUint32(resourceNode, "base", &resource->base, 0) != HDF_SUCCESS) {
HDF_LOGE("uart config read base fail");
HDF_LOGE("uart config read base fail");
return HDF_FAILURE;
}
resource->physBase = (unsigned long)OsalIoRemap(resource->base, 0x48);
......@@ -216,29 +216,29 @@ static uint32_t UartDeviceGetResource(
return HDF_FAILURE;
}
if (dri->GetUint32(resourceNode, "baudrate", &resource->baudrate, 0) != HDF_SUCCESS) {
HDF_LOGE("uart config read baudrate fail");
HDF_LOGE("uart config read baudrate fail");
return HDF_FAILURE;
}
if (dri->GetUint32(resourceNode, "wlen", &resource->wlen, 0) != HDF_SUCCESS) {
HDF_LOGE("uart config read wlen fail");
HDF_LOGE("uart config read wlen fail");
return HDF_FAILURE;
}
if (dri->GetUint32(resourceNode, "parity", &resource->parity, 0) != HDF_SUCCESS) {
HDF_LOGE("uart config read parity fail");
HDF_LOGE("uart config read parity fail");
return HDF_FAILURE;
}
if (dri->GetUint32(resourceNode, "stopBit", &resource->stopBit, 0) != HDF_SUCCESS) {
HDF_LOGE("uart config read stopBit fail");
HDF_LOGE("uart config read stopBit fail");
return HDF_FAILURE;
}
if (dri->GetUint32(resourceNode, "uartClk", &resource->uartClk, 0) != HDF_SUCCESS) {
HDF_LOGE("uart config read uartClk fail");
HDF_LOGE("uart config read uartClk fail");
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
static int32_t SampleAttach(struct UartHost *host, struct HdfDeviceObject *device)
static int32_t AttachUartDevice(struct UartHost *host, struct HdfDeviceObject *device)
{
int32_t ret;
struct UartDevice *uartDevice = NULL;
......@@ -251,18 +251,18 @@ static int32_t SampleAttach(struct UartHost *host, struct HdfDeviceObject *devic
HDF_LOGE("%s: OsalMemCalloc uartDevice error", __func__);
return HDF_ERR_MALLOC_FAIL;
}
ret = UartDeviceGetResource(uartDevice, device->property);
ret = GetUartDeviceResource(uartDevice, device->property);
if (ret != HDF_SUCCESS) {
(void)OsalMemFree(uartDevice);
return HDF_FAILURE;
}
host->num = uartDevice->resource.num;
host->priv = uartDevice;
UartSampleAddDev(host);
return UartDeviceInit(uartDevice);
AddUartDevice(host);
return InitUartDevice(uartDevice);
}
static void UartDeviceDeinit(struct UartDevice *device)
static void DeinitUartDevice(struct UartDevice *device)
{
struct UartRegisterMap *regMap = (struct UartRegisterMap *)device->resource.physBase;
/* wait for uart enter idle. */
......@@ -273,7 +273,7 @@ static void UartDeviceDeinit(struct UartDevice *device)
device->state = UART_DEVICE_UNINITIALIZED;
}
static void SampleDetach(struct UartHost *host)
static void DetachUartDevice(struct UartHost *host)
{
struct UartDevice *uartDevice = NULL;
......@@ -282,13 +282,13 @@ static void SampleDetach(struct UartHost *host)
return;
}
uartDevice = host->priv;
UartDeviceDeinit(uartDevice);
DeinitUartDevice(uartDevice);
(void)OsalMemFree(uartDevice);
host->priv = NULL;
}
/* HdfDriverEntry implementations */
static int32_t HdfUartSampleBind(struct HdfDeviceObject *device)
static int32_t SampleUartDriverBind(struct HdfDeviceObject *device)
{
struct UartHost *uartHost = NULL;
......@@ -306,7 +306,7 @@ static int32_t HdfUartSampleBind(struct HdfDeviceObject *device)
return HDF_SUCCESS;
}
static int32_t HdfUartSampleInit(struct HdfDeviceObject *device)
static int32_t SampleUartDriverInit(struct HdfDeviceObject *device)
{
int32_t ret;
struct UartHost *host = NULL;
......@@ -321,16 +321,16 @@ static int32_t HdfUartSampleInit(struct HdfDeviceObject *device)
HDF_LOGE("%s: host is NULL", __func__);
return HDF_FAILURE;
}
ret = SampleAttach(host, device);
ret = AttachUartDevice(host, device);
if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: attach error", __func__);
return HDF_FAILURE;
}
host->method = &g_uartSampleHostMethod;
host->method = &g_sampleUartHostMethod;
return ret;
}
static void HdfUartSampleRelease(struct HdfDeviceObject *device)
static void SampleUartDriverRelease(struct HdfDeviceObject *device)
{
struct UartHost *host = NULL;
HDF_LOGI("Enter %s:", __func__);
......@@ -345,7 +345,7 @@ static void HdfUartSampleRelease(struct HdfDeviceObject *device)
return;
}
if (host->priv != NULL) {
SampleDetach(host);
DetachUartDevice(host);
}
UartHostDestroy(host);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册