Skip to content

Commit

Permalink
remove the unnecessary cast
Browse files Browse the repository at this point in the history
to make the code a little bit clearer

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
  • Loading branch information
xiaoxiang781216 authored and Wendy Liang committed Feb 27, 2019
1 parent 5b889c7 commit 95b833d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 26 deletions.
3 changes: 1 addition & 2 deletions lib/include/openamp/virtqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ static inline struct virtqueue *virtqueue_allocate(unsigned int num_desc_extra)
uint32_t vq_size = sizeof(struct virtqueue) +
num_desc_extra * sizeof(struct vq_desc_extra);

vqs = (struct virtqueue *)metal_allocate_memory(vq_size);

vqs = metal_allocate_memory(vq_size);
if (vqs) {
memset(vqs, 0x00, vq_size);
}
Expand Down
12 changes: 5 additions & 7 deletions lib/remoteproc/elf_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ static void elf_parse_segment(void *elf_info, const void *elf_phdr,
*p_type = (unsigned int)phdr->p_type;
if (p_offset != NULL)
*p_offset = (size_t)phdr->p_offset;
if (p_vaddr != NULL)
if (p_vaddr != NULL)
*p_vaddr = (metal_phys_addr_t)phdr->p_vaddr;
if (p_paddr != NULL)
Expand Down Expand Up @@ -338,8 +337,7 @@ static void elf_parse_section(void *elf_info, void *elf_shdr,
if (sh_flags != NULL)
*sh_flags = shdr->sh_flags;
if (sh_addr != NULL)
*sh_addr = (metal_phys_addr_t)(shdr->sh_addr &
(metal_phys_addr_t)(-1));
*sh_addr = (metal_phys_addr_t)shdr->sh_addr;
if (sh_offset != NULL)
*sh_offset = shdr->sh_offset;
if (sh_size != NULL)
Expand Down Expand Up @@ -523,7 +521,7 @@ int elf_load_header(const void *img_data, size_t offset, size_t len,
if (*shstrtab == NULL)
return -RPROC_ENOMEM;
memcpy(*shstrtab,
(const void *)((const char *)img_data + shstrtab_offset),
(const char *)img_data + shstrtab_offset,
shstrtab_size);
*load_state = (*load_state & (~ELF_STATE_MASK)) |
ELF_STATE_HDRS_COMPLETE;
Expand Down Expand Up @@ -650,17 +648,17 @@ metal_phys_addr_t elf_get_entry(void *elf_info)
return METAL_BAD_PHYS;

if (elf_is_64(elf_info) == 0) {
Elf32_Ehdr *elf_ehdr = (Elf32_Ehdr *)elf_info;
Elf32_Ehdr *elf_ehdr = elf_info;
Elf32_Addr e_entry;

e_entry = elf_ehdr->e_entry;
return (metal_phys_addr_t)e_entry;
} else {
Elf64_Ehdr *elf_ehdr = (Elf64_Ehdr *)elf_info;
Elf64_Ehdr *elf_ehdr = elf_info;
Elf64_Addr e_entry;

e_entry = elf_ehdr->e_entry;
return (metal_phys_addr_t)(e_entry & (metal_phys_addr_t)(-1));
return (metal_phys_addr_t)e_entry;
}
}

Expand Down
12 changes: 6 additions & 6 deletions lib/remoteproc/remoteproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static int remoteproc_parse_rsc_table(struct remoteproc *rproc,
{
struct metal_io_region *io;

io = remoteproc_get_io_with_va(rproc, (void *)rsc_table);
io = remoteproc_get_io_with_va(rproc, rsc_table);
return handle_rsc_table(rproc, rsc_table, rsc_size, io);
}

Expand All @@ -142,7 +142,7 @@ int remoteproc_set_rsc_table(struct remoteproc *rproc,
int ret;
struct metal_io_region *io;

io = remoteproc_get_io_with_va(rproc, (void *)rsc_table);
io = remoteproc_get_io_with_va(rproc, rsc_table);
if (!io)
return -RPROC_EINVAL;
ret = remoteproc_parse_rsc_table(rproc, rsc_table, rsc_size);
Expand Down Expand Up @@ -787,7 +787,7 @@ int remoteproc_load_noblock(struct remoteproc *rproc,
}
rsc_io_offset = metal_io_virt_to_offset(*io, rsc_table);
ret = metal_io_block_read(*io, rsc_io_offset,
lrsc_table, (int)rsc_size);
lrsc_table, rsc_size);
if (ret != (int)rsc_size) {
metal_log(METAL_LOG_ERROR,
"load failed: failed to get rsc\r\n");
Expand All @@ -805,13 +805,13 @@ int remoteproc_load_noblock(struct remoteproc *rproc,
}
/* Update resource table */
ret = metal_io_block_write(*io, rsc_io_offset,
lrsc_table, (int)rsc_size);
lrsc_table, rsc_size);
if (ret != (int)rsc_size) {
metal_log(METAL_LOG_WARNING,
"load exectuable, failed to update rsc\r\n");
"load executable, failed to update rsc\r\n");
}
rproc->rsc_table = rsc_table;
rproc->rsc_len = (int)rsc_size;
rproc->rsc_len = rsc_size;
metal_free_memory(lrsc_table);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/remoteproc/rsc_table_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int handle_rsc_table(struct remoteproc *rproc,
*/
int handle_carve_out_rsc(struct remoteproc *rproc, void *rsc)
{
struct fw_rsc_carveout *carve_rsc = (struct fw_rsc_carveout *)rsc;
struct fw_rsc_carveout *carve_rsc = rsc;
metal_phys_addr_t da;
metal_phys_addr_t pa;
size_t size;
Expand Down Expand Up @@ -128,7 +128,7 @@ int handle_vendor_rsc(struct remoteproc *rproc, void *rsc)

int handle_vdev_rsc(struct remoteproc *rproc, void *rsc)
{
struct fw_rsc_vdev *vdev_rsc = (struct fw_rsc_vdev *)rsc;
struct fw_rsc_vdev *vdev_rsc = rsc;
unsigned int notifyid, i, num_vrings;

/* only assign notification IDs but do not initialize vdev */
Expand Down Expand Up @@ -167,7 +167,7 @@ int handle_vdev_rsc(struct remoteproc *rproc, void *rsc)
*/
int handle_trace_rsc(struct remoteproc *rproc, void *rsc)
{
struct fw_rsc_trace *vdev_rsc = (struct fw_rsc_trace *)rsc;
struct fw_rsc_trace *vdev_rsc = rsc;
(void)rproc;

if (vdev_rsc->da != FW_RSC_U32_ADDR_ANY && vdev_rsc->len != 0)
Expand Down
10 changes: 4 additions & 6 deletions lib/rpmsg/rpmsg_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ rpmsg_virtio_shm_pool_get_buffer(struct rpmsg_virtio_shm_pool *shpool,

if (shpool->avail < size)
return NULL;
buffer = (void *)((char *)shpool->base + shpool->size - shpool->avail);
buffer = (char *)shpool->base + shpool->size - shpool->avail;
shpool->avail -= size;

return buffer;
Expand Down Expand Up @@ -390,8 +390,7 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
metal_mutex_acquire(&rdev->lock);

/* Process the received data from remote node */
rp_hdr = (struct rpmsg_hdr *)rpmsg_virtio_get_rx_buffer(rvdev,
&len, &idx);
rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);

metal_mutex_release(&rdev->lock);

Expand Down Expand Up @@ -421,8 +420,7 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
/* Return used buffers. */
rpmsg_virtio_return_buffer(rvdev, rp_hdr, len, idx);

rp_hdr = (struct rpmsg_hdr *)
rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
rp_hdr = rpmsg_virtio_get_rx_buffer(rvdev, &len, &idx);
if (rp_hdr == NULL) {
/* tell peer we return some rx buffer */
virtqueue_kick(rvdev->rvq);
Expand Down Expand Up @@ -459,7 +457,7 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
(void)priv;
(void)src;

ns_msg = (struct rpmsg_ns_msg *)data;
ns_msg = data;
if (len != sizeof(*ns_msg))
/* Returns as the message is corrupted */
return RPMSG_SUCCESS;
Expand Down
4 changes: 2 additions & 2 deletions lib/virtio/virtqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ int virtqueue_create(struct virtio_device *virt_dev, unsigned short id,
vq->notify = notify;

/* Initialize vring control block in virtqueue. */
vq_ring_init(vq, (void *)ring->vaddr, ring->align);
vq_ring_init(vq, ring->vaddr, ring->align);
}

return status;
Expand Down Expand Up @@ -509,7 +509,7 @@ static void vq_ring_init(struct virtqueue *vq, void *ring_mem, int alignment)
size = vq->vq_nentries;
vr = &vq->vq_ring;

vring_init(vr, size, (unsigned char *)ring_mem, alignment);
vring_init(vr, size, ring_mem, alignment);

#ifndef VIRTIO_SLAVE_ONLY
if (vq->vq_dev->role == VIRTIO_DEV_MASTER) {
Expand Down

0 comments on commit 95b833d

Please sign in to comment.