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 07/15] mini-os: eliminate consfront union member in struct file
Date: Sun, 9 Jan 2022 02:27:29 +0100	[thread overview]
Message-ID: <20220109012729.kyt3ksnyq3wu6edb@begin> (raw)
In-Reply-To: <20220106115741.3219-8-jgross@suse.com>

Juergen Gross, le jeu. 06 janv. 2022 12:57:33 +0100, a ecrit:
> Replace the consfront specific union member in struct file with the
> common dev pointer.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

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

> ---
>  include/lib.h |  3 ---
>  lib/sys.c     | 31 +++++++++++++++++--------------
>  2 files changed, 17 insertions(+), 17 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index 3a40634..0cedae6 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -202,9 +202,6 @@ struct file {
>  	struct {
>  	    struct fbfront_dev *dev;
>  	} fb;
> -	struct {
> -	    struct consfront_dev *dev;
> -	} cons;
>  #ifdef CONFIG_TPMFRONT
>  	struct {
>  	   struct tpmfront_dev *dev;
> diff --git a/lib/sys.c b/lib/sys.c
> index f2fdbdf..62c2020 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -179,7 +179,7 @@ int posix_openpt(int flags)
>  
>      dev = init_consfront(NULL);
>      dev->fd = alloc_fd(FTYPE_CONSOLE);
> -    files[dev->fd].cons.dev = dev;
> +    files[dev->fd].dev = dev;
>  
>      printk("fd(%d) = posix_openpt\n", dev->fd);
>      return(dev->fd);
> @@ -194,7 +194,7 @@ int open_savefile(const char *path, int save)
>  
>      dev = init_consfront(nodename);
>      dev->fd = alloc_fd(FTYPE_SAVEFILE);
> -    files[dev->fd].cons.dev = dev;
> +    files[dev->fd].dev = dev;
>  
>      printk("fd(%d) = open_savefile\n", dev->fd);
>      return(dev->fd);
> @@ -248,7 +248,7 @@ int read(int fd, void *buf, size_t nbytes)
>              DEFINE_WAIT(w);
>              while(1) {
>                  add_waiter(w, console_queue);
> -                ret = xencons_ring_recv(files[fd].cons.dev, buf, nbytes);
> +                ret = xencons_ring_recv(files[fd].dev, buf, nbytes);
>                  if (ret)
>                      break;
>                  schedule();
> @@ -324,14 +324,14 @@ int write(int fd, const void *buf, size_t nbytes)
>          case FTYPE_SAVEFILE: {
>                  int ret = 0, tot = nbytes;
>                  while (nbytes > 0) {
> -                    ret = xencons_ring_send(files[fd].cons.dev, (char *)buf, nbytes);
> +                    ret = xencons_ring_send(files[fd].dev, (char *)buf, nbytes);
>                      nbytes -= ret;
>                      buf = (char *)buf + ret;
>                  }
>                  return tot - nbytes;
>              }
>  	case FTYPE_CONSOLE:
> -	    console_print(files[fd].cons.dev, (char *)buf, nbytes);
> +	    console_print(files[fd].dev, (char *)buf, nbytes);
>  	    return nbytes;
>  #ifdef HAVE_LWIP
>  	case FTYPE_SOCKET:
> @@ -487,7 +487,7 @@ int close(int fd)
>  #ifdef CONFIG_CONSFRONT
>          case FTYPE_SAVEFILE:
>          case FTYPE_CONSOLE:
> -            fini_consfront(files[fd].cons.dev);
> +            fini_consfront(files[fd].dev);
>              files[fd].type = FTYPE_NONE;
>              return 0;
>  #endif
> @@ -764,7 +764,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>  	    /* Fallthrough.  */
>  	case FTYPE_CONSOLE:
>  	    if (FD_ISSET(i, readfds)) {
> -                if (xencons_ring_avail(files[i].cons.dev))
> +                if (xencons_ring_avail(files[i].dev))
>  		    n++;
>  		else
>  		    FD_CLR(i, readfds);
> @@ -1447,6 +1447,8 @@ const struct termios default_termios = {0,             /* iflag */
>  
>  int tcsetattr(int fildes, int action, const struct termios *tios)
>  {
> +    struct consfront_dev *dev;
> +
>      if (fildes < 0 || fildes >= NOFILE) {
>          errno = EBADF;
>          return -1;
> @@ -1472,21 +1474,21 @@ int tcsetattr(int fildes, int action, const struct termios *tios)
>              return -1;
>      }
>  
> -    if (files[fildes].cons.dev == NULL) {
> +    dev = files[fildes].dev;
> +    if (dev == NULL) {
>          errno = ENOSYS;
>          return -1;
>      }
>  
> -    if (tios->c_oflag & OPOST)
> -        files[fildes].cons.dev->is_raw = false;
> -    else
> -        files[fildes].cons.dev->is_raw = true;
> +    dev->is_raw = !(tios->c_oflag & OPOST);
>  
>      return 0;
>  }
>  
>  int tcgetattr(int fildes, struct termios *tios)
>  {
> +    struct consfront_dev *dev;
> +
>      if (fildes < 0 || fildes >= NOFILE) {
>          errno = EBADF;
>          return -1;
> @@ -1497,7 +1499,8 @@ int tcgetattr(int fildes, struct termios *tios)
>          return -1;
>      }
>  
> -    if (files[fildes].cons.dev == NULL) {
> +    dev = files[fildes].dev;
> +    if (dev == NULL) {
>          errno = ENOSYS;
>          return 0;
>      }
> @@ -1509,7 +1512,7 @@ int tcgetattr(int fildes, struct termios *tios)
>  
>      memcpy(tios, &default_termios, sizeof(struct termios));
>  
> -    if (files[fildes].cons.dev->is_raw)
> +    if (dev->is_raw)
>          tios->c_oflag &= ~OPOST;
>  
>      return 0;
> -- 
> 2.26.2
> 

-- 
Samuel
<s> on se croirait en cool : Some browsers close comments on the first ">" character, so to hide script content from such browsers, you can transpose operands for relational and shift operators (e.g., use "y < x" rather than "x > y") or use scripting language-dependent escapes for ">".
 -+- #ens-mim -+-


  reply	other threads:[~2022-01-09  1:27 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
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 [this message]
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=20220109012729.kyt3ksnyq3wu6edb@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.