aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn
diff options
context:
space:
mode:
authorPavel Emelianov <xemul@sw.ru>2007-07-17 07:04:18 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-17 13:23:05 -0400
commit2b7c30292af56e64feaecdbe97da57918927b730 (patch)
treecf160a7dee6f18335b029ae775e4dc8dea5ec424 /drivers/isdn
parent6acee02712d0592dcd6120bc54d77c47cd2f6059 (diff)
Make ISDN CAPI use seq_list_xxx helpers
The similar code exists here and is called capi_driver_get_idx(). Use generic helpers now and remember to convert list_head to struct capi_driver in .show callback. Signed-off-by: Pavel Emelianov <xemul@openvz.org> Acked-by: Karsten Keil <kkeil@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/isdn')
-rw-r--r--drivers/isdn/capi/kcapi_proc.c28
1 files changed, 4 insertions, 24 deletions
diff --git a/drivers/isdn/capi/kcapi_proc.c b/drivers/isdn/capi/kcapi_proc.c
index 31f4fd8b8b0a..845a797b0030 100644
--- a/drivers/isdn/capi/kcapi_proc.c
+++ b/drivers/isdn/capi/kcapi_proc.c
@@ -243,36 +243,15 @@ create_seq_entry(char *name, mode_t mode, const struct file_operations *f)
243 243
244// --------------------------------------------------------------------------- 244// ---------------------------------------------------------------------------
245 245
246
247static __inline__ struct capi_driver *capi_driver_get_idx(loff_t pos)
248{
249 struct capi_driver *drv = NULL;
250 struct list_head *l;
251 loff_t i;
252
253 i = 0;
254 list_for_each(l, &capi_drivers) {
255 drv = list_entry(l, struct capi_driver, list);
256 if (i++ == pos)
257 return drv;
258 }
259 return NULL;
260}
261
262static void *capi_driver_start(struct seq_file *seq, loff_t *pos) 246static void *capi_driver_start(struct seq_file *seq, loff_t *pos)
263{ 247{
264 struct capi_driver *drv;
265 read_lock(&capi_drivers_list_lock); 248 read_lock(&capi_drivers_list_lock);
266 drv = capi_driver_get_idx(*pos); 249 return seq_list_start(&capi_drivers, *pos);
267 return drv;
268} 250}
269 251
270static void *capi_driver_next(struct seq_file *seq, void *v, loff_t *pos) 252static void *capi_driver_next(struct seq_file *seq, void *v, loff_t *pos)
271{ 253{
272 struct capi_driver *drv = (struct capi_driver *)v; 254 return seq_list_next(v, &capi_drivers, pos);
273 ++*pos;
274 if (drv->list.next == &capi_drivers) return NULL;
275 return list_entry(drv->list.next, struct capi_driver, list);
276} 255}
277 256
278static void capi_driver_stop(struct seq_file *seq, void *v) 257static void capi_driver_stop(struct seq_file *seq, void *v)
@@ -282,7 +261,8 @@ static void capi_driver_stop(struct seq_file *seq, void *v)
282 261
283static int capi_driver_show(struct seq_file *seq, void *v) 262static int capi_driver_show(struct seq_file *seq, void *v)
284{ 263{
285 struct capi_driver *drv = (struct capi_driver *)v; 264 struct capi_driver *drv = list_entry(v, struct capi_driver, list);
265
286 seq_printf(seq, "%-32s %s\n", drv->name, drv->revision); 266 seq_printf(seq, "%-32s %s\n", drv->name, drv->revision);
287 return 0; 267 return 0;
288} 268}