[PATCH] replace list_for_each with list_for_each_entry, saving a few lines of code.
This commit is contained in:
parent
8eb38ef882
commit
843d1a84b9
31
namedev.c
31
namedev.c
|
@ -104,12 +104,11 @@ static int strcmp_pattern(const char *p, const char *s)
|
||||||
|
|
||||||
int add_perm_dev(struct perm_device *new_dev)
|
int add_perm_dev(struct perm_device *new_dev)
|
||||||
{
|
{
|
||||||
struct list_head *tmp;
|
struct perm_device *dev;
|
||||||
struct perm_device *tmp_dev;
|
struct perm_device *tmp_dev;
|
||||||
|
|
||||||
/* update the values if we already have the device */
|
/* update the values if we already have the device */
|
||||||
list_for_each(tmp, &perm_device_list) {
|
list_for_each_entry(dev, &perm_device_list, node) {
|
||||||
struct perm_device *dev = list_entry(tmp, struct perm_device, node);
|
|
||||||
if (strcmp_pattern(new_dev->name, dev->name))
|
if (strcmp_pattern(new_dev->name, dev->name))
|
||||||
continue;
|
continue;
|
||||||
copy_var(dev, new_dev, mode);
|
copy_var(dev, new_dev, mode);
|
||||||
|
@ -130,11 +129,9 @@ int add_perm_dev(struct perm_device *new_dev)
|
||||||
|
|
||||||
static struct perm_device *find_perm(char *name)
|
static struct perm_device *find_perm(char *name)
|
||||||
{
|
{
|
||||||
struct list_head *tmp;
|
struct perm_device *perm;
|
||||||
struct perm_device *perm = NULL;
|
|
||||||
|
|
||||||
list_for_each(tmp, &perm_device_list) {
|
list_for_each_entry(perm, &perm_device_list, node) {
|
||||||
perm = list_entry(tmp, struct perm_device, node);
|
|
||||||
if (strcmp_pattern(perm->name, name))
|
if (strcmp_pattern(perm->name, name))
|
||||||
continue;
|
continue;
|
||||||
return perm;
|
return perm;
|
||||||
|
@ -396,10 +393,8 @@ static int exec_callout(struct config_device *dev, char *value, int len)
|
||||||
static int do_callout(struct sysfs_class_device *class_dev, struct udevice *udev, struct sysfs_device *sysfs_device)
|
static int do_callout(struct sysfs_class_device *class_dev, struct udevice *udev, struct sysfs_device *sysfs_device)
|
||||||
{
|
{
|
||||||
struct config_device *dev;
|
struct config_device *dev;
|
||||||
struct list_head *tmp;
|
|
||||||
|
|
||||||
list_for_each(tmp, &config_device_list) {
|
list_for_each_entry(dev, &config_device_list, node) {
|
||||||
dev = list_entry(tmp, struct config_device, node);
|
|
||||||
if (dev->type != CALLOUT)
|
if (dev->type != CALLOUT)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -468,12 +463,10 @@ static int do_label(struct sysfs_class_device *class_dev, struct udevice *udev,
|
||||||
{
|
{
|
||||||
struct sysfs_pair *pair;
|
struct sysfs_pair *pair;
|
||||||
struct config_device *dev;
|
struct config_device *dev;
|
||||||
struct list_head *tmp;
|
|
||||||
int i;
|
int i;
|
||||||
int match;
|
int match;
|
||||||
|
|
||||||
list_for_each(tmp, &config_device_list) {
|
list_for_each_entry(dev, &config_device_list, node) {
|
||||||
dev = list_entry(tmp, struct config_device, node);
|
|
||||||
if (dev->type != LABEL)
|
if (dev->type != LABEL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -513,7 +506,6 @@ static int do_label(struct sysfs_class_device *class_dev, struct udevice *udev,
|
||||||
static int do_number(struct sysfs_class_device *class_dev, struct udevice *udev, struct sysfs_device *sysfs_device)
|
static int do_number(struct sysfs_class_device *class_dev, struct udevice *udev, struct sysfs_device *sysfs_device)
|
||||||
{
|
{
|
||||||
struct config_device *dev;
|
struct config_device *dev;
|
||||||
struct list_head *tmp;
|
|
||||||
char path[SYSFS_PATH_MAX];
|
char path[SYSFS_PATH_MAX];
|
||||||
int found;
|
int found;
|
||||||
char *temp = NULL;
|
char *temp = NULL;
|
||||||
|
@ -522,8 +514,7 @@ static int do_number(struct sysfs_class_device *class_dev, struct udevice *udev,
|
||||||
if (!sysfs_device)
|
if (!sysfs_device)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
list_for_each(tmp, &config_device_list) {
|
list_for_each_entry(dev, &config_device_list, node) {
|
||||||
dev = list_entry(tmp, struct config_device, node);
|
|
||||||
if (dev->type != NUMBER)
|
if (dev->type != NUMBER)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -558,7 +549,6 @@ static int do_number(struct sysfs_class_device *class_dev, struct udevice *udev,
|
||||||
static int do_topology(struct sysfs_class_device *class_dev, struct udevice *udev, struct sysfs_device *sysfs_device)
|
static int do_topology(struct sysfs_class_device *class_dev, struct udevice *udev, struct sysfs_device *sysfs_device)
|
||||||
{
|
{
|
||||||
struct config_device *dev;
|
struct config_device *dev;
|
||||||
struct list_head *tmp;
|
|
||||||
char path[SYSFS_PATH_MAX];
|
char path[SYSFS_PATH_MAX];
|
||||||
int found;
|
int found;
|
||||||
char *temp = NULL;
|
char *temp = NULL;
|
||||||
|
@ -567,8 +557,7 @@ static int do_topology(struct sysfs_class_device *class_dev, struct udevice *ude
|
||||||
if (!sysfs_device)
|
if (!sysfs_device)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
list_for_each(tmp, &config_device_list) {
|
list_for_each_entry(dev, &config_device_list, node) {
|
||||||
dev = list_entry(tmp, struct config_device, node);
|
|
||||||
if (dev->type != TOPOLOGY)
|
if (dev->type != TOPOLOGY)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -604,10 +593,8 @@ static int do_topology(struct sysfs_class_device *class_dev, struct udevice *ude
|
||||||
static int do_replace(struct sysfs_class_device *class_dev, struct udevice *udev, struct sysfs_device *sysfs_device)
|
static int do_replace(struct sysfs_class_device *class_dev, struct udevice *udev, struct sysfs_device *sysfs_device)
|
||||||
{
|
{
|
||||||
struct config_device *dev;
|
struct config_device *dev;
|
||||||
struct list_head *tmp;
|
|
||||||
|
|
||||||
list_for_each(tmp, &config_device_list) {
|
list_for_each_entry(dev, &config_device_list, node) {
|
||||||
dev = list_entry(tmp, struct config_device, node);
|
|
||||||
if (dev->type != REPLACE)
|
if (dev->type != REPLACE)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -117,12 +117,10 @@ void dump_config_dev(struct config_device *dev)
|
||||||
|
|
||||||
void dump_config_dev_list(void)
|
void dump_config_dev_list(void)
|
||||||
{
|
{
|
||||||
struct list_head *tmp;
|
struct config_device *dev;
|
||||||
|
|
||||||
list_for_each(tmp, &config_device_list) {
|
list_for_each_entry(dev, &config_device_list, node)
|
||||||
struct config_device *dev = list_entry(tmp, struct config_device, node);
|
|
||||||
dump_config_dev(dev);
|
dump_config_dev(dev);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dump_perm_dev(struct perm_device *dev)
|
void dump_perm_dev(struct perm_device *dev)
|
||||||
|
@ -133,12 +131,10 @@ void dump_perm_dev(struct perm_device *dev)
|
||||||
|
|
||||||
void dump_perm_dev_list(void)
|
void dump_perm_dev_list(void)
|
||||||
{
|
{
|
||||||
struct list_head *tmp;
|
struct perm_device *dev;
|
||||||
|
|
||||||
list_for_each(tmp, &perm_device_list) {
|
list_for_each_entry(dev, &perm_device_list, node)
|
||||||
struct perm_device *dev = list_entry(tmp, struct perm_device, node);
|
|
||||||
dump_perm_dev(dev);
|
dump_perm_dev(dev);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue