From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Christian Gromm Subject: [PATCH 48/50] staging: most: core: fix list traversing Date: Tue, 21 Nov 2017 15:05:22 +0100 Message-ID: <1511273124-7840-49-git-send-email-christian.gromm@microchip.com> In-Reply-To: <1511273124-7840-1-git-send-email-christian.gromm@microchip.com> References: <1511273124-7840-1-git-send-email-christian.gromm@microchip.com> MIME-Version: 1.0 Content-Type: text/plain List-ID: To: gregkh@linuxfoundation.org Cc: driverdev-devel@linuxdriverproject.org, Andrey Shvetsov , Christian Gromm From: Andrey Shvetsov This patch fixes the offset and data handling when traversing the list of devices that are attached to the bus. Signed-off-by: Christian Gromm --- drivers/staging/most/core.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c index d03ff97..9729206 100644 --- a/drivers/staging/most/core.c +++ b/drivers/staging/most/core.c @@ -535,10 +535,16 @@ static struct core_component *match_component(char *name) return NULL; } +struct show_links_data { + int offs; + char *buf; +}; + int print_links(struct device *dev, void *data) { - int offs = 0; - char *buf = data; + struct show_links_data *d = data; + int offs = d->offs; + char *buf = d->buf; struct most_channel *c; struct most_interface *iface = to_most_interface(dev); @@ -560,13 +566,16 @@ int print_links(struct device *dev, void *data) dev_name(&c->dev)); } } + d->offs = offs; return 0; } static ssize_t links_show(struct device_driver *drv, char *buf) { - bus_for_each_dev(&mc.bus, NULL, buf, print_links); - return strlen(buf); + struct show_links_data d = { .buf = 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) -- 2.7.4