* into host memory
*/
#define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD) \
- (visorchannel_write(channel, \
- SIG_QUEUE_OFFSET(&channel->chan_hdr, queue) +\
- offsetof(struct signal_queue_header, FIELD), \
- &((sig_hdr)->FIELD), \
- sizeof((sig_hdr)->FIELD)) >= 0)
+ visorchannel_write(channel, \
+ SIG_QUEUE_OFFSET(&channel->chan_hdr, queue) +\
+ offsetof(struct signal_queue_header, FIELD), \
+ &((sig_hdr)->FIELD), \
+ 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,
- SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
- sig_hdr, sizeof(struct signal_queue_header));
- if (err)
- return false;
-
- return true;
+ return visorchannel_read(channel,
+ SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
+ sig_hdr, sizeof(struct signal_queue_header));
}
-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,
- data, sig_hdr->signal_size);
- if (err)
- return false;
-
- return true;
+ return visorchannel_read(channel, signal_data_offset,
+ data, sig_hdr->signal_size);
}
-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,
- data, sig_hdr->signal_size);
- if (err)
- return false;
-
- return true;
+ return visorchannel_write(channel, signal_data_offset,
+ data, sig_hdr->signal_size);
}
-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++;
/*
* 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;
}
/**
rc = signalremove_inner(channel, queue, msg);
}
- return rc;
+ return !rc;
}
EXPORT_SYMBOL_GPL(visorchannel_signalremove);
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;
}
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) {
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++;
* 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;
}
/**
rc = signalinsert_inner(channel, queue, msg);
}
- return rc;
+ return !rc;
}
EXPORT_SYMBOL_GPL(visorchannel_signalinsert);