drivers/rptun/rptun.c: Switch open/close/seek/read to file_* version.

This commit is contained in:
Xiang Xiao 2019-11-03 07:33:04 -06:00 committed by Gregory Nutt
parent 383ce02442
commit 5d2db59424

View File

@ -97,8 +97,8 @@ struct rptun_cb_s
struct rptun_store_s struct rptun_store_s
{ {
int fd; struct file file;
FAR char *buf; FAR char *buf;
}; };
/**************************************************************************** /****************************************************************************
@ -579,23 +579,24 @@ static int rptun_store_open(FAR void *store_, FAR const char *path,
{ {
FAR struct rptun_store_s *store = store_; FAR struct rptun_store_s *store = store_;
int len = 0x100; int len = 0x100;
int ret;
store->fd = open(path, O_RDONLY); ret = file_open(&store->file, path, O_RDONLY);
if (store->fd < 0) if (ret < 0)
{ {
return -EINVAL; return ret;
} }
store->buf = kmm_malloc(len); store->buf = kmm_malloc(len);
if (!store->buf) if (!store->buf)
{ {
close(store->fd); file_close(&store->file);
return -ENOMEM; return -ENOMEM;
} }
*img_data = store->buf; *img_data = store->buf;
return read(store->fd, store->buf, len); return file_read(&store->file, store->buf, len);
} }
static void rptun_store_close(FAR void *store_) static void rptun_store_close(FAR void *store_)
@ -603,7 +604,7 @@ static void rptun_store_close(FAR void *store_)
FAR struct rptun_store_s *store = store_; FAR struct rptun_store_s *store = store_;
kmm_free(store->buf); kmm_free(store->buf);
close(store->fd); file_close(&store->file);
} }
static int rptun_store_load(FAR void *store_, size_t offset, static int rptun_store_load(FAR void *store_, size_t offset,
@ -635,8 +636,8 @@ static int rptun_store_load(FAR void *store_, size_t offset,
} }
} }
lseek(store->fd, offset, SEEK_SET); file_seek(&store->file, offset, SEEK_SET);
return read(store->fd, tmp, size); return file_read(&store->file, tmp, size);
} }
static metal_phys_addr_t rptun_pa_to_da(FAR struct rptun_dev_s *dev, static metal_phys_addr_t rptun_pa_to_da(FAR struct rptun_dev_s *dev,
@ -842,7 +843,7 @@ int rptun_initialize(FAR struct rptun_dev_s *dev)
int rptun_boot(FAR const char *cpuname) int rptun_boot(FAR const char *cpuname)
{ {
struct file filep; struct file file;
char name[16]; char name[16];
int ret; int ret;
@ -853,14 +854,14 @@ int rptun_boot(FAR const char *cpuname)
sprintf(name, "/dev/rptun%s", cpuname); sprintf(name, "/dev/rptun%s", cpuname);
ret = file_open(&filep, name, 0, 0); ret = file_open(&file, name, 0, 0);
if (ret) if (ret)
{ {
return ret; return ret;
} }
ret = file_ioctl(&filep, RPTUNIOC_START, 0); ret = file_ioctl(&file, RPTUNIOC_START, 0);
file_close(&filep); file_close(&file);
return ret; return ret;
} }