* Re: [PATCH 7/15] Make ISDN CAPI use seq_list_xxx helpers
@ 2007-05-18 11:10 Karsten Keil
0 siblings, 0 replies; 2+ messages in thread
From: Karsten Keil @ 2007-05-18 11:10 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Kernel Mailing List, devel, Pavel Emelianov
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.
Acked-by: Karsten Keil <kkeil@suse.de>
Signed-off-by: Pavel Emelianov <xemul@openvz.org>
---
diff --git a/drivers/isdn/capi/kcapi_proc.c b/drivers/isdn/capi/kcapi_proc.c
index 31f4fd8..845a797 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
// ---------------------------------------------------------------------------
-
-static __inline__ struct capi_driver *capi_driver_get_idx(loff_t pos)
-{
- struct capi_driver *drv = NULL;
- struct list_head *l;
- loff_t i;
-
- i = 0;
- list_for_each(l, &capi_drivers) {
- drv = list_entry(l, struct capi_driver, list);
- if (i++ == pos)
- return drv;
- }
- return NULL;
-}
-
static void *capi_driver_start(struct seq_file *seq, loff_t *pos)
{
- struct capi_driver *drv;
read_lock(&capi_drivers_list_lock);
- drv = capi_driver_get_idx(*pos);
- return drv;
+ return seq_list_start(&capi_drivers, *pos);
}
static void *capi_driver_next(struct seq_file *seq, void *v, loff_t *pos)
{
- struct capi_driver *drv = (struct capi_driver *)v;
- ++*pos;
- if (drv->list.next == &capi_drivers) return NULL;
- return list_entry(drv->list.next, struct capi_driver, list);
+ return seq_list_next(v, &capi_drivers, pos);
}
static void capi_driver_stop(struct seq_file *seq, void *v)
@@ -282,7 +261,8 @@ static void capi_driver_stop(struct seq_
static int capi_driver_show(struct seq_file *seq, void *v)
{
- struct capi_driver *drv = (struct capi_driver *)v;
+ struct capi_driver *drv = list_entry(v, struct capi_driver, list);
+
seq_printf(seq, "%-32s %s\n", drv->name, drv->revision);
return 0;
}
--
Karsten Keil
SuSE Labs
ISDN and VOIP development
SUSE LINUX Products GmbH, Maxfeldstr.5 90409 Nuernberg, GF: Markus Rex, HRB 16746 (AG Nuernberg)
^ permalink raw reply [flat|nested] 2+ messages in thread* [PATCH 0/15] Make common helpers for seq_files that work with list_head-s (v2)
@ 2007-05-18 9:14 Pavel Emelianov
2007-05-18 9:41 ` [PATCH 7/15] Make ISDN CAPI use seq_list_xxx helpers Pavel Emelianov
0 siblings, 1 reply; 2+ messages in thread
From: Pavel Emelianov @ 2007-05-18 9:14 UTC (permalink / raw)
To: Andrew Morton
Cc: Linux Kernel Mailing List, dhowells, chas, axboe, herbert,
dmitry.torokhov, kkeil, David Miller, Patrick McHardy, viro,
devel
Many places in kernel use seq_file API to iterate over a regular
list_head. The code for such iteration is identical in all the
places, so it's worth introducing a common helpers.
This makes code about 300 lines smaller:
block/genhd.c | 40 +++-----
crypto/proc.c | 17 ---
drivers/char/misc.c | 18 ----
drivers/input/input.c | 29 ------
drivers/isdn/capi/kcapi_proc.c | 28 ------
fs/afs/proc.c | 81 ++----------------
fs/namespace.c | 14 ---
fs/nfs/client.c | 54 +-----------
fs/proc/proc_tty.c | 15 ---
fs/seq_file.c | 34 +++++++
include/linux/seq_file.h | 11 ++
kernel/module.c | 17 ---
mm/slab.c | 28 +-----
net/atm/br2684.c | 22 ----
net/core/sock.c | 39 --------
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | 27 ------
net/netfilter/nf_conntrack_expect.c | 27 ------
net/rxrpc/ar-proc.c | 48 +---------
18 files changed, 126 insertions(+), 423 deletions(-)
The first version of this patch made the helper functions static inline
in the seq_file.h header. This patch moves them to the fs/seq_file.c as
Andrew proposed. The vmlinux .text section sizes are as follows:
2.6.22-rc1-mm1: 0x001794d5
with the previous version: 0x00179505
with this patch: 0x00179135
The config file used was make allnoconfig with the "y" inclusion of all
the possible options to make the files modified by the patch compile plus
drivers I have on the test node.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 7/15] Make ISDN CAPI use seq_list_xxx helpers
2007-05-18 9:14 [PATCH 0/15] Make common helpers for seq_files that work with list_head-s (v2) Pavel Emelianov
@ 2007-05-18 9:41 ` Pavel Emelianov
0 siblings, 0 replies; 2+ messages in thread
From: Pavel Emelianov @ 2007-05-18 9:41 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Kernel Mailing List, kkeil, devel
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>
---
diff --git a/drivers/isdn/capi/kcapi_proc.c b/drivers/isdn/capi/kcapi_proc.c
index 31f4fd8..845a797 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
// ---------------------------------------------------------------------------
-
-static __inline__ struct capi_driver *capi_driver_get_idx(loff_t pos)
-{
- struct capi_driver *drv = NULL;
- struct list_head *l;
- loff_t i;
-
- i = 0;
- list_for_each(l, &capi_drivers) {
- drv = list_entry(l, struct capi_driver, list);
- if (i++ == pos)
- return drv;
- }
- return NULL;
-}
-
static void *capi_driver_start(struct seq_file *seq, loff_t *pos)
{
- struct capi_driver *drv;
read_lock(&capi_drivers_list_lock);
- drv = capi_driver_get_idx(*pos);
- return drv;
+ return seq_list_start(&capi_drivers, *pos);
}
static void *capi_driver_next(struct seq_file *seq, void *v, loff_t *pos)
{
- struct capi_driver *drv = (struct capi_driver *)v;
- ++*pos;
- if (drv->list.next == &capi_drivers) return NULL;
- return list_entry(drv->list.next, struct capi_driver, list);
+ return seq_list_next(v, &capi_drivers, pos);
}
static void capi_driver_stop(struct seq_file *seq, void *v)
@@ -282,7 +261,8 @@ static void capi_driver_stop(struct seq_
static int capi_driver_show(struct seq_file *seq, void *v)
{
- struct capi_driver *drv = (struct capi_driver *)v;
+ struct capi_driver *drv = list_entry(v, struct capi_driver, list);
+
seq_printf(seq, "%-32s %s\n", drv->name, drv->revision);
return 0;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-05-18 11:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-18 11:10 [PATCH 7/15] Make ISDN CAPI use seq_list_xxx helpers Karsten Keil
-- strict thread matches above, loose matches on Subject: below --
2007-05-18 9:14 [PATCH 0/15] Make common helpers for seq_files that work with list_head-s (v2) Pavel Emelianov
2007-05-18 9:41 ` [PATCH 7/15] Make ISDN CAPI use seq_list_xxx helpers Pavel Emelianov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®