It makes life easier if certain simple devices (ex, things like #version),
would not have to declare empty stubs for functions it does not need to
have.


https://github.com/brho/akaros/compare/master...dlibenzi:tollerate_missing_devfuncs


The following changes since commit c8a6943551e4eb433c058e258bca0a99e713d581:

  Rename backtrace_kframe -> backtrace_hwtf [2/2] (2015-12-10 11:26:40
-0500)

are available in the git repository at:

  [email protected]:dlibenzi/akaros tollerate_missing_devfuncs

for you to fetch changes up to b2b238bfd135d435a390d36067eb472aaa4c239b:

  Allow for certain device APIs to be NULL (2015-12-15 14:42:17 -0800)

----------------------------------------------------------------
Davide Libenzi (1):
      Allow for certain device APIs to be NULL

 kern/src/ns/chan.c   | 18 ++++++++++++------
 kern/src/ns/devtab.c | 15 ++++++++++-----
 2 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/kern/src/ns/chan.c b/kern/src/ns/chan.c
index 918f289..ca2c965 100644
--- a/kern/src/ns/chan.c
+++ b/kern/src/ns/chan.c
@@ -116,16 +116,20 @@ void chandevreset(void)
 {
  int i;

- for (i = 0; &devtab[i] < __devtabend; i++)
- devtab[i].reset();
+ for (i = 0; &devtab[i] < __devtabend; i++) {
+ if (devtab[i].reset)
+ devtab[i].reset();
+ }
 }

 void chandevinit(void)
 {
  int i;

- for (i = 0; &devtab[i] < __devtabend; i++)
- devtab[i].init();
+ for (i = 0; &devtab[i] < __devtabend; i++) {
+ if (devtab[i].init)
+ devtab[i].init();
+ }
 }

 void chandevshutdown(void)
@@ -134,8 +138,10 @@ void chandevshutdown(void)

  /* shutdown in reverse order */
  for (i = 0; &devtab[i] < __devtabend; i++) ;
- for (i--; i >= 0; i--)
- devtab[i].shutdown();
+ for (i--; i >= 0; i--) {
+ if (devtab[i].shutdown)
+ devtab[i].shutdown();
+ }
 }

 static void chan_release(struct kref *kref)
diff --git a/kern/src/ns/devtab.c b/kern/src/ns/devtab.c
index 40ef1e3..7f1c5ab 100644
--- a/kern/src/ns/devtab.c
+++ b/kern/src/ns/devtab.c
@@ -20,8 +20,10 @@ void devtabreset()
 {
  int i;

- for (i = 0; &devtab[i] < __devtabend; i++)
- devtab[i].reset();
+ for (i = 0; &devtab[i] < __devtabend; i++) {
+ if (devtab[i].reset)
+ devtab[i].reset();
+ }
 }

 void devtabinit()
@@ -32,7 +34,8 @@ void devtabinit()
  /* if we have errors, check the align of struct dev and objdump */
  printd("i %d, '%s', dev %p, init %p\n", i, devtab[i].name,
  &devtab[i], devtab[i].init);
- devtab[i].init();
+ if (devtab[i].init)
+ devtab[i].init();
  }
 }

@@ -44,8 +47,10 @@ void devtabshutdown()
  * Shutdown in reverse order.
  */
  for (i = 0; &devtab[i] < __devtabend; i++) ;
- for (i--; i >= 0; i--)
- devtab[i].shutdown();
+ for (i--; i >= 0; i--) {
+ if (devtab[i].shutdown)
+ devtab[i].shutdown();
+ }
 }

 struct dev *devtabget(const char *name, int user)

-- 
You received this message because you are subscribed to the Google Groups 
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to