mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Armando Uribe <x0095078@ti.com>
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: Omar Ramirez Luna <omar.ramirez@ti.com>,
	Ohad Ben-Cohen <ohad@wizery.com>,
	Ameya Palande <ameya.palande@nokia.com>,
	<linux-kernel@vger.kernel.org>, <devel@driverdev.osuosl.org>,
	Rene Sapiens <rene.sapiens@ti.com>,
	Felipe Contreras <felipe.contreras@gmail.com>,
	Armando Uribe <x0095078@ti.com>
Subject: [PATCH 8/9] staging: tidspbridge: Change macros to static inline functions
Date: Thu, 22 Jul 2010 20:25:33 -0500	[thread overview]
Message-ID: <1279848334-4043-9-git-send-email-x0095078@ti.com> (raw)
In-Reply-To: <1279848334-4043-8-git-send-email-x0095078@ti.com>

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 <x0095078@ti.com>
---
 .../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


  reply	other threads:[~2010-07-23  1:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-23  1:25 [PATCH 0/9] staging: tidspbridge: Code Clean Up related to macros Armando Uribe
2010-07-23  1:25 ` [PATCH 1/9] staging: tidspbridge: Remove Redundant wrappers Armando Uribe
2010-07-23  1:25   ` [PATCH 2/9] staging: tidspbridge: Remove redundant macros in io_sm.c Armando Uribe
2010-07-23  1:25     ` [PATCH 3/9] staging: tidspbridge: Change macros to static inline functions in io_sm Armando Uribe
2010-07-23  1:25       ` [PATCH 4/9] staging: tidspbridge: Change macros to static inline functions used in cload Armando Uribe
2010-07-23  1:25         ` [PATCH 5/9] staging: tidspbridge: Remove redundant macro from cod.c Armando Uribe
2010-07-23  1:25           ` [PATCH 6/9] staging: tidspbridge: Remove unused magic number Armando Uribe
2010-07-23  1:25             ` [PATCH 7/9] staging: tidspbridge: Remove macros used as cast Armando Uribe
2010-07-23  1:25               ` Armando Uribe [this message]
2010-07-23  1:25                 ` [PATCH 9/9] staging: tidspbridge: Remove unused macros Armando Uribe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1279848334-4043-9-git-send-email-x0095078@ti.com \
    --to=x0095078@ti.com \
    --cc=ameya.palande@nokia.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=felipe.contreras@gmail.com \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ohad@wizery.com \
    --cc=omar.ramirez@ti.com \
    --cc=rene.sapiens@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®