netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jpirko@redhat.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net-next-2.6] net: use helpers to access uc list
Date: Mon, 25 Jan 2010 09:34:52 +0100	[thread overview]
Message-ID: <20100125083450.GA2902@psychotron.redhat.com> (raw)
In-Reply-To: <20100124.230251.177086043.davem@davemloft.net>

Mon, Jan 25, 2010 at 08:02:51AM CET, davem@davemloft.net wrote:
>From: Jiri Pirko <jpirko@redhat.com>
>Date: Sun, 24 Jan 2010 11:42:45 +0100
>
>> +#define netdev_uc_count(dev) ((dev)->uc.count)
>> +
>> +#define netdev_get_list_by_addr(a) \
>> +	(container_of((void *) a, struct netdev_hw_addr, addr)->list)
>> +
>> +#define netdev_get_addr_by_list(l) \
>> +	(list_entry(l, struct netdev_hw_addr, list)->addr)
>> +
>> +#define netdev_for_each_addr(a, head)					\
>> +	for (a = netdev_get_addr_by_list((head)->next);			\
>> +	     prefetch(netdev_get_list_by_addr(a).next),			\
>> +	     &netdev_get_list_by_addr(a) != (head);			\
>> +	     a = netdev_get_addr_by_list(netdev_get_list_by_addr(a).next))
>> +
>> +#define netdev_for_each_uc_addr(a, dev)	\
>> +	netdev_for_each_addr(a, &dev->uc.list)
>> +
>
>I should have mentioned this the other day, but I don't like
>having "unsigned char *" being the type of the element iterator.
>
>Sure it allows you, I guess, to eliminate one local variable
>in the places the iterate, but it definitely is at the cost
>of aestetics.
>
>Please use some normal iterating object for the iterator, such as
>"struct list_head *" or "struct netdev_hw_addr *".  Probably the
>latter would work best.

Well I use "unsigned char *" as iterator because it would allow smooth thansition
to list_head in case of mc_list. Currently "struct dev_addr_list" is used to
store address in the list but in the end "struct netdev_hw_addr *" will be used.
To use "struct list_head *" or "struct netdev_hw_addr *" as an iterator it would
be needed to convert all drivers at once and that's not doable. Therefore I see
"unsigned char *" cursor as the best option.

Jirka
>

  reply	other threads:[~2010-01-25  8:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-24 10:42 [PATCH net-next-2.6] net: use helpers to access uc list Jiri Pirko
2010-01-25  7:02 ` David Miller
2010-01-25  8:34   ` Jiri Pirko [this message]
2010-01-25 10:06     ` David Miller
2010-01-25 12:14       ` Jiri Pirko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100125083450.GA2902@psychotron.redhat.com \
    --to=jpirko@redhat.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).