summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-04-24 19:41:12 -0400
committerIan Moffett <ian@osmora.org>2024-04-24 19:41:12 -0400
commit97d888144dc6c4773bb5310cc2bd68f06c9d88ee (patch)
tree732459a6e0828dd91da46967ede0df5571c7fdf4 /sys
parentee7d9a7237794b4b8b67a19a244ffb3bf69d34e4 (diff)
kernel: device: Replace DEVICE_ALLOC()
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ic/nvme.c2
-rw-r--r--sys/dev/video/fbdev.c2
-rw-r--r--sys/include/sys/device.h16
3 files changed, 16 insertions, 4 deletions
diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c
index f471627..73533da 100644
--- a/sys/dev/ic/nvme.c
+++ b/sys/dev/ic/nvme.c
@@ -406,7 +406,7 @@ nvme_init_ns(struct nvme_state *state, uint16_t nsid)
ns->cntl = state;
nvme_create_ioq(ns, ns->nsid);
- dev = DEVICE_ALLOC();
+ dev = device_alloc();
dev->read = nvme_dev_read;
dev->write = nvme_dev_write;
dev->blocksize = ns->lba_bsize;
diff --git a/sys/dev/video/fbdev.c b/sys/dev/video/fbdev.c
index 70031a0..1f20ab6 100644
--- a/sys/dev/video/fbdev.c
+++ b/sys/dev/video/fbdev.c
@@ -75,7 +75,7 @@ fbdev_get_front(void)
static int
fbdev_init(void)
{
- dev = DEVICE_ALLOC();
+ dev = device_alloc();
dev->blocksize = 1;
dev->read = NULL;
dev->write = NULL;
diff --git a/sys/include/sys/device.h b/sys/include/sys/device.h
index 8695ab6..a3ce983 100644
--- a/sys/include/sys/device.h
+++ b/sys/include/sys/device.h
@@ -33,10 +33,9 @@
#include <sys/sio.h>
#include <sys/queue.h>
#include <sys/types.h>
+#include <string.h>
#include <vm/dynalloc.h>
-#define DEVICE_ALLOC() dynalloc(sizeof(struct device))
-
struct device {
dev_t major, minor;
size_t blocksize;
@@ -46,6 +45,19 @@ struct device {
TAILQ_ENTRY(device) link;
};
+static inline struct device *
+device_alloc(void)
+{
+ struct device *dev;
+
+ dev = dynalloc(sizeof(struct device));
+ if (dev == NULL)
+ return dev;
+
+ memset(dev, 0, sizeof(struct device));
+ return dev;
+}
+
struct device *device_fetch(dev_t major, dev_t minor);
dev_t device_alloc_major(void);
dev_t device_create(struct device *dev, dev_t major, dev_t minor);