2010-07-23 01:13:00

by Armando Uribe

[permalink] [raw]
Subject: [PATCH 0/9] staging: tidspbridge: Code Clean Up related to macros

This set of patches are intended do a code clean up
related to macros, i.e. use of static inline, remove unused macros, etc.

Armando Uribe (9):
staging: tidspbridge: Remove Redundant wrappers
staging: tidspbridge: Remove redundant macros in io_sm.c
staging: tidspbridge: Change macros to static inline functions in
io_sm
staging: tidspbridge: Change macros to static inline functions used
in cload
staging: tidspbridge: Remove redundant macro from cod.c
staging: tidspbridge: Remove unused magic number
staging: tidspbridge: Remove macros used as cast
staging: tidspbridge: Change macros to static inline functions
staging: tidspbridge: Remove unused macros

drivers/staging/tidspbridge/core/chnl_sm.c | 2 +-
drivers/staging/tidspbridge/core/io_sm.c | 197 ++++++--------------
drivers/staging/tidspbridge/dynload/cload.c | 35 ++--
.../staging/tidspbridge/dynload/dload_internal.h | 4 -
drivers/staging/tidspbridge/dynload/doff.h | 38 +++--
drivers/staging/tidspbridge/dynload/getsection.c | 17 +--
drivers/staging/tidspbridge/dynload/reloc.c | 2 +-
.../tidspbridge/dynload/reloc_table_c6000.c | 2 +-
drivers/staging/tidspbridge/dynload/tramp.c | 2 +-
.../tidspbridge/dynload/tramp_table_c6000.c | 2 +-
.../tidspbridge/include/dspbridge/chnldefs.h | 1 -
.../tidspbridge/include/dspbridge/chnlpriv.h | 3 -
.../staging/tidspbridge/include/dspbridge/dbdefs.h | 43 +----
.../staging/tidspbridge/include/dspbridge/io_sm.h | 13 --
.../staging/tidspbridge/include/dspbridge/mbx_sh.h | 14 --
drivers/staging/tidspbridge/pmgr/cod.c | 34 ++---
drivers/staging/tidspbridge/pmgr/dbll.c | 5 +-
drivers/staging/tidspbridge/rmgr/disp.c | 2 -
drivers/staging/tidspbridge/rmgr/nldr.c | 33 +---
drivers/staging/tidspbridge/rmgr/proc.c | 4 +-
20 files changed, 140 insertions(+), 313 deletions(-)


2010-07-23 01:12:49

by Armando Uribe

[permalink] [raw]
Subject: [PATCH 2/9] staging: tidspbridge: Remove redundant macros in io_sm.c

This patch removes 4 redundant macros used to perform
read/write operations in shared memory region from io_sm.c.

Signed-off-by: Armando Uribe <[email protected]>
---
drivers/staging/tidspbridge/core/io_sm.c | 77 ++++++++------------
.../staging/tidspbridge/include/dspbridge/io_sm.h | 5 --
2 files changed, 30 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/io_sm.c b/drivers/staging/tidspbridge/core/io_sm.c
index b115cb3..03960bd 100644
--- a/drivers/staging/tidspbridge/core/io_sm.c
+++ b/drivers/staging/tidspbridge/core/io_sm.c
@@ -1094,15 +1094,12 @@ static void input_chnl(struct io_mgr *pio_mgr, struct chnl_object *pchnl,
chnl_mgr_obj = pio_mgr->hchnl_mgr;

/* Attempt to perform input */
- if (!IO_GET_VALUE(pio_mgr->hbridge_context, struct shm, sm, input_full))
+ if (!sm->input_full)
goto func_end;

- bytes =
- IO_GET_VALUE(pio_mgr->hbridge_context, struct shm, sm,
- input_size) * chnl_mgr_obj->word_size;
- chnl_id = IO_GET_VALUE(pio_mgr->hbridge_context, struct shm,
- sm, input_id);
- dw_arg = IO_GET_LONG(pio_mgr->hbridge_context, struct shm, sm, arg);
+ bytes = sm->input_size * chnl_mgr_obj->word_size;
+ chnl_id = sm->input_id;
+ dw_arg = sm->arg;
if (chnl_id >= CHNL_MAXCHANNELS) {
/* Shouldn't be here: would indicate corrupted shm. */
DBC_ASSERT(chnl_id);
@@ -1185,8 +1182,7 @@ static void input_chnl(struct io_mgr *pio_mgr, struct chnl_object *pchnl,
}
if (clear_chnl) {
/* Indicate to the DSP we have read the input */
- IO_SET_VALUE(pio_mgr->hbridge_context, struct shm, sm,
- input_full, 0);
+ sm->input_full = 0;
sm_interrupt_dsp(pio_mgr->hbridge_context, MBX_PCPY_CLASS);
}
if (notify_client) {
@@ -1215,12 +1211,8 @@ static void input_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr)

msg_ctr_obj = pio_mgr->msg_input_ctrl;
/* Get the number of input messages to be read */
- input_empty =
- IO_GET_VALUE(pio_mgr->hbridge_context, struct msg_ctrl, msg_ctr_obj,
- buf_empty);
- num_msgs =
- IO_GET_VALUE(pio_mgr->hbridge_context, struct msg_ctrl, msg_ctr_obj,
- size);
+ input_empty = msg_ctr_obj->buf_empty;
+ num_msgs = msg_ctr_obj->size;
if (input_empty)
goto func_end;

@@ -1310,10 +1302,8 @@ static void input_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr)
/* Set the post SWI flag */
if (num_msgs > 0) {
/* Tell the DSP we've read the messages */
- IO_SET_VALUE(pio_mgr->hbridge_context, struct msg_ctrl,
- msg_ctr_obj, buf_empty, true);
- IO_SET_VALUE(pio_mgr->hbridge_context, struct msg_ctrl,
- msg_ctr_obj, post_swi, true);
+ msg_ctr_obj->buf_empty = true;
+ msg_ctr_obj->post_swi = true;
sm_interrupt_dsp(pio_mgr->hbridge_context, MBX_PCPY_CLASS);
}
func_end:
@@ -1375,15 +1365,14 @@ static void output_chnl(struct io_mgr *pio_mgr, struct chnl_object *pchnl,
chnl_mgr_obj = pio_mgr->hchnl_mgr;
sm = pio_mgr->shared_mem;
/* Attempt to perform output */
- if (IO_GET_VALUE(pio_mgr->hbridge_context, struct shm, sm, output_full))
+ if (sm->output_full)
goto func_end;

if (pchnl && !((pchnl->dw_state & ~CHNL_STATEEOS) == CHNL_STATEREADY))
goto func_end;

/* Look to see if both a PC and DSP output channel are ready */
- dw_dsp_f_mask = IO_GET_VALUE(pio_mgr->hbridge_context, struct shm, sm,
- dsp_free_mask);
+ dw_dsp_f_mask = sm->dsp_free_mask;
chnl_id =
find_ready_output(chnl_mgr_obj, pchnl,
(chnl_mgr_obj->dw_output_mask & dw_dsp_f_mask));
@@ -1415,23 +1404,19 @@ static void output_chnl(struct io_mgr *pio_mgr, struct chnl_object *pchnl,
chnl_packet_obj->byte_size);
pchnl->bytes_moved += chnl_packet_obj->byte_size;
/* Write all 32 bits of arg */
- IO_SET_LONG(pio_mgr->hbridge_context, struct shm, sm, arg,
- chnl_packet_obj->dw_arg);
+ sm->arg = chnl_packet_obj->dw_arg;
#if _CHNL_WORDSIZE == 2
- IO_SET_VALUE(pio_mgr->hbridge_context, struct shm, sm, output_id,
- (u16) chnl_id);
- IO_SET_VALUE(pio_mgr->hbridge_context, struct shm, sm, output_size,
- (u16) (chnl_packet_obj->byte_size +
- (chnl_mgr_obj->word_size -
- 1)) / (u16) chnl_mgr_obj->word_size);
+ /* Access can be different SM access word size (e.g. 16/32 bit words) */
+ sm->output_id = (u16) chnl_id;
+ sm->output_size = (u16) (chnl_packet_obj->byte_size +
+ chnl_mgr_obj->word_size - 1) /
+ (u16) chnl_mgr_obj->word_size;
#else
- IO_SET_VALUE(pio_mgr->hbridge_context, struct shm, sm, output_id,
- chnl_id);
- IO_SET_VALUE(pio_mgr->hbridge_context, struct shm, sm, output_size,
- (chnl_packet_obj->byte_size +
- (chnl_mgr_obj->word_size - 1)) / chnl_mgr_obj->word_size);
+ sm->output_id = chnl_id;
+ sm->output_size = (chnl_packet_obj->byte_size +
+ chnl_mgr_obj->word_size - 1) / chnl_mgr_obj->word_size;
#endif
- IO_SET_VALUE(pio_mgr->hbridge_context, struct shm, sm, output_full, 1);
+ sm->output_full = 1;
/* Indicate to the DSP we have written the output */
sm_interrupt_dsp(pio_mgr->hbridge_context, MBX_PCPY_CLASS);
/* Notify client with IO completion record (keep EOS) */
@@ -1463,9 +1448,7 @@ static void output_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr)
msg_ctr_obj = pio_mgr->msg_output_ctrl;

/* Check if output has been cleared */
- output_empty =
- IO_GET_VALUE(pio_mgr->hbridge_context, struct msg_ctrl, msg_ctr_obj,
- buf_empty);
+ output_empty = msg_ctr_obj->buf_empty;
if (output_empty) {
num_msgs = (hmsg_mgr->msgs_pending > hmsg_mgr->max_msgs) ?
hmsg_mgr->max_msgs : hmsg_mgr->msgs_pending;
@@ -1512,17 +1495,17 @@ static void output_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr)
if (num_msgs > 0) {
hmsg_mgr->msgs_pending -= num_msgs;
#if _CHNL_WORDSIZE == 2
- IO_SET_VALUE(pio_mgr->hbridge_context, struct msg_ctrl,
- msg_ctr_obj, size, (u16) num_msgs);
+ /*
+ * Access can be different SM access word size
+ * (e.g. 16/32 bit words)
+ */
+ msg_ctr_obj->size = (u16) num_msgs;
#else
- IO_SET_VALUE(pio_mgr->hbridge_context, struct msg_ctrl,
- msg_ctr_obj, size, num_msgs);
+ msg_ctr_obj->size = num_msgs;
#endif
- IO_SET_VALUE(pio_mgr->hbridge_context, struct msg_ctrl,
- msg_ctr_obj, buf_empty, false);
+ msg_ctr_obj->buf_empty = false;
/* Set the post SWI flag */
- IO_SET_VALUE(pio_mgr->hbridge_context, struct msg_ctrl,
- msg_ctr_obj, post_swi, true);
+ msg_ctr_obj->post_swi = true;
/* Tell the DSP we have written the output. */
sm_interrupt_dsp(pio_mgr->hbridge_context,
MBX_PCPY_CLASS);
diff --git a/drivers/staging/tidspbridge/include/dspbridge/io_sm.h b/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
index 8b51c37..f1c44f8 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
@@ -33,13 +33,8 @@
#define DSP_FIELD_ADDR(type, field, base, wordsize) \
((((s32)&(((type *)0)->field)) / wordsize) + (u32)base)

-/* Access can be different SM access word size (e.g. 16/32 bit words) */
-#define IO_SET_VALUE(context, type, base, field, value) (base->field = value)
-#define IO_GET_VALUE(context, type, base, field) (base->field)
#define IO_OR_VALUE(context, type, base, field, value) (base->field |= value)
#define IO_AND_VALUE(context, type, base, field, value) (base->field &= value)
-#define IO_SET_LONG(context, type, base, field, value) (base->field = value)
-#define IO_GET_LONG(context, type, base, field) (base->field)

#ifdef CONFIG_TIDSPBRIDGE_DVFS
/* The maximum number of OPPs that are supported */
--
1.6.3.3

2010-07-23 01:12:54

by Armando Uribe

[permalink] [raw]
Subject: [PATCH 1/9] staging: tidspbridge: Remove Redundant wrappers

This patch removes redundant wrappers from io_sm.c file

Signed-off-by: Armando Uribe <[email protected]>
---
drivers/staging/tidspbridge/core/chnl_sm.c | 2 +-
drivers/staging/tidspbridge/core/io_sm.c | 98 +++----------------
.../staging/tidspbridge/include/dspbridge/io_sm.h | 2 -
3 files changed, 17 insertions(+), 85 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/chnl_sm.c b/drivers/staging/tidspbridge/core/chnl_sm.c
index 6074bff..69c4784 100644
--- a/drivers/staging/tidspbridge/core/chnl_sm.c
+++ b/drivers/staging/tidspbridge/core/chnl_sm.c
@@ -230,7 +230,7 @@ func_cont:
omap_mbox_enable_irq(dev_ctxt->mbox, IRQ_RX);
spin_unlock_bh(&chnl_mgr_obj->chnl_mgr_lock);
if (mb_val != 0)
- io_intr_dsp2(chnl_mgr_obj->hio_mgr, mb_val);
+ sm_interrupt_dsp(dev_ctxt, mb_val);

/* Schedule a DPC, to do the actual data transfer */
if (sched_dpc)
diff --git a/drivers/staging/tidspbridge/core/io_sm.c b/drivers/staging/tidspbridge/core/io_sm.c
index ba2e6bd..b115cb3 100644
--- a/drivers/staging/tidspbridge/core/io_sm.c
+++ b/drivers/staging/tidspbridge/core/io_sm.c
@@ -132,10 +132,6 @@ struct io_mgr {
};

/* Function Prototypes */
-static void io_dispatch_chnl(struct io_mgr *pio_mgr,
- struct chnl_object *pchnl, u8 io_mode);
-static void io_dispatch_msg(struct io_mgr *pio_mgr,
- struct msg_mgr *hmsg_mgr);
static void io_dispatch_pm(struct io_mgr *pio_mgr);
static void notify_chnl_complete(struct chnl_object *pchnl,
struct chnl_irp *chnl_packet_obj);
@@ -147,10 +143,6 @@ static void input_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr);
static void output_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr);
static u32 find_ready_output(struct chnl_mgr *chnl_mgr_obj,
struct chnl_object *pchnl, u32 mask);
-static u32 read_data(struct bridge_dev_context *dev_ctxt, void *dest,
- void *src, u32 usize);
-static u32 write_data(struct bridge_dev_context *dev_ctxt, void *dest,
- void *src, u32 usize);

/* Bus Addr (cached kernel) */
static int register_shm_segs(struct io_mgr *hio_mgr,
@@ -834,42 +826,6 @@ func_end:
return;
}

-/*
- * ======== io_dispatch_chnl ========
- * Proc-copy chanl dispatch.
- */
-static void io_dispatch_chnl(struct io_mgr *pio_mgr,
- struct chnl_object *pchnl, u8 io_mode)
-{
- if (!pio_mgr)
- goto func_end;
-
- /* See if there is any data available for transfer */
- if (io_mode != IO_SERVICE)
- goto func_end;
-
- /* Any channel will do for this mode */
- input_chnl(pio_mgr, pchnl, io_mode);
- output_chnl(pio_mgr, pchnl, io_mode);
-func_end:
- return;
-}
-
-/*
- * ======== io_dispatch_msg ========
- * Performs I/O dispatch on message queues.
- */
-static void io_dispatch_msg(struct io_mgr *pio_mgr, struct msg_mgr *hmsg_mgr)
-{
- if (!pio_mgr)
- goto func_end;
-
- /* We are performing both input and output processing. */
- input_msg(pio_mgr, hmsg_mgr);
- output_msg(pio_mgr, hmsg_mgr);
-func_end:
- return;
-}

/*
* ======== io_dispatch_pm ========
@@ -956,10 +912,17 @@ void io_dpc(unsigned long ref_data)
pio_mgr->intr_val);
}
}
- io_dispatch_chnl(pio_mgr, NULL, IO_SERVICE);
+ /* Proc-copy chanel dispatch */
+ input_chnl(pio_mgr, NULL, IO_SERVICE);
+ output_chnl(pio_mgr, NULL, IO_SERVICE);
+
#ifdef CHNL_MESSAGES
- if (msg_mgr_obj)
- io_dispatch_msg(pio_mgr, msg_mgr_obj);
+ if (msg_mgr_obj) {
+ /* Perform I/O dispatch on message queues */
+ input_msg(pio_mgr, msg_mgr_obj);
+ output_msg(pio_mgr, msg_mgr_obj);
+ }
+
#endif
#ifdef CONFIG_TIDSPBRIDGE_DEBUG
if (pio_mgr->intr_val & MBX_DBG_SYSPRINTF) {
@@ -1162,10 +1125,8 @@ static void input_chnl(struct io_mgr *pio_mgr, struct chnl_object *pchnl,
* buffer.
*/
bytes = min(bytes, chnl_packet_obj->byte_size);
- /* Transfer buffer from DSP side */
- bytes = read_data(pio_mgr->hbridge_context,
- chnl_packet_obj->host_sys_buf,
- pio_mgr->input, bytes);
+ memcpy(chnl_packet_obj->host_sys_buf,
+ pio_mgr->input, bytes);
pchnl->bytes_moved += bytes;
chnl_packet_obj->byte_size = bytes;
chnl_packet_obj->dw_arg = dw_arg;
@@ -1448,10 +1409,10 @@ static void output_chnl(struct io_mgr *pio_mgr, struct chnl_object *pchnl,
chnl_mgr_obj->dw_output_mask &= ~(1 << chnl_id);

/* Transfer buffer to DSP side */
- chnl_packet_obj->byte_size =
- write_data(pio_mgr->hbridge_context, pio_mgr->output,
- chnl_packet_obj->host_sys_buf, min(pio_mgr->usm_buf_size,
- chnl_packet_obj->byte_size));
+ chnl_packet_obj->byte_size = min(pio_mgr->usm_buf_size,
+ chnl_packet_obj->byte_size);
+ memcpy(pio_mgr->output, chnl_packet_obj->host_sys_buf,
+ chnl_packet_obj->byte_size);
pchnl->bytes_moved += chnl_packet_obj->byte_size;
/* Write all 32 bits of arg */
IO_SET_LONG(pio_mgr->hbridge_context, struct shm, sm, arg,
@@ -1697,34 +1658,7 @@ func_end:
return status;
}

-/*
- * ======== read_data ========
- * Copies buffers from the shared memory to the host buffer.
- */
-static u32 read_data(struct bridge_dev_context *dev_ctxt, void *dest,
- void *src, u32 usize)
-{
- memcpy(dest, src, usize);
- return usize;
-}
-
-/*
- * ======== write_data ========
- * Copies buffers from the host side buffer to the shared memory.
- */
-static u32 write_data(struct bridge_dev_context *dev_ctxt, void *dest,
- void *src, u32 usize)
-{
- memcpy(dest, src, usize);
- return usize;
-}
-
/* ZCPY IO routines. */
-void io_intr_dsp2(struct io_mgr *pio_mgr, u16 mb_val)
-{
- sm_interrupt_dsp(pio_mgr->hbridge_context, mb_val);
-}
-
/*
* ======== IO_SHMcontrol ========
* Sets the requested shm setting.
diff --git a/drivers/staging/tidspbridge/include/dspbridge/io_sm.h b/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
index e9a6c19..8b51c37 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
@@ -287,8 +287,6 @@ extern void io_or_set_value(struct bridge_dev_context *dev_ctxt,
extern void io_and_set_value(struct bridge_dev_context *dev_ctxt,
u32 dsp_addr, u32 value);

-extern void io_intr_dsp2(struct io_mgr *pio_mgr, u16 mb_val);
-
extern void io_sm_init(void);

#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
--
1.6.3.3

2010-07-23 01:12:58

by Armando Uribe

[permalink] [raw]
Subject: [PATCH 4/9] staging: tidspbridge: Change macros to static inline functions used in cload

This patch changes the macros to static inline function used
in cload as well adds two definition of const to avoid using magic
numbers

Signed-off-by: Armando Uribe <[email protected]>
---
drivers/staging/tidspbridge/dynload/cload.c | 16 +++++++-------
drivers/staging/tidspbridge/dynload/doff.h | 31 +++++++++++++++++++-------
drivers/staging/tidspbridge/dynload/tramp.c | 2 +-
3 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/tidspbridge/dynload/cload.c b/drivers/staging/tidspbridge/dynload/cload.c
index e48e91b..32150f0 100644
--- a/drivers/staging/tidspbridge/dynload/cload.c
+++ b/drivers/staging/tidspbridge/dynload/cload.c
@@ -528,7 +528,7 @@ static void allocate_sections(struct dload_state *dlthis)
}
#endif
/* allocate target storage for sections that require it */
- if (DS_NEEDS_ALLOCATION(shp)) {
+ if (ds_needs_allocation(shp)) {
*asecs = *DOFFSEC_IS_LDRSEC(shp);
asecs->context = 0; /* zero the context field */
#if BITS_PER_AU > BITS_PER_BYTE
@@ -540,7 +540,7 @@ static void allocate_sections(struct dload_state *dlthis)
if (dlthis->myalloc != NULL) {
if (!dlthis->myalloc->
dload_allocate(dlthis->myalloc, asecs,
- DS_ALIGNMENT(asecs->type))) {
+ ds_alignment(asecs->type))) {
dload_error(dlthis, tgtalloc,
asecs->name, asecs->size);
return;
@@ -1155,7 +1155,7 @@ static void dload_data(struct dload_state *dlthis)
*/
for (curr_sect = 0; curr_sect < dlthis->dfile_hdr.df_no_scns;
curr_sect += 1) {
- if (DS_NEEDS_DOWNLOAD(sptr)) {
+ if (ds_needs_download(sptr)) {
s32 nip;
ldr_addr image_offset = 0;
/* set relocation info for this section */
@@ -1201,7 +1201,7 @@ static void dload_data(struct dload_state *dlthis)
dest = ibuf.bufr;
#ifdef OPT_ZERO_COPY_LOADER
zero_copy = false;
- if (DLOAD_SECT_TYPE(sptr) != DLOAD_CINIT) {
+ if (!dload_check_type(sptr, DLOAD_CINIT) {
dlthis->myio->writemem(dlthis->myio,
&dest,
lptr->load_addr +
@@ -1267,8 +1267,8 @@ static void dload_data(struct dload_state *dlthis)

/* stuff the result into target
* memory */
- if (DLOAD_SECT_TYPE(sptr) ==
- DLOAD_CINIT) {
+ if (dload_check_type(sptr,
+ DLOAD_CINIT)) {
cload_cinit(dlthis,
&ibuf.ipacket);
cinit_processed = true;
@@ -1306,7 +1306,7 @@ static void dload_data(struct dload_state *dlthis)
BYTE_TO_TADDR(ibuf.ipacket.packet_size);
} /* process packets */
/* if this is a BSS section, we may want to fill it */
- if (DLOAD_SECT_TYPE(sptr) != DLOAD_BSS)
+ if (!dload_check_type(sptr, DLOAD_BSS))
goto loop_cont;

if (!(dlthis->myoptions & DLOAD_INITBSS))
@@ -1330,7 +1330,7 @@ static void dload_data(struct dload_state *dlthis)
}
/* if DS_DOWNLOAD_MASK */
/* If not loading, but BSS, zero initialize */
- if (DLOAD_SECT_TYPE(sptr) != DLOAD_BSS)
+ if (!dload_check_type(sptr, DLOAD_BSS))
goto loop_cont;

if (!(dlthis->myoptions & DLOAD_INITBSS))
diff --git a/drivers/staging/tidspbridge/dynload/doff.h b/drivers/staging/tidspbridge/dynload/doff.h
index 5bf9924..c00d189 100644
--- a/drivers/staging/tidspbridge/dynload/doff.h
+++ b/drivers/staging/tidspbridge/dynload/doff.h
@@ -326,19 +326,32 @@ struct reloc_record_t {
/**************************************************************************** */

/* Enum for DOFF section types (bits 0-3 of flag): See dynamic_loader.h */
-
-/* Macros to help processing of sections */
-#define DLOAD_SECT_TYPE(s_hdr) ((s_hdr)->ds_flags & 0xF)
-
+#define DS_SECTION_TYPE_MASK 0xF
/* DS_ALLOCATE indicates whether a section needs space on the target */
#define DS_ALLOCATE_MASK 0x10
-#define DS_NEEDS_ALLOCATION(s_hdr) ((s_hdr)->ds_flags & DS_ALLOCATE_MASK)
-
/* DS_DOWNLOAD indicates that the loader needs to copy bits */
#define DS_DOWNLOAD_MASK 0x20
-#define DS_NEEDS_DOWNLOAD(s_hdr) ((s_hdr)->ds_flags & DS_DOWNLOAD_MASK)
-
/* Section alignment requirement in AUs */
-#define DS_ALIGNMENT(ds_flags) (1 << (((ds_flags) >> 8) & 0xF))
+#define DS_ALIGNMENT_SHIFT 8
+
+static inline bool dload_check_type(struct doff_scnhdr_t *sptr, u32 flag)
+{
+ return (sptr->ds_flags & DS_SECTION_TYPE_MASK) == flag;
+}
+static inline bool ds_needs_allocation(struct doff_scnhdr_t *sptr)
+{
+ return sptr->ds_flags & DS_ALLOCATE_MASK;
+}
+
+static inline bool ds_needs_download(struct doff_scnhdr_t *sptr)
+{
+ return sptr->ds_flags & DS_DOWNLOAD_MASK;
+}
+
+static inline int ds_alignment(u16 ds_flags)
+{
+ return 1 << ((ds_flags >> DS_ALIGNMENT_SHIFT) & DS_SECTION_TYPE_MASK);
+}
+

#endif /* _DOFF_H */
diff --git a/drivers/staging/tidspbridge/dynload/tramp.c b/drivers/staging/tidspbridge/dynload/tramp.c
index 7b593fc..81314d2 100644
--- a/drivers/staging/tidspbridge/dynload/tramp.c
+++ b/drivers/staging/tidspbridge/dynload/tramp.c
@@ -48,7 +48,7 @@ static int priv_tramp_sect_tgt_alloc(struct dload_state *dlthis)
sect_info->load_addr = 0;
ret_val = dlthis->myalloc->dload_allocate(dlthis->myalloc,
sect_info,
- DS_ALIGNMENT
+ ds_alignment
(sect_info->type));

if (ret_val == 0)
--
1.6.3.3

2010-07-23 01:12:56

by Armando Uribe

[permalink] [raw]
Subject: [PATCH 9/9] staging: tidspbridge: Remove unused macros

This patch removes a couple of macros that are not
being used

Signed-off-by: Armando Uribe <[email protected]>
---
.../staging/tidspbridge/dynload/dload_internal.h | 4 ----
drivers/staging/tidspbridge/dynload/getsection.c | 1 -
.../tidspbridge/include/dspbridge/chnldefs.h | 1 -
.../tidspbridge/include/dspbridge/chnlpriv.h | 3 ---
.../staging/tidspbridge/include/dspbridge/dbdefs.h | 11 -----------
.../staging/tidspbridge/include/dspbridge/io_sm.h | 3 ---
.../staging/tidspbridge/include/dspbridge/mbx_sh.h | 14 --------------
drivers/staging/tidspbridge/rmgr/disp.c | 2 --
drivers/staging/tidspbridge/rmgr/nldr.c | 13 -------------
9 files changed, 0 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/tidspbridge/dynload/dload_internal.h b/drivers/staging/tidspbridge/dynload/dload_internal.h
index 5a17e6c..302a7c5 100644
--- a/drivers/staging/tidspbridge/dynload/dload_internal.h
+++ b/drivers/staging/tidspbridge/dynload/dload_internal.h
@@ -310,10 +310,6 @@ extern uint32_t dload_reverse_checksum16(void *data, unsigned siz);
#endif
#endif

-#define IS_DATA_SCN(zzz) (DLOAD_SECTION_TYPE((zzz)->type) != DLOAD_TEXT)
-#define IS_DATA_SCN_NUM(zzz) \
- (DLOAD_SECT_TYPE(&dlthis->sect_hdrs[(zzz)-1]) != DLOAD_TEXT)
-
/*
* exported by reloc.c
*/
diff --git a/drivers/staging/tidspbridge/dynload/getsection.c b/drivers/staging/tidspbridge/dynload/getsection.c
index 51a7167..e0b3771 100644
--- a/drivers/staging/tidspbridge/dynload/getsection.c
+++ b/drivers/staging/tidspbridge/dynload/getsection.c
@@ -252,7 +252,6 @@ int dload_get_section_info(void *minfo, const char *section_name,
}

#define IPH_SIZE (sizeof(struct image_packet_t) - sizeof(u32))
-#define REVERSE_REORDER_MAP(rawmap) ((rawmap) ^ 0x3030303)

/**************************************************************************
* Procedure dload_get_section
diff --git a/drivers/staging/tidspbridge/include/dspbridge/chnldefs.h b/drivers/staging/tidspbridge/include/dspbridge/chnldefs.h
index 0fe3824..5bf5f6b 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/chnldefs.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/chnldefs.h
@@ -40,7 +40,6 @@
#define CHNL_IOCSTATEOS 0x8000 /* End Of Stream reached. */

/* Macros for checking I/O Completion status: */
-#define CHNL_IS_EOS(ioc) (ioc.status & CHNL_IOCSTATEOS)
#define CHNL_IS_IO_COMPLETE(ioc) (!(ioc.status & ~CHNL_IOCSTATEOS))
#define CHNL_IS_IO_CANCELLED(ioc) (ioc.status & CHNL_IOCSTATCANCEL)
#define CHNL_IS_TIMED_OUT(ioc) (ioc.status & CHNL_IOCSTATTIMEOUT)
diff --git a/drivers/staging/tidspbridge/include/dspbridge/chnlpriv.h b/drivers/staging/tidspbridge/include/dspbridge/chnlpriv.h
index fce5ebd..9292100 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/chnlpriv.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/chnlpriv.h
@@ -50,9 +50,6 @@
#define CHNL_STATECANCEL 1 /* I/O was cancelled. */
#define CHNL_STATEEOS 2 /* End Of Stream reached. */

-/* Determine if user supplied an event for this channel: */
-#define CHNL_IS_USER_EVENT(mode) (mode & CHNL_MODEUSEREVENT)
-
/* Macros for checking mode: */
#define CHNL_IS_INPUT(mode) (mode & CHNL_MODEFROMDSP)
#define CHNL_IS_OUTPUT(mode) (!CHNL_IS_INPUT(mode))
diff --git a/drivers/staging/tidspbridge/include/dspbridge/dbdefs.h b/drivers/staging/tidspbridge/include/dspbridge/dbdefs.h
index ffcc326..397e2cb 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/dbdefs.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/dbdefs.h
@@ -120,17 +120,6 @@ static inline bool is_valid_proc_event(u32 x)
return (x == 0 || (x & VALID_PROC_EVENT && !(x & ~VALID_PROC_EVENT)));
}

-#define IS_VALID_NODE_EVENT(x) (((x) == 0) || \
- (((x) & (DSP_NODESTATECHANGE | DSP_NODEMESSAGEREADY)) && \
- !((x) & ~(DSP_NODESTATECHANGE | DSP_NODEMESSAGEREADY))))
-
-#define IS_VALID_STRM_EVENT(x) (((x) == 0) || (((x) & (DSP_STREAMDONE | \
- DSP_STREAMIOCOMPLETION)) && \
- !((x) & ~(DSP_STREAMDONE | \
- DSP_STREAMIOCOMPLETION))))
-
-#define IS_VALID_NOTIFY_MASK(x) ((x) & DSP_SIGNALEVENT)
-
/* The Node UUID structure */
struct dsp_uuid {
u32 ul_data1;
diff --git a/drivers/staging/tidspbridge/include/dspbridge/io_sm.h b/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
index 841ff94..18aec55 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
@@ -30,9 +30,6 @@
#define IO_SERVICE 2
#define IO_MAXSERVICE IO_SERVICE

-#define DSP_FIELD_ADDR(type, field, base, wordsize) \
- ((((s32)&(((type *)0)->field)) / wordsize) + (u32)base)
-
#ifdef CONFIG_TIDSPBRIDGE_DVFS
/* The maximum number of OPPs that are supported */
extern s32 dsp_max_opps;
diff --git a/drivers/staging/tidspbridge/include/dspbridge/mbx_sh.h b/drivers/staging/tidspbridge/include/dspbridge/mbx_sh.h
index 289f6f3..5d165cd 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/mbx_sh.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/mbx_sh.h
@@ -177,22 +177,8 @@
#define MBX_PM_OPP2 1
#define MBX_PM_OPP3 2
#define MBX_PM_OPP4 3
-#define MBX_OLDOPP_EXTRACT(OPPMSG) ((0x00F0 & (OPPMSG)) >> 4)
-#define MBX_NEWOPP_EXTRACT(OPPMSG) (0x000F & (OPPMSG))
-#define MBX_PREVOPP_EXTRACT(OPPMSG) ((0x00F0 & (OPPMSG)) >> 4)
-#define MBX_CUROPP_EXTRACT(OPPMSG) (0x000F & (OPPMSG))

/* Bridge Debug Commands */
#define MBX_DBG_SYSPRINTF (MBX_DBG_CLASS + 0x0)

-/*
- * Useful macros
- */
-/* DSP-DMA channel */
-#define MBX_SETDDMAVAL(x, y) (MBX_DDMA_CLASS | (x << MBX_DDMA_BUFSHIFT) | \
- (y << MBX_DDMA_CHNLSHIFT))
-
-/* Zero-Copy channel */
-#define MBX_SETZCPYVAL(x) (MBX_ZCPY_CLASS | (x << MBX_ZCPY_CHNLSHIFT))
-
#endif /* _MBX_SH_H */
diff --git a/drivers/staging/tidspbridge/rmgr/disp.c b/drivers/staging/tidspbridge/rmgr/disp.c
index 29cf6cd..417faeb 100644
--- a/drivers/staging/tidspbridge/rmgr/disp.c
+++ b/drivers/staging/tidspbridge/rmgr/disp.c
@@ -54,8 +54,6 @@

#define CHNLIOREQS 1

-#define SWAP_WORD(x) (((u32)(x) >> 16) | ((u32)(x) << 16))
-
/*
* ======== disp_object ========
*/
diff --git a/drivers/staging/tidspbridge/rmgr/nldr.c b/drivers/staging/tidspbridge/rmgr/nldr.c
index 33d2872..23b44cf 100644
--- a/drivers/staging/tidspbridge/rmgr/nldr.c
+++ b/drivers/staging/tidspbridge/rmgr/nldr.c
@@ -114,19 +114,6 @@
#define DELETECODEFLAGBIT 5
#define MAXFLAGS 6

-#define IS_INTERNAL(nldr_obj, segid) (((segid) <= MAXSEGID && \
- nldr_obj->seg_table[(segid)] & DYNM_INTERNAL) || \
- (segid) == MEMINTERNALID)
-
-#define IS_EXTERNAL(nldr_obj, segid) (((segid) <= MAXSEGID && \
- nldr_obj->seg_table[(segid)] & DYNM_EXTERNAL) || \
- (segid) == MEMEXTERNALID)
-
-#define SWAPLONG(x) ((((x) << 24) & 0xFF000000) | (((x) << 8) & 0xFF0000L) | \
- (((x) >> 8) & 0xFF00L) | (((x) >> 24) & 0xFF))
-
-#define SWAPWORD(x) ((((x) << 8) & 0xFF00) | (((x) >> 8) & 0xFF))
-
/*
* These names may be embedded in overlay sections to identify which
* node phase the section should be overlayed.
--
1.6.3.3

2010-07-23 01:13:48

by Armando Uribe

[permalink] [raw]
Subject: [PATCH 7/9] staging: tidspbridge: Remove macros used as cast

This patch removes those macros that are used to
perform casts

Signed-off-by: Armando Uribe <[email protected]>
---
drivers/staging/tidspbridge/dynload/cload.c | 19 ++++++-------------
drivers/staging/tidspbridge/dynload/doff.h | 7 ++-----
drivers/staging/tidspbridge/dynload/getsection.c | 16 ++++------------
drivers/staging/tidspbridge/dynload/reloc.c | 2 +-
.../tidspbridge/dynload/reloc_table_c6000.c | 2 +-
.../tidspbridge/dynload/tramp_table_c6000.c | 2 +-
drivers/staging/tidspbridge/pmgr/dbll.c | 5 +----
7 files changed, 16 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/tidspbridge/dynload/cload.c b/drivers/staging/tidspbridge/dynload/cload.c
index 32150f0..c85a5e8 100644
--- a/drivers/staging/tidspbridge/dynload/cload.c
+++ b/drivers/staging/tidspbridge/dynload/cload.c
@@ -20,13 +20,6 @@
#define LINKER_MODULES_HEADER ("_" MODULES_HEADER)

/*
- * we use the fact that DOFF section records are shaped just like
- * ldr_section_info to reduce our section storage usage. This macro marks
- * the places where that assumption is made
- */
-#define DOFFSEC_IS_LDRSEC(pdoffsec) ((struct ldr_section_info *)(pdoffsec))
-
-/*
* forward references
*/
static void dload_symbols(struct dload_state *dlthis);
@@ -519,17 +512,17 @@ static void allocate_sections(struct dload_state *dlthis)
#if BITS_PER_AU <= BITS_PER_BYTE
/* attempt to insert the name of this section */
if (soffset < dlthis->dfile_hdr.df_strtab_size)
- DOFFSEC_IS_LDRSEC(shp)->name = dlthis->str_head +
- soffset;
+ ((struct ldr_section_info *)shp)->name =
+ dlthis->str_head + soffset;
else {
dload_error(dlthis, "Bad name offset in section %d",
curr_sect);
- DOFFSEC_IS_LDRSEC(shp)->name = NULL;
+ ((struct ldr_section_info *)shp)->name = NULL;
}
#endif
/* allocate target storage for sections that require it */
if (ds_needs_allocation(shp)) {
- *asecs = *DOFFSEC_IS_LDRSEC(shp);
+ *asecs = *(struct ldr_section_info *)shp;
asecs->context = 0; /* zero the context field */
#if BITS_PER_AU > BITS_PER_BYTE
asecs->name = unpack_name(dlthis, soffset);
@@ -1162,7 +1155,7 @@ static void dload_data(struct dload_state *dlthis)
if (curr_sect < dlthis->allocated_secn_count)
dlthis->delta_runaddr = sptr->ds_paddr;
else {
- lptr = DOFFSEC_IS_LDRSEC(sptr);
+ lptr = (struct ldr_section_info *)sptr;
dlthis->delta_runaddr = 0;
}
dlthis->image_secn = lptr;
@@ -1337,7 +1330,7 @@ static void dload_data(struct dload_state *dlthis)
goto loop_cont;

if (curr_sect >= dlthis->allocated_secn_count)
- lptr = DOFFSEC_IS_LDRSEC(sptr);
+ lptr = (struct ldr_section_info *)sptr;

if (cinit_processed) {
/*Don't clear BSS after load-time initialization */
diff --git a/drivers/staging/tidspbridge/dynload/doff.h b/drivers/staging/tidspbridge/dynload/doff.h
index c00d189..a7c3145 100644
--- a/drivers/staging/tidspbridge/dynload/doff.h
+++ b/drivers/staging/tidspbridge/dynload/doff.h
@@ -24,11 +24,8 @@
#ifndef _DOFF_H
#define _DOFF_H

-#ifndef UINT32_C
-#define UINT32_C(zzz) ((u32)zzz)
-#endif

-#define BYTE_RESHUFFLE_VALUE UINT32_C(0x00010203)
+#define BYTE_RESHUFFLE_VALUE 0x00010203

/* DOFF file header containing fields categorizing the remainder of the file */
struct doff_filehdr_t {
@@ -312,7 +309,7 @@ struct reloc_record_t {

/* Return the address/size >= to addr that is at a 32-bit boundary */
/* This assumes that a byte is 8 bits */
-#define DOFF_ALIGN(addr) (((addr) + 3) & ~UINT32_C(3))
+#define DOFF_ALIGN(addr) (((addr) + 3) & ~3UL)

/**************************************************************************** */
/* */
diff --git a/drivers/staging/tidspbridge/dynload/getsection.c b/drivers/staging/tidspbridge/dynload/getsection.c
index 3086118..51a7167 100644
--- a/drivers/staging/tidspbridge/dynload/getsection.c
+++ b/drivers/staging/tidspbridge/dynload/getsection.c
@@ -34,14 +34,6 @@ static const char err_alloc[] = { "Syms->dload_allocate( %d ) failed" };
static const char stbl[] = { "Bad string table offset " FMT_UI32 };
#endif

-/*
- * we use the fact that DOFF section records are shaped just like
- * ldr_section_info to reduce our section storage usage. These macros
- * marks the places where that assumption is made
- */
-#define DOFFSEC_IS_LDRSEC(pdoffsec) ((struct ldr_section_info *)(pdoffsec))
-#define LDRSEC_IS_DOFFSEC(ldrsec) ((struct doff_scnhdr_t *)(ldrsec))
-
/************************************************************** */
/********************* SUPPORT FUNCTIONS ********************** */
/************************************************************** */
@@ -110,7 +102,7 @@ static void expand_sec_names(struct dload_state *dlthis)
/* For each sec, copy and expand its name */
curr = xstrings;
for (sec = 0; sec < dlthis->dfile_hdr.df_no_scns; sec++) {
- shp = DOFFSEC_IS_LDRSEC(&dlthis->sect_hdrs[sec]);
+ shp = (struct ldr_section_info *)&dlthis->sect_hdrs[sec];
next = unpack_sec_name(dlthis, *(u32 *) &shp->name, curr);
if (next == NULL)
break; /* error */
@@ -213,7 +205,7 @@ void *dload_module_open(struct dynamic_loader_stream *module,
/* to a pointer into the string table. */
for (sec = 0; sec < dlthis->dfile_hdr.df_no_scns; sec++) {
struct ldr_section_info *shp =
- DOFFSEC_IS_LDRSEC(&dlthis->sect_hdrs[sec]);
+ (struct ldr_section_info *)&dlthis->sect_hdrs[sec];
shp->name = dlthis->str_head + *(u32 *) &shp->name;
}
#endif
@@ -249,7 +241,7 @@ int dload_get_section_info(void *minfo, const char *section_name,
return false;

for (sec = 0; sec < dlthis->dfile_hdr.df_no_scns; sec++) {
- shp = DOFFSEC_IS_LDRSEC(&dlthis->sect_hdrs[sec]);
+ shp = (struct ldr_section_info *)&dlthis->sect_hdrs[sec];
if (strcmp(section_name, shp->name) == 0) {
*section_info = shp;
return true;
@@ -294,7 +286,7 @@ int dload_get_section(void *minfo,
dlthis = (struct dload_state *)minfo;
if (!dlthis)
return false;
- sptr = LDRSEC_IS_DOFFSEC(section_info);
+ sptr = (struct doff_scnhdr_t *)section_info;
if (sptr == NULL)
return false;

diff --git a/drivers/staging/tidspbridge/dynload/reloc.c b/drivers/staging/tidspbridge/dynload/reloc.c
index ec59777..7b28c07 100644
--- a/drivers/staging/tidspbridge/dynload/reloc.c
+++ b/drivers/staging/tidspbridge/dynload/reloc.c
@@ -107,7 +107,7 @@ int dload_repack(struct dload_state *dlthis, rvalue val, tgt_au_t * data,

fieldsz -= 1; /* avoid nastiness with 32-bit shift of 32-bit value */
/* clip the bits */
- mask = ((UINT32_C(2) << fieldsz) - 1);
+ mask = (2UL << fieldsz) - 1;
objval = (val & mask);
/* * store the bits through the specified mask */
if (TARGET_BIG_ENDIAN) {
diff --git a/drivers/staging/tidspbridge/dynload/reloc_table_c6000.c b/drivers/staging/tidspbridge/dynload/reloc_table_c6000.c
index 8ae3b38..a28bc04 100644
--- a/drivers/staging/tidspbridge/dynload/reloc_table_c6000.c
+++ b/drivers/staging/tidspbridge/dynload/reloc_table_c6000.c
@@ -16,7 +16,7 @@

/* Tables generated for c6000 */

-#define HASH_FUNC(zz) (((((zz) + 1) * UINT32_C(1845)) >> 11) & 63)
+#define HASH_FUNC(zz) (((((zz) + 1) * 1845UL) >> 11) & 63)
#define HASH_L(zz) ((zz) >> 8)
#define HASH_I(zz) ((zz) & 0xFF)

diff --git a/drivers/staging/tidspbridge/dynload/tramp_table_c6000.c b/drivers/staging/tidspbridge/dynload/tramp_table_c6000.c
index 47b7492..09cc64f 100644
--- a/drivers/staging/tidspbridge/dynload/tramp_table_c6000.c
+++ b/drivers/staging/tidspbridge/dynload/tramp_table_c6000.c
@@ -27,7 +27,7 @@
#define C6X_TRAMP_MAX_RELOS 8

/* THIS HASH FUNCTION MUST MATCH THE ONE reloc_table_c6000.c */
-#define HASH_FUNC(zz) (((((zz) + 1) * UINT32_C(1845)) >> 11) & 63)
+#define HASH_FUNC(zz) (((((zz) + 1) * 1845UL) >> 11) & 63)

/* THIS MUST MATCH reloc_record_t FOR A SYMBOL BASED RELO */
struct c6000_relo_record {
diff --git a/drivers/staging/tidspbridge/pmgr/dbll.c b/drivers/staging/tidspbridge/pmgr/dbll.c
index e8da030..d1806aa 100644
--- a/drivers/staging/tidspbridge/pmgr/dbll.c
+++ b/drivers/staging/tidspbridge/pmgr/dbll.c
@@ -41,10 +41,7 @@
/* Max buffer length */
#define MAXEXPR 128

-#ifndef UINT32_C
-#define UINT32_C(zzz) ((uint32_t)zzz)
-#endif
-#define DOFF_ALIGN(x) (((x) + 3) & ~UINT32_C(3))
+#define DOFF_ALIGN(x) (((x) + 3) & ~3UL)

/*
* ======== struct dbll_tar_obj* ========
--
1.6.3.3

2010-07-23 01:13:51

by Armando Uribe

[permalink] [raw]
Subject: [PATCH 8/9] staging: tidspbridge: Change macros to static inline functions

This patch changes preprocesing macros to static inline
funcions. Also the function is_equal_uuid (IS_EQUAL_UUID) now uses the
memcmp function.

Signed-off-by: Armando Uribe <[email protected]>
---
.../staging/tidspbridge/include/dspbridge/dbdefs.h | 32 +++++--------------
drivers/staging/tidspbridge/rmgr/nldr.c | 20 +++++-------
drivers/staging/tidspbridge/rmgr/proc.c | 4 +-
3 files changed, 20 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/tidspbridge/include/dspbridge/dbdefs.h b/drivers/staging/tidspbridge/include/dspbridge/dbdefs.h
index 8f84735..ffcc326 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/dbdefs.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/dbdefs.h
@@ -110,29 +110,15 @@
#define DSPTYPE64 0x99

/* Handy Macros */
-#define IS_VALID_PROC_EVENT(x) (((x) == 0) || (((x) & \
- (DSP_PROCESSORSTATECHANGE | \
- DSP_PROCESSORATTACH | \
- DSP_PROCESSORDETACH | \
- DSP_PROCESSORRESTART | \
- DSP_NODESTATECHANGE | \
- DSP_STREAMDONE | \
- DSP_STREAMIOCOMPLETION | \
- DSP_MMUFAULT | \
- DSP_SYSERROR | \
- DSP_WDTOVERFLOW | \
- DSP_PWRERROR)) && \
- !((x) & ~(DSP_PROCESSORSTATECHANGE | \
- DSP_PROCESSORATTACH | \
- DSP_PROCESSORDETACH | \
- DSP_PROCESSORRESTART | \
- DSP_NODESTATECHANGE | \
- DSP_STREAMDONE | \
- DSP_STREAMIOCOMPLETION | \
- DSP_MMUFAULT | \
- DSP_SYSERROR | \
- DSP_WDTOVERFLOW | \
- DSP_PWRERROR))))
+#define VALID_PROC_EVENT (DSP_PROCESSORSTATECHANGE | DSP_PROCESSORATTACH | \
+ DSP_PROCESSORDETACH | DSP_PROCESSORRESTART | DSP_NODESTATECHANGE | \
+ DSP_STREAMDONE | DSP_STREAMIOCOMPLETION | DSP_MMUFAULT | \
+ DSP_SYSERROR | DSP_WDTOVERFLOW | DSP_PWRERROR)
+
+static inline bool is_valid_proc_event(u32 x)
+{
+ return (x == 0 || (x & VALID_PROC_EVENT && !(x & ~VALID_PROC_EVENT)));
+}

#define IS_VALID_NODE_EVENT(x) (((x) == 0) || \
(((x) & (DSP_NODESTATECHANGE | DSP_NODEMESSAGEREADY)) && \
diff --git a/drivers/staging/tidspbridge/rmgr/nldr.c b/drivers/staging/tidspbridge/rmgr/nldr.c
index 6cf0be9..33d2872 100644
--- a/drivers/staging/tidspbridge/rmgr/nldr.c
+++ b/drivers/staging/tidspbridge/rmgr/nldr.c
@@ -135,13 +135,11 @@
#define PDELETE "delete"
#define PEXECUTE "execute"

-#define IS_EQUAL_UUID(uuid1, uuid2) (\
- ((uuid1).ul_data1 == (uuid2).ul_data1) && \
- ((uuid1).us_data2 == (uuid2).us_data2) && \
- ((uuid1).us_data3 == (uuid2).us_data3) && \
- ((uuid1).uc_data4 == (uuid2).uc_data4) && \
- ((uuid1).uc_data5 == (uuid2).uc_data5) && \
- (strncmp((void *)(uuid1).uc_data6, (void *)(uuid2).uc_data6, 6)) == 0)
+static inline bool is_equal_uuid(struct dsp_uuid *uuid1,
+ struct dsp_uuid *uuid2)
+{
+ return !memcmp(uuid1, uuid2, sizeof(struct dsp_uuid));
+}

/*
* ======== mem_seg_info ========
@@ -1487,8 +1485,8 @@ static int load_ovly(struct nldr_nodeobject *nldr_node_obj,

/* Find the node in the table */
for (i = 0; i < nldr_obj->ovly_nodes; i++) {
- if (IS_EQUAL_UUID
- (nldr_node_obj->uuid, nldr_obj->ovly_table[i].uuid)) {
+ if (is_equal_uuid
+ (&nldr_node_obj->uuid, &nldr_obj->ovly_table[i].uuid)) {
/* Found it */
po_node = &(nldr_obj->ovly_table[i]);
break;
@@ -1825,8 +1823,8 @@ static void unload_ovly(struct nldr_nodeobject *nldr_node_obj,

/* Find the node in the table */
for (i = 0; i < nldr_obj->ovly_nodes; i++) {
- if (IS_EQUAL_UUID
- (nldr_node_obj->uuid, nldr_obj->ovly_table[i].uuid)) {
+ if (is_equal_uuid
+ (&nldr_node_obj->uuid, &nldr_obj->ovly_table[i].uuid)) {
/* Found it */
po_node = &(nldr_obj->ovly_table[i]);
break;
diff --git a/drivers/staging/tidspbridge/rmgr/proc.c b/drivers/staging/tidspbridge/rmgr/proc.c
index 4d3db7e..5f189dc 100644
--- a/drivers/staging/tidspbridge/rmgr/proc.c
+++ b/drivers/staging/tidspbridge/rmgr/proc.c
@@ -1879,7 +1879,7 @@ int proc_notify_clients(void *proc, u32 events)
struct proc_object *p_proc_object = (struct proc_object *)proc;

DBC_REQUIRE(p_proc_object);
- DBC_REQUIRE(IS_VALID_PROC_EVENT(events));
+ DBC_REQUIRE(is_valid_proc_event(events));
DBC_REQUIRE(refs > 0);
if (!p_proc_object) {
status = -EFAULT;
@@ -1902,7 +1902,7 @@ int proc_notify_all_clients(void *proc, u32 events)
int status = 0;
struct proc_object *p_proc_object = (struct proc_object *)proc;

- DBC_REQUIRE(IS_VALID_PROC_EVENT(events));
+ DBC_REQUIRE(is_valid_proc_event(events));
DBC_REQUIRE(refs > 0);

if (!p_proc_object) {
--
1.6.3.3

2010-07-23 01:14:17

by Armando Uribe

[permalink] [raw]
Subject: [PATCH 3/9] staging: tidspbridge: Change macros to static inline functions in io_sm

This patch change to macros to static inline functions, these
macros are used to perform write/read operations in shared memory

Signed-off-by: Armando Uribe <[email protected]>
---
drivers/staging/tidspbridge/core/io_sm.c | 22 ++++++++++++-------
.../staging/tidspbridge/include/dspbridge/io_sm.h | 3 --
2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/tidspbridge/core/io_sm.c b/drivers/staging/tidspbridge/core/io_sm.c
index 03960bd..e5e3684 100644
--- a/drivers/staging/tidspbridge/core/io_sm.c
+++ b/drivers/staging/tidspbridge/core/io_sm.c
@@ -149,6 +149,17 @@ static int register_shm_segs(struct io_mgr *hio_mgr,
struct cod_manager *cod_man,
u32 dw_gpp_base_pa);

+static inline void set_chnl_free(struct shm *sm, u32 chnl)
+{
+ sm->host_free_mask &= ~(1 << chnl);
+}
+
+static inline void set_chnl_busy(struct shm *sm, u32 chnl)
+{
+ sm->host_free_mask |= 1 << chnl;
+}
+
+
/*
* ======== bridge_io_create ========
* Create an IO manager object.
@@ -818,8 +829,7 @@ void io_cancel_chnl(struct io_mgr *hio_mgr, u32 chnl)
sm = hio_mgr->shared_mem;

/* Inform DSP that we have no more buffers on this channel */
- IO_AND_VALUE(pio_mgr->hbridge_context, struct shm, sm, host_free_mask,
- (~(1 << chnl)));
+ set_chnl_free(sm, chnl);

sm_interrupt_dsp(pio_mgr->hbridge_context, MBX_PCPY_CLASS);
func_end:
@@ -994,8 +1004,7 @@ void io_request_chnl(struct io_mgr *io_manager, struct chnl_object *pchnl,
DBC_ASSERT((pchnl->dw_state == CHNL_STATEREADY) ||
(pchnl->dw_state == CHNL_STATEEOS));
/* Indicate to the DSP we have a buffer available for input */
- IO_OR_VALUE(io_manager->hbridge_context, struct shm, sm,
- host_free_mask, (1 << pchnl->chnl_id));
+ set_chnl_busy(sm, pchnl->chnl_id);
*mbx_val = MBX_PCPY_CLASS;
} else if (io_mode == IO_OUTPUT) {
/*
@@ -1156,10 +1165,7 @@ static void input_chnl(struct io_mgr *pio_mgr, struct chnl_object *pchnl,
if (!pchnl->pio_requests)
goto func_end;
if (LST_IS_EMPTY(pchnl->pio_requests)) {
- IO_AND_VALUE(pio_mgr->hbridge_context,
- struct shm, sm,
- host_free_mask,
- ~(1 << pchnl->chnl_id));
+ set_chnl_free(sm, pchnl->chnl_id);
}
clear_chnl = true;
notify_client = true;
diff --git a/drivers/staging/tidspbridge/include/dspbridge/io_sm.h b/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
index f1c44f8..841ff94 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/io_sm.h
@@ -33,9 +33,6 @@
#define DSP_FIELD_ADDR(type, field, base, wordsize) \
((((s32)&(((type *)0)->field)) / wordsize) + (u32)base)

-#define IO_OR_VALUE(context, type, base, field, value) (base->field |= value)
-#define IO_AND_VALUE(context, type, base, field, value) (base->field &= value)
-
#ifdef CONFIG_TIDSPBRIDGE_DVFS
/* The maximum number of OPPs that are supported */
extern s32 dsp_max_opps;
--
1.6.3.3

2010-07-23 01:14:19

by Armando Uribe

[permalink] [raw]
Subject: [PATCH 5/9] staging: tidspbridge: Remove redundant macro from cod.c

This patch removes a redundant macro from cod.c simply used
to verify that a field was not NULL

Signed-off-by: Armando Uribe <[email protected]>
---
drivers/staging/tidspbridge/pmgr/cod.c | 27 ++++++++++++---------------
1 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/tidspbridge/pmgr/cod.c b/drivers/staging/tidspbridge/pmgr/cod.c
index 10db8cf..0cbe6e5 100644
--- a/drivers/staging/tidspbridge/pmgr/cod.c
+++ b/drivers/staging/tidspbridge/pmgr/cod.c
@@ -46,9 +46,6 @@
/* magic number for handle validation */
#define MAGIC 0xc001beef

-/* macro to validate COD manager handles */
-#define IS_VALID(h) ((h) != NULL && (h)->ul_magic == MAGIC)
-
/*
* ======== cod_manager ========
*/
@@ -199,7 +196,7 @@ void cod_close(struct cod_libraryobj *lib)

DBC_REQUIRE(refs > 0);
DBC_REQUIRE(lib != NULL);
- DBC_REQUIRE(IS_VALID(((struct cod_libraryobj *)lib)->cod_mgr));
+ DBC_REQUIRE(lib->cod_mgr);

hmgr = lib->cod_mgr;
hmgr->fxns.close_fxn(lib->dbll_lib);
@@ -285,7 +282,7 @@ int cod_create(struct cod_manager **mgr, char *str_zl_file,
void cod_delete(struct cod_manager *cod_mgr_obj)
{
DBC_REQUIRE(refs > 0);
- DBC_REQUIRE(IS_VALID(cod_mgr_obj));
+ DBC_REQUIRE(cod_mgr_obj);

if (cod_mgr_obj->base_lib) {
if (cod_mgr_obj->loaded)
@@ -328,7 +325,7 @@ int cod_get_base_lib(struct cod_manager *cod_mgr_obj,
int status = 0;

DBC_REQUIRE(refs > 0);
- DBC_REQUIRE(IS_VALID(cod_mgr_obj));
+ DBC_REQUIRE(cod_mgr_obj);
DBC_REQUIRE(plib != NULL);

*plib = (struct dbll_library_obj *)cod_mgr_obj->base_lib;
@@ -345,7 +342,7 @@ int cod_get_base_name(struct cod_manager *cod_mgr_obj, char *sz_name,
int status = 0;

DBC_REQUIRE(refs > 0);
- DBC_REQUIRE(IS_VALID(cod_mgr_obj));
+ DBC_REQUIRE(cod_mgr_obj);
DBC_REQUIRE(sz_name != NULL);

if (usize <= COD_MAXPATHLENGTH)
@@ -365,7 +362,7 @@ int cod_get_base_name(struct cod_manager *cod_mgr_obj, char *sz_name,
int cod_get_entry(struct cod_manager *cod_mgr_obj, u32 *entry_pt)
{
DBC_REQUIRE(refs > 0);
- DBC_REQUIRE(IS_VALID(cod_mgr_obj));
+ DBC_REQUIRE(cod_mgr_obj);
DBC_REQUIRE(entry_pt != NULL);

*entry_pt = cod_mgr_obj->ul_entry;
@@ -384,7 +381,7 @@ int cod_get_loader(struct cod_manager *cod_mgr_obj,
int status = 0;

DBC_REQUIRE(refs > 0);
- DBC_REQUIRE(IS_VALID(cod_mgr_obj));
+ DBC_REQUIRE(cod_mgr_obj);
DBC_REQUIRE(loader != NULL);

*loader = (struct dbll_tar_obj *)cod_mgr_obj->target;
@@ -406,7 +403,7 @@ int cod_get_section(struct cod_libraryobj *lib, char *str_sect,

DBC_REQUIRE(refs > 0);
DBC_REQUIRE(lib != NULL);
- DBC_REQUIRE(IS_VALID(lib->cod_mgr));
+ DBC_REQUIRE(lib->cod_mgr);
DBC_REQUIRE(str_sect != NULL);
DBC_REQUIRE(addr != NULL);
DBC_REQUIRE(len != NULL);
@@ -440,7 +437,7 @@ int cod_get_sym_value(struct cod_manager *cod_mgr_obj, char *str_sym,
struct dbll_sym_val *dbll_sym;

DBC_REQUIRE(refs > 0);
- DBC_REQUIRE(IS_VALID(cod_mgr_obj));
+ DBC_REQUIRE(cod_mgr_obj);
DBC_REQUIRE(str_sym != NULL);
DBC_REQUIRE(pul_value != NULL);

@@ -505,7 +502,7 @@ int cod_load_base(struct cod_manager *cod_mgr_obj, u32 num_argc, char *args[],
u32 i;

DBC_REQUIRE(refs > 0);
- DBC_REQUIRE(IS_VALID(cod_mgr_obj));
+ DBC_REQUIRE(cod_mgr_obj);
DBC_REQUIRE(num_argc > 0);
DBC_REQUIRE(args != NULL);
DBC_REQUIRE(args[0] != NULL);
@@ -561,7 +558,7 @@ int cod_open(struct cod_manager *hmgr, char *sz_coff_path,
struct cod_libraryobj *lib = NULL;

DBC_REQUIRE(refs > 0);
- DBC_REQUIRE(IS_VALID(hmgr));
+ DBC_REQUIRE(hmgr);
DBC_REQUIRE(sz_coff_path != NULL);
DBC_REQUIRE(flags == COD_NOLOAD || flags == COD_SYMB);
DBC_REQUIRE(lib_obj != NULL);
@@ -598,7 +595,7 @@ int cod_open_base(struct cod_manager *hmgr, char *sz_coff_path,
struct dbll_library_obj *lib;

DBC_REQUIRE(refs > 0);
- DBC_REQUIRE(IS_VALID(hmgr));
+ DBC_REQUIRE(hmgr);
DBC_REQUIRE(sz_coff_path != NULL);

/* if we previously opened a base image, close it now */
@@ -636,7 +633,7 @@ int cod_read_section(struct cod_libraryobj *lib, char *str_sect,

DBC_REQUIRE(refs > 0);
DBC_REQUIRE(lib != NULL);
- DBC_REQUIRE(IS_VALID(lib->cod_mgr));
+ DBC_REQUIRE(lib->cod_mgr);
DBC_REQUIRE(str_sect != NULL);
DBC_REQUIRE(str_content != NULL);

--
1.6.3.3

2010-07-23 01:14:41

by Armando Uribe

[permalink] [raw]
Subject: [PATCH 6/9] staging: tidspbridge: Remove unused magic number

This patch removes an unused magic number from the cod_manager
structure.

Signed-off-by: Armando Uribe <[email protected]>
---
drivers/staging/tidspbridge/pmgr/cod.c | 7 -------
1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/tidspbridge/pmgr/cod.c b/drivers/staging/tidspbridge/pmgr/cod.c
index 0cbe6e5..81102d2 100644
--- a/drivers/staging/tidspbridge/pmgr/cod.c
+++ b/drivers/staging/tidspbridge/pmgr/cod.c
@@ -43,9 +43,6 @@
/* ----------------------------------- This */
#include <dspbridge/cod.h>

-/* magic number for handle validation */
-#define MAGIC 0xc001beef
-
/*
* ======== cod_manager ========
*/
@@ -58,7 +55,6 @@ struct cod_manager {
struct dbll_fxns fxns;
struct dbll_attrs attrs;
char sz_zl_file[COD_MAXPATHLENGTH];
- u32 ul_magic;
};

/*
@@ -234,8 +230,6 @@ int cod_create(struct cod_manager **mgr, char *str_zl_file,
if (mgr_new == NULL)
return -ENOMEM;

- mgr_new->ul_magic = MAGIC;
-
/* Set up loader functions */
mgr_new->fxns = ldr_fxns;

@@ -295,7 +289,6 @@ void cod_delete(struct cod_manager *cod_mgr_obj)
cod_mgr_obj->fxns.delete_fxn(cod_mgr_obj->target);
cod_mgr_obj->fxns.exit_fxn();
}
- cod_mgr_obj->ul_magic = ~MAGIC;
kfree(cod_mgr_obj);
}

--
1.6.3.3