Commit 1306c429 authored by David Binder's avatar David Binder Committed by Greg Kroah-Hartman

staging: unisys: visorbus: Change support functions to integer return vals

Per Documentation/CodingStyle, function names that convey an action or an
imperative command should return an integer value. This commit changes
several functions and a macro, internal to visorchannel.c, to follow this
paradigm. These changes will be necessary later on to change other
functions in this file, which are part of the visorbus API, to return
integer values in lieu of a boolean.
Signed-off-by: default avatarDavid Binder <david.binder@unisys.com>
Signed-off-by: default avatarDavid Kershner <david.kershner@unisys.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bff8c1a1
......@@ -185,76 +185,66 @@ visorchannel_get_header(struct visorchannel *channel)
* into host memory
*/
#define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD) \
(visorchannel_write(channel, \
visorchannel_write(channel, \
SIG_QUEUE_OFFSET(&channel->chan_hdr, queue) +\
offsetof(struct signal_queue_header, FIELD), \
&((sig_hdr)->FIELD), \
sizeof((sig_hdr)->FIELD)) >= 0)
sizeof((sig_hdr)->FIELD))
static bool
static int
sig_read_header(struct visorchannel *channel, u32 queue,
struct signal_queue_header *sig_hdr)
{
int err;
if (channel->chan_hdr.ch_space_offset < sizeof(struct channel_header))
return false;
return -EINVAL;
/* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */
err = visorchannel_read(channel,
return visorchannel_read(channel,
SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
sig_hdr, sizeof(struct signal_queue_header));
if (err)
return false;
return true;
}
static inline bool
static inline int
sig_read_data(struct visorchannel *channel, u32 queue,
struct signal_queue_header *sig_hdr, u32 slot, void *data)
{
int err;
int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
sig_hdr, slot);
err = visorchannel_read(channel, signal_data_offset,
return visorchannel_read(channel, signal_data_offset,
data, sig_hdr->signal_size);
if (err)
return false;
return true;
}
static inline bool
static inline int
sig_write_data(struct visorchannel *channel, u32 queue,
struct signal_queue_header *sig_hdr, u32 slot, void *data)
{
int err;
int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
sig_hdr, slot);
err = visorchannel_write(channel, signal_data_offset,
return visorchannel_write(channel, signal_data_offset,
data, sig_hdr->signal_size);
if (err)
return false;
return true;
}
static bool
static int
signalremove_inner(struct visorchannel *channel, u32 queue, void *msg)
{
struct signal_queue_header sig_hdr;
int error;
error = sig_read_header(channel, queue, &sig_hdr);
if (error)
return error;
if (!sig_read_header(channel, queue, &sig_hdr))
return false;
if (sig_hdr.head == sig_hdr.tail)
return false; /* no signals to remove */
return -EIO; /* no signals to remove */
sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots;
if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg))
return false;
error = sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg);
if (error)
return error;
sig_hdr.num_received++;
/*
......@@ -262,11 +252,15 @@ signalremove_inner(struct visorchannel *channel, u32 queue, void *msg)
* update host memory.
*/
mb(); /* required for channel synch */
if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail))
return false;
if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received))
return false;
return true;
error = SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail);
if (error)
return error;
error = SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received);
if (error)
return error;
return 0;
}
/**
......@@ -292,7 +286,7 @@ visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg)
rc = signalremove_inner(channel, queue, msg);
}
return rc;
return !rc;
}
EXPORT_SYMBOL_GPL(visorchannel_signalremove);
......@@ -315,7 +309,7 @@ visorchannel_signalempty(struct visorchannel *channel, u32 queue)
if (channel->needs_lock)
spin_lock_irqsave(&channel->remove_lock, flags);
if (!sig_read_header(channel, queue, &sig_hdr))
if (sig_read_header(channel, queue, &sig_hdr))
rc = true;
if (sig_hdr.head == sig_hdr.tail)
rc = true;
......@@ -326,13 +320,15 @@ visorchannel_signalempty(struct visorchannel *channel, u32 queue)
}
EXPORT_SYMBOL_GPL(visorchannel_signalempty);
static bool
static int
signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
{
struct signal_queue_header sig_hdr;
int error;
if (!sig_read_header(channel, queue, &sig_hdr))
return false;
error = sig_read_header(channel, queue, &sig_hdr);
if (error)
return error;
sig_hdr.head = (sig_hdr.head + 1) % sig_hdr.max_slots;
if (sig_hdr.head == sig_hdr.tail) {
......@@ -343,11 +339,12 @@ signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
num_overflows),
&sig_hdr.num_overflows,
sizeof(sig_hdr.num_overflows));
return false;
return -EIO;
}
if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg))
return false;
error = sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg);
if (error)
return error;
sig_hdr.num_sent++;
......@@ -356,12 +353,15 @@ signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
* update host memory.
*/
mb(); /* required for channel synch */
if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, head))
return false;
if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent))
return false;
return true;
error = SIG_WRITE_FIELD(channel, queue, &sig_hdr, head);
if (error)
return error;
error = SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent);
if (error)
return error;
return 0;
}
/**
......@@ -509,6 +509,6 @@ visorchannel_signalinsert(struct visorchannel *channel, u32 queue, void *msg)
rc = signalinsert_inner(channel, queue, msg);
}
return rc;
return !rc;
}
EXPORT_SYMBOL_GPL(visorchannel_signalinsert);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment