summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2007-10-11 20:20:36 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2007-10-11 20:20:36 +0200
commiteadf71abc77bf97cf5aa7dbe206f4778c4b2480d (patch)
treeb777f0f97d094c836300b11cc390ce10678dd417 /fs
parent29fc9471f5b0f18df699f8e47c5a1fbeb5398e9e (diff)
downloadbarebox-eadf71abc77bf97cf5aa7dbe206f4778c4b2480d.tar.gz
barebox-eadf71abc77bf97cf5aa7dbe206f4778c4b2480d.tar.xz
Use Linux kernel list for drivers and devices instead of handmade
list.
Diffstat (limited to 'fs')
-rw-r--r--fs/devfs.c20
1 files changed, 12 insertions, 8 deletions
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 <fs.h>
#include <command.h>
#include <errno.h>
+#include <xfuncs.h>
#include <linux/stat.h>
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;