All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: Juergen Gross <jgross@suse.com>
Cc: minios-devel@lists.xenproject.org,
	xen-devel@lists.xenproject.org, wl@xen.org
Subject: Re: [PATCH 02/15] mini-os: makes file.read bool and move it ahead of device specific part
Date: Sun, 9 Jan 2022 02:18:44 +0100	[thread overview]
Message-ID: <20220109011844.ztd7uwre6kb3dzwv@begin> (raw)
In-Reply-To: <20220106115741.3219-3-jgross@suse.com>

Juergen Gross, le jeu. 06 janv. 2022 12:57:28 +0100, a ecrit:
> The read member of struct file should be bool.
> 
> In order to have the device specific part at the end of the structure
> move "read" ahead of that.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
>  blkfront.c             |  4 ++--
>  console/xencons_ring.c |  2 +-
>  fbfront.c              | 12 ++++++------
>  include/lib.h          |  3 ++-
>  netfront.c             |  4 ++--
>  tpm_tis.c              |  2 +-
>  tpmfront.c             |  6 +++---
>  7 files changed, 17 insertions(+), 16 deletions(-)
> 
> diff --git a/blkfront.c b/blkfront.c
> index 834a978..7c8eb74 100644
> --- a/blkfront.c
> +++ b/blkfront.c
> @@ -62,7 +62,7 @@ void blkfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
>      int fd = dev->fd;
>  
>      if (fd != -1)
> -        files[fd].read = 1;
> +        files[fd].read = true;
>  #endif
>      wake_up(&blkfront_queue);
>  }
> @@ -484,7 +484,7 @@ int blkfront_aio_poll(struct blkfront_dev *dev)
>  moretodo:
>  #ifdef HAVE_LIBC
>      if (dev->fd != -1) {
> -        files[dev->fd].read = 0;
> +        files[dev->fd].read = false;
>          mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
>      }
>  #endif
> diff --git a/console/xencons_ring.c b/console/xencons_ring.c
> index b6db74e..c348f3c 100644
> --- a/console/xencons_ring.c
> +++ b/console/xencons_ring.c
> @@ -102,7 +102,7 @@ void console_handle_input(evtchn_port_t port, struct pt_regs *regs, void *data)
>          int fd = dev ? dev->fd : -1;
>  
>          if (fd != -1)
> -            files[fd].read = 1;
> +            files[fd].read = true;
>  
>          wake_up(&console_queue);
>  #else
> diff --git a/fbfront.c b/fbfront.c
> index d3b3848..6725da1 100644
> --- a/fbfront.c
> +++ b/fbfront.c
> @@ -45,7 +45,7 @@ void kbdfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
>      int fd = dev->fd;
>  
>      if (fd != -1)
> -        files[fd].read = 1;
> +        files[fd].read = true;
>  #endif
>      wake_up(&kbdfront_queue);
>  }
> @@ -207,7 +207,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
>  
>  #ifdef HAVE_LIBC
>      if (dev->fd != -1) {
> -        files[dev->fd].read = 0;
> +        files[dev->fd].read = false;
>          mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
>      }
>  #endif
> @@ -229,7 +229,7 @@ int kbdfront_receive(struct kbdfront_dev *dev, union xenkbd_in_event *buf, int n
>  #ifdef HAVE_LIBC
>      if (cons != prod && dev->fd != -1)
>          /* still some events to read */
> -        files[dev->fd].read = 1;
> +        files[dev->fd].read = true;
>  #endif
>  
>      return i;
> @@ -349,7 +349,7 @@ void fbfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data)
>      int fd = dev->fd;
>  
>      if (fd != -1)
> -        files[fd].read = 1;
> +        files[fd].read = true;
>  #endif
>      wake_up(&fbfront_queue);
>  }
> @@ -376,7 +376,7 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
>  
>  #ifdef HAVE_LIBC
>      if (dev->fd != -1) {
> -        files[dev->fd].read = 0;
> +        files[dev->fd].read = false;
>          mb(); /* Make sure to let the handler set read to 1 before we start looking at the ring */
>      }
>  #endif
> @@ -398,7 +398,7 @@ int fbfront_receive(struct fbfront_dev *dev, union xenfb_in_event *buf, int n)
>  #ifdef HAVE_LIBC
>      if (cons != prod && dev->fd != -1)
>          /* still some events to read */
> -        files[dev->fd].read = 1;
> +        files[dev->fd].read = true;
>  #endif
>  
>      return i;
> diff --git a/include/lib.h b/include/lib.h
> index a638bc9..df2de9e 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -49,6 +49,7 @@
>  #define _LIB_H_
>  
>  #include <stdarg.h>
> +#include <stdbool.h>
>  #include <stddef.h>
>  #include <xen/xen.h>
>  #include <xen/event_channel.h>
> @@ -183,6 +184,7 @@ struct evtchn_port_info {
>  
>  struct file {
>      enum fd_type type;
> +    bool read;	/* maybe available for read */
>      union {
>  	struct {
>              /* lwIP fd */
> @@ -235,7 +237,6 @@ struct file {
>          } xenbus;
>  #endif
>      };
> -    int read;	/* maybe available for read */
>  };
>  
>  extern struct file files[];
> diff --git a/netfront.c b/netfront.c
> index dfe065b..a566e34 100644
> --- a/netfront.c
> +++ b/netfront.c
> @@ -255,7 +255,7 @@ void netfront_select_handler(evtchn_port_t port, struct pt_regs *regs, void *dat
>      local_irq_restore(flags);
>  
>      if (fd != -1)
> -        files[fd].read = 1;
> +        files[fd].read = true;
>      wake_up(&netfront_queue);
>  }
>  #endif
> @@ -783,7 +783,7 @@ ssize_t netfront_receive(struct netfront_dev *dev, unsigned char *data, size_t l
>      network_rx(dev);
>      if (!dev->rlen && fd != -1)
>          /* No data for us, make select stop returning */
> -        files[fd].read = 0;
> +        files[fd].read = false;
>      /* Before re-enabling the interrupts, in case a packet just arrived in the
>       * meanwhile. */
>      local_irq_restore(flags);
> diff --git a/tpm_tis.c b/tpm_tis.c
> index 475ac5d..4a51027 100644
> --- a/tpm_tis.c
> +++ b/tpm_tis.c
> @@ -845,7 +845,7 @@ int tpm_tis_send(struct tpm_chip* tpm, uint8_t* buf, size_t len) {
>     }
>  #ifdef HAVE_LIBC
>     if(tpm->fd >= 0) {
> -      files[tpm->fd].read = 0;
> +      files[tpm->fd].read = false;
>        files[tpm->fd].tpm_tis.respgot = 0;
>        files[tpm->fd].tpm_tis.offset = 0;
>     }
> diff --git a/tpmfront.c b/tpmfront.c
> index 6049244..d825b49 100644
> --- a/tpmfront.c
> +++ b/tpmfront.c
> @@ -66,7 +66,7 @@ void tpmfront_handler(evtchn_port_t port, struct pt_regs *regs, void *data) {
>     dev->waiting = 0;
>  #ifdef HAVE_LIBC
>     if(dev->fd >= 0) {
> -      files[dev->fd].read = 1;
> +      files[dev->fd].read = true;
>     }
>  #endif
>     wake_up(&dev->waitq);
> @@ -438,7 +438,7 @@ int tpmfront_send(struct tpmfront_dev* dev, const uint8_t* msg, size_t length)
>     dev->resplen = 0;
>  #ifdef HAVE_LIBC
>     if(dev->fd >= 0) {
> -      files[dev->fd].read = 0;
> +      files[dev->fd].read = false;
>        files[dev->fd].tpmfront.respgot = 0;
>        files[dev->fd].tpmfront.offset = 0;
>     }
> @@ -611,7 +611,7 @@ int tpmfront_posix_fstat(int fd, struct stat* buf)
>  
>     /* If we have a response waiting, then read it now from the backend
>      * so we can get its length*/
> -   if(dev->waiting || (files[dev->fd].read == 1 && !files[dev->fd].tpmfront.respgot)) {
> +   if(dev->waiting || (files[dev->fd].read && !files[dev->fd].tpmfront.respgot)) {
>        if ((rc = tpmfront_recv(dev, &dummybuf, &dummysz)) != 0) {
>  	 errno = EIO;
>  	 return -1;
> -- 
> 2.26.2
> 

-- 
Samuel
> No manual is ever necessary.
May I politely interject here: BULLSHIT.  That's the biggest Apple lie of all!
(Discussion in comp.os.linux.misc on the intuitiveness of interfaces.)


  reply	other threads:[~2022-01-09  1:19 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-06 11:57 [PATCH 00/15] mini-os: remove struct file dependency from config Juergen Gross
2022-01-06 11:57 ` [PATCH 01/15] mini-os: split struct file definition from its usage Juergen Gross
2022-01-09  1:17   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 02/15] mini-os: makes file.read bool and move it ahead of device specific part Juergen Gross
2022-01-09  1:18   ` Samuel Thibault [this message]
2022-01-09  1:21     ` Samuel Thibault
2022-01-09  6:12       ` Juergen Gross
2022-01-09 10:20         ` Samuel Thibault
2022-01-09 10:28           ` Juergen Gross
2022-01-09 10:33             ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 03/15] mini-os: make offset a common struct file member for all types Juergen Gross
2022-01-09  1:23   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 04/15] mini-os: replace multiple fd elements in struct file by common one Juergen Gross
2022-01-09  1:25   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 05/15] mini-os: introduce a common dev pointer in struct file Juergen Gross
2022-01-09  1:25   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 06/15] mini-os: eliminate blkfront union member " Juergen Gross
2022-01-09  1:26   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 07/15] mini-os: eliminate consfront " Juergen Gross
2022-01-09  1:27   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 08/15] mini-os: eliminate fbfront " Juergen Gross
2022-01-09  1:27   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 09/15] mini-os: eliminate kbdfront " Juergen Gross
2022-01-09  1:28   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 10/15] mini-os: eliminate netfront " Juergen Gross
2022-01-09  1:28   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 11/15] mini-os: move tpm respgot member of struct file to device specific data Juergen Gross
2022-01-09  1:30   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 12/15] mini-os: eliminate tpmfront union member in struct file Juergen Gross
2022-01-09  1:30   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 13/15] mini-os: eliminate tpmtis " Juergen Gross
2022-01-09  1:31   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 14/15] mini-os: eliminate xenbus " Juergen Gross
2022-01-09  1:32   ` Samuel Thibault
2022-01-06 11:57 ` [PATCH 15/15] mini-os: introduce get_file_from_fd() Juergen Gross
2022-01-09  1:33   ` Samuel Thibault
2022-01-07  2:39 ` [PATCH 00/15] mini-os: remove struct file dependency from config Samuel Thibault

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=20220109011844.ztd7uwre6kb3dzwv@begin \
    --to=samuel.thibault@ens-lyon.org \
    --cc=jgross@suse.com \
    --cc=minios-devel@lists.xenproject.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /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.