feat: better rtc framework which aims to remove single rtc restrictions.
[lunaix-os.git] / lunaix-os / kernel / device / device.c
index 6b901a6593958ac2a38fd4ea35009fd62d67c141..979b461b86184a8c1bcdfa18f3ce0f0505f094a1 100644 (file)
@@ -6,6 +6,7 @@
 #include <lunaix/mm/valloc.h>
 #include <lunaix/spike.h>
 #include <lunaix/syscall.h>
+#include <lunaix/syscall_utils.h>
 
 static DEFINE_LLIST(root_list);
 
@@ -15,7 +16,7 @@ struct device*
 device_add(struct device* parent,
            void* underlay,
            char* name_fmt,
-           uint32_t type,
+           u32_t type,
            va_list args)
 {
     struct device* dev = vzalloc(sizeof(struct device));
@@ -43,6 +44,19 @@ device_add(struct device* parent,
     return dev;
 }
 
+struct device*
+device_addsys(struct device* parent, void* underlay, char* name_fmt, ...)
+{
+    va_list args;
+    va_start(args, name_fmt);
+
+    struct device* dev =
+      device_add(parent, underlay, name_fmt, DEV_IFSEQ, args);
+
+    va_end(args);
+    return dev;
+}
+
 struct device*
 device_addseq(struct device* parent, void* underlay, char* name_fmt, ...)
 {
@@ -156,12 +170,12 @@ __DEFINE_LXSYSCALL3(int, ioctl, int, fd, int, req, va_list, args)
         goto done;
     }
 
-    if (!dev->exec_cmd) {
-        errno = EINVAL;
+    if (!dev->ops.exec_cmd) {
+        errno = ENOTSUP;
         goto done;
     }
 
-    errno = dev->exec_cmd(dev, req, args);
+    errno = dev->ops.exec_cmd(dev, req, args);
 
 done:
     return DO_STATUS_OR_RETURN(errno);