diff options
author | kay.sievers@vrfy.org <kay.sievers@vrfy.org> | 2005-03-04 21:33:57 +0100 |
---|---|---|
committer | Greg KH <gregkh@suse.de> | 2005-04-26 23:39:48 -0700 |
commit | f0308095c78fd68c29be9b3b391bc1c077afa04c (patch) | |
tree | 3a932afd373dd9b2ea447f392acf1dbf7392b037 | |
parent | 03cfa1394fcc2c4386f8af22e5a4d9fdd7cecc50 (diff) |
[PATCH] remove typedef for call_foreach_file() handler function
-rw-r--r-- | namedev_parse.c | 9 | ||||
-rw-r--r-- | udev.h | 1 | ||||
-rw-r--r-- | udev_db.h | 2 | ||||
-rw-r--r-- | udev_multiplex.c | 11 | ||||
-rw-r--r-- | udev_utils.c | 14 | ||||
-rw-r--r-- | udev_utils.h | 12 |
6 files changed, 25 insertions, 24 deletions
diff --git a/namedev_parse.c b/namedev_parse.c index ed38db4b14..e360565950 100644 --- a/namedev_parse.c +++ b/namedev_parse.c @@ -98,7 +98,7 @@ static char *get_key_attribute(char *str) return NULL; } -static int namedev_parse(const char *filename, void *data) +static int namedev_parse(struct udevice *udev, const char *filename) { char line[LINE_SIZE]; char *bufline; @@ -354,9 +354,9 @@ int namedev_init(void) return -1; if ((stats.st_mode & S_IFMT) != S_IFDIR) - retval = namedev_parse(udev_rules_filename, NULL); + retval = namedev_parse(NULL, udev_rules_filename); else - retval = call_foreach_file(namedev_parse, udev_rules_filename, RULEFILE_SUFFIX, NULL); + retval = call_foreach_file(namedev_parse, NULL, udev_rules_filename, RULEFILE_SUFFIX); return retval; } @@ -364,8 +364,9 @@ int namedev_init(void) void namedev_close(void) { struct config_device *dev; + struct config_device *temp_dev; - list_for_each_entry(dev, &config_device_list, node) { + list_for_each_entry_safe(dev, temp_dev, &config_device_list, node) { list_del(&dev->node); free(dev); } @@ -4,6 +4,7 @@ * Userspace devfs * * Copyright (C) 2003 Greg Kroah-Hartman <greg@kroah.com> + * Copyright (C) 2003-2005 Kay Sievers <kay.sievers@vrfy.org> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -28,7 +28,7 @@ extern int udev_db_add_device(struct udevice *dev); extern int udev_db_delete_device(struct udevice *dev); -extern int udev_db_get_device_by_devpath(struct udevice *dev, const char *devpath); +extern int udev_db_get_device_by_devpath(struct udevice *udev, const char *devpath); extern int udev_db_get_device_by_name(struct udevice *udev, const char *name); extern int udev_db_call_foreach(int (*handler_function)(struct udevice *udev)); diff --git a/udev_multiplex.c b/udev_multiplex.c index 3a484068ff..6d7852dbc0 100644 --- a/udev_multiplex.c +++ b/udev_multiplex.c @@ -31,11 +31,10 @@ #include "udev_utils.h" #include "logging.h" -static int run_program(const char *filename, void *data) +static int run_program(struct udevice *udev, const char *filename) { pid_t pid; int fd; - struct udevice *udev = data; dbg("running %s", filename); @@ -89,7 +88,7 @@ void udev_multiplex_directory(struct udevice *udev, const char *basedir, const c if (strcmp(devname, udev->subsystem) != 0) { snprintf(dirname, PATH_MAX, "%s/%s", basedir, devname); dirname[PATH_MAX-1] = '\0'; - call_foreach_file(run_program, dirname, suffix, udev); + call_foreach_file(run_program, udev, dirname, suffix); } temp[0] = '/'; @@ -101,16 +100,16 @@ void udev_multiplex_directory(struct udevice *udev, const char *basedir, const c if (udev->name[0] != '\0') { snprintf(dirname, PATH_MAX, "%s/%s", basedir, udev->name); dirname[PATH_MAX-1] = '\0'; - call_foreach_file(run_program, dirname, suffix, udev); + call_foreach_file(run_program, udev, dirname, suffix); } if (udev->subsystem[0] != '\0') { snprintf(dirname, PATH_MAX, "%s/%s", basedir, udev->subsystem); dirname[PATH_MAX-1] = '\0'; - call_foreach_file(run_program, dirname, suffix, udev); + call_foreach_file(run_program, udev, dirname, suffix); } snprintf(dirname, PATH_MAX, "%s/default", basedir); dirname[PATH_MAX-1] = '\0'; - call_foreach_file(run_program, dirname, suffix, udev); + call_foreach_file(run_program, udev, dirname, suffix); } diff --git a/udev_utils.c b/udev_utils.c index f2534dd331..cfa4ab51b3 100644 --- a/udev_utils.c +++ b/udev_utils.c @@ -259,13 +259,7 @@ void no_trailing_slash(char *path) path[--len] = '\0'; } -struct name_entry { - struct list_head node; - char name[NAME_SIZE]; -}; - -/* sort files in lexical order */ -static int name_list_add(struct list_head *name_list, const char *name, int sort) +int name_list_add(struct list_head *name_list, const char *name, int sort) { struct name_entry *loop_name; struct name_entry *new_name; @@ -288,11 +282,13 @@ static int name_list_add(struct list_head *name_list, const char *name, int sort strfieldcpy(new_name->name, name); list_add_tail(&new_name->node, &loop_name->node); + return 0; } /* calls function for every file found in specified directory */ -int call_foreach_file(file_fnct_t fnct, const char *dirname, const char *suffix, void *data) +int call_foreach_file(int (*handler_function)(struct udevice *udev, const char *string), + struct udevice *udev, const char *dirname, const char *suffix) { struct dirent *ent; DIR *dir; @@ -335,7 +331,7 @@ int call_foreach_file(file_fnct_t fnct, const char *dirname, const char *suffix, snprintf(filename, NAME_SIZE, "%s/%s", dirname, loop_file->name); filename[NAME_SIZE-1] = '\0'; - fnct(filename, data); + handler_function(udev, filename); list_del(&loop_file->node); free(loop_file); diff --git a/udev_utils.h b/udev_utils.h index 268c2075de..1ab4752cd3 100644 --- a/udev_utils.h +++ b/udev_utils.h @@ -76,6 +76,11 @@ do { \ # define asmlinkage /* nothing */ #endif +struct name_entry { + struct list_head node; + char name[NAME_SIZE]; +}; + extern int udev_init_device(struct udevice *udev, const char* devpath, const char *subsystem); extern int kernel_release_satisfactory(unsigned int version, unsigned int patchlevel, unsigned int sublevel); extern int create_path(const char *path); @@ -85,8 +90,7 @@ extern int file_map(const char *filename, char **buf, size_t *bufsize); extern void file_unmap(char *buf, size_t bufsize); extern size_t buf_get_line(const char *buf, size_t buflen, size_t cur); extern void no_trailing_slash(char *path); -typedef int (*file_fnct_t)(const char *filename, void *data); -extern int call_foreach_file(file_fnct_t fnct, const char *dirname, - const char *suffix, void *data); - +extern int name_list_add(struct list_head *name_list, const char *name, int sort); +extern int call_foreach_file(int (*handler_function)(struct udevice *udev, const char *string), + struct udevice *udev, const char *dirname, const char *suffix); #endif |