From eadf71abc77bf97cf5aa7dbe206f4778c4b2480d Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 11 Oct 2007 20:20:36 +0200 Subject: Use Linux kernel list for drivers and devices instead of handmade list. --- fs/devfs.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'fs') diff --git a/fs/devfs.c b/fs/devfs.c index cc8a9d0542..10c2dfeab6 100644 --- a/fs/devfs.c +++ b/fs/devfs.c @@ -27,6 +27,7 @@ #include #include #include +#include #include static int devfs_read(struct device_d *_dev, FILE *f, void *buf, size_t size) @@ -92,11 +93,10 @@ static DIR* devfs_opendir(struct device_d *dev, const char *pathname) { DIR *dir; - dir = malloc(sizeof(DIR)); - if (!dir) - return NULL; + dir = xzalloc(sizeof(DIR)); - dir->priv = get_first_device(); + if (!list_empty(&device_list)) + dir->priv = list_first_entry(&device_list, struct device_d, list); return dir; } @@ -105,12 +105,16 @@ static struct dirent* devfs_readdir(struct device_d *_dev, DIR *dir) { struct device_d *dev = dir->priv; - while (dev && (!strlen(dev->id) || !dev->driver)) - dev = dev->next; + if (!dev) + return NULL; - if (dev) { + list_for_each_entry_from(dev, &device_list, list) { + if (!*dev->id) + continue; + if (!dev->driver) + continue; strcpy(dir->d.d_name, dev->id); - dir->priv = dev->next; + dir->priv = list_entry(dev->list.next, struct device_d, list); return &dir->d; } return NULL; -- cgit v1.2.3