All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Kershner <david.kershner@unisys.com>
To: gregkh@linuxfoundation.org,
	driverdev-devel@linuxdriverproject.org,
	sparmaintainer@unisys.com, jes.sorensen@gmail.com
Subject: [PATCH 08/28] staging: unisys: visorbus: Convert macros to functions.
Date: Wed, 30 Aug 2017 13:36:15 -0400	[thread overview]
Message-ID: <79e67fcc393574697bea3f1b2fa32d8a6459458a.1504109643.git-series.david.kershner@unisys.com> (raw)
In-Reply-To: <cover.7bb5ed2411c582ab1e54255b493f8455545061de.1504109643.git-series.david.kershner@unisys.com>

Several macros in visorchannel.c were doing complex arithmetic, converted
them to functions so that valid type checking could be done.

Signed-off-by: David Kershner <david.kershner@unisys.com>
Reviewed-by: Tim Sell <timothy.sell@unisys.com>
---
 drivers/staging/unisys/visorbus/visorchannel.c | 25 +++++++++++--------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/unisys/visorbus/visorchannel.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 3969217..81e428a 100644
--- a/drivers/staging/unisys/visorbus/visorchannel.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -155,17 +155,22 @@ void *visorchannel_get_header(struct visorchannel *channel)
  * Return offset of a specific SIGNAL_QUEUE_HEADER from the beginning of a
  * channel header
  */
-#define SIG_QUEUE_OFFSET(chan_hdr, q) \
-	((chan_hdr)->ch_space_offset + \
-	 ((q) * sizeof(struct signal_queue_header)))
+int sig_queue_offset(struct channel_header *chan_hdr, int q)
+{
+	return ((chan_hdr)->ch_space_offset +
+	       ((q) * sizeof(struct signal_queue_header)));
+}
 
 /*
  * Return offset of a specific queue entry (data) from the beginning of a
  * channel header
  */
-#define SIG_DATA_OFFSET(chan_hdr, q, sig_hdr, slot) \
-	(SIG_QUEUE_OFFSET(chan_hdr, q) + (sig_hdr)->sig_base_offset + \
-	 ((slot) * (sig_hdr)->signal_size))
+int sig_data_offset(struct channel_header *chan_hdr, int q,
+		    struct signal_queue_header *sig_hdr, int slot)
+{
+	return (sig_queue_offset(chan_hdr, q) + sig_hdr->sig_base_offset +
+	       (slot * sig_hdr->signal_size));
+}
 
 /*
  * Write the contents of a specific field within a SIGNAL_QUEUE_HEADER back
@@ -173,7 +178,7 @@ void *visorchannel_get_header(struct visorchannel *channel)
  */
 #define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD) \
 	visorchannel_write(channel, \
-			   SIG_QUEUE_OFFSET(&channel->chan_hdr, queue) + \
+			   sig_queue_offset(&channel->chan_hdr, queue) + \
 			   offsetof(struct signal_queue_header, FIELD), \
 			   &((sig_hdr)->FIELD), \
 			   sizeof((sig_hdr)->FIELD))
@@ -186,7 +191,7 @@ static int sig_read_header(struct visorchannel *channel, u32 queue,
 
 	/* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */
 	return visorchannel_read(channel,
-				 SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
+				 sig_queue_offset(&channel->chan_hdr, queue),
 				 sig_hdr, sizeof(struct signal_queue_header));
 }
 
@@ -194,7 +199,7 @@ static int sig_read_data(struct visorchannel *channel, u32 queue,
 			 struct signal_queue_header *sig_hdr, u32 slot,
 			 void *data)
 {
-	int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
+	int signal_data_offset = sig_data_offset(&channel->chan_hdr, queue,
 						 sig_hdr, slot);
 
 	return visorchannel_read(channel, signal_data_offset,
@@ -205,7 +210,7 @@ static int sig_write_data(struct visorchannel *channel, u32 queue,
 			  struct signal_queue_header *sig_hdr, u32 slot,
 			  void *data)
 {
-	int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
+	int signal_data_offset = sig_data_offset(&channel->chan_hdr, queue,
 						 sig_hdr, slot);
 
 	return visorchannel_write(channel, signal_data_offset,
-- 
git-series 0.9.1
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

  parent reply	other threads:[~2017-08-30 17:37 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30 17:36 [PATCH 00/28] staging: unisys: More updates to make the code more readable David Kershner
2017-08-30 17:36 ` [PATCH 01/28] staging: unisys: use the kernel min define David Kershner
2017-08-30 17:36 ` [PATCH 02/28] staging: unisys: visorbus: visorchipset.c: Fix bug in parser_init_byte_stream David Kershner
2017-08-30 17:36 ` [PATCH 03/28] staging: unisys: visorbus: visorbus_main.c: Fix return values for checks in visorbus_register_visor_driver David Kershner
2017-08-30 17:36 ` [PATCH 04/28] staging: unisys: visornic: Fix up existing function comments David Kershner
2017-08-30 17:36 ` [PATCH 05/28] staging: unisys: visornic: Fix miscellaneous block comment format issues David Kershner
2017-08-30 17:36 ` [PATCH 06/28] staging: unisys: visorbus: Clean up vmcall address function David Kershner
2017-08-30 17:36 ` [PATCH 07/28] staging: unisys: visorbus: Fix parameter alignment David Kershner
2017-08-30 17:36 ` David Kershner [this message]
2017-08-30 17:36 ` [PATCH 09/28] staging: unisys: visorbus: Use __func__ instead of name David Kershner
2017-08-30 17:36 ` [PATCH 10/28] staging: unisys: Don't check for null before getting driver device David Kershner
2017-08-30 17:36 ` [PATCH 11/28] staging: unisys: include: Add comment next to mutex David Kershner
2017-08-30 17:36 ` [PATCH 12/28] staging: unisys: visorbus: Consolidate controlvm channel creation David Kershner
2017-08-30 17:36 ` [PATCH 13/28] staging: unisys: visorbus: Remove useless comment David Kershner
2017-08-30 17:36 ` [PATCH 14/28] staging: unisys: visorbus: Remove useless initialization David Kershner
2017-08-30 17:36 ` [PATCH 15/28] staging: unisys: visorbus: Remove check for valid parm_addr David Kershner
2017-08-30 17:36 ` [PATCH 16/28] staging: unisys: visorbus: Split else if blocks into multiple if David Kershner
2017-08-30 17:36 ` [PATCH 17/28] staging: unisys: Change data to point to visor_controlvm_parameters_header David Kershner
2017-08-30 17:36 ` [PATCH 18/28] staging: unisys: visorbus: Remove useless else clause in visorutil_spar_detect David Kershner
2017-08-30 17:36 ` [PATCH 19/28] staging: unisys: visorbus: remove uneeded initializations David Kershner
2017-08-30 17:36 ` [PATCH 20/28] staging: unisys: visorbus: Move parser functions location in file David Kershner
2017-08-30 17:36 ` [PATCH 21/28] staging: unisys: visorchipset: Shorten parser_init_byte_stream David Kershner
2017-08-30 17:36 ` [PATCH 22/28] staging: unisys: visorbus: use all 80 characters for multi-line messages David Kershner
2017-08-30 17:36 ` [PATCH 23/28] staging: unisys: visornic: Remove unnecessary return values David Kershner
2017-08-30 17:36 ` [PATCH 24/28] staging: unisys: Use size of channel defined in the channel David Kershner
2017-08-30 17:36 ` [PATCH 25/28] staging: unisys: visorbus: just check for GUID David Kershner
2017-08-30 17:36 ` [PATCH 26/28] staging: unisys: visorbus: Fix up GUID definition David Kershner
2017-08-30 17:36 ` [PATCH 27/28] staging: unisys: visorbus: remove EXPORT_SYMBOL_GPL for visor_check_channel David Kershner
2017-08-30 17:36 ` [PATCH 28/28] staging: unisys: change pr_err to dev_err in visor_check_channel David Kershner

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=79e67fcc393574697bea3f1b2fa32d8a6459458a.1504109643.git-series.david.kershner@unisys.com \
    --to=david.kershner@unisys.com \
    --cc=driverdev-devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jes.sorensen@gmail.com \
    --cc=sparmaintainer@unisys.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.