diff mbox series

[14/15] mini-os: eliminate xenbus union member in struct file

Message ID 20220106115741.3219-15-jgross@suse.com (mailing list archive)
State New, archived
Headers show
Series mini-os: remove struct file dependency from config | expand

Commit Message

Jürgen Groß Jan. 6, 2022, 11:57 a.m. UTC
Replace the xenbus specific union member in struct file with the
common dev pointer.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 include/lib.h |  7 -------
 lib/sys.c     |  2 +-
 lib/xs.c      | 13 +++++++------
 3 files changed, 8 insertions(+), 14 deletions(-)

Comments

Samuel Thibault Jan. 9, 2022, 1:32 a.m. UTC | #1
Juergen Gross, le jeu. 06 janv. 2022 12:57:40 +0100, a ecrit:
> Replace the xenbus 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 |  7 -------
>  lib/sys.c     |  2 +-
>  lib/xs.c      | 13 +++++++------
>  3 files changed, 8 insertions(+), 14 deletions(-)
> 
> diff --git a/include/lib.h b/include/lib.h
> index d6a29ba..91364ba 100644
> --- a/include/lib.h
> +++ b/include/lib.h
> @@ -193,13 +193,6 @@ struct file {
>  	    struct evtchn_port_list ports;
>  	} evtchn;
>  	struct gntmap gntmap;
> -#ifdef CONFIG_XENBUS
> -        struct {
> -            /* To each xenbus FD is associated a queue of watch events for this
> -             * FD.  */
> -            xenbus_event_queue events;
> -        } xenbus;
> -#endif
>      };
>  };
>  
> diff --git a/lib/sys.c b/lib/sys.c
> index 96fc769..6f2b026 100644
> --- a/lib/sys.c
> +++ b/lib/sys.c
> @@ -776,7 +776,7 @@ static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
>  #ifdef CONFIG_XENBUS
>  	case FTYPE_XENBUS:
>  	    if (FD_ISSET(i, readfds)) {
> -                if (files[i].xenbus.events)
> +                if (files[i].dev)
>  		    n++;
>  		else
>  		    FD_CLR(i, readfds);
> diff --git a/lib/xs.c b/lib/xs.c
> index 324bd05..0459f52 100644
> --- a/lib/xs.c
> +++ b/lib/xs.c
> @@ -21,8 +21,8 @@ static inline int _xs_fileno(struct xs_handle *h) {
>  struct xs_handle *xs_daemon_open()
>  {
>      int fd = alloc_fd(FTYPE_XENBUS);
> -    files[fd].xenbus.events = NULL;
> -    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].xenbus.events);
> +    files[fd].dev = NULL;
> +    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].dev);
>      return (void*)(intptr_t) fd;
>  }
>  
> @@ -30,7 +30,7 @@ void xs_daemon_close(struct xs_handle *h)
>  {
>      int fd = _xs_fileno(h);
>      struct xenbus_event *event, *next;
> -    for (event = files[fd].xenbus.events; event; event = next)
> +    for (event = files[fd].dev; event; event = next)
>      {
>          next = event->next;
>          free(event);
> @@ -172,15 +172,16 @@ bool xs_watch(struct xs_handle *h, const char *path, const char *token)
>  {
>      int fd = _xs_fileno(h);
>      printk("xs_watch(%s, %s)\n", path, token);
> -    return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token, &files[fd].xenbus.events));
> +    return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token,
> +                   (xenbus_event_queue *)&files[fd].dev));
>  }
>  
>  char **xs_read_watch(struct xs_handle *h, unsigned int *num)
>  {
>      int fd = _xs_fileno(h);
>      struct xenbus_event *event;
> -    event = files[fd].xenbus.events;
> -    files[fd].xenbus.events = event->next;
> +    event = files[fd].dev;
> +    files[fd].dev = event->next;
>      printk("xs_read_watch() -> %s %s\n", event->path, event->token);
>      *num = 2;
>      return (char **) &event->path;
> -- 
> 2.26.2
>
diff mbox series

Patch

diff --git a/include/lib.h b/include/lib.h
index d6a29ba..91364ba 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -193,13 +193,6 @@  struct file {
 	    struct evtchn_port_list ports;
 	} evtchn;
 	struct gntmap gntmap;
-#ifdef CONFIG_XENBUS
-        struct {
-            /* To each xenbus FD is associated a queue of watch events for this
-             * FD.  */
-            xenbus_event_queue events;
-        } xenbus;
-#endif
     };
 };
 
diff --git a/lib/sys.c b/lib/sys.c
index 96fc769..6f2b026 100644
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -776,7 +776,7 @@  static int select_poll(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exce
 #ifdef CONFIG_XENBUS
 	case FTYPE_XENBUS:
 	    if (FD_ISSET(i, readfds)) {
-                if (files[i].xenbus.events)
+                if (files[i].dev)
 		    n++;
 		else
 		    FD_CLR(i, readfds);
diff --git a/lib/xs.c b/lib/xs.c
index 324bd05..0459f52 100644
--- a/lib/xs.c
+++ b/lib/xs.c
@@ -21,8 +21,8 @@  static inline int _xs_fileno(struct xs_handle *h) {
 struct xs_handle *xs_daemon_open()
 {
     int fd = alloc_fd(FTYPE_XENBUS);
-    files[fd].xenbus.events = NULL;
-    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].xenbus.events);
+    files[fd].dev = NULL;
+    printk("xs_daemon_open -> %d, %p\n", fd, &files[fd].dev);
     return (void*)(intptr_t) fd;
 }
 
@@ -30,7 +30,7 @@  void xs_daemon_close(struct xs_handle *h)
 {
     int fd = _xs_fileno(h);
     struct xenbus_event *event, *next;
-    for (event = files[fd].xenbus.events; event; event = next)
+    for (event = files[fd].dev; event; event = next)
     {
         next = event->next;
         free(event);
@@ -172,15 +172,16 @@  bool xs_watch(struct xs_handle *h, const char *path, const char *token)
 {
     int fd = _xs_fileno(h);
     printk("xs_watch(%s, %s)\n", path, token);
-    return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token, &files[fd].xenbus.events));
+    return xs_bool(xenbus_watch_path_token(XBT_NULL, path, token,
+                   (xenbus_event_queue *)&files[fd].dev));
 }
 
 char **xs_read_watch(struct xs_handle *h, unsigned int *num)
 {
     int fd = _xs_fileno(h);
     struct xenbus_event *event;
-    event = files[fd].xenbus.events;
-    files[fd].xenbus.events = event->next;
+    event = files[fd].dev;
+    files[fd].dev = event->next;
     printk("xs_read_watch() -> %s %s\n", event->path, event->token);
     *num = 2;
     return (char **) &event->path;