Commit e7e3ce04 authored by Andrey Shvetsov's avatar Andrey Shvetsov Committed by Greg Kroah-Hartman

staging: most: core: fix list traversing

This patch fixes the offset and data handling when traversing
the list of devices that are attached to the bus.
Signed-off-by: default avatarChristian Gromm <christian.gromm@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent eb9e2bc8
...@@ -529,10 +529,16 @@ static struct core_component *match_component(char *name) ...@@ -529,10 +529,16 @@ static struct core_component *match_component(char *name)
return NULL; return NULL;
} }
struct show_links_data {
int offs;
char *buf;
};
int print_links(struct device *dev, void *data) int print_links(struct device *dev, void *data)
{ {
int offs = 0; struct show_links_data *d = data;
char *buf = data; int offs = d->offs;
char *buf = d->buf;
struct most_channel *c; struct most_channel *c;
struct most_interface *iface = to_most_interface(dev); struct most_interface *iface = to_most_interface(dev);
...@@ -554,13 +560,16 @@ int print_links(struct device *dev, void *data) ...@@ -554,13 +560,16 @@ int print_links(struct device *dev, void *data)
dev_name(&c->dev)); dev_name(&c->dev));
} }
} }
d->offs = offs;
return 0; return 0;
} }
static ssize_t links_show(struct device_driver *drv, char *buf) static ssize_t links_show(struct device_driver *drv, char *buf)
{ {
bus_for_each_dev(&mc.bus, NULL, buf, print_links); struct show_links_data d = { .buf = buf };
return strlen(buf);
bus_for_each_dev(&mc.bus, NULL, &d, print_links);
return d.offs;
} }
static ssize_t components_show(struct device_driver *drv, char *buf) static ssize_t components_show(struct device_driver *drv, char *buf)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment