refactor: add a async read/write variant to device ops, with allow async io to be...
[lunaix-os.git] / lunaix-os / hal / rng / rngx86.c
index bb069d7f61d13025f05ad19a05abd248e360b343..5c12ca662c6d95ef19e5c008d84e2427c3e1bde0 100644 (file)
@@ -31,16 +31,17 @@ __rand_rd(struct device* dev, void* buf, size_t offset, size_t len)
 int
 pdev_randdev_init(struct device_def* devdef)
 {
-    struct device* devrand = device_addseq(NULL, NULL, "rand");
+    struct device* devrand = device_allocseq(NULL, NULL);
     devrand->ops.read = __rand_rd;
     devrand->ops.read_page = __rand_rd_pg;
 
+    device_register(devrand, &devdef->class, "rand");
+
     return 0;
 }
 
 static struct device_def devrandx86_def = {
-    .name = "null",
-    .class = DEVCLASS(DEVIF_SOC, DEVFN_CHAR, DEV_RNG, 0),
-    .init = pdev_randdev_init
-};
-EXPORT_DEVICE(randdev, &devrandx86_def, load_earlystage);
\ No newline at end of file
+    .name = "x86 On-Chip RNG",
+    .class = DEVCLASS(DEVIF_SOC, DEVFN_CHAR, DEV_RNG),
+    .init = pdev_randdev_init};
+EXPORT_DEVICE(randdev, &devrandx86_def, load_onboot);
\ No newline at end of file