[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 05/11] evtchn: convert evtchn_port_is_*() to plain bool
... at once reducing overall source size by combining some statements and constifying a few pointers. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> --- a/xen/common/event_2l.c +++ b/xen/common/event_2l.c @@ -61,7 +61,7 @@ static void evtchn_2l_unmask(struct doma } } -static bool_t evtchn_2l_is_pending(struct domain *d, evtchn_port_t port) +static bool evtchn_2l_is_pending(const struct domain *d, evtchn_port_t port) { unsigned int max_ports = BITS_PER_EVTCHN_WORD(d) * BITS_PER_EVTCHN_WORD(d); @@ -69,7 +69,7 @@ static bool_t evtchn_2l_is_pending(struc return port < max_ports && test_bit(port, &shared_info(d, evtchn_pending)); } -static bool_t evtchn_2l_is_masked(struct domain *d, evtchn_port_t port) +static bool evtchn_2l_is_masked(const struct domain *d, evtchn_port_t port) { unsigned int max_ports = BITS_PER_EVTCHN_WORD(d) * BITS_PER_EVTCHN_WORD(d); --- a/xen/common/event_fifo.c +++ b/xen/common/event_fifo.c @@ -19,7 +19,7 @@ #include <public/event_channel.h> -static inline event_word_t *evtchn_fifo_word_from_port(struct domain *d, +static inline event_word_t *evtchn_fifo_word_from_port(const struct domain *d, unsigned int port) { unsigned int p, w; @@ -293,37 +293,25 @@ static void evtchn_fifo_unmask(struct do evtchn_fifo_set_pending(v, evtchn); } -static bool_t evtchn_fifo_is_pending(struct domain *d, evtchn_port_t port) +static bool evtchn_fifo_is_pending(const struct domain *d, evtchn_port_t port) { - event_word_t *word; - - word = evtchn_fifo_word_from_port(d, port); - if ( unlikely(!word) ) - return 0; + const event_word_t *word = evtchn_fifo_word_from_port(d, port); - return test_bit(EVTCHN_FIFO_PENDING, word); + return word && test_bit(EVTCHN_FIFO_PENDING, word); } -static bool_t evtchn_fifo_is_masked(struct domain *d, evtchn_port_t port) +static bool_t evtchn_fifo_is_masked(const struct domain *d, evtchn_port_t port) { - event_word_t *word; + const event_word_t *word = evtchn_fifo_word_from_port(d, port); - word = evtchn_fifo_word_from_port(d, port); - if ( unlikely(!word) ) - return 1; - - return test_bit(EVTCHN_FIFO_MASKED, word); + return !word || test_bit(EVTCHN_FIFO_MASKED, word); } -static bool_t evtchn_fifo_is_busy(struct domain *d, evtchn_port_t port) +static bool_t evtchn_fifo_is_busy(const struct domain *d, evtchn_port_t port) { - event_word_t *word; - - word = evtchn_fifo_word_from_port(d, port); - if ( unlikely(!word) ) - return 0; + const event_word_t *word = evtchn_fifo_word_from_port(d, port); - return test_bit(EVTCHN_FIFO_LINKED, word); + return word && test_bit(EVTCHN_FIFO_LINKED, word); } static int evtchn_fifo_set_priority(struct domain *d, struct evtchn *evtchn, --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -137,13 +137,13 @@ struct evtchn_port_ops { void (*set_pending)(struct vcpu *v, struct evtchn *evtchn); void (*clear_pending)(struct domain *d, struct evtchn *evtchn); void (*unmask)(struct domain *d, struct evtchn *evtchn); - bool_t (*is_pending)(struct domain *d, evtchn_port_t port); - bool_t (*is_masked)(struct domain *d, evtchn_port_t port); + bool (*is_pending)(const struct domain *d, evtchn_port_t port); + bool (*is_masked)(const struct domain *d, evtchn_port_t port); /* * Is the port unavailable because it's still being cleaned up * after being closed? */ - bool_t (*is_busy)(struct domain *d, evtchn_port_t port); + bool (*is_busy)(const struct domain *d, evtchn_port_t port); int (*set_priority)(struct domain *d, struct evtchn *evtchn, unsigned int priority); void (*print_state)(struct domain *d, const struct evtchn *evtchn); @@ -174,23 +174,23 @@ static inline void evtchn_port_unmask(st d->evtchn_port_ops->unmask(d, evtchn); } -static inline bool_t evtchn_port_is_pending(struct domain *d, - evtchn_port_t port) +static inline bool evtchn_port_is_pending(const struct domain *d, + evtchn_port_t port) { return d->evtchn_port_ops->is_pending(d, port); } -static inline bool_t evtchn_port_is_masked(struct domain *d, - evtchn_port_t port) +static inline bool evtchn_port_is_masked(const struct domain *d, + evtchn_port_t port) { return d->evtchn_port_ops->is_masked(d, port); } -static inline bool_t evtchn_port_is_busy(struct domain *d, evtchn_port_t port) +static inline bool evtchn_port_is_busy(const struct domain *d, + evtchn_port_t port) { - if ( d->evtchn_port_ops->is_busy ) - return d->evtchn_port_ops->is_busy(d, port); - return 0; + return d->evtchn_port_ops->is_busy && + d->evtchn_port_ops->is_busy(d, port); } static inline int evtchn_port_set_priority(struct domain *d, Attachment:
evtchn-port_is-bool.patch _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |