From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH 05/11] evtchn: convert evtchn_port_is_*() to plain bool Date: Wed, 21 Jun 2017 03:34:07 -0600 Message-ID: <594A59AF020000780016505A@prv-mh.provo.novell.com> References: <594A57B10200007800165012@prv-mh.provo.novell.com> <594A57B10200007800165012@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartD9E1C79F.3__=" Return-path: Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dNc1c-0008NL-0p for xen-devel@lists.xenproject.org; Wed, 21 Jun 2017 09:34:12 +0000 In-Reply-To: <594A57B10200007800165012@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: xen-devel Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartD9E1C79F.3__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline ... at once reducing overall source size by combining some statements and constifying a few pointers. Signed-off-by: Jan Beulich --- a/xen/common/event_2l.c +++ b/xen/common/event_2l.c @@ -61,7 +61,7 @@ static void evtchn_2l_unmask(struct doma } } =20 -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 =3D BITS_PER_EVTCHN_WORD(d) * BITS_PER_EVTCHN_W= ORD(d); =20 @@ -69,7 +69,7 @@ static bool_t evtchn_2l_is_pending(struc return port < max_ports && test_bit(port, &shared_info(d, evtchn_pendi= ng)); } =20 -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 =3D BITS_PER_EVTCHN_WORD(d) * BITS_PER_EVTCHN_W= ORD(d); =20 --- a/xen/common/event_fifo.c +++ b/xen/common/event_fifo.c @@ -19,7 +19,7 @@ =20 #include =20 -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); } =20 -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 =3D evtchn_fifo_word_from_port(d, port); - if ( unlikely(!word) ) - return 0; + const event_word_t *word =3D evtchn_fifo_word_from_port(d, port); =20 - return test_bit(EVTCHN_FIFO_PENDING, word); + return word && test_bit(EVTCHN_FIFO_PENDING, word); } =20 -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 =3D evtchn_fifo_word_from_port(d, port); =20 - word =3D 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); } =20 -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 =3D evtchn_fifo_word_from_port(d, port); - if ( unlikely(!word) ) - return 0; + const event_word_t *word =3D evtchn_fifo_word_from_port(d, port); =20 - return test_bit(EVTCHN_FIFO_LINKED, word); + return word && test_bit(EVTCHN_FIFO_LINKED, word); } =20 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); } =20 -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); } =20 -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); } =20 -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); } =20 static inline int evtchn_port_set_priority(struct domain *d, --=__PartD9E1C79F.3__= Content-Type: text/plain; name="evtchn-port_is-bool.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="evtchn-port_is-bool.patch" evtchn: convert evtchn_port_is_*() to plain bool=0A=0A... at once reducing = overall source size by combining some statements=0Aand constifying a few = pointers.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/xen/common/event_2l.c=0A+++ b/xen/common/event_2l.c=0A@@ -61,7 +61,7 @@ = static void evtchn_2l_unmask(struct doma=0A }=0A }=0A =0A-static = bool_t evtchn_2l_is_pending(struct domain *d, evtchn_port_t port)=0A+static= bool evtchn_2l_is_pending(const struct domain *d, evtchn_port_t port)=0A = {=0A unsigned int max_ports =3D BITS_PER_EVTCHN_WORD(d) * BITS_PER_EVTC= HN_WORD(d);=0A =0A@@ -69,7 +69,7 @@ static bool_t evtchn_2l_is_pending(stru= c=0A return port < max_ports && test_bit(port, &shared_info(d, = evtchn_pending));=0A }=0A =0A-static bool_t evtchn_2l_is_masked(struct = domain *d, evtchn_port_t port)=0A+static bool evtchn_2l_is_masked(const = struct domain *d, evtchn_port_t port)=0A {=0A unsigned int max_ports = =3D BITS_PER_EVTCHN_WORD(d) * BITS_PER_EVTCHN_WORD(d);=0A =0A--- a/xen/comm= on/event_fifo.c=0A+++ b/xen/common/event_fifo.c=0A@@ -19,7 +19,7 @@=0A =0A = #include =0A =0A-static inline event_word_t = *evtchn_fifo_word_from_port(struct domain *d,=0A+static inline event_word_t= *evtchn_fifo_word_from_port(const struct domain *d,=0A = unsigned int port)=0A {=0A = unsigned int p, w;=0A@@ -293,37 +293,25 @@ static void evtchn_fifo_unmask(s= truct do=0A evtchn_fifo_set_pending(v, evtchn);=0A }=0A =0A-static = bool_t evtchn_fifo_is_pending(struct domain *d, evtchn_port_t port)=0A+stat= ic bool evtchn_fifo_is_pending(const struct domain *d, evtchn_port_t = port)=0A {=0A- event_word_t *word;=0A-=0A- word =3D evtchn_fifo_word_= from_port(d, port);=0A- if ( unlikely(!word) )=0A- return 0;=0A+ = const event_word_t *word =3D evtchn_fifo_word_from_port(d, port);=0A = =0A- return test_bit(EVTCHN_FIFO_PENDING, word);=0A+ return word && = test_bit(EVTCHN_FIFO_PENDING, word);=0A }=0A =0A-static bool_t evtchn_fifo_= is_masked(struct domain *d, evtchn_port_t port)=0A+static bool_t evtchn_fif= o_is_masked(const struct domain *d, evtchn_port_t port)=0A {=0A- = event_word_t *word;=0A+ const event_word_t *word =3D evtchn_fifo_word_fr= om_port(d, port);=0A =0A- word =3D evtchn_fifo_word_from_port(d, = port);=0A- if ( unlikely(!word) )=0A- return 1;=0A-=0A- = return test_bit(EVTCHN_FIFO_MASKED, word);=0A+ return !word || = test_bit(EVTCHN_FIFO_MASKED, word);=0A }=0A =0A-static bool_t evtchn_fifo_i= s_busy(struct domain *d, evtchn_port_t port)=0A+static bool_t evtchn_fifo_i= s_busy(const struct domain *d, evtchn_port_t port)=0A {=0A- event_word_t= *word;=0A-=0A- word =3D evtchn_fifo_word_from_port(d, port);=0A- if = ( unlikely(!word) )=0A- return 0;=0A+ const event_word_t *word = =3D evtchn_fifo_word_from_port(d, port);=0A =0A- return test_bit(EVTCHN_= FIFO_LINKED, word);=0A+ return word && test_bit(EVTCHN_FIFO_LINKED, = word);=0A }=0A =0A static int evtchn_fifo_set_priority(struct domain *d, = struct evtchn *evtchn,=0A--- a/xen/include/xen/event.h=0A+++ b/xen/include/= xen/event.h=0A@@ -137,13 +137,13 @@ struct evtchn_port_ops {=0A void = (*set_pending)(struct vcpu *v, struct evtchn *evtchn);=0A void = (*clear_pending)(struct domain *d, struct evtchn *evtchn);=0A void = (*unmask)(struct domain *d, struct evtchn *evtchn);=0A- bool_t = (*is_pending)(struct domain *d, evtchn_port_t port);=0A- bool_t = (*is_masked)(struct domain *d, evtchn_port_t port);=0A+ bool (*is_pendin= g)(const struct domain *d, evtchn_port_t port);=0A+ bool (*is_masked)(co= nst struct domain *d, evtchn_port_t port);=0A /*=0A * Is the port = unavailable because it's still being cleaned up=0A * after being = closed?=0A */=0A- bool_t (*is_busy)(struct domain *d, evtchn_port_t= port);=0A+ bool (*is_busy)(const struct domain *d, evtchn_port_t = port);=0A int (*set_priority)(struct domain *d, struct evtchn = *evtchn,=0A unsigned int priority);=0A void = (*print_state)(struct domain *d, const struct evtchn *evtchn);=0A@@ = -174,23 +174,23 @@ static inline void evtchn_port_unmask(st=0A = d->evtchn_port_ops->unmask(d, evtchn);=0A }=0A =0A-static inline bool_t = evtchn_port_is_pending(struct domain *d,=0A- = evtchn_port_t port)=0A+static inline bool evtchn_port_is_pendi= ng(const struct domain *d,=0A+ = evtchn_port_t port)=0A {=0A return d->evtchn_port_ops->is_pending(d, = port);=0A }=0A =0A-static inline bool_t evtchn_port_is_masked(struct = domain *d,=0A- evtchn_port_t = port)=0A+static inline bool evtchn_port_is_masked(const struct domain = *d,=0A+ evtchn_port_t port)=0A = {=0A return d->evtchn_port_ops->is_masked(d, port);=0A }=0A =0A-static = inline bool_t evtchn_port_is_busy(struct domain *d, evtchn_port_t = port)=0A+static inline bool evtchn_port_is_busy(const struct domain = *d,=0A+ evtchn_port_t port)=0A {=0A- = if ( d->evtchn_port_ops->is_busy )=0A- return d->evtchn_port_ops-= >is_busy(d, port);=0A- return 0;=0A+ return d->evtchn_port_ops->is_bu= sy &&=0A+ d->evtchn_port_ops->is_busy(d, port);=0A }=0A =0A = static inline int evtchn_port_set_priority(struct domain *d,=0A --=__PartD9E1C79F.3__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --=__PartD9E1C79F.3__=--