mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Block device elevator: use list_for_each_entry() instead of list_for_each()
@ 2007-05-27 16:43 Matthias Kaehlcke
  2007-05-27 17:12 ` rae l
  0 siblings, 1 reply; 2+ messages in thread
From: Matthias Kaehlcke @ 2007-05-27 16:43 UTC (permalink / raw)
  To: axboe; +Cc: linux-kernel, akpm

Use list_for_each_entry() instead of list_for_each() in the block
device elevator

Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>

--

diff --git a/block/elevator.c b/block/elevator.c
index ce866eb..4769a25 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -112,12 +112,8 @@ static inline int elv_try_merge(struct request *__rq, struct bio *bio)
 static struct elevator_type *elevator_find(const char *name)
 {
 	struct elevator_type *e;
-	struct list_head *entry;
-
-	list_for_each(entry, &elv_list) {
-
-		e = list_entry(entry, struct elevator_type, list);
 
+	list_for_each_entry(e, &elv_list, list) {
 		if (!strcmp(e->elevator_name, name))
 			return e;
 	}
@@ -1116,14 +1112,11 @@ ssize_t elv_iosched_show(request_queue_t *q, char *name)
 {
 	elevator_t *e = q->elevator;
 	struct elevator_type *elv = e->elevator_type;
-	struct list_head *entry;
+	struct elevator_type *__e;
 	int len = 0;
 
 	spin_lock(&elv_list_lock);
-	list_for_each(entry, &elv_list) {
-		struct elevator_type *__e;
-
-		__e = list_entry(entry, struct elevator_type, list);
+	list_for_each_entry(__e, &elv_list, list) {
 		if (!strcmp(elv->elevator_name, __e->elevator_name))
 			len += sprintf(name+len, "[%s] ", elv->elevator_name);
 		else
 
-- 
Matthias Kaehlcke
Linux Application Developer
Barcelona


   Usually when people are sad, they don't do anything. They just cry over
     their condition. But when they get angry, they bring about a change
                              (Malcolm X)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Block device elevator: use list_for_each_entry() instead of list_for_each()
  2007-05-27 16:43 [PATCH] Block device elevator: use list_for_each_entry() instead of list_for_each() Matthias Kaehlcke
@ 2007-05-27 17:12 ` rae l
  0 siblings, 0 replies; 2+ messages in thread
From: rae l @ 2007-05-27 17:12 UTC (permalink / raw)
  To: Matthias Kaehlcke, axboe, linux-kernel, akpm

it makes sense to what it does.

On 5/28/07, Matthias Kaehlcke <matthias.kaehlcke@gmail.com> wrote:
> Use list_for_each_entry() instead of list_for_each() in the block
> device elevator
>
> Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
>
> --
>
> diff --git a/block/elevator.c b/block/elevator.c
> index ce866eb..4769a25 100644
> --- a/block/elevator.c
> +++ b/block/elevator.c
> @@ -112,12 +112,8 @@ static inline int elv_try_merge(struct request *__rq, struct bio *bio)
>  static struct elevator_type *elevator_find(const char *name)
>  {
>         struct elevator_type *e;
> -       struct list_head *entry;
> -
> -       list_for_each(entry, &elv_list) {
> -
> -               e = list_entry(entry, struct elevator_type, list);
>
> +       list_for_each_entry(e, &elv_list, list) {
>                 if (!strcmp(e->elevator_name, name))
>                         return e;
>         }
> @@ -1116,14 +1112,11 @@ ssize_t elv_iosched_show(request_queue_t *q, char *name)
>  {
>         elevator_t *e = q->elevator;
>         struct elevator_type *elv = e->elevator_type;
> -       struct list_head *entry;
> +       struct elevator_type *__e;
>         int len = 0;
>
>         spin_lock(&elv_list_lock);
> -       list_for_each(entry, &elv_list) {
> -               struct elevator_type *__e;
> -
> -               __e = list_entry(entry, struct elevator_type, list);
> +       list_for_each_entry(__e, &elv_list, list) {
>                 if (!strcmp(elv->elevator_name, __e->elevator_name))
>                         len += sprintf(name+len, "[%s] ", elv->elevator_name);
>                 else
>
> --
> Matthias Kaehlcke
> Linux Application Developer
> Barcelona
>
>
>    Usually when people are sad, they don't do anything. They just cry over
>      their condition. But when they get angry, they bring about a change
>                               (Malcolm X)
>                                                                  .''`.
>     using free software / Debian GNU/Linux | http://debian.org  : :'  :
>                                                                 `. `'`
> gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>


-- 
Denis Cheng
Linux Application Developer

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-05-27 17:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-27 16:43 [PATCH] Block device elevator: use list_for_each_entry() instead of list_for_each() Matthias Kaehlcke
2007-05-27 17:12 ` rae l

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®